wsp-10300 Default Global Mailbox Plan
This commit is contained in:
parent
2e364e190a
commit
0e130a7af0
6 changed files with 183 additions and 182 deletions
|
@ -31,6 +31,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using WebsitePanel.EnterpriseServer.Code.HostedSolution;
|
using WebsitePanel.EnterpriseServer.Code.HostedSolution;
|
||||||
|
@ -2919,23 +2920,18 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<ExchangeMailboxPlan> mailboxPlans = new List<ExchangeMailboxPlan>();
|
List<ExchangeMailboxPlan> mailboxPlans = new List<ExchangeMailboxPlan>();
|
||||||
|
int? defaultPlanId = null;
|
||||||
|
|
||||||
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId));
|
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId));
|
||||||
|
|
||||||
if (user.Role == UserRole.User)
|
if (user.Role == UserRole.User)
|
||||||
ExchangeServerController.GetExchangeMailboxPlansByUser(itemId, user, ref mailboxPlans, archiving);
|
GetExchangeMailboxPlansByUser(itemId, user, ref mailboxPlans, ref defaultPlanId, archiving);
|
||||||
else
|
else
|
||||||
ExchangeServerController.GetExchangeMailboxPlansByUser(0, user, ref mailboxPlans, archiving);
|
GetExchangeMailboxPlansByUser(0, user, ref mailboxPlans, ref defaultPlanId, archiving);
|
||||||
|
|
||||||
|
if (defaultPlanId.HasValue)
|
||||||
ExchangeOrganization ExchangeOrg = ObjectUtils.FillObjectFromDataReader<ExchangeOrganization>(DataProvider.GetExchangeOrganization(itemId));
|
|
||||||
|
|
||||||
if (ExchangeOrg != null)
|
|
||||||
{
|
{
|
||||||
foreach (ExchangeMailboxPlan p in mailboxPlans)
|
mailboxPlans.ForEach(p => p.IsDefault = (p.MailboxPlanId == defaultPlanId.Value));
|
||||||
{
|
|
||||||
p.IsDefault = (p.MailboxPlanId == ExchangeOrg.ExchangeMailboxPlanID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mailboxPlans;
|
return mailboxPlans;
|
||||||
|
@ -2950,7 +2946,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GetExchangeMailboxPlansByUser(int itemId, UserInfo user, ref List<ExchangeMailboxPlan> mailboxPlans, bool archiving)
|
private static void GetExchangeMailboxPlansByUser(int itemId, UserInfo user, ref List<ExchangeMailboxPlan> mailboxPlans, ref int? defaultPlanId, bool archiving)
|
||||||
{
|
{
|
||||||
if ((user != null))
|
if ((user != null))
|
||||||
{
|
{
|
||||||
|
@ -2983,11 +2979,20 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
{
|
{
|
||||||
mailboxPlans.Add(p);
|
mailboxPlans.Add(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set default plan
|
||||||
|
ExchangeOrganization exchangeOrg = ObjectUtils.FillObjectFromDataReader<ExchangeOrganization>(DataProvider.GetExchangeOrganization(OrgId));
|
||||||
|
|
||||||
|
// If the default plan has not been set by the setting of higher priority
|
||||||
|
if (!defaultPlanId.HasValue && exchangeOrg != null && exchangeOrg.ExchangeMailboxPlanID > 0)
|
||||||
|
{
|
||||||
|
defaultPlanId = exchangeOrg.ExchangeMailboxPlanID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInfo owner = UserController.GetUserInternally(user.OwnerId);
|
UserInfo owner = UserController.GetUserInternally(user.OwnerId);
|
||||||
|
|
||||||
GetExchangeMailboxPlansByUser(0, owner, ref mailboxPlans, archiving);
|
GetExchangeMailboxPlansByUser(0, owner, ref mailboxPlans, ref defaultPlanId, archiving);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5335,6 +5335,9 @@
|
||||||
<data name="Success.EXCHANGE_UPDATEPLANS" xml:space="preserve">
|
<data name="Success.EXCHANGE_UPDATEPLANS" xml:space="preserve">
|
||||||
<value>Mailbox plan updated</value>
|
<value>Mailbox plan updated</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Success.EXCHANGE_SET_DEFAULT_MAILBOXPLAN" xml:space="preserve">
|
||||||
|
<value>Succesfully set default mailbox plan.</value>
|
||||||
|
</data>
|
||||||
<data name="Error.LYNC_UPDATEPLANS" xml:space="preserve">
|
<data name="Error.LYNC_UPDATEPLANS" xml:space="preserve">
|
||||||
<value>Lync plan update failed</value>
|
<value>Lync plan update failed</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -249,4 +249,7 @@
|
||||||
<data name="secRetentionPolicy.Text" xml:space="preserve">
|
<data name="secRetentionPolicy.Text" xml:space="preserve">
|
||||||
<value>Retention policy</value>
|
<value>Retention policy</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="lblDefaultMailboxPlan.Text" xml:space="preserve">
|
||||||
|
<value>Default</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -28,6 +28,15 @@
|
||||||
<asp:Label id="lnkDisplayMailboxPlan" runat="server" EnableViewState="true" ><%# PortalAntiXSS.Encode((string)Eval("MailboxPlan"))%></asp:Label>
|
<asp:Label id="lnkDisplayMailboxPlan" runat="server" EnableViewState="true" ><%# PortalAntiXSS.Encode((string)Eval("MailboxPlan"))%></asp:Label>
|
||||||
</ItemTemplate>
|
</ItemTemplate>
|
||||||
</asp:TemplateField>
|
</asp:TemplateField>
|
||||||
|
<asp:TemplateField >
|
||||||
|
<ItemStyle Width="15%"></ItemStyle>
|
||||||
|
<ItemTemplate>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="DefaultMailboxPlan" value='<%# Eval("MailboxPlanId") %>' <%# IsChecked((bool) Eval("IsDefault")) %>/>
|
||||||
|
<asp:Label runat="server" meta:resourcekey="lblDefaultMailboxPlan" Text="Default"></asp:Label>
|
||||||
|
</label>
|
||||||
|
</ItemTemplate>
|
||||||
|
</asp:TemplateField>
|
||||||
<asp:TemplateField>
|
<asp:TemplateField>
|
||||||
<ItemTemplate>
|
<ItemTemplate>
|
||||||
<asp:ImageButton id="imgDelMailboxPlan" runat="server" Text="Delete" SkinID="ExchangeDelete"
|
<asp:ImageButton id="imgDelMailboxPlan" runat="server" Text="Delete" SkinID="ExchangeDelete"
|
||||||
|
@ -53,6 +62,10 @@
|
||||||
</Columns>
|
</Columns>
|
||||||
</asp:GridView>
|
</asp:GridView>
|
||||||
<br />
|
<br />
|
||||||
|
<div style="text-align: center">
|
||||||
|
<asp:Button ID="btnSetDefaultMailboxPlan" runat="server" meta:resourcekey="btnSetDefaultMailboxPlan"
|
||||||
|
Text="Set Default Mailboxplan" CssClass="Button1" OnClick="btnSetDefaultMailboxPlan_Click" />
|
||||||
|
</div>
|
||||||
<wsp:CollapsiblePanel id="secMailboxPlan" runat="server"
|
<wsp:CollapsiblePanel id="secMailboxPlan" runat="server"
|
||||||
TargetControlID="MailboxPlan" meta:resourcekey="secMailboxPlan" Text="Mailboxplan">
|
TargetControlID="MailboxPlan" meta:resourcekey="secMailboxPlan" Text="Mailboxplan">
|
||||||
</wsp:CollapsiblePanel>
|
</wsp:CollapsiblePanel>
|
||||||
|
|
|
@ -36,7 +36,7 @@ using System.Xml.Serialization;
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
using System.Web.UI;
|
using System.Web.UI;
|
||||||
|
@ -99,21 +99,7 @@ namespace WebsitePanel.Portal
|
||||||
|
|
||||||
private void BindMailboxPlans()
|
private void BindMailboxPlans()
|
||||||
{
|
{
|
||||||
Providers.HostedSolution.Organization[] orgs = null;
|
Providers.HostedSolution.Organization[] orgs = GetOrganizations();
|
||||||
|
|
||||||
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))
|
if ((orgs != null) & (orgs.GetLength(0) > 0))
|
||||||
{
|
{
|
||||||
|
@ -123,6 +109,12 @@ namespace WebsitePanel.Portal
|
||||||
gvMailboxPlans.DataBind();
|
gvMailboxPlans.DataBind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if organization has only one default domain or less
|
||||||
|
if (gvMailboxPlans.Rows.Count <= 1)
|
||||||
|
{
|
||||||
|
btnSetDefaultMailboxPlan.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true;
|
btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,21 +177,7 @@ namespace WebsitePanel.Portal
|
||||||
if (PanelSecurity.SelectedUser.Role == UserRole.Reseller)
|
if (PanelSecurity.SelectedUser.Role == UserRole.Reseller)
|
||||||
plan.MailboxPlanType = (int)ExchangeMailboxPlanType.Reseller;
|
plan.MailboxPlanType = (int)ExchangeMailboxPlanType.Reseller;
|
||||||
|
|
||||||
Providers.HostedSolution.Organization[] orgs = null;
|
Providers.HostedSolution.Organization[] orgs = GetOrganizations();
|
||||||
|
|
||||||
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))
|
if ((orgs != null) & (orgs.GetLength(0) > 0))
|
||||||
|
@ -231,20 +209,7 @@ namespace WebsitePanel.Portal
|
||||||
case "DeleteItem":
|
case "DeleteItem":
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
orgs = GetOrganizations();
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
|
plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
|
||||||
|
|
||||||
|
@ -308,20 +273,7 @@ namespace WebsitePanel.Portal
|
||||||
case "EditItem":
|
case "EditItem":
|
||||||
ViewState["MailboxPlanID"] = mailboxPlanId;
|
ViewState["MailboxPlanID"] = mailboxPlanId;
|
||||||
|
|
||||||
if (PanelSecurity.SelectedUserId != 1)
|
orgs = GetOrganizations();
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
|
plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
|
||||||
txtMailboxPlan.Text = plan.MailboxPlan;
|
txtMailboxPlan.Text = plan.MailboxPlan;
|
||||||
|
@ -421,24 +373,9 @@ namespace WebsitePanel.Portal
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int mailboxPlanId = (int)ViewState["MailboxPlanID"];
|
int mailboxPlanId = (int)ViewState["MailboxPlanID"];
|
||||||
Providers.HostedSolution.Organization[] orgs = null;
|
Providers.HostedSolution.Organization[] orgs = GetOrganizations();
|
||||||
Providers.HostedSolution.ExchangeMailboxPlan plan;
|
Providers.HostedSolution.ExchangeMailboxPlan plan;
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
|
plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
|
||||||
|
|
||||||
if (plan.ItemId != orgs[0].Id)
|
if (plan.ItemId != orgs[0].Id)
|
||||||
|
@ -668,23 +605,9 @@ namespace WebsitePanel.Portal
|
||||||
{
|
{
|
||||||
ddTags.Items.Clear();
|
ddTags.Items.Clear();
|
||||||
|
|
||||||
Providers.HostedSolution.Organization[] orgs = null;
|
Organization[] orgs = GetOrganizations();
|
||||||
|
|
||||||
if (PanelSecurity.SelectedUserId != 1)
|
if ((orgs != null) && (orgs.GetLength(0) > 0))
|
||||||
{
|
|
||||||
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))
|
|
||||||
{
|
{
|
||||||
Providers.HostedSolution.ExchangeRetentionPolicyTag[] allTags = ES.Services.ExchangeServer.GetExchangeRetentionPolicyTags(orgs[0].Id);
|
Providers.HostedSolution.ExchangeRetentionPolicyTag[] allTags = ES.Services.ExchangeServer.GetExchangeRetentionPolicyTags(orgs[0].Id);
|
||||||
List<ExchangeMailboxPlanRetentionPolicyTag> selectedTags = ViewState["Tags"] as List<ExchangeMailboxPlanRetentionPolicyTag>;
|
List<ExchangeMailboxPlanRetentionPolicyTag> selectedTags = ViewState["Tags"] as List<ExchangeMailboxPlanRetentionPolicyTag>;
|
||||||
|
@ -737,5 +660,55 @@ namespace WebsitePanel.Portal
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Organization[] GetOrganizations()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return orgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void btnSetDefaultMailboxPlan_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// get domain
|
||||||
|
int mailboxPlanId = Utils.ParseInt(Request.Form["DefaultMailboxPlan"], 0);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var orgs = GetOrganizations();
|
||||||
|
|
||||||
|
if ((orgs != null) && (orgs.GetLength(0) > 0))
|
||||||
|
{
|
||||||
|
ES.Services.ExchangeServer.SetOrganizationDefaultExchangeMailboxPlan(orgs[0].Id, mailboxPlanId);
|
||||||
|
|
||||||
|
messageBox.ShowSuccessMessage("EXCHANGE_SET_DEFAULT_MAILBOXPLAN");
|
||||||
|
|
||||||
|
// rebind domains
|
||||||
|
BindMailboxPlans();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
messageBox.ShowErrorMessage("EXCHANGE_SET_DEFAULT_MAILBOXPLAN", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected string IsChecked(bool val)
|
||||||
|
{
|
||||||
|
return val ? "checked" : "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,12 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace WebsitePanel.Portal {
|
namespace WebsitePanel.Portal
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
public partial class SettingsExchangeMailboxPlansPolicy {
|
public partial class SettingsExchangeMailboxPlansPolicy
|
||||||
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// asyncTasks control.
|
/// asyncTasks control.
|
||||||
|
@ -624,5 +626,7 @@ namespace WebsitePanel.Portal {
|
||||||
/// To modify move field declaration from designer file to code-behind file.
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected global::System.Web.UI.WebControls.TextBox txtStatus;
|
protected global::System.Web.UI.WebControls.TextBox txtStatus;
|
||||||
|
|
||||||
|
protected global::System.Web.UI.WebControls.Button btnSetDefaultMailboxPlan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue