From 54fade88c80ab6925da08d1d7ccb20f92dfbf7aa Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 8 Jan 2014 17:56:16 +0300 Subject: [PATCH] fixing bugs --- WebsitePanel/Database/update_db.sql | 10 ++++++ .../EnterpriseStorageController.cs | 28 +++++------------ .../HostedSolution/OrganizationController.cs | 4 +-- .../Windows2012.cs | 2 +- .../WebsitePanel_SharedResources.ascx.resx | 2 +- .../App_LocalResources/SpaceQuotas.ascx.resx | 2 +- .../OrganizationHome.ascx.resx | 2 +- ...nterpriseStorageFolderGeneralSettings.ascx | 2 +- ...rpriseStorageFolderGeneralSettings.ascx.cs | 24 ++++++++------ .../EnterpriseStorageFolders.ascx | 2 +- .../EnterpriseStorageFolders.ascx.cs | 26 ++++++++++++++-- .../EnterpriseStoragePermissions.ascx.resx | 14 +++------ .../EnterpriseStoragePermissions.ascx | 7 ++--- .../EnterpriseStoragePermissions.ascx.cs | 31 ++----------------- ...erpriseStoragePermissions.ascx.designer.cs | 26 +++------------- .../WebsitePanel.Portal.Modules.csproj | 8 +++-- 16 files changed, 81 insertions(+), 109 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index db477da0..7d8add41 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -3025,4 +3025,14 @@ UPDATE EnterpriseFolders SET FolderName = @FolderName, FolderQuota = @FolderQuota WHERE ItemID = @ItemID AND FolderName = @FolderID +GO + +-- Enterprise Storage Quotas +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'EnterpriseStorage.DiskStorageSpace') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (430, 44, 1,N'EnterpriseStorage.DiskStorageSpace',N'Disk Storage Space (Mb)',2, 0 , NULL) +END +GO + +UPDATE [dbo].[Quotas] SET [QuotaDescription] = N'Disk Storage Space (Mb)' WHERE [QuotaName] = 'EnterpriseStorage.DiskStorageSpace' GO \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs index 97baa68e..ad9ed437 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs @@ -828,19 +828,16 @@ namespace WebsitePanel.EnterpriseServer rule.Users.Add(permission.Account); } - if (permission.Access.ToLower().Contains("read")) + if (permission.Access.ToLower().Contains("read-only")) { rule.Read = true; + rule.Source = true; } - if (permission.Access.ToLower().Contains("write")) + if (permission.Access.ToLower().Contains("read-write")) { rule.Write = true; - } - - if (permission.Access.ToLower().Contains("source")) - { - rule.Source = true; + rule.Read = true; } rule.Pathes.Add("*"); @@ -888,24 +885,13 @@ namespace WebsitePanel.EnterpriseServer permission.DisplayName = userObj.DisplayName; } - if (rule.Read) + if (rule.Read && !rule.Write) { - permission.Access += "Read,"; + permission.Access = "Read-Only"; } - if (rule.Write) { - permission.Access += "Write,"; - } - - if (rule.Source) - { - permission.Access += "Source"; - } - - if (permission.Access[permission.Access.Length - 1] == ',') - { - permission.Access = permission.Access.Remove(permission.Access.Length - 1); + permission.Access = "Read-Write"; } permissions.Add(permission); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs index 5d25ce78..7757dbd5 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs @@ -961,7 +961,7 @@ namespace WebsitePanel.EnterpriseServer stats.CreatedEnterpriseStorageFolders = folders.Count(); - stats.UsedEnterpriseStorageSpace = folders.Where(x => x.FRSMQuotaGB != -1).Sum(x => x.FRSMQuotaGB); + stats.UsedEnterpriseStorageSpace = folders.Where(x => x.FRSMQuotaMB != -1).Sum(x => x.FRSMQuotaMB); } } else @@ -1025,7 +1025,7 @@ namespace WebsitePanel.EnterpriseServer stats.CreatedEnterpriseStorageFolders += folders.Count(); - stats.UsedEnterpriseStorageSpace += folders.Where(x => x.FRSMQuotaGB != -1).Sum(x => x.FRSMQuotaGB); + stats.UsedEnterpriseStorageSpace += folders.Where(x => x.FRSMQuotaMB != -1).Sum(x => x.FRSMQuotaMB); } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs index 35c29376..d97753ac 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs @@ -94,7 +94,7 @@ namespace WebsitePanel.Providers.EnterpriseStorage { folder.Size = FileUtils.BytesToMb(FileUtils.CalculateFolderSize(dir.FullName)); } - + folder.Url = string.Format("https://{0}/{1}/{2}", UsersDomain, organizationId, dir.Name); folder.Rules = webdav.GetFolderWebDavRules(organizationId, dir.Name); folder.FRSMQuotaMB = quota.Size; diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index 002ddaf5..44a4be21 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -5114,7 +5114,7 @@ Recoverable Items Storage, MB - Disk Storage Space, Gb + Disk Storage Space, Mb Number of Root Folders diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SpaceQuotas.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SpaceQuotas.ascx.resx index 42dc6d38..166f40c5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SpaceQuotas.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SpaceQuotas.ascx.resx @@ -205,6 +205,6 @@ Folders: - Enterprise Storage: + Enterprise Storage, MB: \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationHome.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationHome.ascx.resx index 8f3e935f..0fa1a42f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationHome.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationHome.ascx.resx @@ -214,7 +214,7 @@ Folders: - Used Diskspace (Gb): + Used Diskspace (Mb): Enterprise Storage diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx index d5388fee..bd4a80bd 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx @@ -41,7 +41,7 @@ - diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx.cs index 2166bb7f..b3526f3b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolderGeneralSettings.ascx.cs @@ -45,6 +45,12 @@ namespace WebsitePanel.Portal.ExchangeServer { public partial class EnterpriseStorageFolderGeneralSettings : WebsitePanelModuleBase { + #region Constants + + private const int OneGb = 1024; + + #endregion + protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) @@ -56,16 +62,16 @@ namespace WebsitePanel.Portal.ExchangeServer } BindSettings(); - } - - OrganizationStatistics organizationStats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID); - if (organizationStats.AllocatedEnterpriseStorageSpace != -1) - { - OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID); + OrganizationStatistics organizationStats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID); - rangeFolderSize.MaximumValue = (tenantStats.AllocatedEnterpriseStorageSpace - tenantStats.UsedEnterpriseStorageSpace + Utils.ParseInt(txtFolderSize.Text, 0)).ToString(); - rangeFolderSize.ErrorMessage = string.Format("The quota you’ve entered exceeds the available quota for tenant ({0}Gb)", rangeFolderSize.MaximumValue); + if (organizationStats.AllocatedEnterpriseStorageSpace != -1) + { + OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID); + + rangeFolderSize.MaximumValue = ((tenantStats.AllocatedEnterpriseStorageSpace - tenantStats.UsedEnterpriseStorageSpace)/OneGb + Utils.ParseInt(txtFolderSize.Text, 0)).ToString(); + rangeFolderSize.ErrorMessage = string.Format("The quota you’ve entered exceeds the available quota for tenant ({0}Gb)", rangeFolderSize.MaximumValue); + } } } @@ -157,7 +163,7 @@ namespace WebsitePanel.Portal.ExchangeServer folder, permissions.GetPemissions(), chkDirectoryBrowsing.Checked, - int.Parse(txtFolderSize.Text), + int.Parse(txtFolderSize.Text) * OneGb, rbtnQuotaSoft.Checked ? QuotaType.Soft : QuotaType.Hard); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx index f1ecf309..8f0195eb 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx @@ -69,7 +69,7 @@ - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx.cs index 3dbee3a9..d5ffe34f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/EnterpriseStorageFolders.ascx.cs @@ -37,6 +37,12 @@ namespace WebsitePanel.Portal.ExchangeServer { public partial class EnterpriseStorageFolders : WebsitePanelModuleBase { + #region Constants + + private const int OneGb = 1024; + + #endregion + protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) @@ -61,6 +67,11 @@ namespace WebsitePanel.Portal.ExchangeServer "ItemID=" + PanelRequest.ItemID); } + public decimal ConvertMBytesToGB(object size) + { + return Convert.ToDecimal(size) / OneGb; + } + protected void BindEnterpriseStorageStats() { btnAddFolder.Enabled = true; @@ -74,15 +85,24 @@ namespace WebsitePanel.Portal.ExchangeServer if (organizationStats.AllocatedEnterpriseStorageFolders != -1) { int folderAvailable = foldersQuota.QuotaAvailable = tenantStats.AllocatedEnterpriseStorageFolders - tenantStats.CreatedEnterpriseStorageFolders; - int spaceAvailable = tenantStats.AllocatedEnterpriseStorageSpace - tenantStats.UsedEnterpriseStorageSpace; - if (folderAvailable <= 0 || spaceAvailable <= 0) + if (folderAvailable <= 0) { btnAddFolder.Enabled = false; } } - spaceQuota.QuotaValue = organizationStats.UsedEnterpriseStorageSpace; + if (organizationStats.AllocatedEnterpriseStorageSpace != -1) + { + int spaceAvailable = (int)ConvertMBytesToGB(tenantStats.AllocatedEnterpriseStorageSpace - tenantStats.UsedEnterpriseStorageSpace); + + if (spaceAvailable <= 0) + { + btnAddFolder.Enabled = false; + } + } + + spaceQuota.QuotaValue = (int)ConvertMBytesToGB(organizationStats.UsedEnterpriseStorageSpace); } protected void btnAddFolder_Click(object sender, EventArgs e) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/App_LocalResources/EnterpriseStoragePermissions.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/App_LocalResources/EnterpriseStoragePermissions.ascx.resx index bba8d593..ccc8a35f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/App_LocalResources/EnterpriseStoragePermissions.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/App_LocalResources/EnterpriseStoragePermissions.ascx.resx @@ -129,17 +129,11 @@ Delete - - Set Permissions + + Set Read-Only - - Read - - - Source - - - Write + + Set Read-Write Display Name diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx index 30e1d75f..c250f192 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx @@ -38,11 +38,8 @@
- - - -
- + +
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.cs index afa631b9..0e52b390 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.cs @@ -103,7 +103,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls { Account = account.AccountName, DisplayName = account.DisplayName, - Access = "Read", + Access = "Read-Only", }); } @@ -274,41 +274,16 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect"); Literal litAccess = (Literal)row.FindControl("litAccess"); - + if (chkSelect == null || litAccess == null) continue; if (chkSelect.Checked) { chkSelect.Checked = false; - - litAccess.Text = ""; - - if (chkRead.Checked) - { - litAccess.Text = "Read,"; - } - - if (chkWrite.Checked) - { - litAccess.Text += "Write,"; - } - - if (chkSource.Checked) - { - litAccess.Text += "Source"; - } - - if (litAccess.Text[litAccess.Text.Length - 1] == ',') - { - litAccess.Text = litAccess.Text.Remove(litAccess.Text.Length - 1); - } + litAccess.Text = ((Button)sender).CommandArgument; } } - - chkRead.Checked = false; - chkWrite.Checked = false; - chkSource.Checked = false; } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.designer.cs index d3c9a6f3..3e0081d9 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/EnterpriseStoragePermissions.ascx.designer.cs @@ -49,40 +49,22 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls { protected global::System.Web.UI.WebControls.GridView gvPermissions; /// - /// chkRead control. + /// btnSetReadOnly control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.CheckBox chkRead; + protected global::System.Web.UI.WebControls.Button btnSetReadOnly; /// - /// chkWrite control. + /// btnSetReadWrite control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.CheckBox chkWrite; - - /// - /// chkSource control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CheckBox chkSource; - - /// - /// btnSet control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button btnSet; + protected global::System.Web.UI.WebControls.Button btnSetReadWrite; /// /// AddAccountsPanel control. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index 4f74c662..b3546c95 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -229,7 +229,7 @@ ASPXCodeBehind - EnterpriseStorageFolders.ascx + EnterpriseStorageFolders.ascx OrganizationSecurityGroupMemberOf.ascx @@ -5278,12 +5278,14 @@ Designer - + Designer - + + Designer + Designer