Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
0
        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);
            }
        }