From 7755217dfbc4bb340de5e05fc076bc14bb9522e7 Mon Sep 17 00:00:00 2001 From: dev_amdtel Date: Mon, 14 Apr 2014 23:12:27 +0400 Subject: [PATCH] Exchange archiving --- .../ExchangeServerProxy.cs | 31 +- .../ExchangeServerController.cs | 108 +++++- .../esExchangeServer.asmx.cs | 4 +- .../HostedSolution/ExchangeMailboxPlan.cs | 10 + .../ExchangeRetentionPolicyTag.cs | 9 + .../HostedSolution/IExchangeServer.cs | 9 + .../Exchange2013.cs | 249 +++++++++++- .../Exchange2007.cs | 33 ++ .../ExchangeServerProxy.cs | 319 +++++++++++++++- .../ExchangeServer.asmx.cs | 94 ++++- .../ExchangeAddMailboxPlan.ascx | 40 +- .../ExchangeAddMailboxPlan.ascx.cs | 133 ++++--- .../ExchangeAddMailboxPlan.ascx.designer.cs | 72 +++- .../ExchangeServer/ExchangeCreateMailbox.ascx | 2 +- .../ExchangeCreateMailbox.ascx.designer.cs | 4 +- .../ExchangeMailboxGeneralSettings.ascx | 14 +- .../ExchangeMailboxGeneralSettings.ascx.cs | 37 +- ...ngeMailboxGeneralSettings.ascx.designer.cs | 26 +- .../SettingsExchangeMailboxPlansPolicy.ascx | 73 +++- ...SettingsExchangeMailboxPlansPolicy.ascx.cs | 357 +++++++++++++----- ...xchangeMailboxPlansPolicy.ascx.designer.cs | 126 ++++++- 21 files changed, 1485 insertions(+), 265 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs index 9ffbd13b..98d2ecf0 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/ExchangeServerProxy.cs @@ -26,6 +26,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +using WebsitePanel.Providers; +using WebsitePanel.Providers.Common; +using WebsitePanel.Providers.HostedSolution; +using WebsitePanel.Providers.ResultObjects; //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -36,16 +40,10 @@ // //------------------------------------------------------------------------------ -using WebsitePanel.Providers; -using WebsitePanel.Providers.Common; -using WebsitePanel.Providers.HostedSolution; -using WebsitePanel.Providers.ResultObjects; - // // This source code was auto-generated by wsdl, Version=2.0.50727.42. // -namespace WebsitePanel.EnterpriseServer -{ +namespace WebsitePanel.EnterpriseServer { using System.Xml.Serialization; using System.Web.Services; using System.ComponentModel; @@ -1270,17 +1268,19 @@ namespace WebsitePanel.EnterpriseServer /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/DeleteExchangeMailboxPlanRetentionPo" + "licyTag", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public int DeleteExchangeMailboxPlanRetentionPolicyTag(int itemId, int planTagId) { + public int DeleteExchangeMailboxPlanRetentionPolicyTag(int itemID, int policyId, int planTagId) { object[] results = this.Invoke("DeleteExchangeMailboxPlanRetentionPolicyTag", new object[] { - itemId, + itemID, + policyId, planTagId}); return ((int)(results[0])); } /// - public System.IAsyncResult BeginDeleteExchangeMailboxPlanRetentionPolicyTag(int itemId, int planTagId, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginDeleteExchangeMailboxPlanRetentionPolicyTag(int itemID, int policyId, int planTagId, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("DeleteExchangeMailboxPlanRetentionPolicyTag", new object[] { - itemId, + itemID, + policyId, planTagId}, callback, asyncState); } @@ -1291,17 +1291,18 @@ namespace WebsitePanel.EnterpriseServer } /// - public void DeleteExchangeMailboxPlanRetentionPolicyTagAsync(int itemId, int planTagId) { - this.DeleteExchangeMailboxPlanRetentionPolicyTagAsync(itemId, planTagId, null); + public void DeleteExchangeMailboxPlanRetentionPolicyTagAsync(int itemID, int policyId, int planTagId) { + this.DeleteExchangeMailboxPlanRetentionPolicyTagAsync(itemID, policyId, planTagId, null); } /// - public void DeleteExchangeMailboxPlanRetentionPolicyTagAsync(int itemId, int planTagId, object userState) { + public void DeleteExchangeMailboxPlanRetentionPolicyTagAsync(int itemID, int policyId, int planTagId, object userState) { if ((this.DeleteExchangeMailboxPlanRetentionPolicyTagOperationCompleted == null)) { this.DeleteExchangeMailboxPlanRetentionPolicyTagOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteExchangeMailboxPlanRetentionPolicyTagOperationCompleted); } this.InvokeAsync("DeleteExchangeMailboxPlanRetentionPolicyTag", new object[] { - itemId, + itemID, + policyId, planTagId}, this.DeleteExchangeMailboxPlanRetentionPolicyTagOperationCompleted, userState); } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs index 83141117..99973e3b 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs @@ -1758,7 +1758,7 @@ namespace WebsitePanel.EnterpriseServer UpdateExchangeAccount(accountId, accountName, accountType, displayName, email, false, pmmActions.ToString(), samAccount, password, mailboxPlanId, archivedPlanId, subscriberNumber); - + SetMailBoxRetentionPolicy(itemId, archivedPlanId, accountName, exchange, org.OrganizationId); // send setup instructions if (sendSetupInstructions) @@ -2595,7 +2595,6 @@ namespace WebsitePanel.EnterpriseServer } - #endregion @@ -2701,6 +2700,8 @@ namespace WebsitePanel.EnterpriseServer plan.LitigationHoldUrl, plan.LitigationHoldMsg); + SetMailBoxRetentionPolicy(itemId, archivePlanId, account.UserPrincipalName, exchange, org.OrganizationId); + DataProvider.SetExchangeAccountMailboxPlan(accountId, mailboxPlanId, archivePlanId); return 0; @@ -3015,6 +3016,36 @@ namespace WebsitePanel.EnterpriseServer #region Exchange Retention Policy Tags + private static void SetMailBoxRetentionPolicy(int itemId, int retentionPolicyId, string accountName, ExchangeServer exchange, string orgId) + { + bool archive = false; + long archiveQuotaKB = 0; + long archiveWarningQuotaKB = 0; + string RetentionPolicy = ""; + if (retentionPolicyId > 0) + { + ExchangeMailboxPlan retentionPolicy = GetExchangeMailboxPlan(itemId, retentionPolicyId); + if (retentionPolicy != null) + { + archive = retentionPolicy.EnableArchiving; + archiveQuotaKB = retentionPolicy.MailboxSizeMB != -1 ? ((long)retentionPolicy.MailboxSizeMB * 1024) : -1; + archiveWarningQuotaKB = retentionPolicy.MailboxSizeMB != -1 ? (((long)retentionPolicy.IssueWarningPct * (long)retentionPolicy.MailboxSizeMB * 1024) / 100) : -1; + + // update + List listtags = GetExchangeMailboxPlanRetentionPolicyTags(retentionPolicyId); + foreach(ExchangeMailboxPlanRetentionPolicyTag listtag in listtags) + { + ExchangeRetentionPolicyTag tag = GetExchangeRetentionPolicyTag(itemId, listtag.TagID); + exchange.SetRetentionPolicyTag(tag.WSPUniqueName, (ExchangeRetentionPolicyTagType)tag.TagType, tag.AgeLimitForRetention, (ExchangeRetentionPolicyTagAction)tag.RetentionAction); + } + UpdateExchangeMailboxPlanRetentionPolicyTags(itemId, retentionPolicyId); + } + + } + exchange.SetMailBoxArchiving(orgId, accountName, archive, archiveQuotaKB, archiveWarningQuotaKB, RetentionPolicy); + + } + public static List GetExchangeRetentionPolicyTags(int itemId) { // place log record @@ -3124,6 +3155,15 @@ namespace WebsitePanel.EnterpriseServer // quotas } + int exchangeServiceId = GetExchangeServiceID(org.PackageId); + + if (exchangeServiceId > 0) + { + ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId); + + exchange.SetRetentionPolicyTag(tag.WSPUniqueName, (ExchangeRetentionPolicyTagType)tag.TagType, tag.AgeLimitForRetention, (ExchangeRetentionPolicyTagAction)tag.RetentionAction); + } + return DataProvider.AddExchangeRetentionPolicyTag(itemID, tag.TagName, tag.TagType, tag.AgeLimitForRetention, tag.RetentionAction ); } catch (Exception ex) @@ -3156,6 +3196,15 @@ namespace WebsitePanel.EnterpriseServer // quotas } + int exchangeServiceId = GetExchangeServiceID(org.PackageId); + + if (exchangeServiceId > 0) + { + ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId); + + exchange.SetRetentionPolicyTag(tag.WSPUniqueName, (ExchangeRetentionPolicyTagType)tag.TagType, tag.AgeLimitForRetention, (ExchangeRetentionPolicyTagAction)tag.RetentionAction); + } + DataProvider.UpdateExchangeRetentionPolicyTag(tag.TagID, tag.ItemID, tag.TagName, tag.TagType, tag.AgeLimitForRetention, tag.RetentionAction); } catch (Exception ex) @@ -3177,6 +3226,21 @@ namespace WebsitePanel.EnterpriseServer try { + Organization org = GetOrganization(itemID); + if (org == null) + return -1; + + int exchangeServiceId = GetExchangeServiceID(org.PackageId); + if (exchangeServiceId > 0) + { + ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId); + + ExchangeRetentionPolicyTag tag = GetExchangeRetentionPolicyTag(itemID, tagId); + if (tag == null) return -1; + + exchange.RemoveRetentionPolicyTag(tag.WSPUniqueName); + } + DataProvider.DeleteExchangeRetentionPolicyTag(tagId); return 0; @@ -3215,6 +3279,36 @@ namespace WebsitePanel.EnterpriseServer } } + + private static void UpdateExchangeMailboxPlanRetentionPolicyTags(int itemID, int policyId) + { + ExchangeMailboxPlan policy = GetExchangeMailboxPlan(itemID, policyId); + + List policytaglist = GetExchangeMailboxPlanRetentionPolicyTags(policyId); + + List tagLinks = new List(); + + foreach (ExchangeMailboxPlanRetentionPolicyTag policytag in policytaglist) + { + ExchangeRetentionPolicyTag tag = GetExchangeRetentionPolicyTag(itemID, policytag.TagID); + tagLinks.Add(tag.WSPUniqueName); + } + + Organization org = GetOrganization(itemID); + if (org == null) + return; + + int exchangeServiceId = GetExchangeServiceID(org.PackageId); + + if (exchangeServiceId > 0) + { + ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId); + + exchange.SetRetentionPolicy(policy.WSPUniqueName, tagLinks.ToArray()); + } + + } + public static int AddExchangeMailboxPlanRetentionPolicyTag(int itemID, ExchangeMailboxPlanRetentionPolicyTag planTag) { // place log record @@ -3234,7 +3328,11 @@ namespace WebsitePanel.EnterpriseServer // quotas } - return DataProvider.AddExchangeMailboxPlanRetentionPolicyTag(planTag.TagID, planTag.MailboxPlanId); + int res = DataProvider.AddExchangeMailboxPlanRetentionPolicyTag(planTag.TagID, planTag.MailboxPlanId); + + UpdateExchangeMailboxPlanRetentionPolicyTags(itemID, planTag.MailboxPlanId); + + return res; } catch (Exception ex) { @@ -3247,7 +3345,7 @@ namespace WebsitePanel.EnterpriseServer } - public static int DeleteExchangeMailboxPlanRetentionPolicyTag(int itemID, int planTagId) + public static int DeleteExchangeMailboxPlanRetentionPolicyTag(int itemID, int policyId, int planTagId) { TaskManager.StartTask("EXCHANGE", "DELETE_EXCHANGE_RETENTIONPOLICYTAG", itemID); @@ -3255,6 +3353,8 @@ namespace WebsitePanel.EnterpriseServer { DataProvider.DeleteExchangeMailboxPlanRetentionPolicyTag(planTagId); + UpdateExchangeMailboxPlanRetentionPolicyTags(itemID, policyId); + return 0; } catch (Exception ex) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs index 129400c4..09c32e9a 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esExchangeServer.asmx.cs @@ -610,9 +610,9 @@ namespace WebsitePanel.EnterpriseServer } [WebMethod] - public int DeleteExchangeMailboxPlanRetentionPolicyTag(int itemId, int planTagId) + public int DeleteExchangeMailboxPlanRetentionPolicyTag(int itemID, int policyId, int planTagId) { - return ExchangeServerController.DeleteExchangeMailboxPlanRetentionPolicyTag(itemId, planTagId); + return ExchangeServerController.DeleteExchangeMailboxPlanRetentionPolicyTag(itemID, policyId, planTagId); } #endregion diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeMailboxPlan.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeMailboxPlan.cs index 4cee0582..c1f88d8d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeMailboxPlan.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeMailboxPlan.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Text.RegularExpressions; namespace WebsitePanel.Providers.HostedSolution { @@ -223,5 +224,14 @@ namespace WebsitePanel.Providers.HostedSolution get { return this.enableArchiving; } set { this.enableArchiving = value; } } + + public string WSPUniqueName + { + get + { + Regex r = new Regex(@"[^A-Za-z0-9]"); + return "WSPPolicy" + MailboxPlanId.ToString() + "_" + r.Replace(MailboxPlan, ""); + } + } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeRetentionPolicyTag.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeRetentionPolicyTag.cs index a9b6ba1c..29528692 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeRetentionPolicyTag.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ExchangeRetentionPolicyTag.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Text.RegularExpressions; namespace WebsitePanel.Providers.HostedSolution { @@ -76,5 +77,13 @@ namespace WebsitePanel.Providers.HostedSolution set { retentionAction = value; } } + public string WSPUniqueName + { + get + { + Regex r = new Regex(@"[^A-Za-z0-9]"); + return "WSPPolicyTag" + TagID.ToString() + "_" + r.Replace(TagName, ""); + } + } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs index 197a7a0c..866b0237 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IExchangeServer.cs @@ -130,5 +130,14 @@ namespace WebsitePanel.Providers.HostedSolution // Disclaimers int NewDisclaimerTransportRule(string Name, string From, string Text); int RemoveTransportRule(string Name); + + // Archiving + void SetMailBoxArchiving(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy); + + // Retention policy + void SetRetentionPolicyTag(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction); + void RemoveRetentionPolicyTag(string Identity); + void SetRetentionPolicy(string Identity, string[] RetentionPolicyTagLinks); + void RemoveRetentionPolicy(string Identity); } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs index e61b25ca..32206f15 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2012-2014, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -96,6 +96,11 @@ namespace WebsitePanel.Providers.HostedSolution get { return ProviderSettings["MailboxDatabase"]; } } + internal string ArchiveMailboxDatabase + { + get { return ProviderSettings["ArchivingDatabase"]; } + } + internal bool PublicFolderDistributionEnabled { get { return ProviderSettings.GetBool("PublicFolderDistributionEnabled"); } @@ -7246,6 +7251,248 @@ namespace WebsitePanel.Providers.HostedSolution } #endregion + #region Archiving + + public void SetMailBoxArchiving(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy) + { + SetMailBoxArchivingInternal(organizationId, accountName, archive, archiveQuotaKB, archiveWarningQuotaKB, RetentionPolicy); + } + + private void SetMailBoxArchivingInternal(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy) + { + ExchangeLog.LogStart("SetMailBoxArchivingInternal"); + ExchangeLog.DebugInfo("Account: {0}", accountName); + + Runspace runSpace = null; + Runspace runSpaceEx = null; + try + { + runSpace = OpenRunspace(); + runSpaceEx = OpenRunspaceEx(); + + Command cmd; + + if (archive) + { + cmd = new Command("Enable-Mailbox"); + cmd.Parameters.Add("Identity", accountName); + cmd.Parameters.Add("Archive"); + string database = GetDatabase(runSpace, PrimaryDomainController, ArchiveMailboxDatabase); + ExchangeLog.DebugInfo("archivedatabase: " + database); + if (database != string.Empty) + { + cmd.Parameters.Add("ArchiveDatabase", database); + } + ExecuteShellCommand(runSpace, cmd); + + cmd = new Command("Set-Mailbox"); + cmd.Parameters.Add("Identity", accountName); + cmd.Parameters.Add("ArchiveQuota", ConvertKBToUnlimited(archiveQuotaKB)); + cmd.Parameters.Add("ArchiveWarningQuota", ConvertKBToUnlimited(archiveWarningQuotaKB)); + ExecuteShellCommand(runSpace, cmd); + } + else + { + cmd = new Command("Disable-Mailbox"); + cmd.Parameters.Add("Identity", accountName); + cmd.Parameters.Add("Archive"); + ExecuteShellCommand(runSpace, cmd); + } + + if (!String.IsNullOrEmpty(RetentionPolicy)) + { + cmd = new Command("Set-Mailbox"); + cmd.Parameters.Add("Identity", accountName); + cmd.Parameters.Add("RetentionPolicy", RetentionPolicy); + ExecuteShellCommand(runSpace, cmd); + } + + + } + finally + { + + CloseRunspace(runSpace); + CloseRunspaceEx(runSpaceEx); + } + ExchangeLog.LogEnd("SetMailBoxArchivingInternal"); + } + + + #endregion + + #region Retention policy + + public void SetRetentionPolicyTag(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention , ExchangeRetentionPolicyTagAction RetentionAction) + { + SetRetentionPolicyTagInternal(Identity, Type, AgeLimitForRetention, RetentionAction); + } + + private void SetRetentionPolicyTagInternal(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction) + { + ExchangeLog.LogStart("SetRetentionPolicyTagInternal"); + + Runspace runSpace = null; + Runspace runSpaceEx = null; + try + { + runSpace = OpenRunspace(); + runSpaceEx = OpenRunspaceEx(); + + Command cmd; + + bool exists = false; + cmd = new Command("Get-RetentionPolicyTag"); + cmd.Parameters.Add("Identity", Identity); + Collection result = ExecuteShellCommand(runSpace, cmd); + + if (result != null && result.Count > 0) + exists = true; + + if (exists) + { + cmd = new Command("Set-RetentionPolicyTag"); + cmd.Parameters.Add("Identity", Identity); + } + else + { + cmd = new Command("New-RetentionPolicyTag"); + cmd.Parameters.Add("Name", Identity); + cmd.Parameters.Add("Type", Enum.GetName(typeof(ExchangeRetentionPolicyTagType), Type)); + } + + cmd.Parameters.Add("AgeLimitForRetention", AgeLimitForRetention); + cmd.Parameters.Add("RetentionAction", Enum.GetName(typeof(ExchangeRetentionPolicyTagAction), RetentionAction)); + cmd.Parameters.Add("RetentionEnabled", true); + + object[] errors; + result = ExecuteShellCommand(runSpace, cmd,out errors); + } + finally + { + + CloseRunspace(runSpace); + CloseRunspaceEx(runSpaceEx); + } + ExchangeLog.LogEnd("SetRetentionPolicyTagInternal"); + } + + public void RemoveRetentionPolicyTag(string Identity) + { + RemoveRetentionPolicyTagInternal(Identity); + } + + private void RemoveRetentionPolicyTagInternal(string Identity) + { + ExchangeLog.LogStart("RemoveRetentionPolicyTagInternal"); + + Runspace runSpace = null; + Runspace runSpaceEx = null; + try + { + runSpace = OpenRunspace(); + runSpaceEx = OpenRunspaceEx(); + + Command cmd; + + bool exists = false; + cmd = new Command("Remove-RetentionPolicyTag"); + cmd.Parameters.Add("Identity", Identity); + ExecuteShellCommand(runSpace, cmd); + } + finally + { + + CloseRunspace(runSpace); + CloseRunspaceEx(runSpaceEx); + } + ExchangeLog.LogEnd("RemoveRetentionPolicyTagInternal"); + } + + public void SetRetentionPolicy(string Identity, string[] RetentionPolicyTagLinks) + { + SetRetentionPolicyInternal(Identity, RetentionPolicyTagLinks); + } + + private void SetRetentionPolicyInternal(string Identity, string[] RetentionPolicyTagLinks) + { + ExchangeLog.LogStart("SetRetentionPolicyInternal"); + + Runspace runSpace = null; + Runspace runSpaceEx = null; + try + { + runSpace = OpenRunspace(); + runSpaceEx = OpenRunspaceEx(); + + Command cmd; + + bool exists = false; + cmd = new Command("Get-RetentionPolicy"); + cmd.Parameters.Add("Identity", Identity); + Collection result = ExecuteShellCommand(runSpace, cmd); + + if (result != null && result.Count > 0) + exists = true; + + if (exists) + { + cmd = new Command("Set-RetentionPolicy"); + cmd.Parameters.Add("Identity", Identity); + } + else + { + cmd = new Command("New-RetentionPolicy"); + cmd.Parameters.Add("Name", Identity); + } + + cmd.Parameters.Add("RetentionPolicyTagLinks", RetentionPolicyTagLinks); + + result = ExecuteShellCommand(runSpace, cmd); + } + finally + { + + CloseRunspace(runSpace); + CloseRunspaceEx(runSpaceEx); + } + ExchangeLog.LogEnd("SetRetentionPolicyInternal"); + } + + public void RemoveRetentionPolicy(string Identity) + { + RemoveRetentionPolicyInternal(Identity); + } + + private void RemoveRetentionPolicyInternal(string Identity) + { + ExchangeLog.LogStart("RemoveRetentionPolicyInternal"); + + Runspace runSpace = null; + Runspace runSpaceEx = null; + try + { + runSpace = OpenRunspace(); + runSpaceEx = OpenRunspaceEx(); + + Command cmd; + + cmd = new Command("Remove-RetentionPolicy"); + cmd.Parameters.Add("Identity", Identity); + ExecuteShellCommand(runSpace, cmd); + } + finally + { + + CloseRunspace(runSpace); + CloseRunspaceEx(runSpaceEx); + } + ExchangeLog.LogEnd("RemoveRetentionPolicyInternal"); + } + + + #endregion + public override bool IsInstalled() { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs index 4105b2d0..e4a2dea9 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -6965,5 +6965,38 @@ namespace WebsitePanel.Providers.HostedSolution } #endregion + + #region Archiving + public virtual void SetMailBoxArchiving(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy) + { + // not implemented + } + #endregion + + #region Retention policy + + public virtual void SetRetentionPolicyTag(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction) + { + // not implemented + } + + public virtual void RemoveRetentionPolicyTag(string Identity) + { + // not implemented + } + + public virtual void SetRetentionPolicy(string Identity, string[] RetentionPolicyTagLinks) + { + // not implemented + } + + public virtual void RemoveRetentionPolicy(string Identity) + { + // not implemented + } + + + #endregion + } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs index 37fc060b..f9c50bf0 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/ExchangeServerProxy.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2012, Outercurve Foundation. +// Copyright (c) 2012-2014, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -26,6 +26,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +using WebsitePanel.Providers.HostedSolution; + //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -48,7 +50,6 @@ namespace WebsitePanel.Providers.Exchange using System; using System.Diagnostics; - using WebsitePanel.Providers.HostedSolution; /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] @@ -74,6 +75,16 @@ namespace WebsitePanel.Providers.Exchange private System.Threading.SendOrPostCallback RemoveDeviceOperationCompleted; + private System.Threading.SendOrPostCallback SetMailBoxArchivingOperationCompleted; + + private System.Threading.SendOrPostCallback SetRetentionPolicyTagOperationCompleted; + + private System.Threading.SendOrPostCallback RemoveRetentionPolicyTagOperationCompleted; + + private System.Threading.SendOrPostCallback SetRetentionPolicyOperationCompleted; + + private System.Threading.SendOrPostCallback RemoveRetentionPolicyOperationCompleted; + private System.Threading.SendOrPostCallback CheckAccountCredentialsOperationCompleted; private System.Threading.SendOrPostCallback ExtendToExchangeOrganizationOperationCompleted; @@ -203,7 +214,7 @@ namespace WebsitePanel.Providers.Exchange /// public ExchangeServer() { - this.Url = "http://localhost:9003/ExchangeServer.asmx"; + this.Url = "http://localhost:9004/ExchangeServer.asmx"; } /// @@ -224,6 +235,21 @@ namespace WebsitePanel.Providers.Exchange /// public event RemoveDeviceCompletedEventHandler RemoveDeviceCompleted; + /// + public event SetMailBoxArchivingCompletedEventHandler SetMailBoxArchivingCompleted; + + /// + public event SetRetentionPolicyTagCompletedEventHandler SetRetentionPolicyTagCompleted; + + /// + public event RemoveRetentionPolicyTagCompletedEventHandler RemoveRetentionPolicyTagCompleted; + + /// + public event SetRetentionPolicyCompletedEventHandler SetRetentionPolicyCompleted; + + /// + public event RemoveRetentionPolicyCompletedEventHandler RemoveRetentionPolicyCompleted; + /// public event CheckAccountCredentialsCompletedEventHandler CheckAccountCredentialsCompleted; @@ -824,6 +850,273 @@ namespace WebsitePanel.Providers.Exchange } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetMailBoxArchiving", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void SetMailBoxArchiving(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy) + { + this.Invoke("SetMailBoxArchiving", new object[] { + organizationId, + accountName, + archive, + archiveQuotaKB, + archiveWarningQuotaKB, + RetentionPolicy}); + } + + /// + public System.IAsyncResult BeginSetMailBoxArchiving(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("SetMailBoxArchiving", new object[] { + organizationId, + accountName, + archive, + archiveQuotaKB, + archiveWarningQuotaKB, + RetentionPolicy}, callback, asyncState); + } + + /// + public void EndSetMailBoxArchiving(System.IAsyncResult asyncResult) + { + this.EndInvoke(asyncResult); + } + + /// + public void SetMailBoxArchivingAsync(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy) + { + this.SetMailBoxArchivingAsync(organizationId, accountName, archive, archiveQuotaKB, archiveWarningQuotaKB, RetentionPolicy, null); + } + + /// + public void SetMailBoxArchivingAsync(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy, object userState) + { + if ((this.SetMailBoxArchivingOperationCompleted == null)) + { + this.SetMailBoxArchivingOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetMailBoxArchivingOperationCompleted); + } + this.InvokeAsync("SetMailBoxArchiving", new object[] { + organizationId, + accountName, + archive, + archiveQuotaKB, + archiveWarningQuotaKB, + RetentionPolicy}, this.SetMailBoxArchivingOperationCompleted, userState); + } + + private void OnSetMailBoxArchivingOperationCompleted(object arg) + { + if ((this.SetMailBoxArchivingCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetMailBoxArchivingCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetRetentionPolicyTag", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void SetRetentionPolicyTag(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction) + { + this.Invoke("SetRetentionPolicyTag", new object[] { + Identity, + Type, + AgeLimitForRetention, + RetentionAction}); + } + + /// + public System.IAsyncResult BeginSetRetentionPolicyTag(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("SetRetentionPolicyTag", new object[] { + Identity, + Type, + AgeLimitForRetention, + RetentionAction}, callback, asyncState); + } + + /// + public void EndSetRetentionPolicyTag(System.IAsyncResult asyncResult) + { + this.EndInvoke(asyncResult); + } + + /// + public void SetRetentionPolicyTagAsync(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction) + { + this.SetRetentionPolicyTagAsync(Identity, Type, AgeLimitForRetention, RetentionAction, null); + } + + /// + public void SetRetentionPolicyTagAsync(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction, object userState) + { + if ((this.SetRetentionPolicyTagOperationCompleted == null)) + { + this.SetRetentionPolicyTagOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetRetentionPolicyTagOperationCompleted); + } + this.InvokeAsync("SetRetentionPolicyTag", new object[] { + Identity, + Type, + AgeLimitForRetention, + RetentionAction}, this.SetRetentionPolicyTagOperationCompleted, userState); + } + + private void OnSetRetentionPolicyTagOperationCompleted(object arg) + { + if ((this.SetRetentionPolicyTagCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetRetentionPolicyTagCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/RemoveRetentionPolicyTag", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void RemoveRetentionPolicyTag(string Identity) + { + this.Invoke("RemoveRetentionPolicyTag", new object[] { + Identity}); + } + + /// + public System.IAsyncResult BeginRemoveRetentionPolicyTag(string Identity, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("RemoveRetentionPolicyTag", new object[] { + Identity}, callback, asyncState); + } + + /// + public void EndRemoveRetentionPolicyTag(System.IAsyncResult asyncResult) + { + this.EndInvoke(asyncResult); + } + + /// + public void RemoveRetentionPolicyTagAsync(string Identity) + { + this.RemoveRetentionPolicyTagAsync(Identity, null); + } + + /// + public void RemoveRetentionPolicyTagAsync(string Identity, object userState) + { + if ((this.RemoveRetentionPolicyTagOperationCompleted == null)) + { + this.RemoveRetentionPolicyTagOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRemoveRetentionPolicyTagOperationCompleted); + } + this.InvokeAsync("RemoveRetentionPolicyTag", new object[] { + Identity}, this.RemoveRetentionPolicyTagOperationCompleted, userState); + } + + private void OnRemoveRetentionPolicyTagOperationCompleted(object arg) + { + if ((this.RemoveRetentionPolicyTagCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.RemoveRetentionPolicyTagCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetRetentionPolicy", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void SetRetentionPolicy(string Identity, string[] RetentionPolicyTagLinks) + { + this.Invoke("SetRetentionPolicy", new object[] { + Identity, + RetentionPolicyTagLinks}); + } + + /// + public System.IAsyncResult BeginSetRetentionPolicy(string Identity, string[] RetentionPolicyTagLinks, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("SetRetentionPolicy", new object[] { + Identity, + RetentionPolicyTagLinks}, callback, asyncState); + } + + /// + public void EndSetRetentionPolicy(System.IAsyncResult asyncResult) + { + this.EndInvoke(asyncResult); + } + + /// + public void SetRetentionPolicyAsync(string Identity, string[] RetentionPolicyTagLinks) + { + this.SetRetentionPolicyAsync(Identity, RetentionPolicyTagLinks, null); + } + + /// + public void SetRetentionPolicyAsync(string Identity, string[] RetentionPolicyTagLinks, object userState) + { + if ((this.SetRetentionPolicyOperationCompleted == null)) + { + this.SetRetentionPolicyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetRetentionPolicyOperationCompleted); + } + this.InvokeAsync("SetRetentionPolicy", new object[] { + Identity, + RetentionPolicyTagLinks}, this.SetRetentionPolicyOperationCompleted, userState); + } + + private void OnSetRetentionPolicyOperationCompleted(object arg) + { + if ((this.SetRetentionPolicyCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetRetentionPolicyCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/RemoveRetentionPolicy", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void RemoveRetentionPolicy(string Identity) + { + this.Invoke("RemoveRetentionPolicy", new object[] { + Identity}); + } + + /// + public System.IAsyncResult BeginRemoveRetentionPolicy(string Identity, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("RemoveRetentionPolicy", new object[] { + Identity}, callback, asyncState); + } + + /// + public void EndRemoveRetentionPolicy(System.IAsyncResult asyncResult) + { + this.EndInvoke(asyncResult); + } + + /// + public void RemoveRetentionPolicyAsync(string Identity) + { + this.RemoveRetentionPolicyAsync(Identity, null); + } + + /// + public void RemoveRetentionPolicyAsync(string Identity, object userState) + { + if ((this.RemoveRetentionPolicyOperationCompleted == null)) + { + this.RemoveRetentionPolicyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRemoveRetentionPolicyOperationCompleted); + } + this.InvokeAsync("RemoveRetentionPolicy", new object[] { + Identity}, this.RemoveRetentionPolicyOperationCompleted, userState); + } + + private void OnRemoveRetentionPolicyOperationCompleted(object arg) + { + if ((this.RemoveRetentionPolicyCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.RemoveRetentionPolicyCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CheckAccountCredentials", RequestNamespace = "http://smbsaas/websitepanel/server/", ResponseNamespace = "http://smbsaas/websitepanel/server/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] @@ -4787,6 +5080,26 @@ namespace WebsitePanel.Providers.Exchange [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void RemoveDeviceCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void SetMailBoxArchivingCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void SetRetentionPolicyTagCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void RemoveRetentionPolicyTagCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void SetRetentionPolicyCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void RemoveRetentionPolicyCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void CheckAccountCredentialsCompletedEventHandler(object sender, CheckAccountCredentialsCompletedEventArgs e); diff --git a/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs index ff1bf012..833fcf37 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/ExchangeServer.asmx.cs @@ -1216,8 +1216,98 @@ namespace WebsitePanel.Server } } #endregion - - protected void LogStart(string func) + + #region Archiving + [WebMethod, SoapHeader("settings")] + public void SetMailBoxArchiving(string organizationId, string accountName, bool archive, long archiveQuotaKB, long archiveWarningQuotaKB, string RetentionPolicy) + { + try + { + LogStart("SetMailBoxArchiving"); + ES.SetMailBoxArchiving(organizationId, accountName, archive, archiveQuotaKB, archiveWarningQuotaKB, RetentionPolicy); + LogEnd("SetMailBoxArchiving"); + } + catch (Exception ex) + { + LogError("SetMailBoxArchiving", ex); + throw; + } + } + + #endregion + + #region Retention policy + [WebMethod, SoapHeader("settings")] + public void SetRetentionPolicyTag(string Identity, ExchangeRetentionPolicyTagType Type, int AgeLimitForRetention, ExchangeRetentionPolicyTagAction RetentionAction) + { + try + { + LogStart("SetRetentionPolicyTag"); + ES.SetRetentionPolicyTag(Identity, Type, AgeLimitForRetention, RetentionAction); + LogEnd("SetRetentionPolicyTag"); + } + catch (Exception ex) + { + LogError("SetRetentionPolicyTag", ex); + throw; + } + + } + + [WebMethod, SoapHeader("settings")] + public void RemoveRetentionPolicyTag(string Identity) + { + try + { + LogStart("RemoveRetentionPolicyTag"); + ES.RemoveRetentionPolicyTag(Identity); + LogEnd("RemoveRetentionPolicyTag"); + } + catch (Exception ex) + { + LogError("RemoveRetentionPolicyTag", ex); + throw; + } + + } + + [WebMethod, SoapHeader("settings")] + public void SetRetentionPolicy(string Identity, string[] RetentionPolicyTagLinks) + { + try + { + LogStart("SetRetentionPolicy"); + ES.SetRetentionPolicy(Identity, RetentionPolicyTagLinks); + LogEnd("SetRetentionPolicy"); + } + catch (Exception ex) + { + LogError("SetRetentionPolicy", ex); + throw; + } + + } + + [WebMethod, SoapHeader("settings")] + public void RemoveRetentionPolicy(string Identity) + { + try + { + LogStart("RemoveRetentionPolicy"); + ES.RemoveRetentionPolicy(Identity); + LogEnd("RemoveRetentionPolicy"); + } + catch (Exception ex) + { + LogError("RemoveRetentionPolicy", ex); + throw; + } + + } + + #endregion + + protected void LogStart(string func) { Log.WriteStart("'{0}' {1}", ProviderSettings.ProviderName, func); } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx index 4747151b..f9d36a25 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx @@ -80,11 +80,6 @@ - - - - -
@@ -228,6 +223,41 @@ + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+
+ +
+
+
+ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.cs index 6b452dfc..39e9b7e6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.cs @@ -67,38 +67,48 @@ namespace WebsitePanel.Portal.ExchangeServer { Providers.HostedSolution.ExchangeMailboxPlan plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(PanelRequest.ItemID, PanelRequest.GetInt("MailboxPlanId")); txtMailboxPlan.Text = plan.MailboxPlan; - mailboxSize.QuotaValue = plan.MailboxSizeMB; - maxRecipients.QuotaValue = plan.MaxRecipients; - maxSendMessageSizeKB.QuotaValue = plan.MaxSendMessageSizeKB; - maxReceiveMessageSizeKB.QuotaValue = plan.MaxReceiveMessageSizeKB; - chkPOP3.Checked = plan.EnablePOP; - chkIMAP.Checked = plan.EnableIMAP; - chkOWA.Checked = plan.EnableOWA; - chkMAPI.Checked = plan.EnableMAPI; - chkActiveSync.Checked = plan.EnableActiveSync; - sizeIssueWarning.ValueKB = plan.IssueWarningPct; - sizeProhibitSend.ValueKB = plan.ProhibitSendPct; - sizeProhibitSendReceive.ValueKB = plan.ProhibitSendReceivePct; - daysKeepDeletedItems.ValueDays = plan.KeepDeletedItemsDays; - chkHideFromAddressBook.Checked = plan.HideFromAddressBook; - chkEnableLitigationHold.Checked = plan.AllowLitigationHold; - recoverableItemsSpace.QuotaValue = plan.RecoverableItemsSpace; - recoverableItemsWarning.ValueKB = plan.RecoverableItemsWarningPct; - txtLitigationHoldMsg.Text = plan.LitigationHoldMsg; - txtLitigationHoldUrl.Text = plan.LitigationHoldUrl; - RetentionPolicy = plan.Archiving; - chkEnableArchiving.Checked = plan.EnableArchiving; - - locTitle.Text = plan.MailboxPlan; - if (RetentionPolicy) { - ExchangeMailboxPlanRetentionPolicyTag[] tags = ES.Services.ExchangeServer.GetExchangeMailboxPlanRetentionPolicyTags(plan.MailboxPlanId); + chkEnableArchiving.Checked = plan.EnableArchiving; + + archiveQuota.QuotaValue = plan.MailboxSizeMB; + archiveWarningQuota.ValueKB = plan.IssueWarningPct; + + List tags = new List(); + tags.AddRange(ES.Services.ExchangeServer.GetExchangeMailboxPlanRetentionPolicyTags(plan.MailboxPlanId)); + + ViewState["Tags"] = tags; gvPolicy.DataSource = tags; gvPolicy.DataBind(); + UpdateTags(); + } + else + { + mailboxSize.QuotaValue = plan.MailboxSizeMB; + maxRecipients.QuotaValue = plan.MaxRecipients; + maxSendMessageSizeKB.QuotaValue = plan.MaxSendMessageSizeKB; + maxReceiveMessageSizeKB.QuotaValue = plan.MaxReceiveMessageSizeKB; + chkPOP3.Checked = plan.EnablePOP; + chkIMAP.Checked = plan.EnableIMAP; + chkOWA.Checked = plan.EnableOWA; + chkMAPI.Checked = plan.EnableMAPI; + chkActiveSync.Checked = plan.EnableActiveSync; + sizeIssueWarning.ValueKB = plan.IssueWarningPct; + sizeProhibitSend.ValueKB = plan.ProhibitSendPct; + sizeProhibitSendReceive.ValueKB = plan.ProhibitSendReceivePct; + daysKeepDeletedItems.ValueDays = plan.KeepDeletedItemsDays; + chkHideFromAddressBook.Checked = plan.HideFromAddressBook; + chkEnableLitigationHold.Checked = plan.AllowLitigationHold; + recoverableItemsSpace.QuotaValue = plan.RecoverableItemsSpace; + recoverableItemsWarning.ValueKB = plan.RecoverableItemsWarningPct; + txtLitigationHoldMsg.Text = plan.LitigationHoldMsg; + txtLitigationHoldUrl.Text = plan.LitigationHoldUrl; + } + + locTitle.Text = plan.MailboxPlan; this.DisableControls = true; @@ -177,12 +187,16 @@ namespace WebsitePanel.Portal.ExchangeServer locTitle.Text = RetentionPolicy ? GetLocalizedString("locTitleArchiving.Text") : GetLocalizedString("locTitle.Text"); - UpdateTags(); - secMailboxFeatures.Visible = !RetentionPolicy; secMailboxGeneral.Visible = !RetentionPolicy; + secStorageQuotas.Visible = !RetentionPolicy; + secDeleteRetention.Visible = !RetentionPolicy; + secLitigationHold.Visible = !RetentionPolicy; + + secArchiving.Visible = RetentionPolicy; secRetentionPolicyTags.Visible = RetentionPolicy; + btnAdd.CausesValidation = RetentionPolicy; } @@ -222,36 +236,45 @@ namespace WebsitePanel.Portal.ExchangeServer { Providers.HostedSolution.ExchangeMailboxPlan plan = new Providers.HostedSolution.ExchangeMailboxPlan(); plan.MailboxPlan = txtMailboxPlan.Text; - - plan.MailboxSizeMB = mailboxSize.QuotaValue; - - plan.IsDefault = false; - plan.MaxRecipients = maxRecipients.QuotaValue; - plan.MaxSendMessageSizeKB = maxSendMessageSizeKB.QuotaValue; - plan.MaxReceiveMessageSizeKB = maxReceiveMessageSizeKB.QuotaValue; - plan.EnablePOP = chkPOP3.Checked; - plan.EnableIMAP = chkIMAP.Checked; - plan.EnableOWA = chkOWA.Checked; - plan.EnableMAPI = chkMAPI.Checked; - plan.EnableActiveSync = chkActiveSync.Checked; - plan.IssueWarningPct = sizeIssueWarning.ValueKB; - if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; - plan.ProhibitSendPct = sizeProhibitSend.ValueKB; - if ((plan.ProhibitSendPct == 0)) plan.ProhibitSendPct = 100; - plan.ProhibitSendReceivePct = sizeProhibitSendReceive.ValueKB; - if ((plan.ProhibitSendReceivePct == 0)) plan.ProhibitSendReceivePct = 100; - plan.KeepDeletedItemsDays = daysKeepDeletedItems.ValueDays; - plan.HideFromAddressBook = chkHideFromAddressBook.Checked; - plan.AllowLitigationHold = chkEnableLitigationHold.Checked; - plan.RecoverableItemsSpace = recoverableItemsSpace.QuotaValue; - plan.RecoverableItemsWarningPct = recoverableItemsWarning.ValueKB; - if ((plan.RecoverableItemsWarningPct == 0)) plan.RecoverableItemsWarningPct = 100; - plan.LitigationHoldMsg = txtLitigationHoldMsg.Text.Trim(); - plan.LitigationHoldUrl = txtLitigationHoldUrl.Text.Trim(); - plan.Archiving = RetentionPolicy; - plan.EnableArchiving = chkEnableArchiving.Checked; + if (RetentionPolicy) + { + plan.EnableArchiving = chkEnableArchiving.Checked; + + plan.MailboxSizeMB = archiveQuota.QuotaValue; + plan.IssueWarningPct = archiveWarningQuota.ValueKB; + if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; + + } + else + { + plan.MailboxSizeMB = mailboxSize.QuotaValue; + + plan.IsDefault = false; + plan.MaxRecipients = maxRecipients.QuotaValue; + plan.MaxSendMessageSizeKB = maxSendMessageSizeKB.QuotaValue; + plan.MaxReceiveMessageSizeKB = maxReceiveMessageSizeKB.QuotaValue; + plan.EnablePOP = chkPOP3.Checked; + plan.EnableIMAP = chkIMAP.Checked; + plan.EnableOWA = chkOWA.Checked; + plan.EnableMAPI = chkMAPI.Checked; + plan.EnableActiveSync = chkActiveSync.Checked; + plan.IssueWarningPct = sizeIssueWarning.ValueKB; + if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; + plan.ProhibitSendPct = sizeProhibitSend.ValueKB; + if ((plan.ProhibitSendPct == 0)) plan.ProhibitSendPct = 100; + plan.ProhibitSendReceivePct = sizeProhibitSendReceive.ValueKB; + if ((plan.ProhibitSendReceivePct == 0)) plan.ProhibitSendReceivePct = 100; + plan.KeepDeletedItemsDays = daysKeepDeletedItems.ValueDays; + plan.HideFromAddressBook = chkHideFromAddressBook.Checked; + plan.AllowLitigationHold = chkEnableLitigationHold.Checked; + plan.RecoverableItemsSpace = recoverableItemsSpace.QuotaValue; + plan.RecoverableItemsWarningPct = recoverableItemsWarning.ValueKB; + if ((plan.RecoverableItemsWarningPct == 0)) plan.RecoverableItemsWarningPct = 100; + plan.LitigationHoldMsg = txtLitigationHoldMsg.Text.Trim(); + plan.LitigationHoldUrl = txtLitigationHoldUrl.Text.Trim(); + } int planId = ES.Services.ExchangeServer.AddExchangeMailboxPlan(PanelRequest.ItemID, plan); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.designer.cs index 11d7b600..e5997808 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddMailboxPlan.ascx.designer.cs @@ -174,15 +174,6 @@ namespace WebsitePanel.Portal.ExchangeServer { ///
protected global::System.Web.UI.WebControls.CheckBox chkActiveSync; - /// - /// chkEnableArchiving control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox chkEnableArchiving; - /// /// secMailboxGeneral control. /// @@ -498,6 +489,69 @@ namespace WebsitePanel.Portal.ExchangeServer { ///
protected global::System.Web.UI.WebControls.TextBox txtLitigationHoldMsg; + /// + /// secArchiving control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.CollapsiblePanel secArchiving; + + /// + /// Archiving control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel Archiving; + + /// + /// chkEnableArchiving control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox chkEnableArchiving; + + /// + /// locArchiveQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locArchiveQuota; + + /// + /// archiveQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.QuotaEditor archiveQuota; + + /// + /// locArchiveWarningQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locArchiveWarningQuota; + + /// + /// archiveWarningQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.ExchangeServer.UserControls.SizeBox archiveWarningQuota; + /// /// secRetentionPolicyTags control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx index 76fa28eb..67940a0b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx @@ -147,7 +147,7 @@ - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.designer.cs index 948f2580..ded32126 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.designer.cs @@ -328,13 +328,13 @@ namespace WebsitePanel.Portal.ExchangeServer { protected global::WebsitePanel.Portal.ExchangeServer.UserControls.MailboxPlanSelector mailboxPlanSelector; /// - /// locArchivingMailboxplanName control. + /// locRetentionPolicyName control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Localize locArchivingMailboxplanName; + protected global::System.Web.UI.WebControls.Localize locRetentionPolicyName; /// /// archivingMailboxPlanSelector control. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx index b3278a57..10f3cfdb 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx @@ -55,7 +55,7 @@ - + @@ -74,16 +74,10 @@ - - + + - - - - - + - - -
- -
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.cs index 8233dc9c..4d52a840 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.cs @@ -67,8 +67,6 @@ namespace WebsitePanel.Portal.ExchangeServer BindSettings(); - SetArchivingVisible(); - UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId); if (user != null) @@ -124,12 +122,10 @@ namespace WebsitePanel.Portal.ExchangeServer if (account.ArchivingMailboxPlanId<1) { mailboxRetentionPolicySelector.MailboxPlanId = "-1"; - chkArchiving.Checked = false; } else { mailboxRetentionPolicySelector.MailboxPlanId = account.ArchivingMailboxPlanId.ToString(); - chkArchiving.Checked = true; } mailboxSize.QuotaUsedValue = Convert.ToInt32(stats.TotalSize / 1024 / 1024); @@ -182,8 +178,7 @@ namespace WebsitePanel.Portal.ExchangeServer { int planId = Convert.ToInt32(mailboxPlanSelector.MailboxPlanId); int policyId = -1; - if (chkArchiving.Checked) - policyId = Convert.ToInt32(mailboxRetentionPolicySelector.MailboxPlanId); + int.TryParse(mailboxRetentionPolicySelector.MailboxPlanId, out policyId); result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(PanelRequest.ItemID, PanelRequest.AccountID, planId, policyId); @@ -264,35 +259,5 @@ namespace WebsitePanel.Portal.ExchangeServer return result; } - protected void chkArchiving_CheckedChanged(object sender, EventArgs e) - { - SetArchivingVisible(); - } - - private void SetArchivingVisible() - { - int id; - if (!int.TryParse(mailboxPlanSelector.MailboxPlanId, out id)) - return; - - bool archiving = false; - - ExchangeMailboxPlan policy = ES.Services.ExchangeServer.GetExchangeMailboxPlan(PanelRequest.ItemID, id); - - if (policy != null) - archiving = policy.EnableArchiving & Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWARCHIVING, Cntx); - - if (!archiving) - chkArchiving.Checked = false; - - secArchiving.Visible = archiving; - mailboxArchivePlan.Visible = chkArchiving.Checked; - } - - protected void mailboxPlanSelector_Changed(object sender, EventArgs e) - { - SetArchivingVisible(); - } - } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.designer.cs index 9aea4c2d..31535520 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.designer.cs @@ -175,40 +175,22 @@ namespace WebsitePanel.Portal.ExchangeServer { protected global::WebsitePanel.Portal.QuotaViewer mailboxSize; /// - /// secArchiving control. + /// secRetentionPolicy control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::WebsitePanel.Portal.CollapsiblePanel secArchiving; + protected global::WebsitePanel.Portal.CollapsiblePanel secRetentionPolicy; /// - /// Archiving control. + /// RetentionPolicy control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Panel Archiving; - - /// - /// chkArchiving control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox chkArchiving; - - /// - /// mailboxArchivePlan control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlTableRow mailboxArchivePlan; + protected global::System.Web.UI.WebControls.Panel RetentionPolicy; /// /// locRetentionPolicyName control. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx index 9ba5ee59..855b6a24 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx @@ -103,11 +103,6 @@
- -

@@ -260,6 +255,74 @@
+ + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+
+ +
+
+
+ + + + + + + + + + + + <%# PortalAntiXSS.Encode((string)Eval("TagName"))%> + + + + +   + + + + + +
+ + + +
+
+
+
+ diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs index 1eb5b4b6..87185368 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs @@ -70,10 +70,21 @@ namespace WebsitePanel.Portal secMailboxFeatures.Visible = !RetentionPolicy; secMailboxGeneral.Visible = !RetentionPolicy; + secStorageQuotas.Visible = !RetentionPolicy; + secDeleteRetention.Visible = !RetentionPolicy; + secLitigationHold.Visible = !RetentionPolicy; + + secArchiving.Visible = RetentionPolicy; + secRetentionPolicyTags.Visible = RetentionPolicy; gvMailboxPlans.Columns[4].Visible = !RetentionPolicy; gvMailboxPlans.Columns[5].Visible = !RetentionPolicy; + btnAddMailboxPlan.CausesValidation = RetentionPolicy; + btnUpdateMailboxPlan.CausesValidation = RetentionPolicy; + + UpdateTags(); + } @@ -109,44 +120,54 @@ namespace WebsitePanel.Portal public void btnAddMailboxPlan_Click(object sender, EventArgs e) { - Page.Validate("CreateMailboxPlan"); + if (!RetentionPolicy) + Page.Validate("CreateMailboxPlan"); if (!Page.IsValid) return; Providers.HostedSolution.ExchangeMailboxPlan plan = new Providers.HostedSolution.ExchangeMailboxPlan(); plan.MailboxPlan = txtMailboxPlan.Text; - - plan.MailboxSizeMB = mailboxSize.QuotaValue; - - plan.IsDefault = false; - plan.MaxRecipients = maxRecipients.QuotaValue; - plan.MaxSendMessageSizeKB = maxSendMessageSizeKB.QuotaValue; - plan.MaxReceiveMessageSizeKB = maxReceiveMessageSizeKB.QuotaValue; - plan.EnablePOP = chkPOP3.Checked; - plan.EnableIMAP = chkIMAP.Checked; - plan.EnableOWA = chkOWA.Checked; - plan.EnableMAPI = chkMAPI.Checked; - plan.EnableActiveSync = chkActiveSync.Checked; - plan.IssueWarningPct = sizeIssueWarning.ValueKB; - if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; - plan.ProhibitSendPct = sizeProhibitSend.ValueKB; - if ((plan.ProhibitSendPct == 0)) plan.ProhibitSendPct = 100; - plan.ProhibitSendReceivePct = sizeProhibitSendReceive.ValueKB; - if ((plan.ProhibitSendReceivePct == 0)) plan.ProhibitSendReceivePct = 100; - plan.KeepDeletedItemsDays = daysKeepDeletedItems.ValueDays; - plan.HideFromAddressBook = chkHideFromAddressBook.Checked; - plan.AllowLitigationHold = chkEnableLitigationHold.Checked; - plan.RecoverableItemsSpace = recoverableItemsSpace.QuotaValue; - plan.RecoverableItemsWarningPct = recoverableItemsWarning.ValueKB; - if ((plan.RecoverableItemsWarningPct == 0)) plan.RecoverableItemsWarningPct = 100; - plan.LitigationHoldMsg = txtLitigationHoldMsg.Text.Trim(); - plan.LitigationHoldUrl = txtLitigationHoldUrl.Text.Trim(); - - plan.EnableArchiving = chkEnableArchiving.Checked; - plan.Archiving = RetentionPolicy; + if (RetentionPolicy) + { + plan.EnableArchiving = chkEnableArchiving.Checked; + + plan.MailboxSizeMB = archiveQuota.QuotaValue; + plan.IssueWarningPct = archiveWarningQuota.ValueKB; + if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; + + } + else + { + plan.MailboxSizeMB = mailboxSize.QuotaValue; + + plan.IsDefault = false; + plan.MaxRecipients = maxRecipients.QuotaValue; + plan.MaxSendMessageSizeKB = maxSendMessageSizeKB.QuotaValue; + plan.MaxReceiveMessageSizeKB = maxReceiveMessageSizeKB.QuotaValue; + plan.EnablePOP = chkPOP3.Checked; + plan.EnableIMAP = chkIMAP.Checked; + plan.EnableOWA = chkOWA.Checked; + plan.EnableMAPI = chkMAPI.Checked; + plan.EnableActiveSync = chkActiveSync.Checked; + plan.IssueWarningPct = sizeIssueWarning.ValueKB; + if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; + plan.ProhibitSendPct = sizeProhibitSend.ValueKB; + if ((plan.ProhibitSendPct == 0)) plan.ProhibitSendPct = 100; + plan.ProhibitSendReceivePct = sizeProhibitSendReceive.ValueKB; + if ((plan.ProhibitSendReceivePct == 0)) plan.ProhibitSendReceivePct = 100; + plan.KeepDeletedItemsDays = daysKeepDeletedItems.ValueDays; + plan.HideFromAddressBook = chkHideFromAddressBook.Checked; + plan.AllowLitigationHold = chkEnableLitigationHold.Checked; + plan.RecoverableItemsSpace = recoverableItemsSpace.QuotaValue; + plan.RecoverableItemsWarningPct = recoverableItemsWarning.ValueKB; + if ((plan.RecoverableItemsWarningPct == 0)) plan.RecoverableItemsWarningPct = 100; + plan.LitigationHoldMsg = txtLitigationHoldMsg.Text.Trim(); + plan.LitigationHoldUrl = txtLitigationHoldUrl.Text.Trim(); + } + if (PanelSecurity.SelectedUser.Role == UserRole.Administrator) plan.MailboxPlanType = (int)ExchangeMailboxPlanType.Administrator; else @@ -172,13 +193,16 @@ namespace WebsitePanel.Portal if ((orgs != null) & (orgs.GetLength(0) > 0)) { - int result = ES.Services.ExchangeServer.AddExchangeMailboxPlan(orgs[0].Id, plan); + int planId = ES.Services.ExchangeServer.AddExchangeMailboxPlan(orgs[0].Id, plan); - if (result < 0) + if (planId < 0) { - messageBox.ShowResultMessage(result); + messageBox.ShowResultMessage(planId); return; } + + if (RetentionPolicy) + SaveTags(orgs[0].Id, planId); } BindMailboxPlans(); @@ -251,6 +275,13 @@ namespace WebsitePanel.Portal txtLitigationHoldUrl.Text = string.Empty; chkEnableArchiving.Checked = false; + archiveQuota.QuotaValue = 0; + archiveWarningQuota.ValueKB = 0; + ViewState["Tags"] = null; + gvPolicy.DataSource = null; + gvPolicy.DataBind(); + UpdateTags(); + btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true; @@ -282,30 +313,48 @@ namespace WebsitePanel.Portal plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(orgs[0].Id, mailboxPlanId); - txtMailboxPlan.Text = plan.MailboxPlan; - mailboxSize.QuotaValue = plan.MailboxSizeMB; - maxRecipients.QuotaValue = plan.MaxRecipients; - maxSendMessageSizeKB.QuotaValue = plan.MaxSendMessageSizeKB; - maxReceiveMessageSizeKB.QuotaValue = plan.MaxReceiveMessageSizeKB; - chkPOP3.Checked = plan.EnablePOP; - chkIMAP.Checked = plan.EnableIMAP; - chkOWA.Checked = plan.EnableOWA; - chkMAPI.Checked = plan.EnableMAPI; - chkActiveSync.Checked = plan.EnableActiveSync; - sizeIssueWarning.ValueKB = plan.IssueWarningPct; - sizeProhibitSend.ValueKB = plan.ProhibitSendPct; - sizeProhibitSendReceive.ValueKB = plan.ProhibitSendReceivePct; - if (plan.KeepDeletedItemsDays != -1) - daysKeepDeletedItems.ValueDays = plan.KeepDeletedItemsDays; - chkHideFromAddressBook.Checked = plan.HideFromAddressBook; - chkEnableLitigationHold.Checked = plan.AllowLitigationHold; - recoverableItemsSpace.QuotaValue = plan.RecoverableItemsSpace; - recoverableItemsWarning.ValueKB = plan.RecoverableItemsWarningPct; - txtLitigationHoldMsg.Text = plan.LitigationHoldMsg; - txtLitigationHoldUrl.Text = plan.LitigationHoldUrl; - chkEnableArchiving.Checked = plan.EnableArchiving; + if (RetentionPolicy) + { + chkEnableArchiving.Checked = plan.EnableArchiving; + + archiveQuota.QuotaValue = plan.MailboxSizeMB; + archiveWarningQuota.ValueKB = plan.IssueWarningPct; + + List tags = new List(); + tags.AddRange(ES.Services.ExchangeServer.GetExchangeMailboxPlanRetentionPolicyTags(plan.MailboxPlanId)); + + ViewState["Tags"] = tags; + gvPolicy.DataSource = tags; + gvPolicy.DataBind(); + UpdateTags(); + + } + else + { + mailboxSize.QuotaValue = plan.MailboxSizeMB; + maxRecipients.QuotaValue = plan.MaxRecipients; + maxSendMessageSizeKB.QuotaValue = plan.MaxSendMessageSizeKB; + maxReceiveMessageSizeKB.QuotaValue = plan.MaxReceiveMessageSizeKB; + chkPOP3.Checked = plan.EnablePOP; + chkIMAP.Checked = plan.EnableIMAP; + chkOWA.Checked = plan.EnableOWA; + chkMAPI.Checked = plan.EnableMAPI; + chkActiveSync.Checked = plan.EnableActiveSync; + sizeIssueWarning.ValueKB = plan.IssueWarningPct; + sizeProhibitSend.ValueKB = plan.ProhibitSendPct; + sizeProhibitSendReceive.ValueKB = plan.ProhibitSendReceivePct; + if (plan.KeepDeletedItemsDays != -1) + daysKeepDeletedItems.ValueDays = plan.KeepDeletedItemsDays; + chkHideFromAddressBook.Checked = plan.HideFromAddressBook; + chkEnableLitigationHold.Checked = plan.AllowLitigationHold; + recoverableItemsSpace.QuotaValue = plan.RecoverableItemsSpace; + recoverableItemsWarning.ValueKB = plan.RecoverableItemsWarningPct; + txtLitigationHoldMsg.Text = plan.LitigationHoldMsg; + txtLitigationHoldUrl.Text = plan.LitigationHoldUrl; + } + btnUpdateMailboxPlan.Enabled = (string.IsNullOrEmpty(txtMailboxPlan.Text)) ? false : true; @@ -388,37 +437,48 @@ namespace WebsitePanel.Portal plan = new Providers.HostedSolution.ExchangeMailboxPlan(); plan.MailboxPlanId = (int)ViewState["MailboxPlanID"]; plan.MailboxPlan = txtMailboxPlan.Text; - - plan.MailboxSizeMB = mailboxSize.QuotaValue; - - plan.IsDefault = false; - plan.MaxRecipients = maxRecipients.QuotaValue; - plan.MaxSendMessageSizeKB = maxSendMessageSizeKB.QuotaValue; - plan.MaxReceiveMessageSizeKB = maxReceiveMessageSizeKB.QuotaValue; - plan.EnablePOP = chkPOP3.Checked; - plan.EnableIMAP = chkIMAP.Checked; - plan.EnableOWA = chkOWA.Checked; - plan.EnableMAPI = chkMAPI.Checked; - plan.EnableActiveSync = chkActiveSync.Checked; - plan.IssueWarningPct = sizeIssueWarning.ValueKB; - if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; - plan.ProhibitSendPct = sizeProhibitSend.ValueKB; - if ((plan.ProhibitSendPct == 0)) plan.ProhibitSendPct = 100; - plan.ProhibitSendReceivePct = sizeProhibitSendReceive.ValueKB; - if ((plan.ProhibitSendReceivePct == 0)) plan.ProhibitSendReceivePct = 100; - plan.KeepDeletedItemsDays = daysKeepDeletedItems.ValueDays; - plan.HideFromAddressBook = chkHideFromAddressBook.Checked; - plan.AllowLitigationHold = chkEnableLitigationHold.Checked; - plan.RecoverableItemsSpace = recoverableItemsSpace.QuotaValue; - plan.RecoverableItemsWarningPct = recoverableItemsWarning.ValueKB; - if ((plan.RecoverableItemsWarningPct == 0)) plan.RecoverableItemsWarningPct = 100; - plan.LitigationHoldMsg = txtLitigationHoldMsg.Text.Trim(); - plan.LitigationHoldUrl = txtLitigationHoldUrl.Text.Trim(); - - plan.EnableArchiving = chkEnableArchiving.Checked; - plan.Archiving = RetentionPolicy; + if (RetentionPolicy) + { + plan.EnableArchiving = chkEnableArchiving.Checked; + + plan.MailboxSizeMB = archiveQuota.QuotaValue; + plan.IssueWarningPct = archiveWarningQuota.ValueKB; + if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; + + } + else + { + plan.MailboxSizeMB = mailboxSize.QuotaValue; + + plan.IsDefault = false; + plan.MaxRecipients = maxRecipients.QuotaValue; + plan.MaxSendMessageSizeKB = maxSendMessageSizeKB.QuotaValue; + plan.MaxReceiveMessageSizeKB = maxReceiveMessageSizeKB.QuotaValue; + plan.EnablePOP = chkPOP3.Checked; + plan.EnableIMAP = chkIMAP.Checked; + plan.EnableOWA = chkOWA.Checked; + plan.EnableMAPI = chkMAPI.Checked; + plan.EnableActiveSync = chkActiveSync.Checked; + plan.IssueWarningPct = sizeIssueWarning.ValueKB; + if ((plan.IssueWarningPct == 0)) plan.IssueWarningPct = 100; + plan.ProhibitSendPct = sizeProhibitSend.ValueKB; + if ((plan.ProhibitSendPct == 0)) plan.ProhibitSendPct = 100; + plan.ProhibitSendReceivePct = sizeProhibitSendReceive.ValueKB; + if ((plan.ProhibitSendReceivePct == 0)) plan.ProhibitSendReceivePct = 100; + plan.KeepDeletedItemsDays = daysKeepDeletedItems.ValueDays; + plan.HideFromAddressBook = chkHideFromAddressBook.Checked; + plan.AllowLitigationHold = chkEnableLitigationHold.Checked; + plan.RecoverableItemsSpace = recoverableItemsSpace.QuotaValue; + plan.RecoverableItemsWarningPct = recoverableItemsWarning.ValueKB; + if ((plan.RecoverableItemsWarningPct == 0)) plan.RecoverableItemsWarningPct = 100; + plan.LitigationHoldMsg = txtLitigationHoldMsg.Text.Trim(); + plan.LitigationHoldUrl = txtLitigationHoldUrl.Text.Trim(); + } + + + if (PanelSecurity.SelectedUser.Role == UserRole.Administrator) plan.MailboxPlanType = (int)ExchangeMailboxPlanType.Administrator; else @@ -436,8 +496,12 @@ namespace WebsitePanel.Portal } else { + if (RetentionPolicy) + SaveTags(orgs[0].Id, mailboxPlanId); + messageBox.ShowSuccessMessage("EXCHANGE_UPDATEPLANS"); } + } BindMailboxPlans(); @@ -518,5 +582,130 @@ namespace WebsitePanel.Portal BindMailboxPlans(); } + + protected void gvPolicy_RowCommand(object sender, GridViewCommandEventArgs e) + { + + switch (e.CommandName) + { + case "DeleteItem": + try + { + int tagId; + if (!int.TryParse(e.CommandArgument.ToString(), out tagId)) + return; + + List tags = ViewState["Tags"] as List; + if (tags == null) return; + + int i = tags.FindIndex(x => x.TagID == tagId); + if (i >= 0) tags.RemoveAt(i); + + ViewState["Tags"] = tags; + gvPolicy.DataSource = tags; + gvPolicy.DataBind(); + UpdateTags(); + } + catch (Exception) + { + } + + break; + + } + } + + protected void bntAddTag_Click(object sender, EventArgs e) + { + int addTagId; + if (!int.TryParse(ddTags.SelectedValue, out addTagId)) + return; + + Providers.HostedSolution.ExchangeRetentionPolicyTag tag = ES.Services.ExchangeServer.GetExchangeRetentionPolicyTag(PanelRequest.ItemID, addTagId); + if (tag == null) return; + + List res = ViewState["Tags"] as List; + if (res == null) res = new List(); + + ExchangeMailboxPlanRetentionPolicyTag add = new ExchangeMailboxPlanRetentionPolicyTag(); + add.MailboxPlanId = PanelRequest.GetInt("MailboxPlanId"); + add.TagID = tag.TagID; + add.TagName = tag.TagName; + + res.Add(add); + + ViewState["Tags"] = res; + + gvPolicy.DataSource = res; + gvPolicy.DataBind(); + + UpdateTags(); + } + + protected void UpdateTags() + { + if (RetentionPolicy) + { + ddTags.Items.Clear(); + + 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)) + { + Providers.HostedSolution.ExchangeRetentionPolicyTag[] allTags = ES.Services.ExchangeServer.GetExchangeRetentionPolicyTags(orgs[0].Id); + List selectedTags = ViewState["Tags"] as List; + + foreach (Providers.HostedSolution.ExchangeRetentionPolicyTag tag in allTags) + { + if (selectedTags != null) + { + if (selectedTags.Find(x => x.TagID == tag.TagID) != null) + continue; + } + + ddTags.Items.Add(new System.Web.UI.WebControls.ListItem(tag.TagName, tag.TagID.ToString())); + } + } + + } + } + + protected void SaveTags(int ItemId, int planId) + { + ExchangeMailboxPlanRetentionPolicyTag[] currenttags = ES.Services.ExchangeServer.GetExchangeMailboxPlanRetentionPolicyTags(planId); + foreach (ExchangeMailboxPlanRetentionPolicyTag tag in currenttags) + ES.Services.ExchangeServer.DeleteExchangeMailboxPlanRetentionPolicyTag(ItemId, planId, tag.PlanTagID); + + List tags = ViewState["Tags"] as List; + if (tags != null) + { + foreach (ExchangeMailboxPlanRetentionPolicyTag tag in tags) + { + tag.MailboxPlanId = planId; + int result = ES.Services.ExchangeServer.AddExchangeMailboxPlanRetentionPolicyTag(ItemId, tag); + if (result < 0) + { + messageBox.ShowResultMessage(result); + return; + } + } + } + + } + } } \ 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 401575ee..6459f5b0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.designer.cs @@ -138,15 +138,6 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.WebControls.CheckBox chkActiveSync; - /// - /// chkEnableArchiving control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox chkEnableArchiving; - /// /// secMailboxGeneral control. /// @@ -462,6 +453,123 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.WebControls.TextBox txtLitigationHoldMsg; + /// + /// secArchiving control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.CollapsiblePanel secArchiving; + + /// + /// Archiving control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel Archiving; + + /// + /// chkEnableArchiving control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox chkEnableArchiving; + + /// + /// locArchiveQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locArchiveQuota; + + /// + /// archiveQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.QuotaEditor archiveQuota; + + /// + /// locArchiveWarningQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locArchiveWarningQuota; + + /// + /// archiveWarningQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.ExchangeServer.UserControls.SizeBox archiveWarningQuota; + + /// + /// secRetentionPolicyTags control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.CollapsiblePanel secRetentionPolicyTags; + + /// + /// RetentionPolicyTags control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel RetentionPolicyTags; + + /// + /// GeneralUpdatePanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.UpdatePanel GeneralUpdatePanel; + + /// + /// gvPolicy control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.GridView gvPolicy; + + /// + /// ddTags control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddTags; + + /// + /// bntAddTag control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button bntAddTag; + /// /// btnAddMailboxPlan control. ///