/// <summary>Those notification are performed asynchronously as a gain of performance. The function calling it does not actually need to wait and know the result of this operation</summary> /// <param name="pRequestId">Unique ID of the request.</param> /// <param name="pNotification">Type of notification.</param> /// <param name="pParameter">Parameters of the notification to send.</param> /// <param name="pBinding">Represents an interoperable binding that supports distributed transactions and secure, reliable sessions.</param> /// <param name="pEndpointAddress">Provides a unique network address that a client uses to communicate with a service endpoint.</param> /// <param name="pNotifcationURL">Destination URL of the notification sent.</param> private void SendNotificationAppGroundTask(Guid pRequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum pNotification, string pParameter, System.ServiceModel.Channels.Binding pBinding, System.ServiceModel.EndpointAddress pEndpointAddress, string pNotifcationURL) { try { using (PIS.Ground.GroundCore.AppGround.NotificationAppGroundServiceClient lGroundNotificationClient = new PIS.Ground.GroundCore.AppGround.NotificationAppGroundServiceClient(pBinding, pEndpointAddress)) { try { lGroundNotificationClient.SendNotification(pRequestId.ToString(), pNotification, pParameter); lGroundNotificationClient.Close(); } finally { if (lGroundNotificationClient.State == System.ServiceModel.CommunicationState.Faulted) { lGroundNotificationClient.Abort(); } } } } catch (Exception ex) { LogException(pNotifcationURL, ex, pRequestId, pNotification, pParameter); } }
/// <summary>Sends a notification asynchronously.</summary> /// <param name="pNotification">The notification.</param> /// <param name="pParameter">Parameter sent with the notification, can be a simple string or an /// XML serialize data.</param> /// <param name="pRequestID">Unique identifier for the request.</param> public void SendNotification(PIS.Ground.GroundCore.AppGround.NotificationIdEnum pNotification, string pParameter, Guid pRequestID) { //Function is performed Asynchronously. SendNotificationAsync worker = new SendNotificationAsync(SendNotificationTask); worker.BeginInvoke(pNotification, pParameter, pRequestID, worker.EndInvoke, null); }
/// <summary> /// Notification are required to be performed asynchronously as not reply are required. /// </summary> /// <param name="pNotification">Type of notification.</param> /// <param name="pParameter">Parameters of the notification to send.</param> /// <param name="pRequestID">Identifier for the request.</param> private void SendNotificationTask(PIS.Ground.GroundCore.AppGround.NotificationIdEnum pNotification, string pParameter, Guid pRequestID) { try { if (!string.IsNullOrEmpty(PIS.Ground.Core.Utility.ServiceConfiguration.SessionSqLiteDBPath)) { List <string> lNotificationURLs = new List <string>(); string lParameter = String.Empty; string lGetResult; //If no request ID is specified or is null, get all URLs if (pRequestID == Guid.Empty) { //if no request, get all notification URLs lGetResult = _sessionManager.GetNotificationUrls(lNotificationURLs); } else { //Get notification URL for the requestID string NotifURL; lGetResult = _sessionManager.GetNotificationUrlByRequestId(pRequestID, out NotifURL); if (!string.IsNullOrEmpty(NotifURL)) { lNotificationURLs.Add(NotifURL); } } if (0 != lNotificationURLs.Count) { // EndPoint Configuration System.ServiceModel.Channels.Binding lBinding = getBinding(); if (!string.IsNullOrEmpty(pParameter)) { lParameter = pParameter; } // Send notifications foreach (string lNotifcationURL in lNotificationURLs.Distinct()) { // Send notification only if we have a non empty url. if (!string.IsNullOrEmpty(lNotifcationURL)) { try { System.ServiceModel.EndpointAddress lEndpointAddress = new System.ServiceModel.EndpointAddress(lNotifcationURL); SendNotificationAppGroundAsync worker = new SendNotificationAppGroundAsync(SendNotificationAppGroundTask); worker.BeginInvoke(pRequestID, pNotification, lParameter, lBinding, lEndpointAddress, lNotifcationURL, worker.EndInvoke, null); } catch (Exception exception) { LogException(lNotifcationURL, exception, pRequestID, pNotification, pParameter); } } } } else { LogManager.WriteLog(TraceType.DEBUG, "NotificationURLs list is empty.", "PIS.Ground.GroundCore.Common.NotificationSender", null, EventIdEnum.SendNotification); } } } catch (System.Exception exception) { LogException(string.Empty, exception, pRequestID, pNotification, pParameter); } }
/// <summary>Sends a notification asynchronously.</summary> /// <param name="pNotification">The notification.</param> /// <param name="pRequestID">Unique identifier for the request.</param> public void SendNotification(PIS.Ground.GroundCore.AppGround.NotificationIdEnum pNotification, Guid pRequestID) { SendNotification(pNotification, null, pRequestID); }
/// <summary>Sends a notification asynchronously.</summary> /// <param name="pNotification">The notification.</param> /// <param name="pParameter">Parameter sent with the notification, can be a simple string or an XML serialize data.</param> public void SendNotification(PIS.Ground.GroundCore.AppGround.NotificationIdEnum pNotification, string pParameter) { SendNotification(pNotification, pParameter, Guid.Empty); }
/// <summary>Sends a notification.</summary> /// <param name="pNotification">The notification.</param> public void SendNotification(PIS.Ground.GroundCore.AppGround.NotificationIdEnum pNotification) { SendNotification(pNotification, null, Guid.Empty); }