private AssistantTaskContext ProcessStoreMailboxUnderPoisonControl(AssistantTaskContext context, EmergencyKit kit)
        {
            StoreMailboxData     storeMailboxData = context.MailboxData as StoreMailboxData;
            AssistantTaskContext result           = null;
            Guid activityId = (ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value : Guid.Empty;

            base.TracePfd("PFD AIS {0} {1}: ProcessMailbox: {2}", new object[]
            {
                23127,
                this,
                storeMailboxData.DisplayName
            });
            AssistantsLog.LogStartProcessingMailboxEvent(activityId, this.Assistant as AssistantBase, storeMailboxData.MailboxGuid, storeMailboxData.DisplayName, this);
            bool           flag          = false;
            IMailboxFilter mailboxFilter = this.Driver.AssistantType as IMailboxFilter;

            if (mailboxFilter != null && mailboxFilter.MailboxType.Contains(MailboxType.InactiveMailbox))
            {
                flag = true;
                ADSessionSettingsFactory.InactiveMailboxVisibilityEnabler.Enable();
            }
            try
            {
                result = this.ProcessStoreMailbox(context, kit);
            }
            finally
            {
                if (flag)
                {
                    ADSessionSettingsFactory.InactiveMailboxVisibilityEnabler.Disable();
                }
            }
            AssistantsLog.LogEndProcessingMailboxEvent(activityId, this.Assistant as AssistantBase, context.CustomDataToLog, storeMailboxData.MailboxGuid, storeMailboxData.DisplayName, this);
            return(result);
        }
        private AssistantTaskContext ProcessMailboxUnderPoisonControl(AssistantTaskContext context, EmergencyKit kit)
        {
            AIException          exception   = null;
            AssistantTaskContext nextContext = null;

            try
            {
                base.CatchMeIfYouCan(delegate
                {
                    AdminRpcMailboxData adminRpcMailboxData = context.MailboxData as AdminRpcMailboxData;
                    if (adminRpcMailboxData != null)
                    {
                        nextContext = this.ProcessAdminRpcMailboxUnderPoisonControl(context, kit);
                        return;
                    }
                    StoreMailboxData storeMailboxData = context.MailboxData as StoreMailboxData;
                    if (storeMailboxData != null)
                    {
                        nextContext = this.ProcessStoreMailboxUnderPoisonControl(context, kit);
                    }
                }, this.Assistant.NonLocalizedName);
            }
            catch (AIException ex)
            {
                this.LogAIException(context.MailboxData, ex);
                exception = ex;
            }
            this.PostProcessMailbox(exception, nextContext, context.MailboxData);
            return(nextContext);
        }
예제 #3
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);
                }
            }
        }
예제 #4
0
        // Token: 0x060002F6 RID: 758 RVA: 0x0000F11C File Offset: 0x0000D31C
        public override bool Equals(object other)
        {
            if (other == null)
            {
                return(false);
            }
            StoreMailboxData storeMailboxData = other as StoreMailboxData;

            return(storeMailboxData != null && this.Equals(storeMailboxData));
        }
        public override void RunNow(Guid mailboxGuid, string parameters)
        {
            StoreMailboxData mailboxData;

            using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=TBA", null, null, null, null))
            {
                try
                {
                    PropValue[][] mailboxTableInfo = exRpcAdmin.GetMailboxTableInfo(base.DatabaseInfo.Guid, mailboxGuid, new PropTag[]
                    {
                        PropTag.MailboxType,
                        PropTag.PersistableTenantPartitionHint,
                        PropTag.LastLogonTime
                    });
                    if (mailboxTableInfo.Length != 1 || mailboxTableInfo[0].Length < 1)
                    {
                        throw new InvalidOperationException("Failed to get the mailbox property");
                    }
                    PropValue           mailboxProperty     = MailboxTableQuery.GetMailboxProperty(mailboxTableInfo[0], PropTag.PersistableTenantPartitionHint);
                    TenantPartitionHint tenantPartitionHint = null;
                    if (mailboxProperty.PropTag == PropTag.PersistableTenantPartitionHint)
                    {
                        byte[] bytes = mailboxProperty.GetBytes();
                        if (bytes != null && bytes.Length != 0)
                        {
                            tenantPartitionHint = TenantPartitionHint.FromPersistablePartitionHint(bytes);
                        }
                    }
                    if (string.IsNullOrEmpty(parameters))
                    {
                        MailboxInformation mailboxInformation = MailboxInformation.Create(mailboxGuid.ToByteArray(), base.DatabaseInfo.Guid, mailboxGuid.ToString(), ControlData.Empty, mailboxTableInfo[0], MailboxInformation.GetLastLogonTime(mailboxTableInfo[0]), tenantPartitionHint);
                        mailboxData = mailboxInformation.MailboxData;
                    }
                    else
                    {
                        mailboxData = new MailboxDataForDemandJob(mailboxGuid, base.DatabaseInfo.Guid, null, parameters, tenantPartitionHint);
                    }
                }
                catch (MapiExceptionNotFound arg)
                {
                    ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedStoreDatabaseDriver, MapiExceptionNotFound>((long)this.GetHashCode(), "{0}: Mailbox does not exist on the store: {1}", this, arg);
                    if (string.IsNullOrEmpty(parameters))
                    {
                        mailboxData = new StoreMailboxData(mailboxGuid, base.DatabaseInfo.Guid, mailboxGuid.ToString(), null);
                    }
                    else
                    {
                        mailboxData = new MailboxDataForDemandJob(mailboxGuid, base.DatabaseInfo.Guid, null, parameters);
                    }
                }
            }
            ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedStoreDatabaseDriver, Guid>((long)this.GetHashCode(), "{0}: RunNow: about to start processing mailbox {1} on this database.", this, mailboxGuid);
            base.RunNow(mailboxData);
        }
        private AssistantTaskContext ProcessStoreMailbox(AssistantTaskContext context, EmergencyKit kit)
        {
            TimeBasedDatabaseJob.processMailboxTestHook.Value();
            StoreMailboxData     storeMailboxData = context.MailboxData as StoreMailboxData;
            AssistantTaskContext assistantTaskContext;

            using (StoreSession storeSession = this.OpenMailboxSession(storeMailboxData))
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                try
                {
                    if (context.Args == null)
                    {
                        context.Args = InvokeArgs.Create(storeSession, this.Driver.TimePerTask, storeMailboxData);
                    }
                    kit.SetContext(this.Assistant, storeMailboxData);
                    assistantTaskContext = context.Step(context);
                }
                finally
                {
                    kit.UnsetContext();
                    if (this.Driver.AssistantType.ControlDataPropertyDefinition != null && context.Args != null)
                    {
                        context.Args.StoreSession.Mailbox[this.Driver.AssistantType.ControlDataPropertyDefinition] = ControlData.Create(DateTime.UtcNow).ToByteArray();
                        context.Args.StoreSession.Mailbox.Save();
                    }
                }
                stopwatch.Stop();
                this.performanceCounters.AverageMailboxProcessingTime.IncrementBy(stopwatch.ElapsedTicks);
                this.performanceCounters.AverageMailboxProcessingTimeBase.Increment();
                if (assistantTaskContext == null)
                {
                    this.performanceCounters.MailboxesProcessed.Increment();
                }
            }
            return(assistantTaskContext);
        }
예제 #7
0
        public static InvokeArgs Create(StoreSession storeSession)
        {
            StoreMailboxData storeMailboxData = new StoreMailboxData(storeSession.MailboxGuid, storeSession.MdbGuid, storeSession.DisplayAddress, null);

            return(InvokeArgs.Create(storeSession, storeMailboxData));
        }
        private StoreSession OpenMailboxSession(StoreMailboxData mailbox)
        {
            Guid          activityId       = (ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value : Guid.Empty;
            AssistantBase assistant        = this.Assistant as AssistantBase;
            string        nonLocalizedName = this.Assistant.NonLocalizedName;
            Guid          mailboxGuid      = mailbox.MailboxGuid;
            StoreSession  result;

            try
            {
                ExchangePrincipal exchangePrincipal;
                if (mailbox.TenantPartitionHint != null)
                {
                    ADSessionSettings adSettings = ADSessionSettings.FromTenantPartitionHint(mailbox.TenantPartitionHint);
                    exchangePrincipal = ExchangePrincipal.FromLocalServerMailboxGuid(adSettings, this.DatabaseInfo.Guid, mailbox.Guid);
                }
                else
                {
                    exchangePrincipal = ExchangePrincipal.FromMailboxData(mailbox.Guid, this.DatabaseInfo.Guid, mailbox.OrganizationId ?? OrganizationId.ForestWideOrgId, Array <CultureInfo> .Empty);
                }
                if (mailbox.IsPublicFolderMailbox)
                {
                    StoreSession storeSession = PublicFolderSession.OpenAsAdmin(null, exchangePrincipal, null, CultureInfo.InstalledUICulture, string.Format("{0};Action={1}", "Client=TBA", this.Assistant.GetType().Name), null);
                    AssistantsLog.LogMailboxSucceedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, mailboxGuid, mailbox.DisplayName, this);
                    result = storeSession;
                }
                else
                {
                    bool           flag     = false;
                    MailboxSession mailbox2 = this.DatabaseInfo.GetMailbox(exchangePrincipal, ClientType.TimeBased, this.Assistant.GetType().Name);
                    try
                    {
                        mailbox2.ReconstructExchangePrincipal();
                        mailbox2.ExTimeZone = ExTimeZone.CurrentTimeZone;
                        flag = true;
                        AssistantsLog.LogMailboxSucceedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, mailboxGuid, mailbox.DisplayName, this);
                        result = mailbox2;
                    }
                    finally
                    {
                        if (!flag)
                        {
                            mailbox2.Dispose();
                        }
                    }
                }
            }
            catch (ObjectNotFoundException ex)
            {
                string text    = "MailboxNotFound";
                string message = string.Format("{0}: {1}", this, text);
                string value   = string.Format("{0}:{1}", text, mailbox.MailboxGuid);
                ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message);
                AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex, mailboxGuid, mailbox.DisplayName, this);
                throw new SkipException(new LocalizedString(value), ex);
            }
            catch (StorageTransientException ex2)
            {
                string message2 = string.Format("{0}: Could not open mailbox store session due to storage transient error: {1}", this, ex2.Message);
                ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message2);
                AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex2, mailboxGuid, mailbox.DisplayName, this);
                Interlocked.Increment(ref this.mailboxesFailedToOpenStoreSessionCount);
                throw;
            }
            catch (Exception ex3)
            {
                string message3 = string.Format("{0}: Could not open mailbox store session due to error: {1}", this, ex3.Message);
                ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message3);
                AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex3, mailboxGuid, mailbox.DisplayName, this);
                Interlocked.Increment(ref this.mailboxesFailedToOpenStoreSessionCount);
                throw;
            }
            return(result);
        }
예제 #9
0
 // Token: 0x060002F7 RID: 759 RVA: 0x0000F141 File Offset: 0x0000D341
 public bool Equals(StoreMailboxData other)
 {
     return(other != null && !(base.MailboxGuid != other.MailboxGuid) && base.Equals(other));
 }