Merge
This commit is contained in:
commit
cf889bd90c
65 changed files with 15351 additions and 8460 deletions
|
@ -34,6 +34,7 @@ using System.Collections.Specialized;
|
|||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Linq;
|
||||
|
||||
using WebsitePanel.Server;
|
||||
using WebsitePanel.Providers;
|
||||
|
@ -42,13 +43,16 @@ using WebsitePanel.Providers.EnterpriseStorage;
|
|||
using System.Collections;
|
||||
using WebsitePanel.Providers.Common;
|
||||
using WebsitePanel.Providers.ResultObjects;
|
||||
|
||||
using WebsitePanel.Providers.Web;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
public class EnterpriseStorageController
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public static SystemFile[] GetFolders(int itemId)
|
||||
{
|
||||
return GetFoldersInternal(itemId);
|
||||
|
@ -59,20 +63,57 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return GetFolderInternal(itemId, folderName);
|
||||
}
|
||||
|
||||
public static ResultObject CreateFolder(int itemId, string folderName, long quota)
|
||||
public static ResultObject CreateFolder(int itemId)
|
||||
{
|
||||
return CreateFolderInternal(itemId, folderName, quota);
|
||||
return CreateFolder(itemId, string.Empty);
|
||||
}
|
||||
|
||||
public static ResultObject CreateFolder(int itemId, string folderName)
|
||||
{
|
||||
return CreateFolderInternal(itemId, folderName);
|
||||
}
|
||||
|
||||
public static ResultObject DeleteFolder(int itemId)
|
||||
{
|
||||
return DeleteFolder(itemId, string.Empty);
|
||||
}
|
||||
|
||||
public static ResultObject DeleteFolder(int itemId, string folderName)
|
||||
{
|
||||
return DeleteFolderInternal(itemId, folderName);
|
||||
}
|
||||
|
||||
public static List<ExchangeAccount> SearchESAccounts(int itemId, string filterColumn, string filterValue, string sortColumn)
|
||||
{
|
||||
return SearchESAccountsInternal(itemId, filterColumn, filterValue, sortColumn);
|
||||
}
|
||||
|
||||
public static ResultObject SetFolderQuota(int itemId, string folderName, long quota)
|
||||
public static SystemFilesPaged GetEnterpriseFoldersPaged(int itemId, string filterValue, string sortColumn, int startRow, int maximumRows)
|
||||
{
|
||||
return SetFolderQuotaInternal(itemId, folderName, quota);
|
||||
return GetEnterpriseFoldersPagedInternal(itemId, filterValue, sortColumn, startRow, maximumRows);
|
||||
}
|
||||
|
||||
public static ResultObject SetFolderPermission(int itemId, string folder, ESPermission[] permission)
|
||||
{
|
||||
return SetFolderWebDavRulesInternal(itemId, folder, permission);
|
||||
}
|
||||
|
||||
public static ESPermission[] GetFolderPermission(int itemId, string folder)
|
||||
{
|
||||
return ConvertToESPermission(itemId,GetFolderWebDavRulesInternal(itemId, folder));
|
||||
}
|
||||
|
||||
public static bool CheckFileServicesInstallation(int serviceId)
|
||||
{
|
||||
EnterpriseStorage es = GetEnterpriseStorage(serviceId);
|
||||
return es.CheckFileServicesInstallation();
|
||||
}
|
||||
|
||||
public static SystemFile RenameFolder(int itemId, string oldFolder, string newFolder)
|
||||
{
|
||||
return RenameFolderInternal(itemId, oldFolder, newFolder);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -83,37 +124,376 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return es;
|
||||
}
|
||||
|
||||
|
||||
private static SystemFile[] GetFoldersInternal(int itemId)
|
||||
protected static SystemFile[] GetFoldersInternal(int itemId)
|
||||
{
|
||||
return new SystemFile[1];
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
return es.GetFolders(org.OrganizationId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private static SystemFile GetFolderInternal(int itemId, string folderName)
|
||||
protected static SystemFile GetFolderInternal(int itemId, string folderName)
|
||||
{
|
||||
return new SystemFile();
|
||||
}
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ResultObject CreateFolderInternal(int itemId, string folderName, long quota)
|
||||
{
|
||||
return new ResultObject();
|
||||
}
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
private static ResultObject DeleteFolderInternal(int itemId, string folderName)
|
||||
{
|
||||
return new ResultObject();
|
||||
}
|
||||
|
||||
private static ResultObject SetFolderQuotaInternal(int itemId, string folderName, long quota)
|
||||
{
|
||||
return new ResultObject();
|
||||
return es.GetFolder(org.OrganizationId, folderName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool CheckFileServicesInstallation(int serviceId)
|
||||
protected static SystemFile RenameFolderInternal(int itemId, string oldFolder, string newFolder)
|
||||
{
|
||||
EnterpriseStorage es = GetEnterpriseStorage(serviceId);
|
||||
return es.CheckFileServicesInstallation();
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
return es.RenameFolder(org.OrganizationId, oldFolder, newFolder);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
protected static ResultObject CreateFolderInternal(int itemId, string folderName)
|
||||
{
|
||||
ResultObject result = TaskManager.StartResultTask<ResultObject>("ENTERPRISE_STORAGE", "CREATE_FOLDER");
|
||||
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
es.CreateFolder(org.OrganizationId, folderName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.AddError("ENTERPRISE_STORAGE_CREATE_FOLDER", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
TaskManager.CompleteResultTask(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskManager.CompleteResultTask();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static ResultObject DeleteFolderInternal(int itemId, string folderName)
|
||||
{
|
||||
ResultObject result = TaskManager.StartResultTask<ResultObject>("ENTERPRISE_STORAGE", "DELETE_FOLDER");
|
||||
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
es.DeleteFolder(org.OrganizationId, folderName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.AddError("ENTERPRISE_STORAGE_DELETE_FOLDER", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
TaskManager.CompleteResultTask(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskManager.CompleteResultTask();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static List<ExchangeAccount> SearchESAccountsInternal(int itemId, string filterColumn, string filterValue, string sortColumn)
|
||||
{
|
||||
// load organization
|
||||
Organization org = (Organization)PackageController.GetPackageItem(itemId);
|
||||
if (org == null)
|
||||
return null;
|
||||
|
||||
string accountTypes = string.Format("{0}, {1}, {2}", ((int)ExchangeAccountType.SecurityGroup),
|
||||
(int)ExchangeAccountType.DefaultSecurityGroup, ((int)ExchangeAccountType.User));
|
||||
|
||||
if (PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.Exchange) != 0)
|
||||
{
|
||||
accountTypes = string.Format("{0}, {1}, {2}, {3}", accountTypes, ((int)ExchangeAccountType.Mailbox),
|
||||
((int)ExchangeAccountType.Room), ((int)ExchangeAccountType.Equipment));
|
||||
}
|
||||
|
||||
List<ExchangeAccount> tmpAccounts = ObjectUtils.CreateListFromDataReader<ExchangeAccount>(
|
||||
DataProvider.SearchExchangeAccountsByTypes(SecurityContext.User.UserId, itemId,
|
||||
accountTypes, filterColumn, filterValue, sortColumn));
|
||||
|
||||
|
||||
List<ExchangeAccount> exAccounts = new List<ExchangeAccount>();
|
||||
|
||||
foreach (ExchangeAccount tmpAccount in tmpAccounts.ToArray())
|
||||
{
|
||||
if (tmpAccount.AccountType == ExchangeAccountType.SecurityGroup || tmpAccount.AccountType == ExchangeAccountType.SecurityGroup
|
||||
? OrganizationController.GetSecurityGroupGeneralSettings(itemId, tmpAccount.AccountId) == null
|
||||
: OrganizationController.GetSecurityGroupGeneralSettings(itemId, tmpAccount.AccountId) == null)
|
||||
continue;
|
||||
|
||||
exAccounts.Add(tmpAccount);
|
||||
}
|
||||
|
||||
return exAccounts;
|
||||
|
||||
}
|
||||
|
||||
protected static SystemFilesPaged GetEnterpriseFoldersPagedInternal(int itemId, string filterValue, string sortColumn,
|
||||
int startRow, int maximumRows)
|
||||
{
|
||||
SystemFilesPaged result = new SystemFilesPaged();
|
||||
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
List<SystemFile> folders = es.GetFolders(org.OrganizationId).Where(x => x.Name.Contains(filterValue)).ToList();
|
||||
|
||||
switch (sortColumn)
|
||||
{
|
||||
case "Size":
|
||||
folders = folders.OrderBy(x => x.Size).ToList();
|
||||
break;
|
||||
default:
|
||||
folders = folders.OrderBy(x => x.Name).ToList();
|
||||
break;
|
||||
}
|
||||
|
||||
result.RecordsCount = folders.Count;
|
||||
result.PageItems = folders.Skip(startRow).Take(maximumRows).ToArray();
|
||||
}
|
||||
catch { /*skip exception*/}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static ResultObject SetFolderWebDavRulesInternal(int itemId, string folder, ESPermission[] permission)
|
||||
{
|
||||
ResultObject result = TaskManager.StartResultTask<ResultObject>("ENTERPRISE_STORAGE", "SET_WEBDAV_FOLDER_RULES");
|
||||
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var rules = ConvertToWebDavRule(itemId,permission);
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
es.SetFolderWebDavRules(org.OrganizationId, folder, rules);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.AddError("ENTERPRISE_STORAGE_SET_WEBDAV_FOLDER_RULES", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
TaskManager.CompleteResultTask(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskManager.CompleteResultTask();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static WebDavFolderRule[] GetFolderWebDavRulesInternal(int itemId, string folder)
|
||||
{
|
||||
try
|
||||
{
|
||||
// load organization
|
||||
Organization org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||
|
||||
return es.GetFolderWebDavRules(org.OrganizationId, folder);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static int GetEnterpriseStorageServiceID(int packageId)
|
||||
{
|
||||
return PackageController.GetPackageServiceId(packageId, ResourceGroups.EnterpriseStorage);
|
||||
}
|
||||
|
||||
private static EnterpriseStorage GetEnterpriseStorageByPackageId(int packageId)
|
||||
{
|
||||
var serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.EnterpriseStorage);
|
||||
|
||||
return GetEnterpriseStorage(serviceId);
|
||||
}
|
||||
|
||||
private static WebDavFolderRule[] ConvertToWebDavRule(int itemId, ESPermission[] permissions)
|
||||
{
|
||||
var rules = new List<WebDavFolderRule>();
|
||||
|
||||
foreach (var permission in permissions)
|
||||
{
|
||||
var rule = new WebDavFolderRule();
|
||||
|
||||
var account = ObjectUtils.FillObjectFromDataReader<ExchangeAccount>(DataProvider.GetExchangeAccountByAccountName(itemId, permission.Account));
|
||||
|
||||
if (account.AccountType == ExchangeAccountType.SecurityGroup)
|
||||
{
|
||||
rule.Roles.Add(permission.Account);
|
||||
}
|
||||
else
|
||||
{
|
||||
rule.Users.Add(permission.Account);
|
||||
}
|
||||
|
||||
if (permission.Access.ToLower().Contains("read-only"))
|
||||
{
|
||||
rule.Read = true;
|
||||
}
|
||||
|
||||
if (permission.Access.ToLower().Contains("read-write"))
|
||||
{
|
||||
rule.Write = true;
|
||||
rule.Read = true;
|
||||
}
|
||||
|
||||
rule.Pathes.Add("*");
|
||||
|
||||
rules.Add(rule);
|
||||
}
|
||||
|
||||
return rules.ToArray();
|
||||
}
|
||||
|
||||
private static ESPermission[] ConvertToESPermission(int itemId, WebDavFolderRule[] rules)
|
||||
{
|
||||
var permissions = new List<ESPermission>();
|
||||
|
||||
foreach (var rule in rules)
|
||||
{
|
||||
var permission = new ESPermission();
|
||||
|
||||
permission.Account = rule.Users.Any() ? rule.Users[0] : rule.Roles[0];
|
||||
|
||||
permission.IsGroup = rule.Roles.Any();
|
||||
|
||||
var orgObj = OrganizationController.GetAccountByAccountName(itemId, permission.Account);
|
||||
|
||||
if (orgObj == null)
|
||||
continue;
|
||||
|
||||
if (permission.IsGroup)
|
||||
{
|
||||
var secGroupObj = OrganizationController.GetSecurityGroupGeneralSettings(itemId, orgObj.AccountId);
|
||||
|
||||
if (secGroupObj == null)
|
||||
continue;
|
||||
|
||||
permission.DisplayName = secGroupObj.DisplayName;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var userObj = OrganizationController.GetUserGeneralSettings(itemId, orgObj.AccountId);
|
||||
|
||||
if (userObj == null)
|
||||
continue;
|
||||
|
||||
permission.DisplayName = userObj.DisplayName;
|
||||
}
|
||||
|
||||
if (rule.Read && !rule.Write)
|
||||
{
|
||||
permission.Access = "Read-Only";
|
||||
}
|
||||
if (rule.Write)
|
||||
{
|
||||
permission.Access = "Read-Write";
|
||||
}
|
||||
|
||||
|
||||
permissions.Add(permission);
|
||||
}
|
||||
|
||||
return permissions.ToArray();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -910,7 +910,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return users.ToArray();
|
||||
}
|
||||
|
||||
public static int SetFolderQuota(int packageId, string path, string driveName)
|
||||
public static int SetFolderQuota(int packageId, string path, string driveName,string quotas)
|
||||
{
|
||||
|
||||
// check account
|
||||
|
@ -929,8 +929,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
// 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);
|
||||
// It includes the package Add Ons * Quatity + Hosting Plan System disk space value. //Quotas.OS_DISKSPACE
|
||||
QuotaValueInfo diskSpaceQuota = PackageController.GetPackageQuota(packageId, quotas);
|
||||
|
||||
|
||||
#region figure Quota Unit
|
||||
|
@ -965,7 +965,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static int ApplyEnableHardQuotaFeature(int packageId)
|
||||
{
|
||||
if (SecurityContext.CheckAccount(DemandAccount.IsActive | DemandAccount.IsAdmin | DemandAccount.NotDemo) != 0)
|
||||
|
@ -1014,7 +1014,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
continue;
|
||||
|
||||
string homeFolder = FilesController.GetHomeFolder(childPackage.PackageId);
|
||||
FilesController.SetFolderQuota(childPackage.PackageId, homeFolder, driveName);
|
||||
FilesController.SetFolderQuota(childPackage.PackageId, homeFolder, driveName, Quotas.OS_DISKSPACE);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1027,7 +1027,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static int DeleteDirectoryRecursive(int packageId, string rootPath)
|
||||
|
|
|
@ -48,6 +48,7 @@ using System.IO;
|
|||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
|
||||
using WebsitePanel.Providers.OS;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
|
@ -417,6 +418,36 @@ namespace WebsitePanel.EnterpriseServer
|
|||
};
|
||||
|
||||
PackageController.AddPackageItem(orgDomain);
|
||||
|
||||
//Create Enterprise storage
|
||||
|
||||
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);
|
||||
|
||||
EnterpriseStorageController.CreateFolder(itemId);
|
||||
|
||||
WebServerController.AddWebDavDirectory(packageId, usersDomain, 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, organizationId),
|
||||
locationDrive, Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -714,6 +745,26 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteError(ex);
|
||||
}
|
||||
|
||||
//Cleanup Enterprise storage
|
||||
int esId = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.EnterpriseStorage);
|
||||
|
||||
if (esId != 0)
|
||||
{
|
||||
StringDictionary esSesstings = ServerController.GetServiceSettings(esId);
|
||||
|
||||
string usersDomain = esSesstings["UsersDomain"];
|
||||
|
||||
try
|
||||
{
|
||||
WebServerController.DeleteWebDavDirectory(org.PackageId, usersDomain, org.OrganizationId);
|
||||
EnterpriseStorageController.DeleteFolder(itemId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
successful = false;
|
||||
TaskManager.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
//Cleanup Exchange
|
||||
try
|
||||
|
@ -741,8 +792,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.WriteError(ex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// delete organization domains
|
||||
List<OrganizationDomainName> domains = GetOrganizationDomains(itemId);
|
||||
foreach (OrganizationDomainName domain in domains)
|
||||
|
@ -764,7 +813,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// delete meta-item
|
||||
PackageController.DeletePackageItem(itemId);
|
||||
|
||||
|
||||
return successful ? 0 : BusinessErrorCodes.ERROR_ORGANIZATION_DELETE_SOME_PROBLEMS;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -946,7 +994,13 @@ namespace WebsitePanel.EnterpriseServer
|
|||
stats.CreatedLyncUsers = LyncController.GetLyncUsersCount(org.Id).Value;
|
||||
}
|
||||
|
||||
if (cntxTmp.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
|
||||
{
|
||||
SystemFile[] folders = EnterpriseStorageController.GetFolders(itemId);
|
||||
|
||||
stats.CreatedEnterpriseStorageFolders = folders.Count();
|
||||
stats.UsedEnterpriseStorageSpace = (int)folders.Sum(x => x.Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -998,6 +1052,14 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
stats.CreatedLyncUsers += LyncController.GetLyncUsersCount(o.Id).Value;
|
||||
}
|
||||
|
||||
if (cntxTmp.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
|
||||
{
|
||||
SystemFile[] folders = EnterpriseStorageController.GetFolders(itemId);
|
||||
|
||||
stats.CreatedEnterpriseStorageFolders = folders.Count();
|
||||
stats.UsedEnterpriseStorageSpace = (int)folders.Sum(x => x.Size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1035,6 +1097,17 @@ namespace WebsitePanel.EnterpriseServer
|
|||
stats.AllocatedLyncUsers = cntx.Quotas[Quotas.LYNC_USERS].QuotaAllocatedValue;
|
||||
}
|
||||
|
||||
if (cntx.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
|
||||
{
|
||||
stats.AllocatedEnterpriseStorageFolders = cntx.Quotas[Quotas.ENTERPRISESTORAGE_FOLDERS].QuotaAllocatedValue;
|
||||
}
|
||||
|
||||
|
||||
if (cntx.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
|
||||
{
|
||||
stats.AllocatedEnterpriseStorageSpace = cntx.Quotas[Quotas.ENTERPRISESTORAGE_DISKSTORAGESPACE].QuotaAllocatedValue;
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -1011,7 +1011,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return;
|
||||
|
||||
string homeFolder = FilesController.GetHomeFolder(packageId);
|
||||
FilesController.SetFolderQuota(packageId, homeFolder, driveName);
|
||||
FilesController.SetFolderQuota(packageId, homeFolder, driveName, Quotas.OS_DISKSPACE);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -741,7 +741,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (res != null)
|
||||
{
|
||||
res.IsSuccess = false;
|
||||
|
||||
if (!string.IsNullOrEmpty(errorCode))
|
||||
res.ErrorCodes.Add(errorCode);
|
||||
}
|
||||
|
|
|
@ -1708,6 +1708,97 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
public static int AddWebDavDirectory(int packageId, string site, string vdirName, string contentpath)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("ENTERPRISE_STORAGE", "ADD_VDIR", vdirName);
|
||||
|
||||
TaskManager.WriteParameter("enterprise storage", site);
|
||||
|
||||
try
|
||||
{
|
||||
// create virtual directory
|
||||
WebVirtualDirectory dir = new WebVirtualDirectory();
|
||||
dir.Name = vdirName;
|
||||
dir.ContentPath = Path.Combine(contentpath, vdirName);
|
||||
|
||||
dir.EnableAnonymousAccess = false;
|
||||
dir.EnableWindowsAuthentication = false;
|
||||
dir.EnableBasicAuthentication = false;
|
||||
|
||||
//dir.InstalledDotNetFramework = aspNet;
|
||||
|
||||
dir.DefaultDocs = null; // inherit from service
|
||||
dir.HttpRedirect = "";
|
||||
dir.HttpErrors = null;
|
||||
dir.MimeMaps = null;
|
||||
|
||||
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
|
||||
|
||||
if (serviceId == -1)
|
||||
return serviceId;
|
||||
|
||||
// create directory
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, serviceId);
|
||||
if (web.VirtualDirectoryExists(site, vdirName))
|
||||
return BusinessErrorCodes.ERROR_VDIR_ALREADY_EXISTS;
|
||||
|
||||
web.CreateVirtualDirectory(site, dir);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static int DeleteWebDavDirectory(int packageId, string site, string vdirName)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
|
||||
if (accountCheck < 0) return accountCheck;
|
||||
|
||||
// place log record
|
||||
TaskManager.StartTask("ENTERPRISE_STORAGE", "DELETE_VDIR", vdirName);
|
||||
|
||||
TaskManager.WriteParameter("enterprise storage", site);
|
||||
|
||||
try
|
||||
{
|
||||
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
|
||||
|
||||
if (serviceId == -1)
|
||||
return serviceId;
|
||||
|
||||
// create directory
|
||||
WebServer web = new WebServer();
|
||||
ServiceProviderProxy.Init(web, serviceId);
|
||||
if (web.VirtualDirectoryExists(site, vdirName))
|
||||
web.DeleteVirtualDirectory(site, vdirName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw TaskManager.WriteError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static int UpdateVirtualDirectory(int siteItemId, WebVirtualDirectory vdir)
|
||||
{
|
||||
// check account
|
||||
|
@ -4528,5 +4619,57 @@ Please ensure the space has been allocated {0} IP address as a dedicated one and
|
|||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Directory Browsing
|
||||
|
||||
public static bool GetDirectoryBrowseEnabled(int itemId, string siteId)
|
||||
{
|
||||
// load organization
|
||||
var org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
siteId = RemoveProtocolFromUrl(siteId);
|
||||
|
||||
var webServer = GetWebServer(GetWebServerServiceID(org.PackageId));
|
||||
|
||||
return webServer.GetDirectoryBrowseEnabled(siteId);
|
||||
}
|
||||
|
||||
public static void SetDirectoryBrowseEnabled(int itemId, string siteId, bool enabled)
|
||||
{
|
||||
// load organization
|
||||
var org = OrganizationController.GetOrganization(itemId);
|
||||
if (org == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
siteId = RemoveProtocolFromUrl(siteId);
|
||||
|
||||
var webServer = GetWebServer(GetWebServerServiceID(org.PackageId));
|
||||
|
||||
webServer.SetDirectoryBrowseEnabled(siteId, enabled);
|
||||
}
|
||||
|
||||
private static string RemoveProtocolFromUrl(string input)
|
||||
{
|
||||
if (input.Contains("//"))
|
||||
{
|
||||
return System.Text.RegularExpressions.Regex.Split(input, "//")[1];
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static int GetWebServerServiceID(int packageId)
|
||||
{
|
||||
return PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue