private void HandleNotificationErrors(string notificationError, IEnumerable <ChangeNotificationData> syncData)
 {
     if (!string.IsNullOrEmpty(notificationError))
     {
         base.WriteWarning(notificationError);
         AggregatedNotificationClients.SetNotificationResults(syncData, notificationError);
         PolicySettingStatusHelpers.CheckNotificationResultsAndUpdateStatus(this, (IConfigurationSession)base.DataSession, syncData);
     }
 }
Ejemplo n.º 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);
        }
        private static Dictionary <Workload, List <ChangeNotificationData> > NotifyChanges(Task task, IConfigurationSession configurationSession, IEnumerable <UnifiedPolicyStorageBase> policyStorageObjects, ExecutionLog logger, Type client)
        {
            Dictionary <Workload, List <ChangeNotificationData> > dictionary = AggregatedNotificationClients.CreateSyncChangeDataGroupedByWorkload(policyStorageObjects);

            foreach (KeyValuePair <Workload, List <ChangeNotificationData> > keyValuePair in dictionary)
            {
                IEnumerable <SyncChangeInfo> enumerable = from s in keyValuePair.Value
                                                          where s.ShouldNotify
                                                          select s into d
                                                          select d.CreateSyncChangeInfo(false);

                if (enumerable.Any <SyncChangeInfo>())
                {
                    string text2;
                    string text = AggregatedNotificationClients.NotifyChangesByWorkload(task, configurationSession, keyValuePair.Key, enumerable, false, false, logger, client, out text2);
                    if (!string.IsNullOrEmpty(text))
                    {
                        task.WriteWarning(Strings.WarningNotifyWorkloadFailed(keyValuePair.Key.ToString()));
                    }
                    AggregatedNotificationClients.SetNotificationResults(keyValuePair.Value, text);
                }
            }
            return(dictionary);
        }