public Result UploadQaFile(byte[] qaFile, string qaFolderName, string account, string fileExtension, string qaFileName) { var result = new Result(); var saveToUrl = @ParameterAPI.GetConfig("ShareQAFile").ConfigValue + @"\\" + account + @"\\" + qaFolderName + @"\\" + qaFileName + "." + fileExtension; try { var pcbEntities = new PCBEntities(); var pcbQaFolderTb = pcbEntities.PCB_QAFolderTB.FirstOrDefault(p => p.QAFolderName == qaFolderName && p.CreateAccount == account); if (pcbQaFolderTb == null || pcbQaFolderTb == default(PCB_QAFolderTB)) { result.IsOK = false; result.Description = "找不到该目录"; return(result); } var count = pcbEntities.PCB_QAFileTB.Count <PCB_QAFileTB>(p => p.QAFolderID == pcbQaFolderTb.QAFolderID && p.CreateAccount == account && p.QAFileName == qaFileName && p.FileExtension == fileExtension); if (count > 0) { result.IsOK = false; result.Description = "该目录已经存在改文件"; return(result); } result = Common.Common.FileWrite(saveToUrl, qaFile); if (!result.IsOK) { return(result); } var pcbQaFileTb = new PCB_QAFileTB(); pcbQaFileTb.QAFileID = Guid.NewGuid(); pcbQaFileTb.QAFolderID = pcbQaFolderTb.QAFolderID; pcbQaFileTb.QAFileName = qaFileName; pcbQaFileTb.QAFileURL = ParameterAPI.GetConfig("DowLoadShareFileURL").ConfigValue + "//" + account + "//" + qaFolderName + "//" + qaFileName + "." + fileExtension; pcbQaFileTb.FileExtension = fileExtension; pcbQaFileTb.CreateAccount = account; pcbQaFileTb.FileMD5 = Common.Common.GetMD5Hash(qaFile); pcbQaFileTb.FileSize = qaFile.Length.ToString(); pcbQaFileTb.CreateDateTime = DateTime.Now; pcbEntities.AddToPCB_QAFileTB(pcbQaFileTb); result.IsOK = Convert.ToBoolean(pcbEntities.SaveChanges()); if (!result.IsOK) { File.Delete(saveToUrl); result.Description = "上传失败"; return(result); } } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }