Skip to content

Commit

Permalink
EDU-2965: I300 collection updated, push notification examples from he…
Browse files Browse the repository at this point in the history
…lp added
  • Loading branch information
k-s-popova committed Oct 3, 2024
1 parent b0aa949 commit 3f8b1f7
Show file tree
Hide file tree
Showing 4 changed files with 627 additions and 551 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PX.Common;
using PX.Data.PushNotifications;

public class CommitEventEnricher : ICommitEventEnricher
{
public void Enrich(IQueueEvent commitEvent)
{
var businessDate = PXContext.PXIdentity?.BusinessDate;
var userName = PXContext.PXIdentity?.IdentityName;
commitEvent.AdditionalInfo.Add(nameof(businessDate), businessDate);
commitEvent.AdditionalInfo.Add(nameof(userName), userName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using PX.Data;
using PX.PushNotifications.UI.DAC;
using System;
using PX.Data.BQL.Fluent;
using PX.PushNotifications.Sources;

public class TestInCodeDefinition : IInCodeNotificationDefinition
{
public Tuple<BqlCommand, PXDataValue[]> GetSourceSelect()
{
return
Tuple.Create(
SelectFrom<PushNotificationsHook>.
LeftJoin<PushNotificationsSource>.
On<PushNotificationsHook.hookId.
IsEqual<PushNotificationsSource.hookId>>.View
.GetCommand(), new PXDataValue[0]);
}

public Type[] GetRestrictedFields()
{
return new[]
{
typeof(PushNotificationsHook.address),
typeof(PushNotificationsHook.type),
typeof(PushNotificationsSource.designID),
typeof(PushNotificationsSource.inCodeClass),
typeof(PushNotificationsSource.lineNbr)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNet.SignalR.Client;

class Program
{
static void Main(string[] args)
{
var login = "admin";
var tenant = "Tenant";
var password = "123";
// Set up a Basic authentication token
var basicAuthToken = Convert.ToBase64String(
Encoding.UTF8.GetBytes(login + "@" + tenant + ":" + password));

//Connect to an Acumatica ERP instance
var connection = new HubConnection("http://localhost:8081/AcumaticaDB/");
connection.Headers.Add("Authorization", "Basic " + basicAuthToken);

//Create a proxy to hub
//Use "PushNotificationsHub" as the address of the hub
var myHub = connection.CreateHubProxy("PushNotificationsHub");
connection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
{
Console.WriteLine(
"There was an error during open of the connection:{0}",
task.Exception.GetBaseException());
}
else
{
//Instead of "TestSignalR", specify the name
//that you specified on the Push Notifications form
myHub.Invoke<string>("Subscribe", "TestSignalR").Wait();
}
}).Wait();

//Process the notifications
myHub.On<NotificationResult>("ReceiveNotification", nr =>
{
Console.WriteLine("Inserted {0}", nr.Inserted.Length);
Console.WriteLine("Deleted {0}", nr.Deleted.Length);
});
Console.Read();
connection.Stop();
}
}

public class NotificationResult
{
public object[] Inserted { get; set; }
public object[] Deleted { get; set; }
public string Query { get; set; }
public string CompanyId { get; set; }
public Guid Id { get; set; }
public long TimeStamp { get; set; }
public Dictionary<string, object> AdditionalInfo { get; set; }
}
Loading

0 comments on commit 3f8b1f7

Please sign in to comment.