Bug fixes
This commit is contained in:
parent
52c7fb80cc
commit
0611d7bf8f
13 changed files with 2043 additions and 1406 deletions
|
@ -1,30 +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>
|
||||
// This code was generated by a tool.
|
||||
|
@ -946,23 +919,25 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetEnterpriseFolderSettings", 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 void SetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled)
|
||||
public void SetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota)
|
||||
{
|
||||
this.Invoke("SetEnterpriseFolderSettings", new object[] {
|
||||
itemId,
|
||||
folder,
|
||||
permissions,
|
||||
directoyBrowsingEnabled});
|
||||
directoyBrowsingEnabled,
|
||||
quota});
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public System.IAsyncResult BeginSetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, System.AsyncCallback callback, object asyncState)
|
||||
public System.IAsyncResult BeginSetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
return this.BeginInvoke("SetEnterpriseFolderSettings", new object[] {
|
||||
itemId,
|
||||
folder,
|
||||
permissions,
|
||||
directoyBrowsingEnabled}, callback, asyncState);
|
||||
directoyBrowsingEnabled,
|
||||
quota}, callback, asyncState);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
|
@ -972,13 +947,13 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void SetEnterpriseFolderSettingsAsync(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled)
|
||||
public void SetEnterpriseFolderSettingsAsync(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota)
|
||||
{
|
||||
this.SetEnterpriseFolderSettingsAsync(itemId, folder, permissions, directoyBrowsingEnabled, null);
|
||||
this.SetEnterpriseFolderSettingsAsync(itemId, folder, permissions, directoyBrowsingEnabled, quota, null);
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
public void SetEnterpriseFolderSettingsAsync(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, object userState)
|
||||
public void SetEnterpriseFolderSettingsAsync(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, object userState)
|
||||
{
|
||||
if ((this.SetEnterpriseFolderSettingsOperationCompleted == null))
|
||||
{
|
||||
|
@ -988,7 +963,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
itemId,
|
||||
folder,
|
||||
permissions,
|
||||
directoyBrowsingEnabled}, this.SetEnterpriseFolderSettingsOperationCompleted, userState);
|
||||
directoyBrowsingEnabled,
|
||||
quota}, this.SetEnterpriseFolderSettingsOperationCompleted, userState);
|
||||
}
|
||||
|
||||
private void OnSetEnterpriseFolderSettingsOperationCompleted(object arg)
|
||||
|
|
|
@ -47,6 +47,7 @@ using WebsitePanel.Providers.Web;
|
|||
using WebsitePanel.Providers.HostedSolution;
|
||||
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
|
||||
using WebsitePanel.Server.Client;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
|
@ -140,6 +141,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return CheckUsersDomainExistsInternal(itemId);
|
||||
}
|
||||
|
||||
public static void SetFRSMQuotaOnFolder(int itemId, string folderName, int quota)
|
||||
{
|
||||
SetFRSMQuotaOnFolderInternal(itemId, folderName, quota);
|
||||
}
|
||||
|
||||
#region Directory Browsing
|
||||
|
||||
public static bool GetDirectoryBrowseEnabled(int itemId, string siteId)
|
||||
|
@ -260,17 +266,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
EnterpriseStorageController.CreateFolder(itemId);
|
||||
|
||||
EnterpriseStorageController.AddWebDavDirectory(packageId, usersDomain, org.OrganizationId, homePath);
|
||||
|
||||
//int osId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
|
||||
//bool enableHardQuota = (esSesstings["enablehardquota"] != null)
|
||||
// ? bool.Parse(esSesstings["enablehardquota"])
|
||||
// : false;
|
||||
|
||||
//if (enableHardQuota && osId != 0 && OperatingSystemController.CheckFileServicesInstallation(osId))
|
||||
//{
|
||||
// FilesController.SetFolderQuota(packageId, Path.Combine(usersHome, org.OrganizationId),
|
||||
// locationDrive, Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE);
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -412,14 +407,14 @@ namespace WebsitePanel.EnterpriseServer
|
|||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
result.IsSuccess = false;
|
||||
result.AddError("",new NullReferenceException("Organization not found"));
|
||||
return result;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
es.CreateFolder(org.OrganizationId, folderName);
|
||||
|
||||
UpdateESHardQuota(org.PackageId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -440,6 +435,46 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return result;
|
||||
}
|
||||
|
||||
protected static void SetFRSMQuotaOnFolderInternal(int itemId, string folderName, int quota)
|
||||
{
|
||||
ResultObject result = TaskManager.StartResultTask<ResultObject>("ENTERPRISE_STORAGE", "CREATE_FOLDER");
|
||||
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
es.CreateFolder(org.OrganizationId, folderName);
|
||||
|
||||
// check if it's not root folder
|
||||
if (!string.IsNullOrEmpty(folderName))
|
||||
{
|
||||
UpdateESHardQuota(org.PackageId, org.OrganizationId, folderName, quota);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.AddError("ENTERPRISE_STORAGE_CREATE_FOLDER", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
TaskManager.CompleteResultTask(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskManager.CompleteResultTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static ResultObject DeleteFolderInternal(int itemId, string folderName)
|
||||
{
|
||||
ResultObject result = TaskManager.StartResultTask<ResultObject>("ENTERPRISE_STORAGE", "DELETE_FOLDER");
|
||||
|
@ -835,7 +870,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
}
|
||||
|
||||
private static void UpdateESHardQuota(int packageId)
|
||||
private static void UpdateESHardQuota(int packageId, string orgId, string folderName, int quotaSize)
|
||||
{
|
||||
int esServiceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.EnterpriseStorage);
|
||||
|
||||
|
@ -848,16 +883,21 @@ namespace WebsitePanel.EnterpriseServer
|
|||
string usersDomain = esSesstings["UsersDomain"];
|
||||
string locationDrive = esSesstings["LocationDrive"];
|
||||
|
||||
string homePath = string.Format("{0}:\\{1}", locationDrive, usersHome);
|
||||
|
||||
int osId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
|
||||
var orgRootFolder = Path.Combine(usersHome, orgId);
|
||||
var orgFolder = Path.Combine(usersHome, orgId, folderName);
|
||||
|
||||
bool enableHardQuota = (esSesstings["enablehardquota"] != null)
|
||||
? bool.Parse(esSesstings["enablehardquota"])
|
||||
: false;
|
||||
|
||||
if (enableHardQuota && osId != 0 && OperatingSystemController.CheckFileServicesInstallation(osId))
|
||||
if (enableHardQuota)
|
||||
{
|
||||
FilesController.SetFolderQuota(packageId, usersHome, locationDrive, Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE);
|
||||
var os = GetOS(packageId);
|
||||
|
||||
if (os != null && os.CheckFileServicesInstallation())
|
||||
{
|
||||
SetFolderQuotaByQuotaName(packageId, os, orgRootFolder, locationDrive, Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE);
|
||||
SetFolderQuotaByQuotaSize(packageId, os, orgFolder, locationDrive, quotaSize, "MB");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -906,5 +946,128 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int SetFolderQuotaByQuotaName(int packageId, WebsitePanel.Providers.OS.OperatingSystem os, string path, string driveName, string quotaName)
|
||||
{
|
||||
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("FILES", "SET_QUOTA_ON_FOLDER", path, packageId);
|
||||
|
||||
try
|
||||
{
|
||||
// disk space quota
|
||||
// This gets all the disk space allocated for a specific customer
|
||||
// It includes the package Add Ons * Quatity + Hosting Plan System disk space value. //Quotas.OS_DISKSPACE
|
||||
QuotaValueInfo diskSpaceQuota = PackageController.GetPackageQuota(packageId, quotaName);
|
||||
|
||||
#region figure Quota Unit
|
||||
|
||||
// Quota Unit
|
||||
string unit = string.Empty;
|
||||
if (diskSpaceQuota.QuotaDescription.ToLower().Contains("gb"))
|
||||
unit = "GB";
|
||||
else if (diskSpaceQuota.QuotaDescription.ToLower().Contains("mb"))
|
||||
unit = "MB";
|
||||
else
|
||||
unit = "KB";
|
||||
|
||||
#endregion
|
||||
|
||||
os.SetQuotaLimitOnFolder(path, driveName, diskSpaceQuota.QuotaAllocatedValue.ToString() + unit, 0, String.Empty, String.Empty);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Log and return a generic error rather than throwing an exception
|
||||
TaskManager.WriteError(ex);
|
||||
return BusinessErrorCodes.ERROR_FILE_GENERIC_LOGGED;
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
private static int SetFolderQuotaByQuotaSize(int packageId,WebsitePanel.Providers.OS.OperatingSystem os, string path, string driveName, int quotaSize ,string unit)
|
||||
{
|
||||
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// check package
|
||||
int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);
|
||||
if (packageCheck < 0) return packageCheck;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("FILES", "SET_QUOTA_ON_FOLDER", path, packageId);
|
||||
|
||||
try
|
||||
{
|
||||
os.SetQuotaLimitOnFolder(path, driveName, quotaSize.ToString() + unit, 0, String.Empty, String.Empty);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Log and return a generic error rather than throwing an exception
|
||||
TaskManager.WriteError(ex);
|
||||
return BusinessErrorCodes.ERROR_FILE_GENERIC_LOGGED;
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
private static WebsitePanel.Providers.OS.OperatingSystem GetOS(int packageId)
|
||||
{
|
||||
var esServiceInfo = ServerController.GetServiceInfo(GetEnterpriseStorageServiceID(packageId));
|
||||
var esProviderInfo = ServerController.GetProvider(esServiceInfo.ProviderId);
|
||||
|
||||
var osGroups = ServerController.GetResourceGroupByName(ResourceGroups.Os);
|
||||
var osProviders = ServerController.GetProvidersByGroupID(osGroups.GroupId);
|
||||
|
||||
var regexResult = Regex.Match(esProviderInfo.ProviderType,"Windows([0-9]+)");
|
||||
|
||||
if(regexResult.Success)
|
||||
{
|
||||
foreach(var osProvider in osProviders)
|
||||
{
|
||||
BoolResult result = ServerController.IsInstalled(esServiceInfo.ServerId, osProvider.ProviderId);
|
||||
|
||||
if (result.IsSuccess && result.Value)
|
||||
{
|
||||
var os = new WebsitePanel.Providers.OS.OperatingSystem();
|
||||
ServerProxyConfigurator cnfg = new ServerProxyConfigurator();
|
||||
|
||||
cnfg.ProviderSettings.ProviderGroupID = osProvider.GroupId;
|
||||
cnfg.ProviderSettings.ProviderCode = osProvider.ProviderName;
|
||||
cnfg.ProviderSettings.ProviderName = osProvider.DisplayName;
|
||||
cnfg.ProviderSettings.ProviderType = osProvider.ProviderType;
|
||||
|
||||
//// set service settings
|
||||
//StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId);
|
||||
//foreach (string key in serviceSettings.Keys)
|
||||
// cnfg.ProviderSettings.Settings[key] = serviceSettings[key];
|
||||
|
||||
ServiceProviderProxy.ServerInit(os, cnfg, esServiceInfo.ServerId);
|
||||
|
||||
return os;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,10 +150,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
[WebMethod]
|
||||
public void SetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled)
|
||||
public void SetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled,int quota)
|
||||
{
|
||||
EnterpriseStorageController.SetDirectoryBrowseEnabled(itemId, folder.Url, directoyBrowsingEnabled);
|
||||
EnterpriseStorageController.SetFolderPermission(itemId, folder.Name, permissions);
|
||||
EnterpriseStorageController.SetFRSMQuotaOnFolder(itemId, folder.Name, quota);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace WebsitePanel.Providers.OS
|
|||
void ExecuteSyncActions(FileSyncAction[] actions);
|
||||
|
||||
void SetQuotaLimitOnFolder(string folderPath, string shareNameDrive, string quotaLimit, int mode, string wmiUserName, string wmiPassword);
|
||||
int GetQuotaLimitOnFolder(string folderPath, string wmiUserName, string wmiPassword);
|
||||
void DeleteDirectoryRecursive(string rootPath);
|
||||
|
||||
// File Services
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace WebsitePanel.Providers.OS
|
|||
private bool isPublished;
|
||||
private WebDavFolderRule[] rules;
|
||||
private string url;
|
||||
private int fsrmQuotaMB;
|
||||
|
||||
public SystemFile()
|
||||
{
|
||||
|
@ -62,6 +63,12 @@ namespace WebsitePanel.Providers.OS
|
|||
this.changed = changed;
|
||||
}
|
||||
|
||||
public int FRSMQuotaMB
|
||||
{
|
||||
get { return fsrmQuotaMB; }
|
||||
set { fsrmQuotaMB = value; }
|
||||
}
|
||||
|
||||
public string FullName
|
||||
{
|
||||
get { return fullName; }
|
||||
|
|
|
@ -39,6 +39,14 @@
|
|||
<Project>{684C932A-6C75-46AC-A327-F3689D89EB42}</Project>
|
||||
<Name>WebsitePanel.Providers.Base</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebsitePanel.Providers.OS.Windows2003\WebsitePanel.Providers.OS.Windows2003.csproj">
|
||||
<Project>{899b3048-46be-4c4d-9d41-0043c8b0d11e}</Project>
|
||||
<Name>WebsitePanel.Providers.OS.Windows2003</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebsitePanel.Providers.OS.Windows2012\WebsitePanel.Providers.OS.Windows2012.csproj">
|
||||
<Project>{27130bbb-76fa-411e-8b4d-51cd4dc821af}</Project>
|
||||
<Name>WebsitePanel.Providers.OS.Windows2012</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebsitePanel.Providers.Web.IIs60\WebsitePanel.Providers.Web.IIs60.csproj">
|
||||
<Project>{9be0317d-e42e-4ff6-9a87-8c801f046ea1}</Project>
|
||||
<Name>WebsitePanel.Providers.Web.IIs60</Name>
|
||||
|
|
|
@ -67,14 +67,13 @@ namespace WebsitePanel.Providers.EnterpriseStorage
|
|||
ArrayList items = new ArrayList();
|
||||
string rootPath = string.Format("{0}:\\{1}\\{2}", LocationDrive, UsersHome, organizationId);
|
||||
|
||||
var windows = new WebsitePanel.Providers.OS.Windows2012();
|
||||
|
||||
if (Directory.Exists(rootPath))
|
||||
{
|
||||
|
||||
DirectoryInfo root = new DirectoryInfo(rootPath);
|
||||
IWebDav webdav = new Web.WebDav(UsersDomain);
|
||||
|
||||
|
||||
|
||||
// get directories
|
||||
DirectoryInfo[] dirs = root.GetDirectories();
|
||||
foreach (DirectoryInfo dir in dirs)
|
||||
|
@ -86,7 +85,8 @@ namespace WebsitePanel.Providers.EnterpriseStorage
|
|||
|
||||
folder.Url = string.Format("https://{0}/{1}/{2}", UsersDomain, organizationId, dir.Name);
|
||||
folder.Rules = webdav.GetFolderWebDavRules(organizationId, dir.Name);
|
||||
|
||||
folder.FRSMQuotaMB = windows.GetQuotaLimitOnFolder(fullName, string.Empty, string.Empty);
|
||||
|
||||
items.Add(folder);
|
||||
|
||||
// check if the directory is empty
|
||||
|
@ -101,6 +101,8 @@ namespace WebsitePanel.Providers.EnterpriseStorage
|
|||
{
|
||||
string fullName = string.Format("{0}:\\{1}\\{2}\\{3}", LocationDrive, UsersHome, organizationId, folderName);
|
||||
SystemFile folder = null;
|
||||
|
||||
var windows = new WebsitePanel.Providers.OS.Windows2012();
|
||||
|
||||
if (Directory.Exists(fullName))
|
||||
{
|
||||
|
@ -111,6 +113,8 @@ namespace WebsitePanel.Providers.EnterpriseStorage
|
|||
|
||||
folder.Url = string.Format("https://{0}/{1}/{2}", UsersDomain, organizationId, folderName);
|
||||
folder.Rules = GetFolderWebDavRules(organizationId, folderName);
|
||||
|
||||
folder.FRSMQuotaMB = windows.GetQuotaLimitOnFolder(fullName, string.Empty, string.Empty);
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
@ -170,8 +174,39 @@ namespace WebsitePanel.Providers.EnterpriseStorage
|
|||
|
||||
public bool SetFolderWebDavRules(string organizationId, string folder, WebDavFolderRule[] rules)
|
||||
{
|
||||
IWebDav webdav = new WebDav(UsersDomain);
|
||||
var users = new List<UserPermission>();
|
||||
|
||||
foreach (var rule in rules)
|
||||
{
|
||||
foreach (var user in rule.Users)
|
||||
{
|
||||
users.Add(new UserPermission
|
||||
{
|
||||
AccountName = user,
|
||||
Read = rule.Read,
|
||||
Write = rule.Write
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var user in rule.Roles)
|
||||
{
|
||||
users.Add(new UserPermission
|
||||
{
|
||||
AccountName = user,
|
||||
Read = rule.Read,
|
||||
Write = rule.Write
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
string path = string.Format("{0}:\\{1}\\{2}\\{3}", LocationDrive, UsersHome, organizationId, folder);
|
||||
|
||||
SecurityUtils.ResetNtfsPermissions(path);
|
||||
|
||||
SecurityUtils.GrantGroupNtfsPermissions(path, users.ToArray(), true, new RemoteServerSettings(), null, null);
|
||||
|
||||
IWebDav webdav = new WebDav(UsersDomain);
|
||||
|
||||
return webdav.SetFolderWebDavRules(organizationId, folder, rules);
|
||||
}
|
||||
|
||||
|
|
|
@ -215,6 +215,11 @@ namespace WebsitePanel.Providers.OS
|
|||
FileUtils.SetQuotaLimitOnFolder(folderPath, shareNameDrive, quotaLimit, mode, wmiUserName, wmiPassword);
|
||||
}
|
||||
|
||||
public virtual int GetQuotaLimitOnFolder(string folderPath, string wmiUserName, string wmiPassword)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void DeleteDirectoryRecursive(string rootPath)
|
||||
{
|
||||
FileUtils.DeleteDirectoryRecursive(rootPath);
|
||||
|
|
|
@ -125,6 +125,47 @@ namespace WebsitePanel.Providers.OS
|
|||
Log.WriteEnd("SetQuotaLimitOnFolder");
|
||||
}
|
||||
|
||||
public override int GetQuotaLimitOnFolder(string folderPath, string wmiUserName, string wmiPassword)
|
||||
{
|
||||
Log.WriteStart("GetQuotaLimitOnFolder");
|
||||
Log.WriteInfo("FolderPath : {0}", folderPath);
|
||||
|
||||
|
||||
Runspace runSpace = null;
|
||||
int quota = 0;
|
||||
|
||||
try
|
||||
{
|
||||
runSpace = OpenRunspace();
|
||||
|
||||
if (folderPath.IndexOfAny(Path.GetInvalidPathChars()) == -1)
|
||||
{
|
||||
Command cmd = new Command("Get-FsrmQuota");
|
||||
cmd.Parameters.Add("Path", folderPath);
|
||||
var result = ExecuteShellCommand(runSpace, cmd, false);
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
quota = ConvertBytesToMB(Convert.ToInt64(GetPSObjectProperty(result[0], "size")));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError("GetQuotaLimitOnFolder", ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseRunspace(runSpace);
|
||||
}
|
||||
|
||||
Log.WriteEnd("GetQuotaLimitOnFolder");
|
||||
|
||||
return quota;
|
||||
}
|
||||
|
||||
|
||||
public UInt64 CalculateQuota(string quota)
|
||||
{
|
||||
UInt64 OneKb = 1024;
|
||||
|
@ -150,6 +191,17 @@ namespace WebsitePanel.Providers.OS
|
|||
return result;
|
||||
}
|
||||
|
||||
public int ConvertBytesToMB(long bytes)
|
||||
{
|
||||
int OneKb = 1024;
|
||||
int OneMb = OneKb * 1024;
|
||||
|
||||
if (bytes == 0)
|
||||
return 0;
|
||||
|
||||
return (int)bytes / OneMb;
|
||||
}
|
||||
|
||||
public void RemoveOldQuotaOnFolder(Runspace runSpace, string path)
|
||||
{
|
||||
try
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -551,6 +551,23 @@ namespace WebsitePanel.Server
|
|||
}
|
||||
}
|
||||
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public int GetQuotaLimitOnFolder(string folderPath, string wmiUserName, string wmiPassword)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.WriteStart("'{0}' GetQuotaLimitOnFolder", ProviderSettings.ProviderName);
|
||||
var result = OsProvider.GetQuotaLimitOnFolder(folderPath, wmiUserName, wmiPassword);
|
||||
Log.WriteEnd("'{0}' GetQuotaLimitOnFolder", ProviderSettings.ProviderName);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError(String.Format("'{0}' GetQuotaLimitOnFolder", ProviderSettings.ProviderName), ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod, SoapHeader("settings")]
|
||||
public void DeleteDirectoryRecursive(string rootPath)
|
||||
{
|
||||
|
|
|
@ -96,8 +96,6 @@ namespace WebsitePanel.Portal.ExchangeServer
|
|||
|
||||
try
|
||||
{
|
||||
bool redirectNeeded = false;
|
||||
|
||||
litFolderName.Text = txtFolderName.Text;
|
||||
|
||||
SystemFile folder = new SystemFile { Name = PanelRequest.FolderID, Url = lblFolderUrl.Text };
|
||||
|
@ -122,19 +120,13 @@ namespace WebsitePanel.Portal.ExchangeServer
|
|||
}
|
||||
|
||||
folder = ES.Services.EnterpriseStorage.RenameEnterpriseFolder(PanelRequest.ItemID, PanelRequest.FolderID, txtFolderName.Text);
|
||||
|
||||
redirectNeeded = true;
|
||||
}
|
||||
|
||||
ES.Services.EnterpriseStorage.SetEnterpriseFolderSettings(PanelRequest.ItemID, folder, permissions.GetPemissions(), chkDirectoryBrowsing.Checked);
|
||||
ES.Services.EnterpriseStorage.SetEnterpriseFolderSettings(PanelRequest.ItemID, folder, permissions.GetPemissions(), chkDirectoryBrowsing.Checked, 100);
|
||||
|
||||
if (redirectNeeded)
|
||||
{
|
||||
Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "enterprisestorage_folders",
|
||||
|
||||
Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "enterprisestorage_folders",
|
||||
"ItemID=" + PanelRequest.ItemID));
|
||||
}
|
||||
|
||||
messageBox.ShowSuccessMessage("ENTERPRISE_STORAGE_UPDATE_FOLDER_SETTINGS");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -203,9 +203,6 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
|
|||
if (chkSelect == null)
|
||||
continue;
|
||||
|
||||
ExchangeAccount[] accounts = ES.Services.EnterpriseStorage.SearchESAccounts(PanelRequest.ItemID,
|
||||
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
|
||||
|
||||
ESPermission permission = new ESPermission();
|
||||
permission.Account = (string)gvPermissions.DataKeys[i][0];
|
||||
permission.Access = ((Literal)row.FindControl("litAccess")).Text;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue