public static void FileLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, string actionCode, ActionType logType) { if (fileVerModel == null && fileModel == null) { return; } string remark = string.Empty; Model.UserModel UserInfo = SystemBll.UserInfo; if (logType == ActionType.RENAME) { remark = string.Format("{0}({1})重命名文件:{2}为==>:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name); fileModel = new BLL.FileBll().GetModel(fileModel.ID); remark = remark + fileModel.File_Name; } if (logType == ActionType.ONEDELFILE) { remark = string.Format("{0}({1})删除文件:{2}:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name); } if (fileModel == null && fileVerModel != null) { fileModel = new BLL.FileBll().GetModel(fileVerModel.File_Id); } if (fileModel != null && fileVerModel == null) { FileBll fileBll = new FileBll(); fileVerModel = fileBll.GetFileLastVer(fileModel.ID); } ActionLogAsyn(fileVerModel, fileModel, remark, actionCode, logType); }
/// <summary> /// 文件操作日志 /// </summary> /// <param name="logType"></param> /// <param name="fileModel"></param> public static void FileLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, ActionType logType) { if (fileVerModel == null && fileModel == null) { return; } string remark = string.Empty; if (logType == ActionType.RENAME) { remark = string.Format("文件:{0}重命名为:", fileModel.File_Name); fileModel = new BLL.FileBll().GetModel(fileModel.ID); remark = remark + fileModel.File_Name; } if (fileModel == null && fileVerModel != null) { fileModel = new BLL.FileBll().GetModel(fileVerModel.File_Id); } if (fileModel != null && fileVerModel == null) { FileBll fileBll = new FileBll(); fileVerModel = fileBll.GetFileLastVer(fileModel.ID); } ActionLogAsyn(fileVerModel, fileModel, remark, string.Empty, logType); }
/// <summary> /// 递归检查文件夹和文件 /// </summary> /// <param name="dirInfo"></param> /// <param name="parentId"></param> /// <param name="user"></param> private void CheckFolderDownloadAllFromDb_OtherUser(DirectoryInfo dirInfo, int parentId, string userName, int projectId) { //开始从文件夹获取子文件夹和文件列表 ForderBll forderBll = new ForderBll(); FileBll fileBll = new FileBll(); var subFiles = forderBll.GetSubFiles(parentId, projectId, string.Empty); var files = subFiles; //文件下载 foreach (var item in files) { Application.DoEvents(); var verModel = fileBll.GetFileLastVer(item.ID); if (verModel == null || verModel.Ver <= 0) { continue; } string fileClientPath = string.Format("{0}\\{1}", dirInfo.FullName, item.File_Name); FileInfo clientFileInfo = new FileInfo(fileClientPath); item.ActionNum = 1; AddFileToCache(fileClientPath, item); AddNeedAllDownloadFilesToCache(fileClientPath, item); } var subForders = forderBll.GetSubForders(parentId, projectId); if (subForders != null && subForders.Count > 0) { foreach (var item in subForders) { Application.DoEvents(); string forderPath = string.Format("{0}\\{1}", dirInfo.FullName, item.Title); //文件夹不存在,全部新增 List <Model.FileModel> fileLists = GetAllServerFiles_OtherUser(item); foreach (var subFileItem in fileLists) { AddFileToCache(subFileItem.ClientPath, subFileItem); AddNeedAllUploadFilesToCache(subFileItem.ClientPath, subFileItem); } DirectoryInfo dirItemInfo = new DirectoryInfo(forderPath); //判断文件夹操作 CheckFolderDownloadAllFromDb_OtherUser(dirItemInfo, item.ID, userName, projectId); } } }
/// <summary> /// 递归检查文件夹和文件 /// </summary> /// <param name="dirInfo"></param> /// <param name="parentId"></param> /// <param name="user"></param> private void CheckFolderDownloadAllFromDb(DirectoryInfo dirInfo, int parentId, string userName, int projectId) { //开始从文件夹获取子文件夹和文件列表 ForderBll forderBll = new ForderBll(); FileBll fileBll = new FileBll(); var subFiles = forderBll.GetSubFiles(parentId, projectId, string.Empty); var files = subFiles; //文件下载 foreach (var item in files) { Application.DoEvents(); var verModel = fileBll.GetFileLastVer(item.ID); if (verModel == null || verModel.Ver <= 0) { continue; } string fileClientPath = string.Format("{0}\\{1}", dirInfo.FullName, item.File_Name); FileInfo clientFileInfo = new FileInfo(fileClientPath); if (clientFileInfo.Exists) { if (clientFileInfo.LastAccessTime.Ticks == verModel.File_Modify_Time) { continue; } } //if (clientFileInfo.Exists && clientFileInfo.LastAccessTime.Ticks == item.File_Modify_Time) //{ // continue; //} if (clientFileInfo.Exists) { item.ActionNum = 2; if (verModel.File_Modify_Time == clientFileInfo.LastWriteTime.Ticks) { continue; } AddFileToCache(fileClientPath, item); //服务器文件最新 if (verModel.File_Modify_Time > clientFileInfo.LastWriteTime.Ticks) { AddNeedAllDownloadFilesToCache(fileClientPath, item); } } else { item.ActionNum = 1; AddFileToCache(fileClientPath, item); AddNeedAllDownloadFilesToCache(fileClientPath, item); } } var subForders = forderBll.GetSubForders(parentId, projectId); if (subForders != null && subForders.Count > 0) { foreach (var item in subForders) { Application.DoEvents(); string forderPath = string.Format("{0}\\{1}", dirInfo.FullName, item.Title); if (!Directory.Exists(forderPath)) { //文件夹不存在,全部新增 List <Model.FileModel> fileLists = GetAllServerFiles(item); foreach (var subFileItem in fileLists) { AddFileToCache(subFileItem.ClientPath, subFileItem); AddNeedAllUploadFilesToCache(subFileItem.ClientPath, subFileItem); } //Directory.CreateDirectory(forderPath); } DirectoryInfo dirItemInfo = new DirectoryInfo(forderPath); //判断文件夹操作 CheckFolderDownloadAllFromDb(dirItemInfo, item.ID, userName, projectId); } } }