private static void PopulateExchangeReportItems(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller) { TaskManager.Write("Exchange Report Items " + org.Name); //Check if exchange organization if (string.IsNullOrEmpty(org.GlobalAddressList)) { return; } List <ExchangeAccount> mailboxes; Providers.Exchange.ExchangeServer exchange; try { mailboxes = ExchangeServerController.GetExchangeMailboxes(org.Id); } catch (Exception ex) { TaskManager.WriteError(ex); throw new ApplicationException( string.Format("Could not get mailboxes for current organization {0}", org.Id), ex); } TaskManager.WriteParameter("mailboxes.Count", mailboxes.Count); try { int exchangeServiceId = GetExchangeServiceID(org.PackageId); exchange = ExchangeServerController.GetExchangeServer(exchangeServiceId, org.ServiceId); } catch (Exception ex) { TaskManager.WriteError(ex); throw new ApplicationException( string.Format("Could not get exchange server. PackageId: {0}", org.PackageId), ex); } ExchangeMailboxStatistics stats; foreach (ExchangeAccount mailbox in mailboxes) { try { TaskManager.WriteParameter("mailbox", mailbox.UserPrincipalName); stats = null; try { stats = exchange.GetMailboxStatistics(mailbox.UserPrincipalName); } catch (Exception ex) { TaskManager.WriteError(ex); TaskManager.WriteError(ex, "Could not get mailbox statistics. AccountName: {0}", mailbox.UserPrincipalName); } if (stats != null) { PopulateBaseItem(stats, org, topReseller); stats.MailboxType = mailbox.AccountType; if (mailbox.AccountType == ExchangeAccountType.Mailbox) { ExchangeAccount a = ExchangeServerController.GetAccount(mailbox.ItemId, mailbox.AccountId); stats.MailboxPlan = a.MailboxPlan; } stats.BlackberryEnabled = BlackBerryController.CheckBlackBerryUserExists(mailbox.AccountId); report.ExchangeReport.Items.Add(stats); TaskManager.Write("Items.Add"); } } catch (Exception ex) { TaskManager.WriteError(ex); } } TaskManager.Write("End Populate Exchange Report Items " + org.Name); }
public ExchangeAccount GetAccount(int itemId, int accountId) { return(ExchangeServerController.GetAccount(itemId, accountId)); }