From a17e35e5895dae78cbc79295b9b8c88ccd56e362 Mon Sep 17 00:00:00 2001 From: dev_amdtel Date: Tue, 10 Jun 2014 17:03:26 +0400 Subject: [PATCH] Fix archiving --- WebsitePanel/Database/update_db.sql | 69 +++++++++++++++++++ .../Packages/Quotas.cs | 5 +- .../ExchangeServerController.cs | 3 + .../Exchange2013.cs | 16 +++++ .../ExchangeCreateMailbox.ascx.cs | 4 +- .../ExchangeMailboxGeneralSettings.ascx.cs | 17 +++-- .../ExchangeServer/OrganizationHome.ascx.cs | 4 +- 7 files changed, 104 insertions(+), 14 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 921a552f..e7bbfa49 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -4378,3 +4378,72 @@ WHERE RETURN GO + + + + + +-- Exchange2013 Archiving + +ALTER PROCEDURE [dbo].[GetExchangeOrganizationStatistics] +( + @ItemID int +) +AS + +DECLARE @ARCHIVESIZE INT +IF -1 in (SELECT B.ArchiveSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN + SET @ARCHIVESIZE = -1 +END +ELSE +BEGIN + SET @ARCHIVESIZE = (SELECT SUM(B.ArchiveSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +END + +IF -1 IN (SELECT B.MailboxSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT MIN(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT MIN(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace, + @ARCHIVESIZE AS UsedArchingStorage +END +ELSE +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT SUM(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace, + @ARCHIVESIZE AS UsedArchingStorage +END + + +RETURN +GO + + +BEGIN +DELETE FROM [dbo].[HostingPlanQuotas] WHERE QuotaID = 427 +END +GO + +BEGIN +DELETE FROM [dbo].[PackageQuotas] WHERE QuotaID = 427 +END +GO + + +BEGIN +DELETE FROM [dbo].[Quotas] WHERE QuotaID = 427 +END +GO + diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs index 888e9a0e..547417f4 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs @@ -119,9 +119,8 @@ order by rg.groupOrder public const string EXCHANGE2007_RECOVERABLEITEMSSPACE = "Exchange2007.RecoverableItemsSpace"; public const string EXCHANGE2007_DISCLAIMERSALLOWED = "Exchange2007.DisclaimersAllowed"; - public const string EXCHANGE2013_ALLOWARCHIVING = "Exchange2013.AllowArchiving"; - public const string EXCHANGE2013_ALLOWRETENTIONPOLICY = "Exchange2013.AllowRetentionPolicy"; // Archiving - public const string EXCHANGE2013_ARCHIVINGSTORAGE = "Exchange2013.ArchivingStorage"; + public const string EXCHANGE2013_ALLOWRETENTIONPOLICY = "Exchange2013.AllowRetentionPolicy"; // RetentionPolicy + public const string EXCHANGE2013_ARCHIVINGSTORAGE = "Exchange2013.ArchivingStorage"; // Archiving public const string EXCHANGE2013_ARCHIVINGMAILBOXES = "Exchange2013.ArchivingMailboxes"; public const string MSSQL2000_DATABASES = "MsSQL2000.Databases"; // Databases diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs index c9c91cbe..062ab07e 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs @@ -192,6 +192,7 @@ namespace WebsitePanel.EnterpriseServer stats.CreatedPublicFolders = tempStats.CreatedPublicFolders; stats.UsedDiskSpace = tempStats.UsedDiskSpace; stats.UsedLitigationHoldSpace = tempStats.UsedLitigationHoldSpace; + stats.UsedArchingStorage = tempStats.UsedArchingStorage; } else { @@ -219,6 +220,7 @@ namespace WebsitePanel.EnterpriseServer stats.CreatedPublicFolders += tempStats.CreatedPublicFolders; stats.UsedDiskSpace += tempStats.UsedDiskSpace; stats.UsedLitigationHoldSpace += tempStats.UsedLitigationHoldSpace; + stats.UsedArchingStorage += tempStats.UsedArchingStorage; } } } @@ -237,6 +239,7 @@ namespace WebsitePanel.EnterpriseServer stats.AllocatedPublicFolders = cntx.Quotas[Quotas.EXCHANGE2007_PUBLICFOLDERS].QuotaAllocatedValue; stats.AllocatedDiskSpace = cntx.Quotas[Quotas.EXCHANGE2007_DISKSPACE].QuotaAllocatedValue; stats.AllocatedLitigationHoldSpace = cntx.Quotas[Quotas.EXCHANGE2007_RECOVERABLEITEMSSPACE].QuotaAllocatedValue; + stats.AllocatedArchingStorage = cntx.Quotas[Quotas.EXCHANGE2013_ARCHIVINGSTORAGE].QuotaAllocatedValue; return stats; } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs index c0a1ae5e..b75993f8 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs @@ -3079,6 +3079,22 @@ namespace WebsitePanel.Providers.HostedSolution info.LastLogon = DateTime.MinValue; } + cmd = new Command("Get-MailboxStatistics"); + cmd.Parameters.Add("Identity", id); + cmd.Parameters.Add("Archive"); + result = ExecuteShellCommand(runSpace, cmd); + if (result.Count > 0) + { + PSObject statistics = result[0]; + Unlimited totalItemSize = + (Unlimited)GetPSObjectProperty(statistics, "TotalItemSize"); + info.ArchivingTotalSize = ConvertUnlimitedToBytes(totalItemSize); + } + else + { + info.ArchivingTotalSize = 0; + } + if (info.LitigationHoldEnabled) { cmd = new Command("Get-MailboxFolderStatistics"); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.cs index 474a452e..d0d54618 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeCreateMailbox.ascx.cs @@ -104,13 +104,13 @@ namespace WebsitePanel.Portal.ExchangeServer rowRetentionPolicy.Visible = Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWRETENTIONPOLICY, cntx); } - rowArchiving.Visible = Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWARCHIVING, cntx); + rowArchiving.Visible = false; int planId = -1; int.TryParse(mailboxPlanSelector.MailboxPlanId, out planId); ExchangeMailboxPlan plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(PanelRequest.ItemID, planId); if (plan!=null) - rowArchiving.Visible = rowArchiving.Visible && plan.EnableArchiving; + rowArchiving.Visible = plan.EnableArchiving; } 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 5840b482..c59e5e69 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxGeneralSettings.ascx.cs @@ -89,7 +89,7 @@ namespace WebsitePanel.Portal.ExchangeServer int.TryParse(mailboxPlanSelector.MailboxPlanId, out planId); ExchangeMailboxPlan plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(PanelRequest.ItemID, planId); - secArchiving.Visible = Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWARCHIVING, Cntx) && plan.EnableArchiving; + secArchiving.Visible = plan.EnableArchiving; rowArchiving.Visible = chkEnableArchiving.Checked; } @@ -119,6 +119,10 @@ namespace WebsitePanel.Portal.ExchangeServer // get account meta ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID); + + // get mailbox plan + ExchangeMailboxPlan plan = ES.Services.ExchangeServer.GetExchangeMailboxPlan(PanelRequest.ItemID, account.MailboxPlanId); + chkPmmAllowed.Checked = (account.MailboxManagerActions & MailboxManagerActions.GeneralSettings) > 0; if (account.MailboxPlanId == 0) @@ -156,12 +160,11 @@ namespace WebsitePanel.Portal.ExchangeServer ddDisclaimer.SelectedValue = disclaimerId.ToString(); } - if (Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWARCHIVING, Cntx)) - { - chkEnableArchiving.Checked = account.EnableArchiving; - archivingQuotaViewer.QuotaUsedValue = Convert.ToInt32(stats.ArchivingTotalSize / 1024 / 1024); - archivingQuotaViewer.QuotaValue = (stats.ArchivingMaxSize == -1) ? -1 : (int)Math.Round((double)(stats.ArchivingMaxSize / 1024 / 1024)); - } + int ArchivingMaxSize = -1; + if (plan != null) ArchivingMaxSize = plan.ArchiveSizeMB; + chkEnableArchiving.Checked = account.EnableArchiving; + archivingQuotaViewer.QuotaUsedValue = Convert.ToInt32(stats.ArchivingTotalSize / 1024 / 1024); + archivingQuotaViewer.QuotaValue = ArchivingMaxSize; } catch (Exception ex) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationHome.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationHome.ascx.cs index e73b8adc..cf461192 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationHome.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationHome.ascx.cs @@ -123,13 +123,13 @@ namespace WebsitePanel.Portal.ExchangeServer else this.rowExchangeLitigationHold.Style.Add("display", "none"); - if ((!hideItems) && (Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWARCHIVING, cntx))) + if (!hideItems) { exchangeArchivingStatus.QuotaUsedValue = exchangeOrgStats.UsedArchingStorage; exchangeArchivingStatus.QuotaValue = exchangeOrgStats.AllocatedArchingStorage; if (exchangeOrgStats.AllocatedArchingStorage != -1) { - exchangeLitigationHoldStats.QuotaAvailable = exchangeTenantStats.AllocatedArchingStorage - exchangeTenantStats.UsedArchingStorage; + exchangeArchivingStatus.QuotaAvailable = exchangeTenantStats.AllocatedArchingStorage - exchangeTenantStats.UsedArchingStorage; } } else