public static void Delete(FileSystemItem file) { if (file.IsFolder) { List<FileSystemItem> childFolders = GetAll().FindAll(item => item.IsFolder && item.ParentId == file.FileId); if (childFolders != null && childFolders.Count > 0) { foreach (var childFolder in childFolders) { Delete(childFolder); } } List<FileSystemItem> files = GetAll().FindAll(item => item.ParentId == file.FileId); if (files != null && files.Count > 0) { foreach (var item in files) { Delete(item); } } } if (service.Delete(file.FileId).IsSuccess) { GetAll().Remove(file); } }
protected string GetRelativeName(FileSystemItem item) { if (item.FileId == RootItemId) return string.Empty; if (item.ParentId == RootItemId) return item.Name; if(!FolderCache.ContainsKey((int)item.ParentId)) return null; string name = GetRelativeName(FolderCache[(int)item.ParentId]); return name == null ? null : Path.Combine(name,item.Name); }
public string GetRelativeName(FileSystemItem item) { //if (item.FileId == RootItemId) return string.Empty; //if (item.ParentId == RootItemId) return item.Name; //if (!FolderCache.ContainsKey((int)item.ParentId)) return null; //var parent = FolderCache[(int)item.ParentId]; //string name = GetRelativeName(FolderCache[(int)item.ParentId]); //return name == null ? null : Path.Combine(name, item.Name); if (item.FileId == RootItemId) return string.Empty; if (item.ParentId == RootItemId) return item.Name; if (!FolderCache.ContainsKey((int)item.ParentId)) return null; //var parent = FolderCache[(int)item.ParentId]; string name = GetRelativeName(FolderCache[(int)item.ParentId]); //if (parent.ParentId != -1 && parent.FileId > 1) //{ // name = Path.Combine(GetRelativeName(FolderCache[(int)parent.ParentId]), name); //} string result = name == null ? null : Path.Combine(name, item.Name); return result; }
public static void Update(FileSystemItem file) { service.Save(new SaveProcessBlueprintRequest { Id = file.FileId, ParentId = file.ParentId, IsFolder = file.IsFolder, Name = file.Name, Data = file.Data, LastWriteTime = file.LastWriteTime, UserId = sessionData.UserId }); }
public static void Insert(FileSystemItem file) { var response = service.Save(new SaveProcessBlueprintRequest { IsFolder = file.IsFolder, ParentId = file.ParentId, Name = file.Name, Data = file.Data, LastWriteTime = file.LastWriteTime, UserId = sessionData.UserId }); if (response.IsSuccess) { file.FileId = response.Id; GetAll().Add(file); AddDefaultPrivilege(response.Id); } }
public ActionResult ProcessConfigPartial(string relativePath, bool? isFileSelected) { string selecetedFile = string.Empty; FileSystemItem item = new FileSystemItem(); if (!string.IsNullOrEmpty(relativePath)) { string[] val = relativePath.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray(); for (int i = 0; i < val.Length; i++) { selecetedFile = Path.Combine(selecetedFile, val[i]); } var provider = ProcessBlueprintControllerProcessBlueprintSettings.ProcessBlueprintFileSystemProvider; if (isFileSelected.HasValue && isFileSelected.Value == true) { var file = new FileManagerFile(provider, selecetedFile); item = ProcessBlueprintControllerProcessBlueprintSettings.ProcessBlueprintFileSystemProvider.GetFile(file); } else { var folder = new FileManagerFolder(provider, selecetedFile); item = ProcessBlueprintControllerProcessBlueprintSettings.ProcessBlueprintFileSystemProvider.GetFolder(folder); } } //FileManagerFile file = ProcessBlueprintControllerProcessBlueprintSettings.ProcessBlueprintFileSystemProvider.GetFile() return PartialView("_PrivilegeConfigPartial", item); }
public PartialViewResult PrivilegeViewPartialView(FileSystemItem model) { List<FileManagerRolePrivilegeViewModel> models = new List<FileManagerRolePrivilegeViewModel>(); ///todo create matrix of file vs role vs privilege if (model != null && model.FileId > 0) { var data = ProcessBlueprintDataProvider.service.GetPrivileges(new Services.Requests.ProcessBlueprint.GetProcessBlueprintPrivilegeRequest { FileId = model.FileId }); if (data.IsSuccess) { models = data.FileManagerRolePrivileges.ToList().MapTo<FileManagerRolePrivilegeViewModel>(); } } return PartialView("_PrivilegePartial", models); }