// Token: 0x06001603 RID: 5635 RVA: 0x00052250 File Offset: 0x00050450 private void OnIterateCompleted(object sender, EventArgs eventArgs) { if (this.context.InvocationInfo != null) { Guid uniqueId = this.context.UniqueId; this.parametersSetInLog = true; CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.Cmdlet, this.context.InvocationInfo.CommandName); CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.Parameters, TaskVerboseStringHelper.FormatUserSpecifiedParameters(this.context.InvocationInfo.UserSpecifiedParameters ?? new PropertyBag())); } }
// Token: 0x060015C1 RID: 5569 RVA: 0x00050C28 File Offset: 0x0004EE28 private void LogCmdletIterationEvent() { bool flag = this.context.ExchangeRunspaceConfig == null; bool flag2 = VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.WriteEventLogInEnglish.Enabled && (CultureInfo.CurrentUICulture != CmdletLogHelper.DefaultLoggingCulture || CultureInfo.CurrentCulture != CmdletLogHelper.DefaultLoggingCulture); object[] array = new object[27]; array[0] = ((this.context.InvocationInfo != null) ? this.context.InvocationInfo.DisplayName : string.Empty); array[1] = ((this.context.InvocationInfo == null) ? null : TaskVerboseStringHelper.FormatUserSpecifiedParameters(this.context.InvocationInfo.UserSpecifiedParameters ?? new PropertyBag())); array[2] = (flag ? ((this.context.UserInfo != null && this.context.UserInfo.ExecutingUserId != null) ? this.context.UserInfo.ExecutingUserId.ToString() : string.Empty) : this.context.ExchangeRunspaceConfig.IdentityName); array[3] = (flag ? null : this.context.ExchangeRunspaceConfig.LogonUserSid); array[4] = null; if (!flag) { SecurityIdentifier securityIdentifier = null; this.context.ExchangeRunspaceConfig.TryGetExecutingUserSid(out securityIdentifier); array[4] = securityIdentifier; } array[5] = this.GenerateApplicationString(); array[6] = CmdletIterationEventModule.processIdAndName; array[7] = (flag ? ((this.context.UserInfo != null) ? this.context.UserInfo.CurrentOrganizationId : null) : this.context.ExchangeRunspaceConfig.OrganizationId); array[8] = Environment.CurrentManagedThreadId; DateTime utcNow = DateTime.UtcNow; array[9] = utcNow.Subtract(this.lastDateTimeValue); this.lastDateTimeValue = utcNow; ADDriverContext threadADContext = ADSessionSettings.GetThreadADContext(); if (threadADContext == null) { array[10] = null; } else { array[10] = (flag2 ? TaskVerboseStringHelper.GetADServerSettings(null, threadADContext.ServerSettings, CmdletLogHelper.DefaultLoggingCulture) : TaskVerboseStringHelper.GetADServerSettings(null, threadADContext.ServerSettings, null)); } if (this.context.ErrorInfo.HasErrors) { if (this.context.ErrorInfo.Exception != null) { Exception exception = this.context.ErrorInfo.Exception; array[11] = exception; array[12] = this.context.ErrorInfo.ExchangeErrorCategory.Value; if (exception != null && exception.InnerException != null) { array[13] = exception.InnerException; } if (exception is LocalizedException) { array[14] = ((LocalizedException)exception).LocalizedString.StringId; if (!flag2) { goto IL_2DE; } LocalizedException ex = (LocalizedException)exception; IFormatProvider formatProvider = ex.FormatProvider; try { ex.FormatProvider = CmdletLogHelper.DefaultLoggingCulture; array[11] = ex.ToString(); goto IL_2DE; } finally { ex.FormatProvider = formatProvider; } } array[14] = "NonLocalizedException"; } else { array[11] = "null"; } } IL_2DE: object obj; this.context.Items.TryGetValue("Log_AdditionalLogData", out obj); array[15] = obj; LocalizedString delayedInfo = ThrottlingModule <ResourceThrottlingCallback> .GetDelayedInfo(this.context); if (!string.IsNullOrEmpty(delayedInfo)) { array[16] = (flag2 ? delayedInfo.ToString(CmdletLogHelper.DefaultLoggingCulture) : delayedInfo) + ThrottlingModule <ResourceThrottlingCallback> .GetThrottlingInfo(this.context); } array[17] = SuppressingPiiContext.NeedPiiSuppression; this.context.Items.TryGetValue("Log_CmdletProxyInfo", out obj); array[18] = obj; if (this.context.Items.TryGetValue("Log_ProxiedObjectCount", out obj)) { obj = string.Format("{0} objects execution has been proxied to remote server.", obj); } array[19] = obj; if (this.context.Items.TryGetValue("Log_RequestQueryFilterInGetTasks", out obj)) { array[20] = string.Format("Request Filter used is: {0}", obj); } if (this.context.Items.TryGetValue("Log_InternalQueryFilterInGetTasks", out obj)) { array[21] = string.Format("Cmdlet Filter used is: {0}", obj); } array[22] = this.outputObjectCount; array[23] = "ActivityId: " + ((ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value.ToString() : string.Empty); if (!flag && this.context.ExchangeRunspaceConfig != null) { array[24] = this.context.ExchangeRunspaceConfig.GetRBACInformationSummary(); } if (Constants.IsPowerShellWebService && HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Headers != null) { array[25] = HttpContext.Current.Request.Headers["client-request-id"]; } array[26] = CultureInfo.CurrentUICulture.Name; ExEventLog.EventTuple eventInfo; if (this.context.ErrorInfo.HasErrors) { eventInfo = TaskEventLogConstants.Tuple_LogCmdletError; } else if (this.context.WasCancelled) { eventInfo = TaskEventLogConstants.Tuple_LogCmdletCancelled; } else if (this.wasStopped) { eventInfo = TaskEventLogConstants.Tuple_LogCmdletStopped; } else { eventInfo = this.CmdletSuccessEventTuple; } try { TaskLogger.LogEvent("All", eventInfo, array); } catch (ArgumentException ex2) { if (this.context.CommandShell != null) { this.context.CommandShell.WriteWarning(Strings.WarningCannotWriteToEventLog(ex2.ToString())); } } }
// Token: 0x06001608 RID: 5640 RVA: 0x000524C4 File Offset: 0x000506C4 private void CommitLog(string loggingStep) { if (!this.logPendingCommit) { return; } this.logPendingCommit = false; Guid cmdletUniqueId = this.context.UniqueId; try { CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.CmdletUniqueId, cmdletUniqueId); if (loggingStep != null) { CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "Logging", loggingStep); } CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ProcessId, Constants.ProcessId); CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ProcessName, Constants.ProcessName); CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ThreadId, Environment.CurrentManagedThreadId); CmdletLatencyTracker.EndInternalTracking(cmdletUniqueId, "Cmd"); CmdletLatencyTracker.PushLatencyDetailsToLog(cmdletUniqueId, CmdletLogHelper.FuncNameToLogMetaDic, delegate(Enum metadata, double latency) { CmdletLogger.UpdateLatency(cmdletUniqueId, metadata, latency); }, delegate(string funcName, string totalLatency) { CmdletLogger.SafeAppendColumn(RpsCommonMetadata.GenericLatency, funcName, totalLatency); }); long num = CmdletLatencyTracker.StopLatencyTracker(cmdletUniqueId); CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.TotalTime, num); CmdletLatencyTracker.DisposeLatencyTracker(cmdletUniqueId); if (!this.parametersSetInLog) { if (this.context.InvocationInfo != null) { CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.Cmdlet, this.context.InvocationInfo.CommandName); CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.Parameters, TaskVerboseStringHelper.FormatUserSpecifiedParameters(this.context.InvocationInfo.UserSpecifiedParameters ?? new PropertyBag())); } else { CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "InvocationInfo", "null"); } } TaskUserInfo userInfo = this.context.UserInfo; if (userInfo != null) { CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.TenantId, userInfo.ExecutingUserOrganizationId.GetFriendlyName()); CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.AuthenticatedUser, (userInfo.ExecutingWindowsLiveId != SmtpAddress.Empty) ? userInfo.ExecutingWindowsLiveId.ToString() : ((userInfo.ExecutingUserId != null && !string.IsNullOrWhiteSpace(userInfo.ExecutingUserId.Name)) ? userInfo.ExecutingUserId.Name : userInfo.ExecutingUserIdentityName)); CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.EffectiveOrganization, userInfo.CurrentOrganizationId.GetFriendlyName()); } else { CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "UserInfo", "null"); } if (this.context.ExchangeRunspaceConfig != null) { CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.UserServicePlan, this.context.ExchangeRunspaceConfig.ServicePlanForLogging); CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.IsAdmin, this.context.ExchangeRunspaceConfig.HasAdminRoles); if (this.context.ExchangeRunspaceConfig.ConfigurationSettings != null && this.context.ExchangeRunspaceConfig.ConfigurationSettings.ClientApplication != ExchangeRunspaceConfigurationSettings.ExchangeApplication.Unknown) { CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.ClientApplication, this.context.ExchangeRunspaceConfig.ConfigurationSettings.ClientApplication); } } else { CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "ExchangeRunspaceConfig", "null"); } if (!CmdletLogHelper.DefaultLoggingCulture.Equals(CultureInfo.CurrentUICulture) || !CmdletLogHelper.DefaultLoggingCulture.Equals(CultureInfo.CurrentCulture)) { CmdletLogger.SafeSetLogger(cmdletUniqueId, RpsCmdletMetadata.CultureInfo, CultureInfo.CurrentUICulture + "," + CultureInfo.CurrentCulture); } } catch (Exception ex) { Diagnostics.LogExceptionWithTrace(Constants.CoreEventLogger, TaskEventLogConstants.Tuple_NonCrashingException, null, ExTraceGlobals.InstrumentationTracer, null, "Exception from CmdletLogger.AsyncCommit : {0}", ex); CmdletLogger.SafeAppendGenericError(cmdletUniqueId, "CommitLog", ex, new Func <Exception, bool>(TaskHelper.IsTaskUnhandledException)); } finally { try { CmdletLogger.SafeSetLogger(this.context.UniqueId, RpsCmdletMetadata.EndTime, DateTime.UtcNow); CmdletLogger.AsyncCommit(cmdletUniqueId, true); CmdletThreadStaticData.UnRegisterCmdletUniqueId(cmdletUniqueId); } catch (Exception exception) { this.logPendingCommit = true; Diagnostics.LogExceptionWithTrace(Constants.CoreEventLogger, TaskEventLogConstants.Tuple_NonCrashingException, null, ExTraceGlobals.InstrumentationTracer, null, "Exception from CmdletLogger.AsyncCommit : {0}", exception); } } }