Example #1
0
        public static SyncNotificationResult NotifyStatusChanges(string identity, string targetServerFqdn, Guid tenantId, string statusUpdateSvcUrl, bool syncNow, IList <UnifiedPolicyStatus> statusUpdates)
        {
            if (string.IsNullOrEmpty(identity))
            {
                throw new ArgumentNullException("identity");
            }
            if (tenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }
            if (string.IsNullOrEmpty(statusUpdateSvcUrl))
            {
                throw new ArgumentNullException("statusUpdateSvcUrl");
            }
            if (statusUpdates == null || statusUpdates.Count == 0)
            {
                throw new ArgumentNullException("statusUpdates");
            }
            RpcClientWrapper.InitializeIfNeeded();
            NotificationType type = NotificationType.ApplicationStatus;

            if (!RpcClientWrapper.instance.initialized)
            {
                return(new SyncNotificationResult(new SyncAgentTransientException("RPC client not initialized")));
            }
            SyncNotificationResult result;

            try
            {
                using (UnifiedPolicyNotificationRpcClient unifiedPolicyNotificationRpcClient = new UnifiedPolicyNotificationRpcClient(targetServerFqdn ?? RpcClientWrapper.instance.localServer.Fqdn))
                {
                    SyncStatusUpdateWorkitem syncStatusUpdateWorkitem = new SyncStatusUpdateWorkitem(identity, syncNow, new TenantContext(tenantId, null), statusUpdates, statusUpdateSvcUrl, 0);
                    byte[] data = unifiedPolicyNotificationRpcClient.Notify(1, (int)type, syncStatusUpdateWorkitem.Serialize());
                    NotificationRpcOutParameters notificationRpcOutParameters = new NotificationRpcOutParameters(data);
                    result = notificationRpcOutParameters.Result;
                }
            }
            catch (RpcException ex)
            {
                result = new SyncNotificationResult(new SyncAgentTransientException(ex.Message, ex));
            }
            return(result);
        }
Example #2
0
        public static SyncNotificationResult NotifySyncChanges(string identity, string targetServerFqdn, Guid tenantId, string syncSvcUrl, bool fullSync, bool syncNow, SyncChangeInfo[] syncChangeInfos)
        {
            if (string.IsNullOrEmpty(identity))
            {
                throw new ArgumentNullException("identity");
            }
            if (tenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }
            if (string.IsNullOrEmpty(syncSvcUrl))
            {
                throw new ArgumentNullException("syncSvcUrl");
            }
            RpcClientWrapper.InitializeIfNeeded();
            NotificationType type = NotificationType.Sync;

            if (!RpcClientWrapper.instance.initialized)
            {
                return(new SyncNotificationResult(new SyncAgentTransientException("RPC client not initialized")));
            }
            SyncNotificationResult result;

            try
            {
                using (UnifiedPolicyNotificationRpcClient unifiedPolicyNotificationRpcClient = new UnifiedPolicyNotificationRpcClient(targetServerFqdn ?? RpcClientWrapper.instance.localServer.Fqdn))
                {
                    SyncWorkItem syncWorkItem = new SyncWorkItem(identity, syncNow, new TenantContext(tenantId, null), syncChangeInfos, syncSvcUrl, fullSync, Workload.Exchange, false);
                    byte[]       data         = unifiedPolicyNotificationRpcClient.Notify(1, (int)type, syncWorkItem.Serialize());
                    NotificationRpcOutParameters notificationRpcOutParameters = new NotificationRpcOutParameters(data);
                    result = notificationRpcOutParameters.Result;
                }
            }
            catch (RpcException ex)
            {
                result = new SyncNotificationResult(new SyncAgentTransientException(ex.Message, ex));
            }
            return(result);
        }