-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EDU-2965: I300 collection updated, push notification examples from he…
…lp added
- Loading branch information
1 parent
b0aa949
commit 3f8b1f7
Showing
4 changed files
with
627 additions
and
551 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...evelopment/Help/ConfiguringPushNotifications/AdditionalInformation/CommitEventEnricher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...elopment/Help/ConfiguringPushNotifications/BuildInQueryDefinition/TestInCodeDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
IntegrationDevelopment/Help/ConfiguringPushNotifications/SignalRHub/TestSignalR.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
Oops, something went wrong.