WebDav Performance issues fixed

This commit is contained in:
vfedosevich 2014-03-05 12:14:41 -08:00
parent 5cf9bfa4bb
commit 22745dde02
3 changed files with 69 additions and 14 deletions

View file

@ -81,6 +81,8 @@ namespace WebsitePanel.Providers.EnterpriseStorage
// get directories // get directories
DirectoryInfo[] dirs = root.GetDirectories(); DirectoryInfo[] dirs = root.GetDirectories();
var quotas = windows.GetQuotasForOrganization(rootPath, string.Empty, string.Empty);
foreach (DirectoryInfo dir in dirs) foreach (DirectoryInfo dir in dirs)
{ {
string fullName = System.IO.Path.Combine(rootPath, dir.Name); string fullName = System.IO.Path.Combine(rootPath, dir.Name);
@ -91,22 +93,23 @@ namespace WebsitePanel.Providers.EnterpriseStorage
folder.FullName = dir.FullName; folder.FullName = dir.FullName;
folder.IsDirectory = true; folder.IsDirectory = true;
Quota quota = windows.GetQuotaOnFolder(fullName, string.Empty, string.Empty); if (quotas.ContainsKey(fullName))
folder.Size = quota.Usage;
if (folder.Size == -1)
{ {
folder.Size = FileUtils.BytesToMb(FileUtils.CalculateFolderSize(dir.FullName)); folder.Size = quotas[fullName].Usage;
if (folder.Size == -1)
{
folder.Size = FileUtils.BytesToMb(FileUtils.CalculateFolderSize(dir.FullName));
}
folder.Url = string.Format("https://{0}/{1}/{2}", setting.Domain, organizationId, dir.Name);
folder.Rules = webdav.GetFolderWebDavRules(organizationId, dir.Name);
folder.FRSMQuotaMB = quotas[fullName].Size;
folder.FRSMQuotaGB = windows.ConvertMegaBytesToGB(folder.FRSMQuotaMB);
folder.FsrmQuotaType = quotas[fullName].QuotaType;
items.Add(folder);
} }
folder.Url = string.Format("https://{0}/{1}/{2}", setting.Domain, organizationId, dir.Name);
folder.Rules = webdav.GetFolderWebDavRules(organizationId, dir.Name);
folder.FRSMQuotaMB = quota.Size;
folder.FRSMQuotaGB = windows.ConvertMegaBytesToGB(folder.FRSMQuotaMB);
folder.FsrmQuotaType = quota.QuotaType;
items.Add(folder);
} }
} }
} }

View file

@ -220,6 +220,11 @@ namespace WebsitePanel.Providers.OS
throw new NotImplementedException(); throw new NotImplementedException();
} }
public virtual Dictionary<string, Quota> GetQuotasForOrganization(string folderPath, string wmiUserName, string wmiPassword)
{
throw new NotImplementedException();
}
public virtual void DeleteDirectoryRecursive(string rootPath) public virtual void DeleteDirectoryRecursive(string rootPath)
{ {
FileUtils.DeleteDirectoryRecursive(rootPath); FileUtils.DeleteDirectoryRecursive(rootPath);

View file

@ -175,6 +175,53 @@ namespace WebsitePanel.Providers.OS
return quota; return quota;
} }
public override Dictionary<string, Quota> GetQuotasForOrganization(string folderPath, string wmiUserName, string wmiPassword)
{
Log.WriteStart("GetQuotasLimitsForOrganization");
Runspace runSpace = null;
Quota quota = null;
var quotas = new Dictionary<string, Quota>();
try
{
runSpace = OpenRunspace();
Command cmd = new Command("Get-FsrmQuota");
cmd.Parameters.Add("Path", folderPath + "\\*");
var result = ExecuteShellCommand(runSpace, cmd, false);
if (result.Count > 0)
{
foreach (var element in result)
{
quota = new Quota();
quota.Size = ConvertBytesToMB(Convert.ToInt64(GetPSObjectProperty(element, "Size")));
quota.QuotaType = Convert.ToBoolean(GetPSObjectProperty(element, "SoftLimit")) ? QuotaType.Soft : QuotaType.Hard;
quota.Usage = ConvertBytesToMB(Convert.ToInt64(GetPSObjectProperty(element, "usage")));
quotas.Add(Convert.ToString(GetPSObjectProperty(element, "Path")), quota);
}
}
}
catch (Exception ex)
{
Log.WriteError("GetQuotasLimitsForOrganization", ex);
throw;
}
finally
{
CloseRunspace(runSpace);
}
Log.WriteEnd("GetQuotasLimitsForOrganization");
return quotas;
}
public UInt64 CalculateQuota(string quota) public UInt64 CalculateQuota(string quota)
{ {
UInt64 OneKb = 1024; UInt64 OneKb = 1024;