Exemple #1
0
 // Token: 0x060000D7 RID: 215 RVA: 0x000058D0 File Offset: 0x00003AD0
 public AssistantTaskContext(MailboxData mailboxData, TimeBasedDatabaseJob job, List <KeyValuePair <string, object> > customDataToLog = null)
 {
     this.mailboxData     = mailboxData;
     this.job             = job;
     this.CustomDataToLog = (customDataToLog ?? new List <KeyValuePair <string, object> >());
     if (job != null)
     {
         this.step = new AssistantStep(job.Assistant.InitialStep);
     }
 }
        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);
            }
        }
        internal static void LogMailboxFailedToOpenStoreSessionEvent(Guid activityId, string assistantName, AssistantBase assistant, Exception storeSessionException, Guid mailboxGuid, string mailboxDisplayNameTracingOnlyUsage, TimeBasedDatabaseJob job)
        {
            List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >();

            if (storeSessionException != null)
            {
                list.Add(new KeyValuePair <string, object>("ExceptionType", storeSessionException.GetType().ToString()));
                list.Add(new KeyValuePair <string, object>("ExceptionMessage", storeSessionException.Message));
                if (storeSessionException.InnerException != null)
                {
                    list.Add(new KeyValuePair <string, object>("InnerExceptionType", storeSessionException.InnerException.GetType().ToString()));
                    list.Add(new KeyValuePair <string, object>("InnerExceptionMessage", storeSessionException.InnerException.Message));
                }
            }
            AssistantsLog.InternalLogRow(activityId, assistantName, assistant, AssistantsEventType.FailedOpenMailboxStoreSession, list, mailboxGuid);
            AssistantsLog.LogMailboxSlaEvent(assistant, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, job, MailboxSlaEventType.FailedOpenMailboxStoreSession, MailboxSlaFilterReasonType.None, storeSessionException);
        }
 internal static void LogMailboxSucceedToOpenStoreSessionEvent(Guid activityId, string assistantName, AssistantBase assistant, Guid mailboxGuid, string mailboxDisplayNameTracingOnlyUsage, TimeBasedDatabaseJob job)
 {
     AssistantsLog.InternalLogRow(activityId, assistantName, assistant, AssistantsEventType.SucceedOpenMailboxStoreSession, null, mailboxGuid);
     AssistantsLog.LogMailboxSlaEvent(assistant, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, job, MailboxSlaEventType.SucceedOpenMailboxStoreSession, MailboxSlaFilterReasonType.None, null);
 }
 internal static void LogEndProcessingMailboxEvent(Guid activityId, AssistantBase assistant, List <KeyValuePair <string, object> > customData, Guid mailboxGuid, string mailboxDisplayNameTracingOnlyUsage, TimeBasedDatabaseJob job = null)
 {
     AssistantsLog.InternalLogAssistantEvent(activityId, assistant, AssistantsEventType.EndProcessingMailbox, customData, mailboxGuid);
     if (job != null)
     {
         AssistantsLog.LogMailboxSlaEvent(assistant, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, job, MailboxSlaEventType.EndProcessingMailbox, MailboxSlaFilterReasonType.None, null);
     }
 }
 internal static void LogStartProcessingMailboxEvent(Guid activityId, AssistantBase assistant, Guid mailboxGuid, string mailboxDisplayNameTracingOnlyUsage, TimeBasedDatabaseJob job)
 {
     ArgumentValidator.ThrowIfNull("job", job);
     AssistantsLog.InternalLogAssistantEvent(activityId, assistant, AssistantsEventType.StartProcessingMailbox, null, mailboxGuid);
     AssistantsLog.LogMailboxSlaEvent(assistant, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, job, MailboxSlaEventType.StartProcessingMailbox, MailboxSlaFilterReasonType.None, null);
 }
        // Token: 0x060003F3 RID: 1011 RVA: 0x00013198 File Offset: 0x00011398
        protected AssistantTaskContext ProcessOneMailbox(ref AssistantTaskContext context)
        {
            lock (this.instanceLock)
            {
                if (context == null)
                {
                    if (!this.started)
                    {
                        ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, string>((long)this.GetHashCode(), "{0}: Worker bailing (Not started) for assistant: {1}", this, this.Assistant.NonLocalizedName);
                        AssistantsLog.LogNotStartedEvent(this.Assistant.NonLocalizedName, this.Assistant as AssistantBase);
                        return(null);
                    }
                    if (this.TotalMailboxesQueued == 0U)
                    {
                        ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, string>((long)this.GetHashCode(), "{0}: Worker bailing (Empty queue) for assistant: {1}", this, this.Assistant.NonLocalizedName);
                        AssistantsLog.LogNoMailboxesPendingEvent(this.Assistant.NonLocalizedName);
                        return(null);
                    }
                }
                if (this.workersActive++ == 0)
                {
                    FastManualResetEvent fastManualResetEvent = this.workerThreadsClear;
                    if (fastManualResetEvent != null)
                    {
                        fastManualResetEvent.Reset();
                    }
                }
                ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int, string>((long)this.GetHashCode(), "{0}: Worker started. Workers Active on this Driver: {1}, assistant: {2}", this, this.workersActive, this.Assistant.NonLocalizedName);
            }
            AssistantTaskContext assistantTaskContext = null;
            TimeBasedDatabaseJob timeBasedDatabaseJob = null;
            MailboxData          mailboxData          = null;

            try
            {
                if (context == null)
                {
                    lock (this.instanceLock)
                    {
                        timeBasedDatabaseJob = this.GetPendingJob(true);
                        ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, uint, string>((long)this.GetHashCode(), "{0}: Total Mailboxes Queued on this database: {1}, assistant: {2}", this, this.TotalMailboxesQueued, this.Assistant.NonLocalizedName);
                    }
                    if (timeBasedDatabaseJob != null)
                    {
                        mailboxData = timeBasedDatabaseJob.GetNextMailbox();
                        if (mailboxData != null)
                        {
                            context = this.Assistant.InitializeContext(mailboxData, timeBasedDatabaseJob);
                        }
                    }
                    else
                    {
                        AssistantsLog.LogNoJobsEvent(this.Assistant.NonLocalizedName);
                    }
                }
                else
                {
                    timeBasedDatabaseJob = context.Job;
                    mailboxData          = context.MailboxData;
                }
                if (context != null && context.Job != null)
                {
                    assistantTaskContext = context.Job.ProcessNextMailbox(context);
                }
            }
            catch
            {
                lock (this.instanceLock)
                {
                    if (--this.workersActive == 0)
                    {
                        ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int, string>((long)this.GetHashCode(), "{0}: Worker exiting due to exception. Workers Active {1}, assistant: {2}", this, this.workersActive, this.Assistant.NonLocalizedName);
                        this.workerThreadsClear.Set();
                    }
                }
                throw;
            }
            finally
            {
                if (timeBasedDatabaseJob != null && mailboxData != null && (assistantTaskContext == null || context == null))
                {
                    timeBasedDatabaseJob.RemoveFromActive(mailboxData);
                    timeBasedDatabaseJob.FinishIfNecessary();
                }
            }
            lock (this.instanceLock)
            {
                try
                {
                    ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int, uint>((long)this.GetHashCode(), "{0}: Yielding thread. Workers Active: {1}, Remaining Mailboxes on this database: {2}", this, this.workersActive, this.TotalMailboxesQueued);
                    if (context != null && context.Job != null && (context.Job.MailboxesQueued == 0 || context.Job.Finished))
                    {
                        TimeBasedDatabaseDemandJob timeBasedDatabaseDemandJob = context.Job as TimeBasedDatabaseDemandJob;
                        if (timeBasedDatabaseDemandJob != null)
                        {
                            this.demandJobs.Remove(timeBasedDatabaseDemandJob);
                            ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int>((long)this.GetHashCode(), "{0}: Demand Job is done and has been removed. Remaining Demand Jobs: {1}", this, this.demandJobs.Count);
                        }
                        else
                        {
                            this.RemoveWindowJobWithHistoryEntry();
                        }
                    }
                }
                finally
                {
                    if (--this.workersActive == 0)
                    {
                        ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedDatabaseDriver, int>((long)this.GetHashCode(), "{0}: Worker exiting. Workers Active {1}", this, this.workersActive);
                        this.workerThreadsClear.Set();
                    }
                }
            }
            return(assistantTaskContext);
        }