diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsExchangeMailboxPlansPolicy.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsExchangeMailboxPlansPolicy.ascx.resx
index 9c902360..7df808f1 100644
--- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsExchangeMailboxPlansPolicy.ascx.resx
+++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SettingsExchangeMailboxPlansPolicy.ascx.resx
@@ -216,14 +216,14 @@
Add Mailbox Plans Template to All Tenants
-
- Match Mailbox Plan to User
+
+ Stamp unassigned mailboxes
Tools
- Restamp all mailboxes
+ Restamp mailboxes
Update Mailbox Plan
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx
index 2398ef06..ef531784 100644
--- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx
+++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx
@@ -33,6 +33,21 @@
meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to delete selected mailbox plan?')">
+
+
+
+
+
+
+
+
+
+
+
@@ -192,29 +207,5 @@
-
-
-
-
-
-
-
- |
-
-
- |
-
-
-
-
- |
-
-
-
-
-
+
\ No newline at end of file
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs
index a9423eaf..f5d49868 100644
--- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs
+++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs
@@ -275,6 +275,13 @@ namespace WebsitePanel.Portal
btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true;
break;
+ case "RestampItem":
+ RestampMailboxes(mailboxPlanId);
+ break;
+ case "StampUnassigned":
+ StampUnAssigned(mailboxPlanId);
+ break;
+
}
}
@@ -407,139 +414,12 @@ namespace WebsitePanel.Portal
return result;
}
- protected void btnMatchMailboxPlanToUser_Click(object sender, EventArgs e)
- {
- MatchMailboxPlanToUser("serverAdmin");
- }
-
- private void MatchMailboxPlanToUser(string serverAdmin)
- {
- UserInfo ServerAdminInfo = ES.Services.Users.GetUserByUsername(serverAdmin);
-
- if (ServerAdminInfo == null) return;
-
- UserInfo[] UsersInfo = ES.Services.Users.GetUsers(ServerAdminInfo.UserId, 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))
- {
- ExchangeMailboxPlan[] plans = ES.Services.ExchangeServer.GetExchangeMailboxPlans(org.Id);
-
- ExchangeAccount[] mailboxes = ES.Services.ExchangeServer.GetAccounts(org.Id, ExchangeAccountType.Mailbox);
-
- ExchangeAccount[] rooms = ES.Services.ExchangeServer.GetAccounts(org.Id, ExchangeAccountType.Room);
-
- ExchangeAccount[] equipment = ES.Services.ExchangeServer.GetAccounts(org.Id, ExchangeAccountType.Equipment);
-
- MatchExchangeAccountToPlan(org.Id, mailboxes, plans);
- MatchExchangeAccountToPlan(org.Id, rooms, plans);
- MatchExchangeAccountToPlan(org.Id, equipment, plans);
- }
- }
- }
- }
- }
- }
- messageBox.ShowSuccessMessage("EXCHANGE_MATCHPLANS");
- }
- catch (Exception ex)
- {
- messageBox.ShowErrorMessage("EXCHANGE_MATCHPLANS", ex);
- }
- }
-
- private void MatchExchangeAccountToPlan(int itemId, ExchangeAccount[] mailboxes, ExchangeMailboxPlan[] plans)
- {
-
- foreach (ExchangeAccount a in mailboxes)
- {
- if (string.IsNullOrEmpty(a.MailboxPlan))
- {
- ExchangeMailbox mailbox = ES.Services.ExchangeServer.GetMailboxAdvancedSettings(itemId, a.AccountId);
-
- if (mailbox != null)
- {
- List pl = new List();
- //sort a list of similar MAPI
- foreach (ExchangeMailboxPlan p in plans)
- {
- if (p.EnableMAPI == mailbox.EnableMAPI)
- pl.Add(p);
- }
-
- //remove plans smaller than mailbox size
- ExchangeMailboxPlan p3 = null;
- foreach (ExchangeMailboxPlan p2 in pl)
- {
- if ((p2.MailboxSizeMB == -1) & (mailbox.ProhibitSendReceiveKB == -1))
- {
- p3 = p2;
- break;
- }
-
-
- if (p2.MailboxSizeMB >= (mailbox.ProhibitSendReceiveKB / 1024))
- {
- if (p3 == null)
- p3 = p2;
- else
- if ((p2.MailboxSizeMB) <= p3.MailboxSizeMB)
- p3 = p2;
- }
- }
-
- // no matching plan, just match on size
- if (p3 == null)
- {
- foreach (ExchangeMailboxPlan p in plans)
- {
- if ((p.MailboxSizeMB == -1) & (mailbox.ProhibitSendReceiveKB == -1))
- {
- p3 = p;
- break;
- }
-
- if (p.MailboxSizeMB >= (mailbox.ProhibitSendReceiveKB / 1024))
- {
- if (p3 == null)
- p3 = p;
- else
- if ((p.MailboxSizeMB) <= p3.MailboxSizeMB)
- p3 = p;
- }
- }
- }
-
- if (p3 != null)
- ES.Services.ExchangeServer.SetExchangeMailboxPlan(itemId, a.AccountId, p3.MailboxPlanId);
- }
- }
- }
- }
-
protected void txtMailboxPlan_TextChanged(object sender, EventArgs e)
{
btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true;
}
- protected void btnStampClick(object sender, EventArgs e)
+ private void RestampMailboxes(int mailboxPlanId)
{
txtStatus.Visible = true;
@@ -563,23 +443,18 @@ namespace WebsitePanel.Portal
if ((orgs != null) & (orgs.GetLength(0) > 0))
{
- ExchangeMailboxPlan[] list = ES.Services.ExchangeServer.GetExchangeMailboxPlans(orgs[0].Id);
+ ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(0, mailboxPlanId);
- foreach (ExchangeMailboxPlan p in list)
+ foreach (ExchangeAccount a in Accounts)
{
- ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(0, p.MailboxPlanId);
-
- foreach (ExchangeAccount a in Accounts)
+ txtStatus.Text = "Completed";
+ int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(a.ItemId, a.AccountId, mailboxPlanId);
+ if (result < 0)
{
- txtStatus.Text = "Completed";
- int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(a.ItemId, a.AccountId, p.MailboxPlanId);
- if (result < 0)
- {
- BindMailboxPlans();
- txtStatus.Text = "Error: " + a.AccountName;
- messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES");
- return;
- }
+ BindMailboxPlans();
+ txtStatus.Text = "Error: " + a.AccountName;
+ messageBox.ShowErrorMessage("EXCHANGE_STAMPMAILBOXES");
+ return;
}
}
}
@@ -595,5 +470,56 @@ namespace WebsitePanel.Portal
}
+ 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;
+ }
+ }
+ }
+ messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES");
+
+ }
+ catch (Exception ex)
+ {
+ messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP", ex);
+ }
+
+ BindMailboxPlans();
+ }
}
+
}
\ No newline at end of file
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.designer.cs
index 2fd8b893..50e80473 100644
--- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.designer.cs
+++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.designer.cs
@@ -372,33 +372,6 @@ namespace WebsitePanel.Portal {
///
protected global::System.Web.UI.WebControls.Button btnUpdateMailboxPlan;
- ///
- /// secTools control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::WebsitePanel.Portal.CollapsiblePanel secTools;
-
- ///
- /// Tools control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::System.Web.UI.WebControls.Panel Tools;
-
- ///
- /// btnStamp control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::System.Web.UI.WebControls.Button btnStamp;
-
///
/// txtStatus control.
///
@@ -407,14 +380,5 @@ namespace WebsitePanel.Portal {
/// To modify move field declaration from designer file to code-behind file.
///
protected global::System.Web.UI.WebControls.TextBox txtStatus;
-
- ///
- /// btnMatchMailboxPlanToUser control.
- ///
- ///
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- ///
- protected global::System.Web.UI.WebControls.Button btnMatchMailboxPlanToUser;
}
}