Merge Changes wsp-10029 wsp-10030
This commit is contained in:
commit
dfbdfc0024
35 changed files with 1698 additions and 478 deletions
|
@ -912,5 +912,163 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
return users.ToArray();
|
||||
}
|
||||
|
||||
public static int SetFolderQuota(int packageId, string path, string driveName)
|
||||
{
|
||||
|
||||
// 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);
|
||||
TaskManager.ItemId = 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.
|
||||
QuotaValueInfo diskSpaceQuota = PackageController.GetPackageQuota(packageId, Quotas.OS_DISKSPACE);
|
||||
|
||||
|
||||
#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.OperatingSystem os = GetOS(packageId);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static int ApplyEnableHardQuotaFeature(int packageId)
|
||||
{
|
||||
if (SecurityContext.CheckAccount(DemandAccount.IsActive | DemandAccount.IsAdmin | DemandAccount.NotDemo) != 0)
|
||||
throw new Exception("This method could be called by serveradmin only.");
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("FILES", "APPLY_ENABLEHARDQUOTAFEATURE");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
// request OS service
|
||||
//int osId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);
|
||||
//if (osId == 0)
|
||||
// return -1;
|
||||
|
||||
//OS.OperatingSystem os = new OS.OperatingSystem();
|
||||
//ServiceProviderProxy.Init(os, osId);
|
||||
|
||||
////Get operating system settings
|
||||
// StringDictionary osSesstings = ServerController.GetServiceSettings(osId);
|
||||
// bool diskQuotaEnabled = (osSesstings["EnableHardQuota"] != null) ? bool.Parse(osSesstings["EnableHardQuota"]) : false;
|
||||
//string driveName = osSesstings["LocationDrive"];
|
||||
|
||||
//if (!diskQuotaEnabled)
|
||||
// return -1;
|
||||
|
||||
|
||||
List<PackageInfo> allPackages = PackageController.GetPackagePackages(packageId, true);
|
||||
|
||||
foreach (PackageInfo childPackage in allPackages)
|
||||
{
|
||||
// request OS service
|
||||
int osId = PackageController.GetPackageServiceId(childPackage.PackageId, ResourceGroups.Os);
|
||||
if (osId == 0)
|
||||
continue;
|
||||
|
||||
OS.OperatingSystem os = new OS.OperatingSystem();
|
||||
ServiceProviderProxy.Init(os, osId);
|
||||
|
||||
//Get operating system settings
|
||||
StringDictionary osSesstings = ServerController.GetServiceSettings(osId);
|
||||
string driveName = osSesstings["LocationDrive"];
|
||||
|
||||
if (String.IsNullOrEmpty(driveName))
|
||||
continue;
|
||||
|
||||
string homeFolder = FilesController.GetHomeFolder(childPackage.PackageId);
|
||||
FilesController.SetFolderQuota(childPackage.PackageId, homeFolder, driveName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static int DeleteDirectoryRecursive(int packageId, string rootPath)
|
||||
{
|
||||
|
||||
// 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", "DELETE_DIRECTORY_RECURSIVE", rootPath);
|
||||
TaskManager.ItemId = packageId;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
OS.OperatingSystem os = GetOS(packageId);
|
||||
os.DeleteDirectoryRecursive(rootPath);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,6 +406,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
// Check If FSRM Role services were installed
|
||||
public static bool CheckFileServicesInstallation(int serviceId)
|
||||
{
|
||||
OS.OperatingSystem os = GetOS(serviceId);
|
||||
return os.CheckFileServicesInstallation();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Web Platform Installer
|
||||
|
|
|
@ -770,6 +770,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
if (result.ExceedingQuotas.Tables[0].Rows.Count > 0)
|
||||
result.Result = BusinessErrorCodes.ERROR_PACKAGE_QUOTA_EXCEED;
|
||||
|
||||
// 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);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -963,6 +966,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
homeFolder.PackageId = packageId;
|
||||
homeFolder.Name = path;
|
||||
|
||||
// Added By Haya
|
||||
UpdatePackageHardQuota(packageId);
|
||||
|
||||
// save package item
|
||||
return AddPackageItem(homeFolder);
|
||||
}
|
||||
|
@ -976,6 +982,30 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
DataProvider.UpdatePackageBandwidthUpdate(packageId, updateDate);
|
||||
}
|
||||
|
||||
// This gets the system quota and updates the home folder with the value
|
||||
public static void UpdatePackageHardQuota(int packageId)
|
||||
{
|
||||
// request OS service
|
||||
int osId = GetPackageServiceId(packageId, ResourceGroups.Os);
|
||||
if (osId == 0)
|
||||
return;
|
||||
|
||||
OS.OperatingSystem os = new OS.OperatingSystem();
|
||||
ServiceProviderProxy.Init(os, osId);
|
||||
|
||||
//Get operating system settings
|
||||
StringDictionary osSesstings = ServerController.GetServiceSettings(osId);
|
||||
bool diskQuotaEnabled = (osSesstings["EnableHardQuota"] != null) ? bool.Parse(osSesstings["EnableHardQuota"]) : false;
|
||||
string driveName = osSesstings["LocationDrive"];
|
||||
|
||||
if (!diskQuotaEnabled)
|
||||
return;
|
||||
|
||||
string homeFolder = FilesController.GetHomeFolder(packageId);
|
||||
FilesController.SetFolderQuota(packageId, homeFolder, driveName);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -1035,6 +1065,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
result.Result = addonId;
|
||||
|
||||
// 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);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1062,6 +1094,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (result.ExceedingQuotas.Tables[0].Rows.Count > 0)
|
||||
result.Result = BusinessErrorCodes.ERROR_PACKAGE_QUOTA_EXCEED;
|
||||
|
||||
// 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);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1072,6 +1107,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
| DemandAccount.IsReseller);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -583,7 +583,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
public static int DeleteWebSite(int siteItemId)
|
||||
public static int DeleteWebSite(int siteItemId, bool deleteWebsiteDirectory)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
|
@ -655,6 +655,16 @@ namespace WebsitePanel.EnterpriseServer
|
|||
//
|
||||
web.DeleteSite(siteItem.SiteId);
|
||||
|
||||
// Delete WebManagementAccess Account
|
||||
WebServerController.RevokeWebManagementAccess(siteItemId);
|
||||
|
||||
if (deleteWebsiteDirectory)
|
||||
{
|
||||
// Delete website directory from file server
|
||||
// This will remove the hard quota as well
|
||||
FilesController.DeleteDirectoryRecursive(siteItem.PackageId, new DirectoryInfo(siteItem.DataPath).Parent.FullName);
|
||||
|
||||
}
|
||||
// delete service item
|
||||
PackageController.DeletePackageItem(siteItemId);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue