diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs index d7510e2f..808637cd 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs @@ -48,6 +48,7 @@ using WebsitePanel.Providers.HostedSolution; using WebsitePanel.EnterpriseServer.Base.HostedSolution; using WebsitePanel.Server.Client; using System.Text.RegularExpressions; +using System.Threading; namespace WebsitePanel.EnterpriseServer { @@ -146,6 +147,11 @@ namespace WebsitePanel.EnterpriseServer SetFRSMQuotaOnFolderInternal(itemId, folderName, quota, quotaType); } + public static void StartSetEnterpriseFolderSettingsBackgroundTask(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, QuotaType quotaType) + { + StartESBackgroundTaskInternal("SET_ENTERPRISE_FOLDER_SETTINGS", itemId, folder, permissions, directoyBrowsingEnabled, quota, quotaType); + } + #region Directory Browsing public static bool GetDirectoryBrowseEnabled(int itemId, string siteId) @@ -176,6 +182,41 @@ namespace WebsitePanel.EnterpriseServer #endregion + protected static void StartESBackgroundTaskInternal(string taskName, int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, QuotaType quotaType) + { + // load organization + var org = OrganizationController.GetOrganization(itemId); + + new Thread(() => + { + try + { + TaskManager.StartTask("ENTERPRISE_STORAGE", taskName, org.PackageId); + + EnterpriseStorageController.SetDirectoryBrowseEnabled(itemId, folder.Url, directoyBrowsingEnabled); + EnterpriseStorageController.SetFolderPermission(itemId, folder.Name, permissions); + EnterpriseStorageController.SetFRSMQuotaOnFolder(itemId, folder.Name, quota, quotaType); + } + catch (Exception ex) + { + // log error + TaskManager.WriteError(ex, "Error executing enterprise storage background task"); + } + finally + { + // complete task + try + { + TaskManager.CompleteTask(); + } + catch (Exception) + { + } + } + + }).Start(); + } + protected static bool CheckUsersDomainExistsInternal(int itemId) { Organization org = OrganizationController.GetOrganization(itemId); @@ -524,7 +565,7 @@ namespace WebsitePanel.EnterpriseServer protected static void SetFRSMQuotaOnFolderInternal(int itemId, string folderName, int quota, QuotaType quotaType) { - ResultObject result = TaskManager.StartResultTask("ENTERPRISE_STORAGE", "CREATE_FOLDER"); + ResultObject result = TaskManager.StartResultTask("ENTERPRISE_STORAGE", "SET_FRSM_QUOTA"); try { @@ -548,7 +589,7 @@ namespace WebsitePanel.EnterpriseServer } catch (Exception ex) { - result.AddError("ENTERPRISE_STORAGE_CREATE_FOLDER", ex); + result.AddError("ENTERPRISE_STORAGE_SET_FRSM_QUOTA", ex); } finally { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs index 8f81ab72..2748401f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs @@ -152,9 +152,7 @@ namespace WebsitePanel.EnterpriseServer [WebMethod] public void SetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, QuotaType quotaType) { - EnterpriseStorageController.SetDirectoryBrowseEnabled(itemId, folder.Url, directoyBrowsingEnabled); - EnterpriseStorageController.SetFolderPermission(itemId, folder.Name, permissions); - EnterpriseStorageController.SetFRSMQuotaOnFolder(itemId, folder.Name, quota, quotaType); + EnterpriseStorageController.StartSetEnterpriseFolderSettingsBackgroundTask(itemId, folder, permissions, directoyBrowsingEnabled, quota, quotaType); } #endregion