bug fixes
This commit is contained in:
parent
0043689b8f
commit
d859dd56c1
3 changed files with 120 additions and 34 deletions
|
@ -261,16 +261,16 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
EnterpriseStorageController.AddWebDavDirectory(packageId, usersDomain, org.OrganizationId, homePath);
|
EnterpriseStorageController.AddWebDavDirectory(packageId, usersDomain, org.OrganizationId, homePath);
|
||||||
|
|
||||||
int osId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
|
//int osId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
|
||||||
bool enableHardQuota = (esSesstings["enablehardquota"] != null)
|
//bool enableHardQuota = (esSesstings["enablehardquota"] != null)
|
||||||
? bool.Parse(esSesstings["enablehardquota"])
|
// ? bool.Parse(esSesstings["enablehardquota"])
|
||||||
: false;
|
// : false;
|
||||||
|
|
||||||
if (enableHardQuota && osId != 0 && OperatingSystemController.CheckFileServicesInstallation(osId))
|
//if (enableHardQuota && osId != 0 && OperatingSystemController.CheckFileServicesInstallation(osId))
|
||||||
{
|
//{
|
||||||
FilesController.SetFolderQuota(packageId, Path.Combine(usersHome, org.OrganizationId),
|
// FilesController.SetFolderQuota(packageId, Path.Combine(usersHome, org.OrganizationId),
|
||||||
locationDrive, Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE);
|
// locationDrive, Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -579,11 +579,6 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
dir.HttpErrors = null;
|
dir.HttpErrors = null;
|
||||||
dir.MimeMaps = null;
|
dir.MimeMaps = null;
|
||||||
|
|
||||||
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
|
|
||||||
|
|
||||||
if (serviceId == -1)
|
|
||||||
return serviceId;
|
|
||||||
|
|
||||||
// create directory
|
// create directory
|
||||||
|
|
||||||
WebServer web = GetWebServer(packageId);
|
WebServer web = GetWebServer(packageId);
|
||||||
|
@ -867,6 +862,11 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
cnfg.ProviderSettings.ProviderName = webProvider.DisplayName;
|
cnfg.ProviderSettings.ProviderName = webProvider.DisplayName;
|
||||||
cnfg.ProviderSettings.ProviderType = webProvider.ProviderType;
|
cnfg.ProviderSettings.ProviderType = webProvider.ProviderType;
|
||||||
|
|
||||||
|
//// set service settings
|
||||||
|
//StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId);
|
||||||
|
//foreach (string key in serviceSettings.Keys)
|
||||||
|
// cnfg.ProviderSettings.Settings[key] = serviceSettings[key];
|
||||||
|
|
||||||
ServiceProviderProxy.ServerInit(web, cnfg, package.ServerId);
|
ServiceProviderProxy.ServerInit(web, cnfg, package.ServerId);
|
||||||
|
|
||||||
return web;
|
return web;
|
||||||
|
|
|
@ -783,6 +783,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
||||||
UpdatePackageHardQuota(package.PackageId);
|
UpdatePackageHardQuota(package.PackageId);
|
||||||
|
UpdateESHardQuota(package.PackageId);
|
||||||
|
|
||||||
DataProvider.DistributePackageServices(SecurityContext.User.UserId, package.PackageId);
|
DataProvider.DistributePackageServices(SecurityContext.User.UserId, package.PackageId);
|
||||||
}
|
}
|
||||||
|
@ -980,6 +981,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
// Added By Haya
|
// Added By Haya
|
||||||
UpdatePackageHardQuota(packageId);
|
UpdatePackageHardQuota(packageId);
|
||||||
|
UpdateESHardQuota(packageId);
|
||||||
|
|
||||||
// save package item
|
// save package item
|
||||||
return AddPackageItem(homeFolder);
|
return AddPackageItem(homeFolder);
|
||||||
|
@ -1019,6 +1021,33 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateESHardQuota(int packageId)
|
||||||
|
{
|
||||||
|
int esServiceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.EnterpriseStorage);
|
||||||
|
|
||||||
|
if (esServiceId != 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringDictionary esSesstings = ServerController.GetServiceSettings(esServiceId);
|
||||||
|
|
||||||
|
string usersHome = esSesstings["UsersHome"];
|
||||||
|
string usersDomain = esSesstings["UsersDomain"];
|
||||||
|
string locationDrive = esSesstings["LocationDrive"];
|
||||||
|
|
||||||
|
string homePath = string.Format("{0}:\\{1}", locationDrive, usersHome);
|
||||||
|
|
||||||
|
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, usersHome, locationDrive, Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Package Add-ons
|
#region Package Add-ons
|
||||||
|
@ -1079,6 +1108,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
||||||
UpdatePackageHardQuota(addon.PackageId);
|
UpdatePackageHardQuota(addon.PackageId);
|
||||||
|
UpdateESHardQuota(addon.PackageId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,7 +1138,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
||||||
UpdatePackageHardQuota(addon.PackageId);
|
UpdatePackageHardQuota(addon.PackageId);
|
||||||
|
UpdateESHardQuota(addon.PackageId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,12 +1149,14 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
| DemandAccount.IsReseller);
|
| DemandAccount.IsReseller);
|
||||||
if (accountCheck < 0) return accountCheck;
|
if (accountCheck < 0) return accountCheck;
|
||||||
|
|
||||||
|
var packageId = GetPackageAddon(packageAddonId).PackageId;
|
||||||
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
|
||||||
UpdatePackageHardQuota(GetPackageAddon(packageAddonId).PackageId);
|
|
||||||
|
|
||||||
DataProvider.DeletePackageAddon(SecurityContext.User.UserId, packageAddonId);
|
DataProvider.DeletePackageAddon(SecurityContext.User.UserId, packageAddonId);
|
||||||
|
|
||||||
|
// Update the Hard quota on home folder in case it was enabled and in case there was a change in disk space
|
||||||
|
UpdatePackageHardQuota(packageId);
|
||||||
|
UpdateESHardQuota(packageId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ using System.Management.Automation.Runspaces;
|
||||||
using WebsitePanel.Providers.Common;
|
using WebsitePanel.Providers.Common;
|
||||||
using WebsitePanel.Providers;
|
using WebsitePanel.Providers;
|
||||||
using WebsitePanel.Providers.HostedSolution;
|
using WebsitePanel.Providers.HostedSolution;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|
||||||
namespace WebsitePanel.Providers.OS
|
namespace WebsitePanel.Providers.OS
|
||||||
|
@ -80,27 +81,33 @@ namespace WebsitePanel.Providers.OS
|
||||||
Log.WriteInfo("ShareNameDrive : {0}", shareNameDrive);
|
Log.WriteInfo("ShareNameDrive : {0}", shareNameDrive);
|
||||||
Log.WriteInfo("QuotaLimit : {0}", quotaLimit);
|
Log.WriteInfo("QuotaLimit : {0}", quotaLimit);
|
||||||
|
|
||||||
|
string path = Path.Combine(shareNameDrive + @":\", folderPath);
|
||||||
|
var quota = CalculateQuota(quotaLimit);
|
||||||
|
|
||||||
Runspace runSpace = null;
|
Runspace runSpace = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
runSpace = OpenRunspace();
|
runSpace = OpenRunspace();
|
||||||
string[] splits = folderPath.Split('\\');
|
|
||||||
if (splits.Length > 0)
|
|
||||||
{
|
|
||||||
string sharePath = String.Empty;
|
|
||||||
|
|
||||||
if (splits.Length > 4)
|
if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1)
|
||||||
{
|
{
|
||||||
// Form the share physicalPath
|
if (!FileUtils.DirectoryExists(path))
|
||||||
sharePath = shareNameDrive + @":\" + splits[3];
|
FileUtils.CreateDirectory(path);
|
||||||
|
|
||||||
if (splits.Length == 5 && !quotaLimit.Equals(String.Empty))
|
switch (mode)
|
||||||
{
|
{
|
||||||
Command cmd = new Command("Set-FsrmQuota");
|
//deleting old quota and creating new one
|
||||||
cmd.Parameters.Add("Path", sharePath + @"\" + splits[4]);
|
case 0:
|
||||||
cmd.Parameters.Add("Size", quotaLimit);
|
{
|
||||||
cmd.Parameters.Add("Confirm", true);
|
RemoveOldQuotaOnFolder(runSpace, path);
|
||||||
ExecuteShellCommand(runSpace, cmd, false);
|
ChangeQuotaOnFolder(runSpace, "New-FsrmQuota", path, quota);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//modifying folder quota
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
ChangeQuotaOnFolder(runSpace, "Set-FsrmQuota", path, quota);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,13 +119,60 @@ namespace WebsitePanel.Providers.OS
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
||||||
CloseRunspace(runSpace);
|
CloseRunspace(runSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.WriteEnd("SetQuotaLimitOnFolder");
|
Log.WriteEnd("SetQuotaLimitOnFolder");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UInt64 CalculateQuota(string quota)
|
||||||
|
{
|
||||||
|
UInt64 OneKb = 1024;
|
||||||
|
UInt64 OneMb = OneKb * 1024;
|
||||||
|
UInt64 OneGb = OneMb * 1024;
|
||||||
|
|
||||||
|
UInt64 result = 0;
|
||||||
|
|
||||||
|
// Quota Unit
|
||||||
|
if (quota.ToLower().Contains("gb"))
|
||||||
|
{
|
||||||
|
result = UInt64.Parse(quota.ToLower().Replace("gb", "")) * OneGb;
|
||||||
|
}
|
||||||
|
else if (quota.ToLower().Contains("mb"))
|
||||||
|
{
|
||||||
|
result = UInt64.Parse(quota.ToLower().Replace("mb", "")) * OneMb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = UInt64.Parse(quota.ToLower().Replace("kb", "")) * OneKb;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveOldQuotaOnFolder(Runspace runSpace, string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runSpace = OpenRunspace();
|
||||||
|
if (!string.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
Command cmd = new Command("Remove-FsrmQuota");
|
||||||
|
cmd.Parameters.Add("Path", path);
|
||||||
|
ExecuteShellCommand(runSpace, cmd, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { /* do nothing */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeQuotaOnFolder(Runspace runSpace, string command, string path, UInt64 quota)
|
||||||
|
{
|
||||||
|
Command cmd = new Command(command);
|
||||||
|
cmd.Parameters.Add("Path", path);
|
||||||
|
cmd.Parameters.Add("Size", quota);
|
||||||
|
ExecuteShellCommand(runSpace, cmd, false);
|
||||||
|
}
|
||||||
|
|
||||||
#region PowerShell integration
|
#region PowerShell integration
|
||||||
private static InitialSessionState session = null;
|
private static InitialSessionState session = null;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue