public virtual object GetNewFileInfo(HttpContext context) { string uid = YZAuthHelper.LoginUserAccount; FileSystem.Folder folder = new FileSystem.Folder(); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { folder.FolderType = "BPAFileAttachments"; folder.ParentID = -1; folder.Name = ""; folder.Desc = ""; folder.Owner = uid; folder.CreateAt = DateTime.Now; folder.OrderIndex = 1; FileSystem.DirectoryManager.Insert(provider, cn, folder); folder.RootID = folder.FolderID; FileSystem.DirectoryManager.Update(provider, cn, folder); } } return(new { fileid = AttachmentManager.GetNewFileID(), folderid = folder.FolderID }); }
public static FileSystem.Folder CreateHierarchy(string rootPath) { string[] subDirectories = null; FileSystem.Folder[] subFolders = null; try { subDirectories = Directory.GetDirectories(rootPath); subFolders = new FileSystem.Folder[subDirectories.Length]; for (int i = 0; i < subDirectories.Length; i++) { subFolders[i] = CreateHierarchy(subDirectories[i]); } } catch (UnauthorizedAccessException e) { return(null); } string[] filePaths = null; FileSystem.File[] files = null; try { filePaths = Directory.GetFiles(rootPath); files = new FileSystem.File[filePaths.Length]; for (int i = 0; i < filePaths.Length; i++) { FileInfo currentFile = new FileInfo(filePaths[i]); if (currentFile.Exists) { files[i] = new FileSystem.File(currentFile.Name, (int)currentFile.Length); } else { files[i] = null; } } } catch (UnauthorizedAccessException e) { } FileSystem.Folder folder = new FileSystem.Folder(rootPath, files, subFolders); return(folder); }
public static void Execute() { FileSystem.Folder folder = CreateHierarchy(SearchingDirectory); Console.WriteLine("Hierarchy created !"); for (int i = 0; i < folder.Folders.Length; i++) { FileSystem.Folder currentFolder = folder.Folders[i]; if (currentFolder != null) { long size = currentFolder.GetFilesSize(); int files = currentFolder.GetFileNumber(); int folders = currentFolder.GetFolderNumber(); Console.WriteLine(currentFolder.Name + " size : " + size); Console.WriteLine(folders + " Folders"); Console.WriteLine(files + " Files"); Console.WriteLine("--- + ---"); } } }
public virtual object GetProcessDefine(HttpContext context) { YZRequest request = new YZRequest(context); string fileid = request.GetString("fileid"); string filePath = AttachmentInfo.FileIDToPath(fileid, AttachmentManager.AttachmentRootPath); string uid = YZAuthHelper.LoginUserAccount; AttachmentInfo attachment; JObject jProcess; if (!System.IO.File.Exists(filePath)) { throw new Exception(String.Format(Resources.YZStrings.Aspx_Upload_FileIDNotFount, fileid)); } using (System.IO.StreamReader rd = new System.IO.StreamReader(filePath)) jProcess = JObject.Parse(rd.ReadToEnd()); bool writable; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { attachment = AttachmentManager.GetAttachmentInfo(provider, cn, fileid); //文件夹 if (attachment.LParam1 == -1) { FileSystem.Folder folder = new FileSystem.Folder(); folder.FolderType = "BPAFileAttachments"; folder.ParentID = -1; folder.Name = ""; folder.Desc = ""; folder.Owner = uid; folder.CreateAt = DateTime.Now; folder.OrderIndex = 1; FileSystem.DirectoryManager.Insert(provider, cn, folder); folder.RootID = folder.FolderID; FileSystem.DirectoryManager.Update(provider, cn, folder); FileSystem.DirectoryManager.Insert(provider, cn, folder); attachment.LParam1 = folder.FolderID; AttachmentManager.Update(provider, cn, attachment); } this.ApplyLinkText(provider, cn, jProcess["Nodes"] as JArray); using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); writable = BPAManager.ISBPAFileWritable(provider, cn, bpmcn, fileid); } } } JObject jProperty = jProcess["Property"] as JObject; if (jProperty != null) { using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); string account; account = (string)jProperty["Creator"]; if (!String.IsNullOrEmpty(account)) { User user = User.TryGetUser(cn, account); jProperty["CreatorShortName"] = user != null ? user.ShortName : account; } account = (string)jProperty["ChangeBy"]; if (!String.IsNullOrEmpty(account)) { User user = User.TryGetUser(cn, account); jProperty["ChangeByShortName"] = user != null ? user.ShortName : account; } } } return(new { attachment = attachment, writable = writable, processDefine = jProcess }); }