private void PublishModificationOfAuditingEvents( AuditDatabaseDecoratedContainer auditDatabaseDecoratedContainer, int insertedId) { if (this.notificationPublisherManager == null) { this.notificationPublisherManager = PublisherClient.get_Instance(); } this.notificationPublisherManager.Publish((INotification) new Notification("System.InstanceCreated", (IDictionary <string, object>)IndicationHelper.GetIndicationProperties(), (IDictionary <string, object>) new Dictionary <string, object>() { { "ActionType", (object)((object)auditDatabaseDecoratedContainer.get_ActionType()).ToString() }, { "AuditEventId", (object)insertedId }, { "InstanceType", (object)"Orion.AuditingEvents" }, { "OriginalAccountId", (object)auditDatabaseDecoratedContainer.AccountId } })); }
// Token: 0x06000028 RID: 40 RVA: 0x00002B7C File Offset: 0x00000D7C private void PublishModificationOfAuditingEvents(AuditDatabaseDecoratedContainer auditDatabaseDecoratedContainer, int insertedId) { if (this.indicationPublisher == null) { this.indicationPublisher = IndicationPublisher.CreateV3(); } Dictionary <string, object> dictionary = new Dictionary <string, object> { { "ActionType", auditDatabaseDecoratedContainer.ActionType.ToString() }, { "AuditEventId", insertedId }, { "InstanceType", "Orion.AuditingEvents" }, { "OriginalAccountId", auditDatabaseDecoratedContainer.AccountId } }; Indication indication = new Indication { IndicationProperties = IndicationHelper.GetIndicationProperties(), IndicationType = "System.InstanceCreated", SourceInstanceProperties = new PropertyBag(dictionary) }; this.indicationPublisher.Publish(indication); }
public Task OnNotificationAsync(Notification notification) { if (AuditingNotificationSubscriber.log.get_IsDebugEnabled()) { AuditingNotificationSubscriber.log.DebugFormat("OnNotification type: {0} SubscriptionId: {1}", (object)notification.get_IndicationType(), (object)notification.get_SubscriptionId()); } PropertyBag propertyBag1 = new PropertyBag(notification.get_SourceInstanceProperties()); PropertyBag propertyBag2 = new PropertyBag(notification.get_IndicationProperties()); if (this.checkAuditingSetting) { try { object obj; if (IndicationHelper.GetIndicationType((IndicationType)2) == notification.get_IndicationType() && propertyBag1 != null && ((string)propertyBag1.TryGet <string>("SettingsID") == "SWNetPerfMon-AuditingTrails" && (string)propertyBag1.TryGet <string>("InstanceType") == "Orion.Settings") && ((Dictionary <string, object>)propertyBag1).TryGetValue("CurrentValue", out obj)) { this.AuditingTrailsEnabled = Convert.ToBoolean(obj); } else if (!this.AuditingTrailsEnabled) { return(Task.CompletedTask); } } catch (Exception ex) { AuditingNotificationSubscriber.log.FatalFormat("Auditing check error - will be forciby enabled. {0}", (object)ex); this.AuditingTrailsEnabled = true; this.checkAuditingSetting = false; } } AuditNotificationContainer auditNotificationContainer = new AuditNotificationContainer(notification.get_IndicationType(), propertyBag2, propertyBag1); IEnumerable <IAuditing2> iauditing2s; if (this.subscriptionIdToAuditingInstances.TryGetValue(notification.get_SubscriptionId().ToString(), out iauditing2s)) { using (IEnumerator <IAuditing2> enumerator1 = iauditing2s.GetEnumerator()) { while (((IEnumerator)enumerator1).MoveNext()) { IAuditing2 current1 = enumerator1.Current; try { if (AuditingNotificationSubscriber.log.get_IsTraceEnabled()) { AuditingNotificationSubscriber.log.TraceFormat("Trying plugin {0}", new object[1] { (object)current1 }); } IEnumerable <AuditDataContainer> source = ((IAuditing)current1).ComposeDataContainers(auditNotificationContainer); if (source != null) { if (AuditingNotificationSubscriber.log.get_IsTraceEnabled()) { AuditingNotificationSubscriber.log.Trace((object)"Storing notification."); } CultureInfo currentUiCulture = Thread.CurrentThread.CurrentUICulture; try { Thread.CurrentThread.CurrentUICulture = LocaleConfiguration.GetNonNeutralLocale(LocaleConfiguration.get_PrimaryLocale()); } catch (Exception ex) { AuditingNotificationSubscriber.log.Warn((object)"Unable set CurrentUICulture to PrimaryLocale.", ex); } using (IEnumerator <AuditDataContainer> enumerator2 = source.Select <AuditDataContainer, AuditDataContainer>((Func <AuditDataContainer, AuditDataContainer>)(composedDataContainer => new AuditDataContainer(composedDataContainer, auditNotificationContainer.get_AccountId()))).GetEnumerator()) { while (((IEnumerator)enumerator2).MoveNext()) { AuditDataContainer current2 = enumerator2.Current; AuditDatabaseDecoratedContainer decoratedContainer = new AuditDatabaseDecoratedContainer(current2, auditNotificationContainer, ((IAuditing)current1).GetMessage(current2)); int insertedId = this.auditingDAL.StoreNotification(decoratedContainer); this.PublishModificationOfAuditingEvents(decoratedContainer, insertedId); } } try { Thread.CurrentThread.CurrentUICulture = currentUiCulture; } catch (Exception ex) { AuditingNotificationSubscriber.log.Warn((object)"Unable set CurrentUICulture back to original locale.", ex); } } else if (AuditingNotificationSubscriber.log.get_IsTraceEnabled()) { AuditingNotificationSubscriber.log.Trace((object)"ComposeDataContainers returned null."); } } catch (Exception ex) { string seed = string.Empty; if (propertyBag2 != null) { seed = ((IEnumerable <KeyValuePair <string, object> >)propertyBag2).Aggregate <KeyValuePair <string, object>, string>(Environment.NewLine, (Func <string, KeyValuePair <string, object>, string>)((current, item) => current + this.FormatPropertyData("Indication Property: ", item.Key, item.Value))); } if (propertyBag1 != null) { seed = ((IEnumerable <KeyValuePair <string, object> >)propertyBag1).Aggregate <KeyValuePair <string, object>, string>(seed, (Func <string, KeyValuePair <string, object>, string>)((current, item) => current + this.FormatPropertyData("SourceInstance Property: ", item.Key, item.Value))); } AuditingNotificationSubscriber.log.ErrorFormat("Auditing translation failed. IndicationType: {0}, {1} PluginName: {2}, subscriptionId: {3} Exception: {4}", new object[5] { (object)notification.get_IndicationType(), (object)seed, (object)((IAuditing)current1).get_PluginName(), (object)notification.get_SubscriptionId(), (object)ex }); } } } } else if (AuditingNotificationSubscriber.log.get_IsDebugEnabled()) { AuditingNotificationSubscriber.log.DebugFormat("No auditing instances has been registered yet for subscriptionId '{0}'", (object)notification.get_SubscriptionId().ToString()); } return(Task.CompletedTask); }
// Token: 0x06000027 RID: 39 RVA: 0x000027E0 File Offset: 0x000009E0 public void OnIndication(string subscriptionId, string indicationType, PropertyBag indicationProperties, PropertyBag sourceInstanceProperties) { if (AuditingNotificationSubscriber.log.IsDebugEnabled) { AuditingNotificationSubscriber.log.DebugFormat("OnIndication type: {0} SubscriptionId: {1}", indicationType, subscriptionId); } if (this.checkAuditingSetting) { try { object value; if (IndicationHelper.GetIndicationType(2) == indicationType && sourceInstanceProperties != null && sourceInstanceProperties.TryGet <string>("SettingsID") == "SWNetPerfMon-AuditingTrails" && sourceInstanceProperties.TryGet <string>("InstanceType") == "Orion.Settings" && sourceInstanceProperties.TryGetValue("CurrentValue", out value)) { this.AuditingTrailsEnabled = Convert.ToBoolean(value); } else if (!this.AuditingTrailsEnabled) { return; } } catch (Exception ex) { AuditingNotificationSubscriber.log.FatalFormat("Auditing check error - will be forciby enabled. {0}", ex); this.AuditingTrailsEnabled = true; this.checkAuditingSetting = false; } } AuditNotificationContainer auditNotificationContainer = new AuditNotificationContainer(indicationType, indicationProperties, sourceInstanceProperties); Func <AuditDataContainer, AuditDataContainer> < > 9__0; Func <string, KeyValuePair <string, object>, string> < > 9__1; Func <string, KeyValuePair <string, object>, string> < > 9__2; foreach (IAuditing2 auditing in this.subscriptionIdToAuditingInstances[subscriptionId]) { try { if (AuditingNotificationSubscriber.log.IsTraceEnabled) { AuditingNotificationSubscriber.log.TraceFormat("Trying plugin {0}", new object[] { auditing }); } IEnumerable <AuditDataContainer> enumerable = auditing.ComposeDataContainers(auditNotificationContainer); if (enumerable != null) { if (AuditingNotificationSubscriber.log.IsTraceEnabled) { AuditingNotificationSubscriber.log.Trace("Storing notification."); } CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture; try { Thread.CurrentThread.CurrentUICulture = LocaleConfiguration.GetNonNeutralLocale(LocaleConfiguration.PrimaryLocale); } catch (Exception ex2) { AuditingNotificationSubscriber.log.Warn("Unable set CurrentUICulture to PrimaryLocale.", ex2); } IEnumerable <AuditDataContainer> source = enumerable; Func <AuditDataContainer, AuditDataContainer> selector; if ((selector = < > 9__0) == null) { selector = (< > 9__0 = ((AuditDataContainer composedDataContainer) => new AuditDataContainer(composedDataContainer, auditNotificationContainer.AccountId))); } foreach (AuditDataContainer auditDataContainer in source.Select(selector)) { AuditDatabaseDecoratedContainer auditDatabaseDecoratedContainer = new AuditDatabaseDecoratedContainer(auditDataContainer, auditNotificationContainer, auditing.GetMessage(auditDataContainer)); int insertedId = this.auditingDAL.StoreNotification(auditDatabaseDecoratedContainer); this.PublishModificationOfAuditingEvents(auditDatabaseDecoratedContainer, insertedId); } try { Thread.CurrentThread.CurrentUICulture = currentUICulture; continue; } catch (Exception ex3) { AuditingNotificationSubscriber.log.Warn("Unable set CurrentUICulture back to original locale.", ex3); continue; } } if (AuditingNotificationSubscriber.log.IsTraceEnabled) { AuditingNotificationSubscriber.log.Trace("ComposeDataContainers returned null."); } } catch (Exception ex4) { string text = string.Empty; if (indicationProperties != null) { string newLine = Environment.NewLine; Func <string, KeyValuePair <string, object>, string> func; if ((func = < > 9__1) == null) { func = (< > 9__1 = ((string current, KeyValuePair <string, object> item) => current + this.FormatPropertyData("Indication Property: ", item.Key, item.Value))); } text = indicationProperties.Aggregate(newLine, func); } if (sourceInstanceProperties != null) { string seed = text; Func <string, KeyValuePair <string, object>, string> func2; if ((func2 = < > 9__2) == null) { func2 = (< > 9__2 = ((string current, KeyValuePair <string, object> item) => current + this.FormatPropertyData("SourceInstance Property: ", item.Key, item.Value))); } text = sourceInstanceProperties.Aggregate(seed, func2); } AuditingNotificationSubscriber.log.ErrorFormat("Auditing translation failed. IndicationType: {0}, {1} PluginName: {2}, subscriptionId: {3} Exception: {4}", new object[] { indicationType, text, auditing.PluginName, subscriptionId, ex4 }); } } }