protected virtual IConfigDataProvider CreateMailboxDataProvider(ADUser adUser)
 {
     return(new MailboxStoreTypeProvider(adUser)
     {
         MailboxSession = StoreTasksHelper.OpenMailboxSession(ExchangePrincipal.FromADUser(base.SessionSettings, adUser, RemotingOptions.AllowCrossSite), "GetMailboxConfigurationTaskBase")
     });
 }
        private IEnumerable <CalendarLogAnalysis> LoadMailboxLogs(IEnumerable <CalendarLog> logs)
        {
            if (this.principal == null)
            {
                throw new InvalidOperationException("The Analyzer was not provided with session objects during construction and cannot connect to the specified mailbox");
            }
            List <CalendarLogAnalysis> list = new List <CalendarLogAnalysis>();

            using (MailboxSession mailboxSession = StoreTasksHelper.OpenMailboxSession(this.principal, "Get-CalendarDiagnosticLogs"))
            {
                foreach (CalendarLog calendarLog in logs)
                {
                    CalendarLogId calendarLogId = calendarLog.Identity as CalendarLogId;
                    if (calendarLogId != null)
                    {
                        UriHandler uriHandler = new UriHandler(calendarLogId.Uri);
                        if (uriHandler.IsValidLink && !uriHandler.IsFileLink)
                        {
                            CalendarLogAnalysis calendarLogAnalysis = this.LoadFromMailbox(calendarLogId, uriHandler, mailboxSession);
                            if (calendarLogAnalysis != null)
                            {
                                list.Add(calendarLogAnalysis);
                            }
                        }
                    }
                }
            }
            return(list);
        }
        protected override IConfigDataProvider CreateMailboxDataProvider(ADUser adUser)
        {
            MailboxStoreTypeProvider mailboxStoreTypeProvider = new MailboxStoreTypeProvider(adUser);
            ExchangePrincipal        principal = ExchangePrincipal.FromADUser(base.SessionSettings, adUser, RemotingOptions.AllowCrossSite);

            mailboxStoreTypeProvider.MailboxSession = StoreTasksHelper.OpenMailboxSession(principal, "Set-MailboxConfiguration", this.LocalizeDefaultFolderName.IsPresent);
            return(mailboxStoreTypeProvider);
        }
Exemplo n.º 4
0
        private void OutputLogs()
        {
            TaskLogger.LogEnter();
            ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(base.SessionSettings, this.logSourceUser, RemotingOptions.AllowCrossSite);

            using (MailboxSession mailboxSession = StoreTasksHelper.OpenMailboxSession(exchangePrincipal, "Get-CalendarDiagnosticLogs"))
            {
                Dictionary <string, List <VersionedId> > allCalendarLogItems = this.GetAllCalendarLogItems(mailboxSession);
                if (allCalendarLogItems.Keys.Count == 0)
                {
                    this.WriteWarning(Strings.CalendarDiagnosticLogsNotFound(this.Subject, mailboxSession.MailboxOwner.MailboxInfo.DisplayName));
                    return;
                }
                MailboxSession mailboxSession2 = null;
                try
                {
                    if (this.outputMailboxUser != null)
                    {
                        ExchangePrincipal principal = exchangePrincipal;
                        mailboxSession2 = StoreTasksHelper.OpenMailboxSession(principal, "Get-CalendarDiagnosticLogs");
                    }
                    else
                    {
                        mailboxSession2 = mailboxSession;
                    }
                    SmtpAddress address = new SmtpAddress(exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString());
                    foreach (KeyValuePair <string, List <VersionedId> > keyValuePair in allCalendarLogItems)
                    {
                        if (!string.IsNullOrEmpty(this.LogLocation))
                        {
                            this.diagnosticLogWriter = new CalendarDiagnosticLogFileWriter(this.LogLocation, mailboxSession.MailboxOwner.MailboxInfo.DisplayName, address.Domain);
                        }
                        base.WriteProgress(Strings.GetCalendarDiagnosticLog(this.Identity.ToString()), Strings.SavingCalendarLogs, 0);
                        List <VersionedId> value = keyValuePair.Value;
                        int count = value.Count;
                        foreach (VersionedId storeId in value)
                        {
                            using (Item item = Item.Bind(mailboxSession, storeId))
                            {
                                if (!(item.LastModifiedTime > this.EndDate) && !(item.LastModifiedTime < this.StartDate))
                                {
                                    if (!string.IsNullOrEmpty(this.LogLocation))
                                    {
                                        string text = null;
                                        if (Directory.Exists(this.LogLocation))
                                        {
                                            FileInfo fileInfo = this.diagnosticLogWriter.LogItem(item, out text);
                                            if (fileInfo == null && !string.IsNullOrEmpty(text))
                                            {
                                                base.WriteWarning(text);
                                            }
                                            else
                                            {
                                                base.WriteResult(new CalendarLog(item, fileInfo, (string)address));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        base.WriteResult(new CalendarLog(item, (string)address));
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (mailboxSession2 != null)
                    {
                        mailboxSession2.Dispose();
                    }
                }
            }
            TaskLogger.LogExit();
        }
Exemplo n.º 5
0
 internal static MailboxSession OpenMailboxSession(ExchangePrincipal principal, string taskName)
 {
     return(StoreTasksHelper.OpenMailboxSession(principal, taskName, false));
 }