Merge
This commit is contained in:
commit
66070ddc66
147 changed files with 223854 additions and 595 deletions
|
@ -4543,6 +4543,69 @@ namespace WebsitePanel.EnterpriseServer
|
|||
);
|
||||
}
|
||||
|
||||
public static void DeleteAllEnterpriseFolderOwaUsers(int itemId, int folderId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"DeleteAllEnterpriseFolderOwaUsers",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@FolderID", folderId)
|
||||
);
|
||||
}
|
||||
|
||||
public static int AddEnterpriseFolderOwaUser(int itemId, int folderId, int accountId)
|
||||
{
|
||||
SqlParameter id = new SqlParameter("@ESOwsaUserId", SqlDbType.Int);
|
||||
id.Direction = ParameterDirection.Output;
|
||||
|
||||
SqlHelper.ExecuteNonQuery(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"AddEnterpriseFolderOwaUser",
|
||||
id,
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@FolderID", folderId),
|
||||
new SqlParameter("@AccountId", accountId)
|
||||
);
|
||||
|
||||
// read identity
|
||||
return Convert.ToInt32(id.Value);
|
||||
}
|
||||
|
||||
public static IDataReader GetEnterpriseFolderOwaUsers(int itemId, int folderId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetEnterpriseFolderOwaUsers",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@FolderID", folderId)
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetEnterpriseFolderId(int itemId, string folderName)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetEnterpriseFolderId",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@FolderName", folderName)
|
||||
);
|
||||
}
|
||||
|
||||
public static IDataReader GetUserEnterpriseFolderWithOwaEditPermission(int itemId, int accountId)
|
||||
{
|
||||
return SqlHelper.ExecuteReader(
|
||||
ConnectionString,
|
||||
CommandType.StoredProcedure,
|
||||
"GetUserEnterpriseFolderWithOwaEditPermission",
|
||||
new SqlParameter("@ItemID", itemId),
|
||||
new SqlParameter("@AccountID", accountId)
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Support Service Levels
|
||||
|
|
|
@ -32,6 +32,7 @@ using System.Collections.Specialized;
|
|||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using WebsitePanel.Providers;
|
||||
using WebsitePanel.Providers.DNS;
|
||||
|
@ -385,7 +386,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
var idn = new IdnMapping();
|
||||
|
||||
if (itemType == typeof(DnsZone))
|
||||
items.AddRange(dns.GetZones().Select(z => idn.GetUnicode(z)));
|
||||
items.AddRange(dns.GetZones().Select(z =>
|
||||
Encoding.UTF8.GetByteCount(z) == z.Length ? // IsASCII
|
||||
idn.GetUnicode(z) : z ));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
|
|
@ -152,6 +152,16 @@ namespace WebsitePanel.EnterpriseServer
|
|||
StartESBackgroundTaskInternal("SET_ENTERPRISE_FOLDER_SETTINGS", itemId, folder, permissions, directoyBrowsingEnabled, quota, quotaType);
|
||||
}
|
||||
|
||||
public static void SetESGeneralSettings(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType)
|
||||
{
|
||||
SetESGeneralSettingsInternal("SET_ENTERPRISE_FOLDER_GENERAL_SETTINGS", itemId, folder, directoyBrowsingEnabled, quota, quotaType);
|
||||
}
|
||||
|
||||
public static void SetESFolderPermissionSettings(int itemId, SystemFile folder, ESPermission[] permissions)
|
||||
{
|
||||
SetESFolderPermissionSettingsInternal("SET_ENTERPRISE_FOLDER_GENERAL_SETTINGS", itemId, folder, permissions);
|
||||
}
|
||||
|
||||
public static int AddWebDavAccessToken(WebDavAccessToken accessToken)
|
||||
{
|
||||
return DataProvider.AddWebDavAccessToken(accessToken);
|
||||
|
@ -257,6 +267,69 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return rootFolders;
|
||||
}
|
||||
|
||||
protected static void SetESGeneralSettingsInternal(string taskName, int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType)
|
||||
{
|
||||
// load organization
|
||||
var org = OrganizationController.GetOrganization(itemId);
|
||||
|
||||
try
|
||||
{
|
||||
TaskManager.StartTask("ENTERPRISE_STORAGE", taskName, org.PackageId);
|
||||
|
||||
EnterpriseStorageController.SetFRSMQuotaOnFolder(itemId, folder.Name, quota, quotaType);
|
||||
EnterpriseStorageController.SetDirectoryBrowseEnabled(itemId, folder.Url, directoyBrowsingEnabled);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log error
|
||||
TaskManager.WriteError(ex, "Error executing enterprise storage background task");
|
||||
}
|
||||
finally
|
||||
{
|
||||
// complete task
|
||||
try
|
||||
{
|
||||
TaskManager.CompleteTask();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static void SetESFolderPermissionSettingsInternal(string taskName, int itemId, SystemFile folder, ESPermission[] permissions)
|
||||
{
|
||||
// load organization
|
||||
var org = OrganizationController.GetOrganization(itemId);
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
TaskManager.StartTask("ENTERPRISE_STORAGE", taskName, org.PackageId);
|
||||
|
||||
EnterpriseStorageController.SetFolderPermission(itemId, folder.Name, permissions);
|
||||
}
|
||||
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 void StartESBackgroundTaskInternal(string taskName, int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, QuotaType quotaType)
|
||||
{
|
||||
// load organization
|
||||
|
@ -1265,6 +1338,87 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return null;
|
||||
}
|
||||
|
||||
public static OrganizationUser[] GetFolderOwaAccounts(int itemId, string folderName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var folderId = GetFolderId(itemId, folderName);
|
||||
|
||||
var users = ObjectUtils.CreateListFromDataReader<OrganizationUser>(DataProvider.GetEnterpriseFolderOwaUsers(itemId, folderId));
|
||||
|
||||
return users.ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetFolderOwaAccounts(int itemId, string folderName, OrganizationUser[] users)
|
||||
{
|
||||
try
|
||||
{
|
||||
var folderId = GetFolderId(itemId, folderName);
|
||||
|
||||
DataProvider.DeleteAllEnterpriseFolderOwaUsers(itemId, folderId);
|
||||
|
||||
foreach (var user in users)
|
||||
{
|
||||
DataProvider.AddEnterpriseFolderOwaUser(itemId, folderId, user.AccountId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
protected static int GetFolderId(int itemId, string folderName)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetFolder(itemId, folderName);
|
||||
|
||||
var dataReader = DataProvider.GetEnterpriseFolderId(itemId, folderName);
|
||||
|
||||
while (dataReader.Read())
|
||||
{
|
||||
return (int)dataReader[0];
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<string> GetUserEnterpriseFolderWithOwaEditPermission(int itemId, List<int> accountIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = new List<string>();
|
||||
|
||||
|
||||
foreach (var accountId in accountIds)
|
||||
{
|
||||
var reader = DataProvider.GetUserEnterpriseFolderWithOwaEditPermission(itemId, accountId);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToString(reader["FolderName"]));
|
||||
}
|
||||
}
|
||||
|
||||
return result.Distinct().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
#region WebDav portal
|
||||
|
||||
public static string GetWebDavPortalUserSettingsByAccountId(int accountId)
|
||||
|
|
|
@ -1074,10 +1074,14 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
private static void CheckNumericQuota(PackageContext cntx, List<string> errors, string quotaName, int currentVal, int val, string messageKey)
|
||||
private static void CheckNumericQuota(PackageContext cntx, List<string> errors, string quotaName, long currentVal, long val, string messageKey)
|
||||
{
|
||||
CheckQuotaValue(cntx, errors, quotaName, currentVal, val, messageKey);
|
||||
}
|
||||
private static void CheckNumericQuota(PackageContext cntx, List<string> errors, string quotaName, int currentVal, int val, string messageKey)
|
||||
{
|
||||
CheckQuotaValue(cntx, errors, quotaName, Convert.ToInt64(currentVal), Convert.ToInt64(val), messageKey);
|
||||
}
|
||||
|
||||
private static void CheckNumericQuota(PackageContext cntx, List<string> errors, string quotaName, int val, string messageKey)
|
||||
{
|
||||
|
@ -1094,7 +1098,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
CheckQuotaValue(cntx, errors, quotaName, 0, -1, messageKey);
|
||||
}
|
||||
|
||||
private static void CheckQuotaValue(PackageContext cntx, List<string> errors, string quotaName, int currentVal, int val, string messageKey)
|
||||
private static void CheckQuotaValue(PackageContext cntx, List<string> errors, string quotaName, long currentVal, long val, string messageKey)
|
||||
{
|
||||
if (!cntx.Quotas.ContainsKey(quotaName))
|
||||
return;
|
||||
|
@ -1111,7 +1115,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
errors.Add(messageKey);
|
||||
else if (quota.QuotaTypeId == 2)
|
||||
{
|
||||
int maxValue = quota.QuotaAllocatedValue - quota.QuotaUsedValue + currentVal;
|
||||
long maxValue = quota.QuotaAllocatedValue - quota.QuotaUsedValue + currentVal;
|
||||
if(val > maxValue)
|
||||
errors.Add(messageKey + ":" + maxValue);
|
||||
}
|
||||
|
@ -1795,8 +1799,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
else if (state == VirtualMachineRequestedState.Reboot)
|
||||
{
|
||||
// shutdown first
|
||||
ResultObject shutdownResult = ChangeVirtualMachineState(itemId, VirtualMachineRequestedState.ShutDown);
|
||||
if(!shutdownResult.IsSuccess)
|
||||
ResultObject shutdownResult = ChangeVirtualMachineState(itemId,
|
||||
VirtualMachineRequestedState.ShutDown);
|
||||
if (!shutdownResult.IsSuccess)
|
||||
{
|
||||
TaskManager.CompleteResultTask(res);
|
||||
return shutdownResult;
|
||||
|
@ -1817,20 +1822,29 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
JobResult result = vps.ChangeVirtualMachineState(machine.VirtualMachineId, state);
|
||||
|
||||
// check return
|
||||
if (result.ReturnValue != ReturnCode.JobStarted)
|
||||
if (result.Job.JobState == ConcreteJobState.Completed)
|
||||
{
|
||||
LogReturnValueResult(res, result);
|
||||
TaskManager.CompleteResultTask(res);
|
||||
TaskManager.CompleteTask();
|
||||
return res;
|
||||
}
|
||||
|
||||
// wait for completion
|
||||
if (!JobCompleted(vps, result.Job))
|
||||
else
|
||||
{
|
||||
LogJobResult(res, result.Job);
|
||||
TaskManager.CompleteResultTask(res);
|
||||
return res;
|
||||
// check return
|
||||
if (result.ReturnValue != ReturnCode.JobStarted)
|
||||
{
|
||||
LogReturnValueResult(res, result);
|
||||
TaskManager.CompleteResultTask(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
// wait for completion
|
||||
if (!JobCompleted(vps, result.Job))
|
||||
{
|
||||
LogJobResult(res, result.Job);
|
||||
TaskManager.CompleteResultTask(res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue