Commit changes from Robvde

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

View file

@ -419,99 +419,52 @@ 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);
}
if ((orgs != null) & (orgs.GetLength(0) > 0))
{
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(0, mailboxPlanId);
foreach (ExchangeAccount a in Accounts)
{
txtStatus.Text = "Completed";
int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(a.ItemId, a.AccountId, mailboxPlanId);
if (result < 0)
{ {
BindMailboxPlans(); Providers.HostedSolution.Organization[] orgs = null;
txtStatus.Text = "Error: " + a.AccountName;
messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES");
return;
}
}
}
messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES"); orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Package.PackageId, false);
}
catch (Exception ex)
{
messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES",ex);
}
BindMailboxPlans(); if ((orgs != null) & (orgs.GetLength(0) > 0))
} {
foreach (Organization org in orgs)
{
if (!string.IsNullOrEmpty(org.GlobalAddressList))
{
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(org.Id, mailboxPlanId);
foreach (ExchangeAccount a in Accounts)
private void StampUnAssigned(int mailboxPlanId) {
{ txtStatus.Text = "Completed";
int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(org.Id, a.AccountId, mailboxPlanId);
txtStatus.Visible = true; if (result < 0)
{
try BindMailboxPlans();
{ txtStatus.Text = "Error: " + a.AccountName;
Providers.HostedSolution.Organization[] orgs = null; messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES");
return;
if (PanelSecurity.SelectedUserId != 1) }
{ }
PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId); }
}
if ((Packages != null) & (Packages.GetLength(0) > 0)) }
{
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Packages[0].PackageId, false);
}
}
else
{
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(1, false);
}
if ((orgs != null) & (orgs.GetLength(0) > 0))
{
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(PanelRequest.ItemID, -1);
foreach (ExchangeAccount a in Accounts)
{
txtStatus.Text = "Completed";
int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(PanelRequest.ItemID, a.AccountId, mailboxPlanId);
if (result < 0)
{
BindMailboxPlans();
txtStatus.Text = "Error: " + a.AccountName;
messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP");
return;
} }
} }
} }
messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES"); messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -520,6 +473,63 @@ namespace WebsitePanel.Portal
BindMailboxPlans(); BindMailboxPlans();
} }
private void StampUnAssigned(int mailboxPlanId)
{
UserInfo[] UsersInfo = ES.Services.Users.GetUsers(PanelSecurity.SelectedUserId, true);
try
{
foreach (UserInfo ui in UsersInfo)
{
PackageInfo[] Packages = ES.Services.Packages.GetPackages(ui.UserId);
if ((Packages != null) & (Packages.GetLength(0) > 0))
{
foreach (PackageInfo Package in Packages)
{
Providers.HostedSolution.Organization[] orgs = null;
orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Package.PackageId, false);
if ((orgs != null) & (orgs.GetLength(0) > 0))
{
foreach (Organization org in orgs)
{
if (!string.IsNullOrEmpty(org.GlobalAddressList))
{
ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(org.Id, -1);
foreach (ExchangeAccount a in Accounts)
{
txtStatus.Text = "Completed";
int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(org.Id, a.AccountId, mailboxPlanId);
if (result < 0)
{
BindMailboxPlans();
txtStatus.Text = "Error: " + a.AccountName;
messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP");
return;
}
}
}
}
}
}
}
}
messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES");
}
catch (Exception ex)
{
messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP", ex);
}
BindMailboxPlans();
}
} }
} }