Commit changes from Robvde

This commit is contained in:
Virtuworks 2012-08-07 11:17:00 -04:00
commit 18c68db5d7

View file

@ -419,36 +419,37 @@ namespace WebsitePanel.Portal
btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true; btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true;
} }
private void RestampMailboxes(int mailboxPlanId) private void RestampMailboxes(int mailboxPlanId)
{ {
txtStatus.Visible = true; UserInfo[] UsersInfo = ES.Services.Users.GetUsers(PanelSecurity.SelectedUserId, true);
try try
{ {
Providers.HostedSolution.Organization[] orgs = null; foreach (UserInfo ui in UsersInfo)
if (PanelSecurity.SelectedUserId != 1)
{ {
PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId); PackageInfo[] Packages = ES.Services.Packages.GetPackages(ui.UserId);
if ((Packages != null) & (Packages.GetLength(0) > 0)) if ((Packages != null) & (Packages.GetLength(0) > 0))
{ {
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Packages[0].PackageId, false); foreach (PackageInfo Package in Packages)
}
}
else
{ {
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, false); Providers.HostedSolution.Organization[] orgs = null;
}
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Package.PackageId, false);
if ((orgs != null) & (orgs.GetLength(0) > 0)) if ((orgs != null) & (orgs.GetLength(0) > 0))
{ {
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(0, mailboxPlanId); foreach (Organization org in orgs)
{
if (!string.IsNullOrEmpty(org.GlobalAddressList))
{
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(org.Id, mailboxPlanId);
foreach (ExchangeAccount a in Accounts) foreach (ExchangeAccount a in Accounts)
{ {
txtStatus.Text = "Completed"; txtStatus.Text = "Completed";
int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(a.ItemId, a.AccountId, mailboxPlanId); int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(org.Id, a.AccountId, mailboxPlanId);
if (result < 0) if (result < 0)
{ {
BindMailboxPlans(); BindMailboxPlans();
@ -458,49 +459,53 @@ namespace WebsitePanel.Portal
} }
} }
} }
}
}
}
}
}
messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES"); messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES");
} }
catch (Exception ex) catch (Exception ex)
{ {
messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES",ex); messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP", ex);
} }
BindMailboxPlans(); BindMailboxPlans();
} }
private void StampUnAssigned(int mailboxPlanId) private void StampUnAssigned(int mailboxPlanId)
{ {
UserInfo[] UsersInfo = ES.Services.Users.GetUsers(PanelSecurity.SelectedUserId, true);
txtStatus.Visible = true;
try try
{ {
Providers.HostedSolution.Organization[] orgs = null; foreach (UserInfo ui in UsersInfo)
if (PanelSecurity.SelectedUserId != 1)
{ {
PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId); PackageInfo[] Packages = ES.Services.Packages.GetPackages(ui.UserId);
if ((Packages != null) & (Packages.GetLength(0) > 0)) if ((Packages != null) & (Packages.GetLength(0) > 0))
{ {
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Packages[0].PackageId, false); foreach (PackageInfo Package in Packages)
}
}
else
{ {
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, false); Providers.HostedSolution.Organization[] orgs = null;
}
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Package.PackageId, false);
if ((orgs != null) & (orgs.GetLength(0) > 0)) if ((orgs != null) & (orgs.GetLength(0) > 0))
{ {
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(PanelRequest.ItemID, -1); foreach (Organization org in orgs)
{
if (!string.IsNullOrEmpty(org.GlobalAddressList))
{
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(org.Id, -1);
foreach (ExchangeAccount a in Accounts) foreach (ExchangeAccount a in Accounts)
{ {
txtStatus.Text = "Completed"; txtStatus.Text = "Completed";
int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(PanelRequest.ItemID, a.AccountId, mailboxPlanId); int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(org.Id, a.AccountId, mailboxPlanId);
if (result < 0) if (result < 0)
{ {
BindMailboxPlans(); BindMailboxPlans();
@ -510,8 +515,12 @@ namespace WebsitePanel.Portal
} }
} }
} }
}
}
}
}
}
messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES"); messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -520,6 +529,7 @@ namespace WebsitePanel.Portal
BindMailboxPlans(); BindMailboxPlans();
} }
} }
} }