private bool CheckSpecialFileUploadToDb(FileInfo item, int forderId, string userName, int projectId) { string md5 = ""; //上传文件之前判断文件是否已经存在 FileDalEx fileDal = new FileDalEx("FM_"); int fileID = fileDal.GetFileID(this.connection, forderId, item.Name, md5); FileVersionDalEx fVerDal = new FileVersionDalEx("FM_"); //返回文件信息 Model.FileModel file = null; if (fileID > 0) { //判断是否需要创建版本 int curVer = 0; var lastFileVer = fileDal.GetFileLastVer(this.connection, fileID); if (lastFileVer != null) { curVer = lastFileVer.Ver; } //如果文件已经存在相同文件的版本,则忽略上传 if (curVer <= 0 || (lastFileVer != null && lastFileVer.File_Modify_Time < item.LastWriteTime.Ticks)) { return(true); } } else { // 文件不存在 return(true); } return(false); }
/// <summary> /// 单个文件检查 /// </summary> /// <param name="item"></param> private Model.FileModel CheckFileUploadToDb(FileInfo item, int forderId, string userName, int projectId) { //string md5 = GetMD5HashFromFile(item.FullName); string md5 = ""; //上传文件之前判断文件是否已经存在 FileDalEx fileDal = new FileDalEx("FM_"); int fileID = fileDal.GetFileID(this.connection, forderId, item.Name, md5); //int fileID = 1; FileVersionDalEx fVerDal = new FileVersionDalEx("FM_"); //返回文件信息 Model.FileModel file = null; //文件信息不存在,则新建一个 if (fileID > 0) { //判断是否需要创建版本 //int curVer = fileBll.GetFileLastVer(fileID, item.LastWriteTime); int curVer = 0; var lastFileVer = fileDal.GetFileLastVer(this.connection, fileID); if (lastFileVer != null) { curVer = lastFileVer.Ver; } //如果文件已经存在相同文件的版本,则忽略上传 if (curVer <= 0 || (lastFileVer != null && lastFileVer.File_Modify_Time < item.LastWriteTime.Ticks)) { file = new Model.FileModel() { ActionNum = 2, ClientPath = item.FullName, File_Ext = item.Extension, File_Size = (int)item.Length, File_Name = item.Name, File_Modify_Time = item.LastAccessTime.Ticks }; AddNeedAllUploadFilesToCache(item.FullName, file); } } //文件信息不存在,则新建一个 else { file = new Model.FileModel() { ActionNum = 1, ClientPath = item.FullName, File_Ext = item.Extension, File_Size = (int)item.Length, File_Name = item.Name, File_Modify_Time = item.LastAccessTime.Ticks }; AddNeedAllUploadFilesToCache(item.FullName, file); } return(file); }