From 786614e0b979a3f43496e2dc2da505c4ad2d8cc0 Mon Sep 17 00:00:00 2001 From: robvde Date: Tue, 7 Aug 2012 08:45:30 +0400 Subject: [PATCH 1/2] Fixed Stamp and StampUnassigned were not retrieving mailboxes when serveradmin is not on expected ItemID --- ...SettingsExchangeMailboxPlansPolicy.ascx.cs | 162 +++++++++--------- 1 file changed, 84 insertions(+), 78 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs index f5d49868..6530d2c3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs @@ -419,107 +419,113 @@ namespace WebsitePanel.Portal btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true; } + private void RestampMailboxes(int mailboxPlanId) { - txtStatus.Visible = true; + UserInfo[] UsersInfo = ES.Services.Users.GetUsers(PanelSecurity.SelectedUserId, true); try { - Providers.HostedSolution.Organization[] orgs = null; - - if (PanelSecurity.SelectedUserId != 1) + foreach (UserInfo ui in UsersInfo) { - PackageInfo[] Packages = ES.Services.Packages.GetPackages(PanelSecurity.SelectedUserId); + PackageInfo[] Packages = ES.Services.Packages.GetPackages(ui.UserId); 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(0, mailboxPlanId); - - foreach (ExchangeAccount a in Accounts) - { - txtStatus.Text = "Completed"; - int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(a.ItemId, a.AccountId, mailboxPlanId); - if (result < 0) + foreach (PackageInfo Package in Packages) { - BindMailboxPlans(); - txtStatus.Text = "Error: " + a.AccountName; - messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES"); - return; - } - } - } + Providers.HostedSolution.Organization[] orgs = null; - messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES"); - } - catch (Exception ex) - { - messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES",ex); - } + orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Package.PackageId, false); - 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); - - private void StampUnAssigned(int mailboxPlanId) - { - - txtStatus.Visible = true; - - try - { - Providers.HostedSolution.Organization[] orgs = null; - - 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; + 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_STAMPMAILBOXES"); + return; + } + } + } + } + } } } } messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES"); - } catch (Exception ex) { messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP", ex); } - - 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); + } + } + } } \ No newline at end of file From 69e778b2b090c6e0c863eced41fcc2dd4af0f0cd Mon Sep 17 00:00:00 2001 From: robvde Date: Tue, 7 Aug 2012 08:51:36 +0400 Subject: [PATCH 2/2] rebind of mailbox plan added --- .../WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs index 6530d2c3..5b2e65a1 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs @@ -470,6 +470,8 @@ namespace WebsitePanel.Portal { messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP", ex); } + + BindMailboxPlans(); } @@ -524,6 +526,8 @@ namespace WebsitePanel.Portal { messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP", ex); } + + BindMailboxPlans(); } }