private static void LogMailboxSlaEvent(AssistantBase assistant, Guid mailboxGuid, string mailboxDisplayNameTracingOnlyUsage, TimeBasedDatabaseJob job, MailboxSlaEventType eventType, MailboxSlaFilterReasonType reason = MailboxSlaFilterReasonType.None, Exception exception = null)
        {
            string text         = "Unknown";
            string databaseName = "Unknown";
            string jobId        = string.Empty;
            MailboxSlaRequestType requestType = MailboxSlaRequestType.Unknown;

            if (assistant != null)
            {
                databaseName = ((assistant.DatabaseInfo == null) ? "Unknown" : assistant.DatabaseInfo.DatabaseName);
                text         = assistant.NonLocalizedName;
            }
            if (job != null)
            {
                jobId       = job.StartTime.ToString("O");
                requestType = ((job is TimeBasedDatabaseWindowJob) ? MailboxSlaRequestType.Scheduled : MailboxSlaRequestType.OnDemand);
            }
            MailboxAssistantsSlaReportLogFactory.MailboxAssistantsSlaReportLog logInstance = MailboxAssistantsSlaReportLogFactory.GetLogInstance(text, SlaLogType.MailboxSlaLog);
            if (logInstance != null)
            {
                logInstance.LogMailboxEvent(text, databaseName, jobId, requestType, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, eventType, reason, exception);
            }
        }
Beispiel #2
0
            // Token: 0x060005AD RID: 1453 RVA: 0x0001BB20 File Offset: 0x00019D20
            internal void LogMailboxEvent(string assistantName, string databaseName, string jobId, MailboxSlaRequestType requestType, Guid mailboxGuid, string mailboxDisplayNameTracingOnlyUsage, MailboxSlaEventType eventType, MailboxSlaFilterReasonType reason = MailboxSlaFilterReasonType.None, Exception exception = null)
            {
                if (!this.ShouldLog())
                {
                    return;
                }
                LogRowFormatter logRowFormatter = new LogRowFormatter(base.LogSchema);

                logRowFormatter[1]  = this.ServerName;
                logRowFormatter[2]  = (assistantName ?? string.Empty);
                logRowFormatter[3]  = (databaseName ?? string.Empty);
                logRowFormatter[4]  = (jobId ?? string.Empty);
                logRowFormatter[5]  = ((requestType == MailboxSlaRequestType.Unknown) ? string.Empty : requestType.ToString());
                logRowFormatter[6]  = ((mailboxGuid == Guid.Empty) ? string.Empty : mailboxGuid.ToString("D"));
                logRowFormatter[7]  = eventType.ToString();
                logRowFormatter[8]  = ((reason == MailboxSlaFilterReasonType.None) ? string.Empty : reason.ToString());
                logRowFormatter[9]  = ((exception != null) ? exception.GetType().ToString() : string.Empty);
                logRowFormatter[10] = ((exception != null && exception.InnerException != null) ? exception.InnerException.GetType().ToString() : string.Empty);
                base.AppendLog(logRowFormatter);
                if (base.IsDebugTraceEnabled)
                {
                    string message = string.Format("Assistant: {0}, Server: {1}, Database: {2}, WindowJob: {3}, Request: {4}, Mailbox: {5}, Event: {6}, Reason: {7}, Exception: {8}", new object[]
                    {
                        assistantName,
                        this.ServerName,
                        databaseName ?? string.Empty,
                        jobId ?? string.Empty,
                        requestType,
                        string.IsNullOrEmpty(mailboxDisplayNameTracingOnlyUsage) ? mailboxGuid.ToString("D") : mailboxDisplayNameTracingOnlyUsage,
                        eventType,
                        (reason == MailboxSlaFilterReasonType.None) ? string.Empty : reason.ToString(),
                        (exception != null) ? exception.Message : string.Empty
                    });
                    base.SafeTraceDebug((long)this.GetHashCode(), message, new object[0]);
                }
            }
        internal static void LogErrorProcessingMailboxEvent(string assistantName, MailboxData mailbox, Exception e, string databaseName = "", string jobId = "", MailboxSlaRequestType requestType = MailboxSlaRequestType.Unknown)
        {
            string value             = string.Empty;
            string value2            = "unknown";
            string value3            = "unknown";
            Guid   guid              = Guid.Empty;
            string value4            = string.Empty;
            string value5            = (e.InnerException != null) ? e.InnerException.GetType().ToString() : "null";
            string diagnosticContext = AssistantsLog.GetDiagnosticContext(e);
            Guid   activityId        = (ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value : Guid.Empty;

            if (mailbox != null)
            {
                value3 = mailbox.DatabaseGuid.ToString();
                StoreMailboxData storeMailboxData = mailbox as StoreMailboxData;
                if (storeMailboxData != null)
                {
                    value2 = "Store";
                    guid   = storeMailboxData.Guid;
                    if (storeMailboxData.OrganizationId != null)
                    {
                        value = storeMailboxData.OrganizationId.ToString();
                    }
                }
                else
                {
                    AdminRpcMailboxData adminRpcMailboxData = mailbox as AdminRpcMailboxData;
                    if (adminRpcMailboxData != null)
                    {
                        value2 = "AdminRpc";
                        value4 = adminRpcMailboxData.MailboxNumber.ToString(CultureInfo.InvariantCulture);
                    }
                }
            }
            List <KeyValuePair <string, object> > customData = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>("MailboxType", value2),
                new KeyValuePair <string, object>("MailboxGuid", guid),
                new KeyValuePair <string, object>("MailboxId", value4),
                new KeyValuePair <string, object>("TenantId", value),
                new KeyValuePair <string, object>("Database", value3),
                new KeyValuePair <string, object>("ExceptionType", e.GetType().ToString()),
                new KeyValuePair <string, object>("InnerExceptionType", value5),
                new KeyValuePair <string, object>("DiagnosticContext", diagnosticContext)
            };

            AssistantsLog.InternalLogRow(activityId, assistantName, null, AssistantsEventType.ErrorProcessingMailbox, customData, guid);
            if (!string.IsNullOrEmpty(assistantName))
            {
                MailboxAssistantsSlaReportLogFactory.MailboxAssistantsSlaReportLog logInstance = MailboxAssistantsSlaReportLogFactory.GetLogInstance(assistantName, SlaLogType.MailboxSlaLog);
                if (logInstance != null)
                {
                    logInstance.LogMailboxEvent(assistantName, databaseName, jobId, requestType, guid, (mailbox == null) ? string.Empty : mailbox.DisplayName, MailboxSlaEventType.ErrorProcessingMailbox, MailboxSlaFilterReasonType.None, e);
                }
            }
        }