fixed bugs

This commit is contained in:
vfedosevich 2013-12-26 19:33:27 +03:00
parent 4514eb02e9
commit c6da249767
12 changed files with 83 additions and 55 deletions

View file

@ -345,7 +345,14 @@ namespace WebsitePanel.EnterpriseServer
return new SystemFile[0]; return new SystemFile[0];
} }
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId)); int serviceId = GetEnterpriseStorageServiceID(org.PackageId);
if (serviceId == 0)
{
return new SystemFile[0];
}
EnterpriseStorage es = GetEnterpriseStorage(serviceId);
return es.GetFolders(org.OrganizationId); return es.GetFolders(org.OrganizationId);
} }

View file

@ -960,7 +960,10 @@ namespace WebsitePanel.EnterpriseServer
SystemFile[] folders = EnterpriseStorageController.GetFolders(itemId); SystemFile[] folders = EnterpriseStorageController.GetFolders(itemId);
stats.CreatedEnterpriseStorageFolders = folders.Count(); stats.CreatedEnterpriseStorageFolders = folders.Count();
stats.UsedEnterpriseStorageSpace = (int)folders.Sum(x => x.Size); stats.UsedEnterpriseStorageSpace = (int)folders.Sum(x => x.Size);
stats.AllocatedEnterpriseStorageSpace = folders.Where(x => x.FRSMQuotaMB != -1).Sum(x => x.FRSMQuotaMB);
} }
} }
else else
@ -1020,10 +1023,13 @@ namespace WebsitePanel.EnterpriseServer
if (cntxTmp.Groups.ContainsKey(ResourceGroups.EnterpriseStorage)) if (cntxTmp.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
{ {
SystemFile[] folders = EnterpriseStorageController.GetFolders(itemId); SystemFile[] folders = EnterpriseStorageController.GetFolders(o.Id);
stats.CreatedEnterpriseStorageFolders = folders.Count(); stats.CreatedEnterpriseStorageFolders += folders.Count();
stats.UsedEnterpriseStorageSpace = (int)folders.Sum(x => x.Size);
stats.UsedEnterpriseStorageSpace += (int)folders.Sum(x => x.Size);
stats.AllocatedEnterpriseStorageSpace += folders.Where(x => x.FRSMQuotaMB != -1).Sum(x => x.FRSMQuotaMB);
} }
} }
} }
@ -1069,12 +1075,6 @@ namespace WebsitePanel.EnterpriseServer
stats.AllocatedEnterpriseStorageFolders = cntx.Quotas[Quotas.ENTERPRISESTORAGE_FOLDERS].QuotaAllocatedValue; stats.AllocatedEnterpriseStorageFolders = cntx.Quotas[Quotas.ENTERPRISESTORAGE_FOLDERS].QuotaAllocatedValue;
} }
if (cntx.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
{
stats.AllocatedEnterpriseStorageSpace = cntx.Quotas[Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE].QuotaAllocatedValue;
}
return stats; return stats;
} }
catch (Exception ex) catch (Exception ex)

View file

@ -238,6 +238,18 @@ namespace WebsitePanel.Providers.OS
return result; return result;
} }
public int ConvertBytesToGB(long bytes)
{
int OneKb = 1024;
int OneMb = OneKb * 1024;
int OneGb = OneMb * 1024;
if (bytes == 0)
return 0;
return (int)(bytes / OneGb);
}
public int ConvertBytesToMB(long bytes) public int ConvertBytesToMB(long bytes)
{ {
int OneKb = 1024; int OneKb = 1024;
@ -246,7 +258,7 @@ namespace WebsitePanel.Providers.OS
if (bytes == 0) if (bytes == 0)
return 0; return 0;
return (int)bytes / OneMb; return (int)(bytes / OneMb);
} }
public void RemoveOldQuotaOnFolder(Runspace runSpace, string path) public void RemoveOldQuotaOnFolder(Runspace runSpace, string path)

View file

@ -148,7 +148,7 @@
<value>Folder Url:</value> <value>Folder Url:</value>
</data> </data>
<data name="locFolderSize" xml:space="preserve"> <data name="locFolderSize" xml:space="preserve">
<value>Folder Limit Size (Mb):</value> <value>Folder Limit Size (Gb):</value>
</data> </data>
<data name="valNumericFolderSize" xml:space="preserve"> <data name="valNumericFolderSize" xml:space="preserve">
<value>*</value> <value>*</value>

View file

@ -135,7 +135,7 @@
<data name="HSFormComments.Text" xml:space="preserve"> <data name="HSFormComments.Text" xml:space="preserve">
<value /> <value />
</data> </data>
<data name="locQuota.Text" xml:space="preserve"> <data name="locQuotaFolders.Text" xml:space="preserve">
<value>Total Folders Allocated:</value> <value>Total Folders Allocated:</value>
</data> </data>
<data name="Text.PageName" xml:space="preserve"> <data name="Text.PageName" xml:space="preserve">
@ -153,4 +153,7 @@
<data name="gvFolderUrl.Header" xml:space="preserve"> <data name="gvFolderUrl.Header" xml:space="preserve">
<value>Url</value> <value>Url</value>
</data> </data>
<data name="locQuotaSpace.Text" xml:space="preserve">
<value>Total Space Allocated (Mb):</value>
</data>
</root> </root>

View file

@ -36,7 +36,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="FormLabel150"><asp:Localize ID="locFolderSize" runat="server" meta:resourcekey="locFolderSize" Text="Folder Limit Size (Mb):"></asp:Localize></td> <td class="FormLabel150"><asp:Localize ID="locFolderSize" runat="server" meta:resourcekey="locFolderSize" Text="Folder Limit Size (Gb):"></asp:Localize></td>
<td> <td>
<asp:TextBox ID="txtFolderSize" runat="server" CssClass="HugeTextBox200"></asp:TextBox> <asp:TextBox ID="txtFolderSize" runat="server" CssClass="HugeTextBox200"></asp:TextBox>
<asp:CompareValidator ID="valNumericFolderSize" runat="server" meta:resourcekey="valNumericFolderSize" ControlToValidate="txtFolderSize" <asp:CompareValidator ID="valNumericFolderSize" runat="server" meta:resourcekey="valNumericFolderSize" ControlToValidate="txtFolderSize"

View file

@ -45,6 +45,12 @@ namespace WebsitePanel.Portal.ExchangeServer
{ {
public partial class EnterpriseStorageFolderGeneralSettings : WebsitePanelModuleBase public partial class EnterpriseStorageFolderGeneralSettings : WebsitePanelModuleBase
{ {
#region Constansts
const int OneMb = 1024;
#endregion
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
if (!IsPostBack) if (!IsPostBack)
@ -78,7 +84,7 @@ namespace WebsitePanel.Portal.ExchangeServer
if (folder.FRSMQuotaMB != -1) if (folder.FRSMQuotaMB != -1)
{ {
txtFolderSize.Text = folder.FRSMQuotaMB.ToString(); txtFolderSize.Text = ((int)(folder.FRSMQuotaMB / OneMb)).ToString();
} }
var esPermissions = ES.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(PanelRequest.ItemID,folder.Name); var esPermissions = ES.Services.EnterpriseStorage.GetEnterpriseFolderPermissions(PanelRequest.ItemID,folder.Name);
@ -127,8 +133,8 @@ namespace WebsitePanel.Portal.ExchangeServer
folder = ES.Services.EnterpriseStorage.RenameEnterpriseFolder(PanelRequest.ItemID, PanelRequest.FolderID, txtFolderName.Text); folder = ES.Services.EnterpriseStorage.RenameEnterpriseFolder(PanelRequest.ItemID, PanelRequest.FolderID, txtFolderName.Text);
} }
ES.Services.EnterpriseStorage.SetEnterpriseFolderSettings(PanelRequest.ItemID, folder, permissions.GetPemissions(), ES.Services.EnterpriseStorage.SetEnterpriseFolderSettings(PanelRequest.ItemID, folder, permissions.GetPemissions(),
chkDirectoryBrowsing.Checked, txtFolderSize.Text.Length == 0 ? -1 : int.Parse(txtFolderSize.Text)); chkDirectoryBrowsing.Checked, txtFolderSize.Text.Length == 0 ? -1 : int.Parse(txtFolderSize.Text) * OneMb);
Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "enterprisestorage_folders", Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "enterprisestorage_folders",

View file

@ -93,9 +93,15 @@
</asp:ObjectDataSource> </asp:ObjectDataSource>
<br /> <br />
<asp:Localize ID="locQuota" runat="server" meta:resourcekey="locQuota" Text="Total Folders Used:"></asp:Localize> <asp:Localize ID="locQuotaFolders" runat="server" meta:resourcekey="locQuotaFolders" Text="Total Folders Allocated:"></asp:Localize>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<wsp:QuotaViewer ID="foldersQuota" runat="server" QuotaTypeId="2" /> <wsp:QuotaViewer ID="foldersQuota" runat="server" QuotaTypeId="2" />
<br />
<br />
<asp:Localize ID="locQuotaSpace" runat="server" meta:resourcekey="locQuotaSpace" Text="Total Space Allocated (Mb):"></asp:Localize>
&nbsp;&nbsp;&nbsp;
<wsp:QuotaViewer ID="spaceQuota" runat="server" QuotaTypeId="2" />
</div> </div>
</div> </div>
</div> </div>

View file

@ -80,6 +80,10 @@ namespace WebsitePanel.Portal.ExchangeServer
btnAddFolder.Enabled = false; btnAddFolder.Enabled = false;
} }
} }
spaceQuota.QuotaUsedValue = organizationStats.UsedEnterpriseStorageSpace;
spaceQuota.QuotaValue = organizationStats.AllocatedEnterpriseStorageSpace;
} }
protected void btnAddFolder_Click(object sender, EventArgs e) protected void btnAddFolder_Click(object sender, EventArgs e)

View file

@ -1,31 +1,3 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
@ -167,13 +139,13 @@ namespace WebsitePanel.Portal.ExchangeServer {
protected global::System.Web.UI.WebControls.ObjectDataSource odsEnterpriseFoldersPaged; protected global::System.Web.UI.WebControls.ObjectDataSource odsEnterpriseFoldersPaged;
/// <summary> /// <summary>
/// locQuota control. /// locQuotaFolders control.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Auto-generated field. /// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Localize locQuota; protected global::System.Web.UI.WebControls.Localize locQuotaFolders;
/// <summary> /// <summary>
/// foldersQuota control. /// foldersQuota control.
@ -183,5 +155,23 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer foldersQuota; protected global::WebsitePanel.Portal.QuotaViewer foldersQuota;
/// <summary>
/// locQuotaSpace control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locQuotaSpace;
/// <summary>
/// spaceQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer spaceQuota;
} }
} }

View file

@ -251,7 +251,7 @@
<asp:HyperLink ID="lnkEnterpriseStorageSpace" runat="server" meta:resourcekey="lnkEnterpriseStorageSpace" /> <asp:HyperLink ID="lnkEnterpriseStorageSpace" runat="server" meta:resourcekey="lnkEnterpriseStorageSpace" />
</td> </td>
<td> <td>
<wsp:QuotaViewer ID="enterpriseStorageSpaceStats" QuotaTypeId="3" runat="server" DisplayGauge="true" /> <wsp:QuotaViewer ID="enterpriseStorageSpaceStats" QuotaTypeId="2" runat="server" DisplayGauge="true" />
</td> </td>
</tr> </tr>
<tr class="OrgStatsRow"> <tr class="OrgStatsRow">

View file

@ -150,7 +150,6 @@ namespace WebsitePanel.Portal.ExchangeServer
if (!hideItems) if (!hideItems)
{ {
domainStats.QuotaUsedValue = orgStats.CreatedDomains; domainStats.QuotaUsedValue = orgStats.CreatedDomains;
domainStats.QuotaValue = orgStats.AllocatedDomains; domainStats.QuotaValue = orgStats.AllocatedDomains;
if (orgStats.AllocatedDomains != -1) domainStats.QuotaAvailable = tenantStats.AllocatedDomains - tenantStats.CreatedDomains; if (orgStats.AllocatedDomains != -1) domainStats.QuotaAvailable = tenantStats.AllocatedDomains - tenantStats.CreatedDomains;
@ -170,9 +169,6 @@ namespace WebsitePanel.Portal.ExchangeServer
else else
organizationStatsPanel.Visible = false; organizationStatsPanel.Visible = false;
if (cntx.Groups.ContainsKey(ResourceGroups.Exchange)) if (cntx.Groups.ContainsKey(ResourceGroups.Exchange))
{ {
@ -300,14 +296,18 @@ namespace WebsitePanel.Portal.ExchangeServer
private void BindEnterpriseStorageStats(OrganizationStatistics stats, OrganizationStatistics tenantStats) private void BindEnterpriseStorageStats(OrganizationStatistics stats, OrganizationStatistics tenantStats)
{ {
enterpriseStorageSpaceStats.QuotaValue = stats.UsedEnterpriseStorageSpace; enterpriseStorageSpaceStats.QuotaValue = stats.AllocatedEnterpriseStorageSpace;
enterpriseStorageSpaceStats.QuotaUsedValue = stats.UsedEnterpriseStorageSpace;
lnkBESUsers.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "enterprisestorage_folders", lnkBESUsers.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "enterprisestorage_folders",
"SpaceID=" + PanelSecurity.PackageId.ToString()); "SpaceID=" + PanelSecurity.PackageId.ToString());
enterpriseStorageFoldersStats.QuotaValue = stats.AllocatedEnterpriseStorageFolders; enterpriseStorageFoldersStats.QuotaValue = stats.AllocatedEnterpriseStorageFolders;
enterpriseStorageFoldersStats.QuotaUsedValue = stats.CreatedEnterpriseStorageFolders; enterpriseStorageFoldersStats.QuotaUsedValue = stats.CreatedEnterpriseStorageFolders;
if (stats.AllocatedEnterpriseStorageFolders != -1) enterpriseStorageFoldersStats.QuotaAvailable = tenantStats.AllocatedEnterpriseStorageFolders - tenantStats.CreatedEnterpriseStorageFolders; if (stats.AllocatedEnterpriseStorageFolders != -1)
{
enterpriseStorageFoldersStats.QuotaAvailable = tenantStats.AllocatedEnterpriseStorageFolders - tenantStats.CreatedEnterpriseStorageFolders;
}
lnkBESUsers.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "enterprisestorage_folders", lnkBESUsers.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "enterprisestorage_folders",
"SpaceID=" + PanelSecurity.PackageId.ToString()); "SpaceID=" + PanelSecurity.PackageId.ToString());