internal static void UpdateActivityScopeRequestIdFromUrl(string httpUrl) { if (string.IsNullOrWhiteSpace(httpUrl)) { return; } Uri uri = new Uri(httpUrl); NameValueCollection urlProperties = LoggerHelper.GetUrlProperties(uri); string text = urlProperties["RequestId48CD6591-0506-4D6E-9131-797489A3260F"]; Guid guid; if (text == null || !Guid.TryParse(text, out guid)) { return; } ActivityScopeImpl activityScopeImpl = ActivityContext.GetCurrentActivityScope() as ActivityScopeImpl; if (activityScopeImpl == null) { return; } if (activityScopeImpl.ActivityId == guid) { return; } ActivityContextState state = new ActivityContextState(new Guid?(guid), LoggerHelper.EmptyConcurrentDic); activityScopeImpl.UpdateFromState(state); }
// Token: 0x060000BF RID: 191 RVA: 0x00005000 File Offset: 0x00003200 public void HandleEvent(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item) { using (new GuidTraceFilter(base.DatabaseInfo.Guid, mapiEvent.MailboxGuid)) { string value = (item != null) ? item.ClassName : mapiEvent.ObjectClass; if (!string.IsNullOrEmpty(value) || mapiEvent.ItemType == ObjectType.MAPI_STORE || mapiEvent.ItemType == ObjectType.MAPI_FOLDER) { EventBasedAssistant.Tracer.TraceDebug <EventBasedAssistant, long, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Started handling event {1} for mailbox {2}.", this, mapiEvent.EventCounter, itemStore.MailboxOwner); List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); Guid activityId = Guid.Empty; if (currentActivityScope != null) { activityId = currentActivityScope.ActivityId; } AssistantsLog.LogStartProcessingMailboxEvent(activityId, this, mapiEvent, itemStore.MailboxGuid); TraceContext.Set(itemStore); try { this.HandleEventInternal(mapiEvent, itemStore, item, list); goto IL_103; } finally { TraceContext.Reset(); AssistantsLog.LogEndProcessingMailboxEvent(activityId, this, list, itemStore.MailboxGuid, string.Empty, null); EventBasedAssistant.Tracer.TraceDebug <EventBasedAssistant, long, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Ended handling event {1} for mailbox {2}.", this, mapiEvent.EventCounter, itemStore.MailboxOwner); } } EventBasedAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Event not processed because we are unable get the ObjectClass on the item.", itemStore.MailboxOwner); IL_103 :; } }
public string GetCallerInformation() { int num = 0; if (string.IsNullOrEmpty(this.FilePath) || (num = this.FilePath.LastIndexOf("\\")) <= 0) { return(string.Empty); } IActivityScope activityScope = null; try { activityScope = (this.scope ?? ActivityContext.GetCurrentActivityScope()); } catch { } if (activityScope != null && !string.IsNullOrEmpty(activityScope.Action)) { return(string.Format("{0}: Method {1}; Line {2}; Action {3}", new object[] { this.FilePath.Substring(num + 1), this.MemberName, this.FileLine, activityScope.Action })); } return(string.Format("{0}: Method {1}; Line {2}", this.FilePath.Substring(num + 1), this.MemberName, this.FileLine)); }
public TResult Execute(CommandContext context) { this.Context = context; Stopwatch stopwatch = Stopwatch.StartNew(); TResult result; try { this.onBeforeExecute(); result = this.OnExecute(); } catch (Exception obj) { this.SetCustomLoggingData("Exception", obj); throw; } finally { stopwatch.Stop(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.SetProperty(EntitiesMetadata.CommandName, base.GetType().Name); currentActivityScope.SetProperty(EntitiesMetadata.CoreExecutionLatency, stopwatch.ElapsedMilliseconds.ToString()); string customLoggingData = this.GetCustomLoggingData(); currentActivityScope.SetProperty(EntitiesMetadata.CustomData, customLoggingData); } } return(result); }
private static string GetAuthUser(this HttpContextBase context) { if (context != null) { try { if (context.User != null && context.User.Identity.IsAuthenticated) { string name = context.User.Identity.Name; if (!string.IsNullOrEmpty(name)) { return(name); } } } catch (SystemException ex) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.AppendToProperty(ServiceCommonMetadata.GenericErrors, ex.Message); } } } return(null); }
private static void UploadContacts(MailboxSession mailboxSession, string accessToken) { NewFacebookSubscription.Tracer.TraceFunction(0L, "Entering NewFacebookSubscription.UploadContacts. Mailbox {0}.", new object[] { mailboxSession.Identity }); try { IPeopleConnectApplicationConfig peopleConnectApplicationConfig = CachedPeopleConnectApplicationConfig.Instance.ReadFacebook(); string graphApiEndpoint = peopleConnectApplicationConfig.GraphApiEndpoint; using (FacebookClient facebookClient = new FacebookClient(new Uri(graphApiEndpoint))) { ContactsUploaderPerformanceTracker contactsUploaderPerformanceTracker = new ContactsUploaderPerformanceTracker(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.UserState = contactsUploaderPerformanceTracker; } else { NewFacebookSubscription.Tracer.TraceFunction(0L, "Can't add metadata for Contacts upload as there is no current activity scope."); } FacebookContactsUploader facebookContactsUploader = new FacebookContactsUploader(contactsUploaderPerformanceTracker, facebookClient, peopleConnectApplicationConfig, (PropertyDefinition[] propertiesToLoad) => new RecursiveContactsEnumerator(mailboxSession, new XSOFactory(), DefaultFolderType.Contacts, propertiesToLoad)); facebookContactsUploader.UploadContacts(accessToken); } } finally { NewFacebookSubscription.Tracer.TraceFunction(0L, "Leaving NewFacebookSubscription.UploadContacts. Mailbox {0}.", new object[] { mailboxSession.Identity }); } }
// Token: 0x060010D1 RID: 4305 RVA: 0x00062714 File Offset: 0x00060914 public void SetMetadataValues(object context, RecipientType recipientType, string chunkId) { this.TraceDebug(context, "Entering SetMetadataValues - TaskName='{0}', RecipientType='{1}', ChunkId='{2}'", new object[] { this.TaskName, recipientType, chunkId }); Logger.RegisterMetadata(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null && currentActivityScope.Status == ActivityContextStatus.ActivityStarted) { this.TraceDebug(context, "Setting metadata values TaskName='{0}', RecipientType='{1}', ChunkId='{2}', MailboxGuid='{3}', TenantGuid='{4}'", new object[] { this.TaskName, recipientType, chunkId, this.RunData.MailboxGuid, this.RunData.TenantGuid }); currentActivityScope.SetProperty(DirectoryProcessorMetadata.TaskName, this.TaskName); currentActivityScope.SetProperty(DirectoryProcessorMetadata.RecipientType, recipientType.ToString()); currentActivityScope.SetProperty(DirectoryProcessorMetadata.ChunkId, chunkId); currentActivityScope.SetProperty(DirectoryProcessorMetadata.MailboxGuid, this.RunData.MailboxGuid.ToString()); currentActivityScope.SetProperty(DirectoryProcessorMetadata.TenantGuid, this.RunData.TenantGuid.ToString()); } }
public static void PublishMetadata() { if (!BudgetMetadataPublisher.isBudgetMetadataRegistered) { ActivityContext.RegisterMetadata(typeof(BudgetMetadata)); BudgetMetadataPublisher.isBudgetMetadataRegistered = true; } HttpContext httpContext = HttpContext.Current; if (httpContext == null) { return; } IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope == null) { return; } string contextItem = httpContext.GetContextItem("StartBudget"); if (contextItem != null) { string[] budgetElements = contextItem.Split(new char[] { ',' }); currentActivityScope.SetProperty(BudgetMetadata.BeginBudgetConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 1)); currentActivityScope.SetProperty(BudgetMetadata.MaxConn, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 2)); currentActivityScope.SetProperty(BudgetMetadata.MaxBurst, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 3)); currentActivityScope.SetProperty(BudgetMetadata.BeginBalance, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 4)); currentActivityScope.SetProperty(BudgetMetadata.Cutoff, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 5)); currentActivityScope.SetProperty(BudgetMetadata.RechargeRate, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 6)); currentActivityScope.SetProperty(BudgetMetadata.ThrottlingPolicy, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 7)); currentActivityScope.SetProperty(BudgetMetadata.IsServiceAct, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 8)); currentActivityScope.SetProperty(BudgetMetadata.LiveTime, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 9)); currentActivityScope.SetProperty(BudgetMetadata.BeginBudgetHangingConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements, 10)); currentActivityScope.SetProperty(BudgetMetadata.BeginBudgetSubscriptions, BudgetMetadataPublisher.GetBugdetSnapshotSubscriptions(contextItem)); } currentActivityScope.SetProperty(BudgetMetadata.TotalDCRequestCount, httpContext.GetContextItem("TotalLdapRequestCount")); currentActivityScope.SetProperty(BudgetMetadata.TotalDCRequestLatency, httpContext.GetContextItem("TotalLdapRequestLatency")); currentActivityScope.SetProperty(BudgetMetadata.TotalMBXRequestCount, httpContext.GetContextItem("TotalRpcRequestCount")); currentActivityScope.SetProperty(BudgetMetadata.TotalMBXRequestLatency, httpContext.GetContextItem("TotalRpcRequestLatency")); string contextItem2 = httpContext.GetContextItem("EndBudget"); if (contextItem2 != null) { string[] budgetElements2 = contextItem2.Split(new char[] { ',' }); currentActivityScope.SetProperty(BudgetMetadata.EndBudgetConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements2, 1)); currentActivityScope.SetProperty(BudgetMetadata.EndBalance, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements2, 4)); currentActivityScope.SetProperty(BudgetMetadata.EndBudgetHangingConnections, BudgetMetadataPublisher.GetBudgetSnapshotValueAtIndex(budgetElements2, 10)); string bugdetSnapshotResources = BudgetMetadataPublisher.GetBugdetSnapshotResources(contextItem2); BudgetMetadataPublisher.SetBudgetSnapshotResourceInfo(bugdetSnapshotResources, currentActivityScope); currentActivityScope.SetProperty(BudgetMetadata.EndBudgetSubscriptions, BudgetMetadataPublisher.GetBugdetSnapshotSubscriptions(contextItem2)); } }
private Guid GetActivityId() { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); Guid guid = (currentActivityScope != null) ? currentActivityScope.ActivityId : Guid.NewGuid(); this.AddVerboseLog("ActivityId: " + guid); return(guid); }
public GroupMailboxConfigurationActionStopwatch(GroupMailboxConfigurationReport report, GroupMailboxConfigurationAction actionType) { this.report = report; this.actionType = actionType; this.activityScope = ActivityContext.GetCurrentActivityScope(); this.stopwatch = Stopwatch.StartNew(); this.initialLatencyStatistics = this.CreateLatencyStatisticsSnapshot(); }
private static void OnAgentInvokeStart(object dispatcher, IMExSession context) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = context.CurrentAgent.Name; } }
private static void OnAgentInvokeReturns(object dispatcher, IMExSession context) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = null; } }
public void Dispose() { this.performanceTracker.Stop(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.Action = this.previousActionDescription; } }
private static Guid GetActivityId() { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope == null) { return(Guid.NewGuid()); } return(currentActivityScope.ActivityId); }
// Token: 0x06002599 RID: 9625 RVA: 0x0008835C File Offset: 0x0008655C public ICollection <KeyValuePair <string, object> > GetEventData() { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); Dictionary <string, object> dictionary = new Dictionary <string, object> { { UserContextCookie.UserContextCookiePrefix, this.userContextKey }, { "ActID", (currentActivityScope == null) ? Guid.Empty : currentActivityScope.ActivityId }, { "C", this.userContextStatistics.Created.ToString(CultureInfo.InvariantCulture) }, { "CT", this.userContextStatistics.AcquireLatency }, { "EPT", this.userContextStatistics.ExchangePrincipalCreationTime }, { "MR", this.userContextStatistics.MiniRecipientCreationTime }, { "SKU", this.userContextStatistics.SKUCapabilityTestTime }, { "IL", this.userContextStatistics.CookieCreated ? 1 : 0 }, { "Err", (int)this.userContextStatistics.Error }, { "CAN", this.requestUri.AbsolutePath } }; if (this.userContext != null && this.userContext.ExchangePrincipal != null) { dictionary.Add("MG", this.userContext.ExchangePrincipal.MailboxInfo.MailboxGuid); dictionary.Add("PSA", ExtensibleLogger.FormatPIIValue(this.userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString())); } return(dictionary); }
public TaskFrame(SyncActivity activity, PublicFolderActivityPerformanceTracker performanceTracker) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { this.previousActionDescription = currentActivityScope.Action; currentActivityScope.Action = activity.ToString(); } this.performanceTracker = performanceTracker; this.performanceTracker.Start(); }
// Token: 0x06000663 RID: 1635 RVA: 0x000177AC File Offset: 0x000159AC public AdminAuditOpticsLogData() { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { this.requestId = currentActivityScope.ActivityId; return; } this.activityScopeToDispose = ActivityContext.Start(null); this.requestId = this.activityScopeToDispose.ActivityId; }
public AuditLogOpticsLogData() { this.Stopwatch = Stopwatch.StartNew(); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { this.requestId = currentActivityScope.ActivityId; return; } this.activityScopeToDispose = ActivityContext.Start(null); this.requestId = this.activityScopeToDispose.ActivityId; }
private static IActivityScope GetCurrentActivityScope(HttpContextBase context) { IActivityScope activityScope = null; if (context != null) { activityScope = (context.Items[typeof(ActivityScope)] as IActivityScope); } if (activityScope == null) { activityScope = ActivityContext.GetCurrentActivityScope(); } return(activityScope); }
internal static Uri BuildCmdletProxyUri(string targetFqdn, ExchangeRunspaceConfiguration runspaceConfig, int targetVersion) { if (string.IsNullOrWhiteSpace(targetFqdn)) { throw new ArgumentNullException("targetFqdn"); } if (runspaceConfig == null) { throw new ArgumentNullException("runspaceConfig"); } ExchangeRunspaceConfigurationSettings configurationSettings = runspaceConfig.ConfigurationSettings; ExAssert.RetailAssert(configurationSettings != null, "runspaceConfig.ConfigurationSettings should not be null."); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("https://"); stringBuilder.Append(targetFqdn); if (targetVersion >= Server.E15MinVersion) { stringBuilder.Append(":444/powershell/Powershell-proxy?"); } else { stringBuilder.Append("/Powershell-proxy?"); } stringBuilder.AppendFormat("{0}={1}", "X-Rps-CAT", Uri.EscapeDataString(configurationSettings.UserToken.CommonAccessTokenForCmdletProxy().Serialize())); stringBuilder.AppendFormat(";{0}={1}", "serializationLevel", configurationSettings.CurrentSerializationLevel.ToString()); stringBuilder.AppendFormat(";{0}={1}", "clientApplication", configurationSettings.ClientApplication.ToString()); if (configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.ECP || configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.EMC || configurationSettings.ClientApplication == ExchangeRunspaceConfigurationSettings.ExchangeApplication.OSP) { stringBuilder.AppendFormat(";{0}={1}", "proxyFullSerialization", "true"); } string managedOrganization = ProxyHelper.GetManagedOrganization(runspaceConfig); if (!string.IsNullOrEmpty(managedOrganization)) { stringBuilder.AppendFormat(";{0}", ProxyHelper.GetOrganizationAppendQueryIfNeeded(managedOrganization)); } stringBuilder.AppendFormat(";{0}={1}", WellKnownHeader.CmdletProxyIsOn, "99C6ECEE-5A4F-47B9-AE69-49EAFB58F368"); IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null && currentActivityScope.ActivityId != Guid.Empty) { stringBuilder.AppendFormat(";{0}={1}", "RequestId48CD6591-0506-4D6E-9131-797489A3260F", currentActivityScope.ActivityId); } return(new Uri(stringBuilder.ToString())); }
// Token: 0x06000790 RID: 1936 RVA: 0x0001BD48 File Offset: 0x00019F48 public WebResponse SendRequest(string requestUri, NetworkCredential credential, string method, int timeout, bool allowAutoRedirect, string contentType, NameValueCollection headers, string requestContent) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUri); httpWebRequest.Credentials = credential; httpWebRequest.Method = method; httpWebRequest.Timeout = timeout; httpWebRequest.AllowAutoRedirect = allowAutoRedirect; httpWebRequest.ContentType = contentType; foreach (object obj in headers.Keys) { string name = (string)obj; httpWebRequest.Headers[name] = headers[name]; } IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.SerializeTo(httpWebRequest); } if (!string.IsNullOrEmpty(requestContent)) { byte[] bytes = Encoding.UTF8.GetBytes(requestContent); try { using (Stream requestStream = httpWebRequest.GetRequestStream()) { requestStream.Write(bytes, 0, bytes.Length); } } catch (Exception ex) { throw new PswsProxyException(Strings.PswsRequestException(ex.Message), ex); } } WebResponse result = null; try { result = httpWebRequest.GetResponse(); } catch (Exception ex2) { throw new PswsProxyException(Strings.PswsRequestException(ex2.Message), ex2); } return(result); }
internal static void Append(string operation, string parameter, string ipAddress, string resultCode, GlsRawResponse rawResponse, long processingTime, string failure, string transactionid, string connectionid, string diagnostics) { Guid activityId = Guid.Empty; try { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null && currentActivityScope.Status == ActivityContextStatus.ActivityStarted) { activityId = currentActivityScope.ActivityId; } } catch (Exception ex) { diagnostics += ex.ToString(); } GLSLogger.AppendInternal(operation, parameter, ipAddress, resultCode, rawResponse, processingTime, failure, transactionid, connectionid, diagnostics, activityId); }
internal void InitializeDiagnostics(HttpContextBase context) { context.InitializeLogging(); this.Logger = RequestLogger.GetLogger(context); this.Logger.LatencyTracker.LogElapsedTimeInDetailedLatencyInfo("Diagnosticmodule_InitializeDiagnostics_Start"); this.activityScope = (context.Items[typeof(ActivityScope)] as IActivityScope); if (this.activityScope == null) { this.activityScope = ActivityContext.GetCurrentActivityScope(); if (this.activityScope == null) { this.activityScope = ActivityContext.Start(null); } context.Items[typeof(ActivityScope)] = this.activityScope; } this.AddDiagnosticHeaders(context.Request); this.Logger.LatencyTracker.LogElapsedTimeInDetailedLatencyInfo("Diagnosticmodule_InitializeDiagnostics_End"); }
private static ActivitySession.ClientInfo ExtractClientInfo(MailboxSession mailboxSession) { ActivitySession.ClientInfo clientInfo = new ActivitySession.ClientInfo { Id = ClientId.Other, Version = "15.00.1497.012" }; string text = (mailboxSession == null || mailboxSession.ClientInfoString == null) ? string.Empty : mailboxSession.ClientInfoString; if (text.Equals("Client=MSExchangeRPC", StringComparison.OrdinalIgnoreCase) && ActivityContext.GetCurrentActivityScope() != null) { clientInfo = ActivitySession.ExtractMapiClientInfo(ActivityContext.GetCurrentActivityScope().ClientInfo, clientInfo); } else if (text.IndexOf("macoutlook", StringComparison.OrdinalIgnoreCase) != -1) { clientInfo.Id = ClientId.MacOutlook; } else if (text.IndexOf("Client=OWA", StringComparison.OrdinalIgnoreCase) != -1) { clientInfo.Id = ClientId.Web; } else if (text.IndexOf("Client=ActiveSync", StringComparison.OrdinalIgnoreCase) != -1) { clientInfo.Id = ClientId.Mobile; } else if (text.StartsWith("Client=Hub Transport", StringComparison.OrdinalIgnoreCase)) { clientInfo.Id = ClientId.Exchange; } else if (text.StartsWith("Client=POP3/IMAP4;Protocol=POP3", StringComparison.OrdinalIgnoreCase)) { clientInfo.Id = ClientId.POP3; } else if (text.StartsWith("Client=POP3/IMAP4;Protocol=IMAP4", StringComparison.OrdinalIgnoreCase)) { clientInfo.Id = ClientId.IMAP4; } else { clientInfo.Id = ClientId.Other; } clientInfo.Id = clientInfo.Id.GetServerSideInstrumentationVariant(true); return(clientInfo); }
internal static void SetResponseHeader(this HttpContext context, string source, string propertyName, string value) { if (!string.IsNullOrEmpty(value)) { try { string name = string.Format("{0}_{1}_{2}", "X-DEBUG", source, propertyName); context.Response.Headers[name] = value; } catch (SystemException ex) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.AppendToProperty(ServiceCommonMetadata.GenericErrors, ex.Message); } } } }
private static string GetRequestHeader(this HttpRequestBase request, string key) { if (request != null) { try { return(request.Headers[key]); } catch (SystemException ex) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null) { currentActivityScope.AppendToProperty(ServiceCommonMetadata.GenericErrors, ex.Message); } } } return(null); }
public Activity(ActivityId id, ClientId clientId, ExDateTime timeStamp, Guid clientSessionId, string clientVersion, long sequenceNumber, IMailboxSession mailboxSession, StoreObjectId itemId = null, StoreObjectId previousItemId = null, IDictionary <string, string> customProperties = null) : this(new MemoryPropertyBag()) { ArgumentValidator.ThrowIfNull("clientId", clientId); ArgumentValidator.ThrowIfNullOrEmpty("clientVersion", clientVersion); ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession); EnumValidator <ActivityId> .ThrowIfInvalid(id); if (id == ActivityId.Min) { throw new ArgumentException("The value supplied for ActivityId is invalid (ActivityId.Min)"); } if (clientId == ClientId.Min) { throw new ArgumentException("The value is not a valid ClientId (ClientId.Min)"); } if (!timeStamp.HasTimeZone) { throw new ArgumentException("Timestamp has unspecified timezone: " + Activity.BuildDiagnosticString(id, clientId, timeStamp, clientSessionId, clientVersion, sequenceNumber, mailboxSession, itemId, previousItemId, customProperties)); } this.Id = id; this.ClientId = clientId; this.TimeStamp = timeStamp.ToUtc(); this.ClientSessionId = clientSessionId; this.SequenceNumber = sequenceNumber; this.ClientVersion = clientVersion; this.MailboxGuid = mailboxSession.MailboxGuid; IUserPrincipal userPrincipal = mailboxSession.MailboxOwner as IUserPrincipal; this.NetId = ((userPrincipal != null) ? userPrincipal.NetId : null); if (mailboxSession.Capabilities != null && mailboxSession.Capabilities.CanHaveCulture && mailboxSession.PreferedCulture != null) { this.LocaleName = mailboxSession.PreferedCulture.Name; this.LocaleId = Activity.GetLcidFromMailboxSession(mailboxSession); } IExchangePrincipal mailboxOwner = mailboxSession.MailboxOwner; if (mailboxOwner != null) { if (mailboxOwner.MailboxInfo.OrganizationId != null && mailboxOwner.MailboxInfo.OrganizationId.OrganizationalUnit != null) { this.TenantName = mailboxOwner.MailboxInfo.OrganizationId.OrganizationalUnit.Name; } this.mailboxType = new long?((long)mailboxOwner.RecipientTypeDetails); } if (itemId != null) { this.ItemId = itemId; } if (previousItemId != null) { this.PreviousItemId = previousItemId; } this.CustomPropertiesDictionary = (customProperties ?? new Dictionary <string, string>()); if (clientId.Equals(ClientId.Other, true)) { this.customPropertiesDictionary["ClientString"] = mailboxSession.ClientInfoString; IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope != null && !string.IsNullOrEmpty(currentActivityScope.ClientInfo)) { this.customPropertiesDictionary["ActivityScopeClientInfo"] = currentActivityScope.ClientInfo; } } this.activityCreationTime = ExDateTime.UtcNow; }
internal static void InitializeRequestLogger() { if (!LoggerSettings.LogEnabled) { return; } if (LoggerSettings.IsRemotePS) { IActivityScope activityScope = null; if (!ActivityContext.IsStarted) { ActivityContext.ClearThreadScope(); activityScope = ActivityContext.Start(null); } RequestDetailsLoggerBase <RpsAuthZLogger> .InitializeRequestLogger(activityScope ?? ActivityContext.GetCurrentActivityScope()); } }
internal static void AsyncCommit(Guid cmdletUniqueId, bool forceSync) { if (!LoggerSettings.LogEnabled) { return; } if (!LoggerHelper.IsPswsNormalRequest) { IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope(); if (currentActivityScope == null) { throw new ArgumentException("activityScope is null."); } RequestDetailsLoggerBase <RpsCmdletLogger> .InitializeRequestLogger(currentActivityScope); RpsCmdletLogger rpsCmdletLogger = RequestDetailsLoggerBase <RpsCmdletLogger> .Current; if (rpsCmdletLogger == null) { return; } rpsCmdletLogger.EndActivityContext = false; RpsCmdletLoggerBuffer rpsCmdletLoggerBuffer = RpsCmdletLoggerBuffer.Get(cmdletUniqueId); foreach (KeyValuePair <Enum, object> keyValuePair in rpsCmdletLoggerBuffer.MetadataLogCache) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeSetLogger(rpsCmdletLogger, keyValuePair.Key, keyValuePair.Value); } foreach (KeyValuePair <string, string> keyValuePair2 in rpsCmdletLoggerBuffer.GenericInfoLogCache) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeAppendColumn(rpsCmdletLogger, RpsCmdletMetadata.GenericInfo, keyValuePair2.Key, keyValuePair2.Value); } foreach (KeyValuePair <string, string> keyValuePair3 in rpsCmdletLoggerBuffer.GenericErrorLogCache) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeAppendColumn(rpsCmdletLogger, RpsCmdletMetadata.GenericErrors, keyValuePair3.Key, keyValuePair3.Value); } foreach (KeyValuePair <Enum, Dictionary <string, string> > keyValuePair4 in rpsCmdletLoggerBuffer.GenericColumnLogCache) { foreach (KeyValuePair <string, string> keyValuePair5 in keyValuePair4.Value) { RequestDetailsLoggerBase <RpsCmdletLogger> .SafeAppendColumn(rpsCmdletLogger, keyValuePair4.Key, keyValuePair5.Key, keyValuePair5.Value); } } foreach (KeyValuePair <Enum, double> keyValuePair6 in rpsCmdletLoggerBuffer.LatencyLogCache) { rpsCmdletLogger.UpdateLatency(keyValuePair6.Key, keyValuePair6.Value); } rpsCmdletLogger.AsyncCommit(forceSync); foreach (KeyValuePair <Enum, object> keyValuePair7 in rpsCmdletLoggerBuffer.MetadataLogCache) { currentActivityScope.SetProperty(keyValuePair7.Key, null); } foreach (KeyValuePair <Enum, double> keyValuePair8 in rpsCmdletLoggerBuffer.LatencyLogCache) { currentActivityScope.SetProperty(keyValuePair8.Key, null); } foreach (KeyValuePair <Enum, Dictionary <string, string> > keyValuePair9 in rpsCmdletLoggerBuffer.GenericColumnLogCache) { currentActivityScope.SetProperty(keyValuePair9.Key, null); } currentActivityScope.SetProperty(RpsCmdletMetadata.GenericInfo, null); currentActivityScope.SetProperty(RpsCmdletMetadata.GenericErrors, null); rpsCmdletLoggerBuffer.Reset(); CmdletStaticDataWithUniqueId <RpsCmdletLoggerBuffer> .Remove(cmdletUniqueId); } }