Beispiel #1
0
        public SystemFile[] GetQuotasForOrganization(SystemFile[] folders)
        {
            var windows = new SolidCP.Providers.OS.Windows2012();

            var quotasArray = new Dictionary <string, Dictionary <string, Quota> >();

            foreach (var folder in folders)
            {
                var parentFolderPath = Directory.GetParent(folder.FullName).ToString();

                var quotas = quotasArray.ContainsKey(parentFolderPath)
                    ? quotasArray[parentFolderPath]
                    : windows.GetQuotasForOrganization(parentFolderPath, string.Empty, string.Empty);

                if (quotas.ContainsKey(folder.FullName) == false)
                {
                    continue;
                }

                var quota = quotas[folder.FullName];

                if (quota != null)
                {
                    folder.Size          = quota.Usage;
                    folder.FsrmQuotaType = quota.QuotaType;

                    if (folder.Size == -1)
                    {
                        folder.Size = FileUtils.BytesToMb(FileUtils.CalculateFolderSize(folder.FullName));
                    }
                }
            }

            return(folders);
        }
Beispiel #2
0
        public SystemFile[] GetFolders(string organizationId, WebDavSetting[] settings)
        {
            ArrayList items = new ArrayList();

            var webDavSettings = GetWebDavSettings(settings);

            foreach (var setting in webDavSettings)
            {
                string rootPath = string.Format("{0}:\\{1}\\{2}", setting.LocationDrive, setting.HomeFolder,
                                                organizationId);

                var windows = new SolidCP.Providers.OS.Windows2012();

                if (Directory.Exists(rootPath))
                {
                    DirectoryInfo root   = new DirectoryInfo(rootPath);
                    IWebDav       webdav = new Web.WebDav(setting);

                    // get directories
                    DirectoryInfo[] dirs   = root.GetDirectories();
                    var             quotas = windows.GetQuotasForOrganization(rootPath, string.Empty, string.Empty);

                    foreach (DirectoryInfo dir in dirs)
                    {
                        string fullName = System.IO.Path.Combine(rootPath, dir.Name);

                        SystemFile folder = new SystemFile();

                        folder.Name        = dir.Name;
                        folder.FullName    = dir.FullName;
                        folder.IsDirectory = true;

                        if (quotas.ContainsKey(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);
                        }
                    }
                }
            }

            return((SystemFile[])items.ToArray(typeof(SystemFile)));
        }
Beispiel #3
0
        public SystemFile GetFolder(string organizationId, string folderName, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            string fullName = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                                            organizationId, folderName);
            SystemFile folder = null;

            var windows = new SolidCP.Providers.OS.Windows2012();

            if (Directory.Exists(fullName))
            {
                DirectoryInfo root = new DirectoryInfo(fullName);

                folder = new SystemFile();

                folder.Name        = root.Name;
                folder.FullName    = root.FullName;
                folder.IsDirectory = true;

                Quota quota = windows.GetQuotaOnFolder(fullName, string.Empty, string.Empty);

                folder.Size = quota.Usage;

                if (folder.Size == -1)
                {
                    folder.Size = FileUtils.BytesToMb(FileUtils.CalculateFolderSize(root.FullName));
                }

                folder.Url           = string.Format("https://{0}/{1}/{2}", webDavSetting.Domain, organizationId, folderName);
                folder.Rules         = GetFolderWebDavRules(organizationId, folderName, webDavSetting);
                folder.FRSMQuotaMB   = quota.Size;
                folder.FRSMQuotaGB   = windows.ConvertMegaBytesToGB(folder.FRSMQuotaMB);
                folder.FsrmQuotaType = quota.QuotaType;
            }

            return(folder);
        }