protected override void InternalValidate()
 {
     if (this.SyncChangeInfos != null)
     {
         try
         {
             foreach (string input in this.SyncChangeInfos)
             {
                 SyncChangeInfo.Parse(input);
             }
         }
         catch (FormatException ex)
         {
             base.WriteError(new InvalidOperationException("Invalid format for SyncChangeInfo paramemter. The detail of the error is " + ex.Message), (ErrorCategory)1000, this.SyncChangeInfos);
         }
     }
     try
     {
         if (!string.IsNullOrEmpty(this.SyncSvcUrl))
         {
             new Uri(this.SyncSvcUrl, UriKind.Absolute);
         }
     }
     catch (FormatException ex2)
     {
         base.WriteError(new InvalidOperationException("Invalid format for SyncSvcUrl parameter. The detail of the error is " + ex2.Message), (ErrorCategory)1000, this.SyncChangeInfos);
     }
     base.InternalValidate();
 }
Exemple #2
0
        internal static IList <ChangeNotificationData> NotifyChange(Task task, UnifiedPolicyStorageBase policyStorageObject, IEnumerable <UnifiedPolicyStorageBase> relatedStorageObjects, IConfigurationSession dataSession, ExecutionLog logger)
        {
            Exception exception = null;
            string    text      = string.Empty;
            string    empty     = string.Empty;
            ChangeNotificationData        changeNotificationData = IntuneCompliancePolicySyncNotificationClient.CreateChangeData(Workload.Intune, policyStorageObject);
            List <ChangeNotificationData> list = new List <ChangeNotificationData>
            {
                changeNotificationData
            };
            List <SyncChangeInfo> list2 = new List <SyncChangeInfo>();

            foreach (UnifiedPolicyStorageBase policyStorageObject2 in relatedStorageObjects)
            {
                list.Add(IntuneCompliancePolicySyncNotificationClient.CreateChangeData(Workload.Intune, policyStorageObject2));
            }
            foreach (ChangeNotificationData changeNotificationData2 in list)
            {
                SyncChangeInfo syncChangeInfo = changeNotificationData2.ShouldNotify ? changeNotificationData2.CreateSyncChangeInfo(true) : null;
                if (syncChangeInfo == null)
                {
                    logger.LogOneEntry(task.GetType().Name, string.Empty, ExecutionLog.EventType.Warning, string.Format("We did not notify workload '{0}' for changes to objectId {1}", Workload.Intune, changeNotificationData2.Id), exception);
                }
                list2.Add(syncChangeInfo);
            }
            try
            {
                if (list2.Any <SyncChangeInfo>())
                {
                    text = IntuneCompliancePolicySyncNotificationClient.MakeNotificationCall(task, list2, changeNotificationData.UseFullSync, changeNotificationData.ShouldNotify, dataSession, logger);
                }
            }
            catch (Exception ex)
            {
                text      = Strings.ErrorMessageForNotificationFailure(Workload.Intune.ToString(), ex.Message);
                exception = ex;
            }
            if (!string.IsNullOrEmpty(text))
            {
                task.WriteWarning(Strings.WarningNotifyWorkloadFailed(changeNotificationData.ToString()));
                logger.LogOneEntry(task.GetType().Name, string.Empty, ExecutionLog.EventType.Warning, string.Format("We failed to notify workload '{0}' with error message '{1}'", Workload.Intune, text), exception);
                MonitoringItemErrorPublisher.Instance.PublishEvent("UnifiedPolicySync.SendNotificationError", UnifiedPolicyConfiguration.GetInstance().GetOrganizationIdKey(dataSession), string.Format("Workload={0};Timestamp={1}", Workload.Intune, DateTime.UtcNow), exception);
            }
            else
            {
                logger.LogOneEntry(ExecutionLog.EventType.Verbose, task.GetType().Name, empty, "Notification '{0}' was sent to workload '{1}' with sync change info: '{2}'", new object[]
                {
                    empty,
                    Workload.Intune,
                    list2.First <SyncChangeInfo>().ToString()
                });
            }
            AggregatedNotificationClients.SetNotificationResults(list, text);
            return(list);
        }