protected void btnSave_Click(object sender, EventArgs e) { if (!Page.IsValid) return; try { SystemFile folder = new SystemFile { Name = PanelRequest.FolderID }; if (!ES.Services.EnterpriseStorage.CheckEnterpriseStorageInitialization(PanelSecurity.PackageId, PanelRequest.ItemID)) { ES.Services.EnterpriseStorage.CreateEnterpriseStorage(PanelSecurity.PackageId, PanelRequest.ItemID); } ES.Services.EnterpriseStorage.SetFolderOwaAccounts( PanelRequest.ItemID, folder, owaUsers.GetUsers()); Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "enterprisestorage_folders", "ItemID=" + PanelRequest.ItemID)); } catch (Exception ex) { messageBox.ShowErrorMessage("ENTERPRISE_STORAGE_UPDATE_FOLDER_SETTINGS", ex); } }
/// <remarks/> public void SetFolderOwaAccountsAsync(int itemId, SystemFile folder, OrganizationUser[] users) { this.SetFolderOwaAccountsAsync(itemId, folder, users, null); }
private static void GetDirectoriesRecursive(ArrayList folders, string rootFolder, string folder) { // add the current folder SystemFile fi = new SystemFile("\\" + folder, folder, true, 0, DateTime.Now, DateTime.Now); folders.Add(fi); // add children folders string fullPath = System.IO.Path.Combine(rootFolder, folder); DirectoryInfo dir = new DirectoryInfo(fullPath); fi.Created = dir.CreationTime; fi.Changed = dir.LastWriteTime; DirectoryInfo[] subDirs = dir.GetDirectories(); foreach (DirectoryInfo subDir in subDirs) { GetDirectoriesRecursive(folders, rootFolder, System.IO.Path.Combine(folder, subDir.Name)); } }
public static SystemFile[] GetFiles(string path) { ArrayList items = new ArrayList(); DirectoryInfo root = new DirectoryInfo(path); // get directories DirectoryInfo[] dirs = root.GetDirectories(); foreach (DirectoryInfo dir in dirs) { string fullName = System.IO.Path.Combine(path, dir.Name); SystemFile fi = new SystemFile(dir.Name, fullName, true, 0, dir.CreationTime, dir.LastWriteTime); items.Add(fi); // check if the directory is empty fi.IsEmpty = (Directory.GetFileSystemEntries(fullName).Length == 0); } // get files FileInfo[] files = root.GetFiles(); foreach (FileInfo file in files) { string fullName = System.IO.Path.Combine(path, file.Name); SystemFile fi = new SystemFile(file.Name, fullName, false, file.Length, file.CreationTime, file.LastWriteTime); items.Add(fi); } return (SystemFile[])items.ToArray(typeof(SystemFile)); }
public OrganizationUser[] GetFolderOwaAccounts(int itemId, SystemFile folder) { return EnterpriseStorageController.GetFolderOwaAccounts(itemId, folder.Name); }
public void SetEnterpriseFolderGeneralSettings(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType) { EnterpriseStorageController.SetESGeneralSettings(itemId, folder, directoyBrowsingEnabled, quota, quotaType); }
public List<SystemFile> GetSystemSubFolders(string path) { DirectoryInfo rootDir = new DirectoryInfo(path); DirectoryInfo[] subdirs = rootDir.GetDirectories(); var folders = new List<SystemFile>(); foreach (var subdir in subdirs) { var folder = new SystemFile(); folder.Name = subdir.FullName; folders.Add(folder); } return folders; }
public SystemFile[] Search(string[] searchPaths, string searchText, bool recursive) { var result = new List<SystemFile>(); using (var conn = new OleDbConnection("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';")) { var wsSql = string.Format( @"SELECT System.FileName, System.DateModified, System.Size, System.Kind, System.ItemPathDisplay, System.ItemType, System.Search.AutoSummary FROM SYSTEMINDEX WHERE System.FileName LIKE '%{0}%' AND ({1})", searchText, string.Join(" OR ", searchPaths.Select(x => string.Format("{0} = '{1}'", recursive ? "SCOPE" : "DIRECTORY", x)).ToArray())); conn.Open(); var cmd = new OleDbCommand(wsSql, conn); using (OleDbDataReader reader = cmd.ExecuteReader()) { while (reader != null && reader.Read()) { var file = new SystemFile {Name = reader[0] as string}; file.Changed = file.CreatedDate = reader[1] is DateTime ? (DateTime) reader[1] : new DateTime(); file.Size = reader[2] is Decimal ? Convert.ToInt64((Decimal) reader[2]) : 0; var kind = reader[3] is IEnumerable ? ((IEnumerable) reader[3]).Cast<string>().ToList() : null; var itemType = reader[5] as string ?? string.Empty; if (kind != null && kind.Any() && itemType.ToLowerInvariant() != ".zip") { file.IsDirectory = kind.Any(x => x == "folder"); } file.FullName = (reader[4] as string ?? string.Empty); file.Summary = SanitizeXmlString(reader[6] as string); result.Add(file); } } } return result.ToArray(); }
private void BindPath() { List<SystemFile> pathList = new List<SystemFile>(); // add "Home" link SystemFile item = new SystemFile(GetLocalizedString("Home.Text"), "\\", false, 0, DateTime.Now, DateTime.Now); pathList.Add(item); string currPath = Server.HtmlDecode(litPath.Text).Substring(1); if (currPath != "") { string[] pathParts = currPath.Split(new char[] { '\\', '/' }); for (int i = 0; i < pathParts.Length; i++) { string subPath = "\\" + String.Join("\\", pathParts, 0, i + 1); item = new SystemFile(pathParts[i], subPath, false, 0, DateTime.Now, DateTime.Now); pathList.Add(item); } } path.DataSource = pathList; path.DataBind(); }
public SystemFile[] GetQuotasForOrganization(SystemFile[] folders) { try { Log.WriteStart("'{0}' GetQuotasForOrganization", ProviderSettings.ProviderName); var newFolders = EnterpriseStorageProvider.GetQuotasForOrganization(folders); Log.WriteEnd("'{0}' GetQuotasForOrganization", ProviderSettings.ProviderName); return newFolders; } catch (Exception ex) { Log.WriteError(String.Format("'{0}' GetQuotasForOrganization", ProviderSettings.ProviderName), ex); throw; } }
/// <remarks/> public void GetQuotasForOrganizationAsync(SystemFile[] folders, object userState) { if ((this.GetQuotasForOrganizationOperationCompleted == null)) { this.GetQuotasForOrganizationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetQuotasForOrganizationOperationCompleted); } this.InvokeAsync("GetQuotasForOrganization", new object[] { folders}, this.GetQuotasForOrganizationOperationCompleted, userState); }
/// <remarks/> public void GetQuotasForOrganizationAsync(SystemFile[] folders) { this.GetQuotasForOrganizationAsync(folders, null); }
/// <remarks/> public System.IAsyncResult BeginGetQuotasForOrganization(SystemFile[] folders, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetQuotasForOrganization", new object[] { folders}, callback, asyncState); }
public SystemFile[] GetQuotasForOrganization(SystemFile[] folders) { object[] results = this.Invoke("GetQuotasForOrganization", new object[] { folders}); return ((SystemFile[])(results[0])); }
/// <remarks/> public void SetFolderOwaAccountsAsync(int itemId, SystemFile folder, OrganizationUser[] users, object userState) { if ((this.SetFolderOwaAccountsOperationCompleted == null)) { this.SetFolderOwaAccountsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetFolderOwaAccountsOperationCompleted); } this.InvokeAsync("SetFolderOwaAccounts", new object[] { itemId, folder, users}, this.SetFolderOwaAccountsOperationCompleted, userState); }
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); var esFolder = ObjectUtils.FillObjectFromDataReader<EsFolder>(DataProvider.GetEnterpriseFolder(itemId, folder.Name)); if (esFolder.StorageSpaceFolderId != null) { StorageSpacesController.SetFolderNtfsPermissions(esFolder.StorageSpaceId, esFolder.Path, ConvertToUserPermissions(itemId, permissions.ToArray()), true, false); } } catch (Exception ex) { // log error TaskManager.WriteError(ex, "Error executing Cloud Folders 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 var org = OrganizationController.GetOrganization(itemId); new Thread(() => { try { TaskManager.StartTask("ENTERPRISE_STORAGE", taskName, org.PackageId); EnterpriseStorageController.SetFRSMQuotaOnFolder(itemId, folder.Name, quota, quotaType); EnterpriseStorageController.SetFolderPermission(itemId, folder.Name, permissions); } catch (Exception ex) { // log error TaskManager.WriteError(ex, "Error executing Cloud Folders background task"); } finally { // complete task try { TaskManager.CompleteTask(); } catch (Exception) { } } }).Start(); }
private static void UpdateFolderDriveMapPath(int itemId, SystemFile folder, string newFolder) { // load organization Organization org = OrganizationController.GetOrganization(itemId); if (org == null) { return; } Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId); var mappedDrive = GetFolderMappedDrive(orgProxy.GetDriveMaps(org.OrganizationId), folder); if (mappedDrive != null) { var oldFolderDriveMapPath = mappedDrive.Path; var newPath = GetDriveMapPath(itemId, org.OrganizationId, newFolder); ChangeDriveMapFolderPath(itemId, oldFolderDriveMapPath, newPath); } }
public List<SystemFile> GetAllDriveLetters() { DriveInfo[] drives = DriveInfo.GetDrives(); var folders = new List<SystemFile>(); foreach (var drive in drives) { var folder = new SystemFile(); folder.Name = drive.Name; folders.Add(folder); } return folders; }
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); }
public void SetEnterpriseFolderSettings(int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, QuotaType quotaType) { EnterpriseStorageController.StartSetEnterpriseFolderSettingsBackgroundTask(itemId, folder, permissions, directoyBrowsingEnabled, quota, quotaType); }
private static SystemFile ConvertToSystemFile(EsFolder esfolder, string organizationId) { string fullName = esfolder.StorageSpaceFolderId == null ? System.IO.Path.Combine(string.Format("{0}:\\{1}\\{2}", esfolder.LocationDrive, esfolder.HomeFolder, organizationId), esfolder.FolderName) : esfolder.Path; var folder = new SystemFile(); folder.Name = esfolder.FolderName; folder.FullName = fullName; folder.IsDirectory = true; folder.Url = string.Format("https://{0}/{1}/{2}", esfolder.Domain, organizationId, esfolder.FolderName); folder.FRSMQuotaMB = esfolder.FolderQuota; folder.UncPath = esfolder.UncPath; folder.FRSMQuotaGB = ConvertMegaBytesToGB(esfolder.FolderQuota); folder.StorageSpaceFolderId = esfolder.StorageSpaceFolderId; return folder; }
public void SetEnterpriseFolderPermissionSettings(int itemId, SystemFile folder, ESPermission[] permissions) { EnterpriseStorageController.SetESFolderPermissionSettings(itemId, folder, permissions); }
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 void SetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users) { EnterpriseStorageController.SetFolderOwaAccounts(itemId, folder.Name, users); }
public static void SetESFolderPermissionSettings(int itemId, SystemFile folder, ESPermission[] permissions) { SetESFolderPermissionSettingsInternal("SET_ENTERPRISE_FOLDER_GENERAL_SETTINGS", itemId, folder, permissions); }
private static void GetFilesList(ArrayList files, string rootFolder, string folder, string pattern) { string fullPath = System.IO.Path.Combine(rootFolder, folder); // add files in the current folder FileInfo[] dirFiles = new DirectoryInfo(fullPath).GetFiles(pattern); foreach (FileInfo file in dirFiles) { SystemFile fi = new SystemFile(folder + "\\" + file.Name, file.Name, false, file.Length, file.CreationTime, file.LastWriteTime); files.Add(fi); } // add children folders DirectoryInfo[] dirs = new DirectoryInfo(fullPath).GetDirectories(); foreach (DirectoryInfo dir in dirs) { GetFilesList(files, rootFolder, System.IO.Path.Combine(folder, dir.Name), pattern); } }
private static MappedDrive GetFolderMappedDrive(IEnumerable<MappedDrive> drives, SystemFile folder) { foreach (MappedDrive drive in drives) { var name = folder.StorageSpaceFolderId == null ? folder.Name : folder.UncPath.Split('\\').Last(); if (drive.Path.Split('\\').Last() == name) { drive.Folder = folder; return drive; } } return null; }
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); var esFolder = ObjectUtils.FillObjectFromDataReader<EsFolder>(DataProvider.GetEnterpriseFolder(itemId, folder.Name)); if (esFolder.StorageSpaceFolderId == null) { EnterpriseStorageController.SetFRSMQuotaOnFolder(itemId, folder.Name, quota, quotaType); } else { StorageSpacesController.SetStorageSpaceFolderQuota(esFolder.StorageSpaceId, esFolder.StorageSpaceFolderId.Value, (long)quota * 1024 * 1024, quotaType); DataProvider.UpdateEnterpriseFolder(itemId, folder.Name, folder.Name, quota); } } catch (Exception ex) { // log error TaskManager.WriteError(ex, "Error executing cloud folders background task"); } finally { // complete task try { TaskManager.CompleteTask(); } catch (Exception) { } } }
/// <remarks/> public System.IAsyncResult BeginSetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("SetFolderOwaAccounts", new object[] { itemId, folder, users}, callback, asyncState); }