public ActionResult ToTargetContent(string keyValue, int mode) { //当前用户 Operator curUser = OperatorProvider.Provider.Current(); var entity = findquestioninfobll.GetEntity(keyValue); //发现问题对象 var userInfo = userbll.GetUserInfoEntity(entity.CREATEUSERID); //创建人对象 List <FileInfoEntity> filelist = fileinfobll.GetImageListByObject(entity.QUESTIONPIC).ToList(); //问题图片集合 string resultMsg = string.Empty; //返回结果信息 bool isSucess = false; //创建流程是否成功 bool isSucessful = true; //返回流程推进结果 string wfFlag = string.Empty; //流程流转标记 string participant = string.Empty; //下一步流程参与者 string workFlow = string.Empty; //流程实例代码 string applicationId = string.Empty; //关联的应用id string applicationType = string.Empty; //关联的应用类型 WfControlObj wfentity = new WfControlObj(); WfControlResult result = new WfControlResult(); switch (mode) { //转隐患 case 0: applicationType = "yh"; #region 转隐患 string HidCode = DateTime.Now.ToString("yyyyMMddHHmmssfff").ToString(); try { #region 隐患基本信息 HTBaseInfoEntity bentity = new HTBaseInfoEntity(); bentity.ADDTYPE = "0"; bentity.CREATEUSERID = userInfo.UserId; bentity.CREATEUSERNAME = userInfo.RealName; bentity.CREATEUSERDEPTCODE = userInfo.DepartmentCode; bentity.CREATEUSERORGCODE = userInfo.OrganizeCode; bentity.HIDCODE = HidCode; bentity.HIDDEPART = userInfo.OrganizeId; bentity.HIDDEPARTNAME = userInfo.OrganizeName; bentity.HIDPHOTO = Guid.NewGuid().ToString(); //图片 foreach (FileInfoEntity fentity in filelist) { string sourcefile = Server.MapPath(fentity.FilePath); string targetFileName = Guid.NewGuid().ToString() + "." + fentity.FileType; string targetUrl = fentity.FilePath.Substring(0, fentity.FilePath.LastIndexOf("/")); if (System.IO.File.Exists(sourcefile)) { System.IO.FileInfo sfileInfo = new System.IO.FileInfo(sourcefile); string targetDir = sfileInfo.DirectoryName; string targetFile = targetDir + "\\" + targetFileName; System.IO.File.Copy(sourcefile, targetFile); } FileInfoEntity newfileEntity = new FileInfoEntity(); newfileEntity = fentity; newfileEntity.FilePath = targetUrl + "/" + targetFileName; newfileEntity.FileId = string.Empty; newfileEntity.RecId = bentity.HIDPHOTO; fileinfobll.SaveForm("", newfileEntity); } bentity.HIDBMID = entity.DEPTID; //所属部门id bentity.HIDBMNAME = entity.DEPTNAME; //所属部门名称 bentity.HIDDESCRIBE = entity.QUESTIONCONTENT; //隐患描述(问题内容) //排查信息 bentity.CHECKDATE = DateTime.Now; bentity.CHECKMAN = userInfo.UserId; bentity.CHECKMANNAME = userInfo.RealName; bentity.CHECKDEPARTID = userInfo.DepartmentCode; bentity.CHECKDEPARTNAME = userInfo.DeptName; //bentity.CHECKTYPE = dataitemdetailbll.GetDataItemListByItemCode("'SaftyCheckType'").Where(p => p.ItemName.Contains("日常")).FirstOrDefault().ItemDetailId; //检查类型 //添加 htbaseinfobll.SaveForm("", bentity); applicationId = bentity.ID; #endregion #region 创建隐患流程 workFlow = "01"; //隐患处理 isSucess = htworkflowbll.CreateWorkFlowObj(workFlow, applicationId, userInfo.UserId); if (isSucess) { htworkflowbll.UpdateWorkStreamByObjectId(applicationId); //更新业务流程状态 } #endregion #region 整改信息 HTChangeInfoEntity centity = new HTChangeInfoEntity(); centity.HIDCODE = HidCode; htchangeinfobll.SaveForm("", centity); #endregion #region 验收信息 HTAcceptInfoEntity aentity = new HTAcceptInfoEntity(); aentity.HIDCODE = HidCode; htacceptinfobll.SaveForm("", aentity); #endregion #region 推进流程 wfentity.businessid = applicationId; //隐患主键 wfentity.argument1 = string.Empty; //专业分类 wfentity.argument2 = userInfo.DepartmentId; //当前部门 wfentity.argument3 = string.Empty; //隐患类别 wfentity.argument4 = bentity.HIDBMID; //所属部门 wfentity.startflow = "隐患登记"; wfentity.submittype = "提交"; wfentity.rankid = string.Empty; wfentity.spuser = userInfo; wfentity.mark = "厂级隐患排查"; wfentity.organizeid = bentity.HIDDEPART; //对应电厂id //获取下一流程的操作人 result = wfcontrolbll.GetWfControl(wfentity); //处理成功 if (result.code == WfCode.Sucess) { participant = result.actionperson; wfFlag = result.wfflag; if (!string.IsNullOrEmpty(participant)) { int count = htworkflowbll.SubmitWorkFlow(wfentity, result, applicationId, participant, wfFlag, userInfo.UserId); if (count > 0) { htworkflowbll.UpdateWorkStreamByObjectId(applicationId); //更新业务流程状态 } } else { isSucessful = false; resultMsg = "请联系系统管理员,添加本单位及相关单位评估人员!"; } resultMsg = "已成功转为隐患,并进入对应流程,请知晓"; } else { isSucessful = false; resultMsg = result.message; } #endregion } catch (Exception ex) { isSucessful = false; resultMsg = ex.Message; } #endregion break; //转违章 case 1: applicationType = "wz"; #region 转违章 try { #region 违章基础信息 string lenNum = !string.IsNullOrEmpty(dataitemdetailbll.GetItemValue("LllegalSerialNumberLen")) ? dataitemdetailbll.GetItemValue("LllegalSerialNumberLen") : "3"; LllegalRegisterEntity wzentity = new LllegalRegisterEntity(); wzentity.ADDTYPE = "0"; wzentity.LLLEGALNUMBER = lllegalregisterbll.GenerateHidCode("bis_lllegalregister", "lllegalnumber", int.Parse(lenNum)); //违章编码 wzentity.CREATEUSERID = userInfo.UserId; wzentity.CREATEUSERNAME = userInfo.RealName; wzentity.CREATEUSERDEPTCODE = userInfo.DepartmentCode; wzentity.CREATEUSERORGCODE = userInfo.OrganizeCode; wzentity.CREATEDEPTID = userInfo.DepartmentId; wzentity.CREATEDEPTNAME = userInfo.DeptName; //所属单位 wzentity.BELONGDEPARTID = userInfo.OrganizeId; wzentity.BELONGDEPART = userInfo.OrganizeName; wzentity.LLLEGALPIC = Guid.NewGuid().ToString(); foreach (FileInfoEntity fentity in filelist) { string sourcefile = Server.MapPath(fentity.FilePath); string targetFileName = Guid.NewGuid().ToString() + "." + fentity.FileType; string targetUrl = fentity.FilePath.Substring(0, fentity.FilePath.LastIndexOf("/")); if (System.IO.File.Exists(sourcefile)) { System.IO.FileInfo sfileInfo = new System.IO.FileInfo(sourcefile); string targetDir = sfileInfo.DirectoryName; string targetFile = targetDir + "\\" + targetFileName; System.IO.File.Copy(sourcefile, targetFile); } FileInfoEntity newfileEntity = new FileInfoEntity(); newfileEntity = fentity; newfileEntity.FilePath = targetUrl + "/" + targetFileName; newfileEntity.FileId = string.Empty; newfileEntity.RecId = wzentity.LLLEGALPIC; fileinfobll.SaveForm("", newfileEntity); } wzentity.LLLEGALDESCRIBE = entity.QUESTIONCONTENT; lllegalregisterbll.SaveForm("", wzentity); applicationId = wzentity.ID; #endregion #region 创建流程 workFlow = "03"; isSucess = htworkflowbll.CreateWorkFlowObj(workFlow, applicationId, userInfo.UserId); if (isSucess) { lllegalregisterbll.UpdateFlowStateByObjectId("bis_lllegalregister", "flowstate", applicationId); //更新业务流程状态 } #endregion if (!string.IsNullOrEmpty(wzentity.ID)) { wzentity = lllegalregisterbll.GetEntity(wzentity.ID); } #region 违章整改信息 LllegalReformEntity reformEntity = new LllegalReformEntity(); reformEntity.LLLEGALID = applicationId; lllegalreformbll.SaveForm("", reformEntity); #endregion #region 违章验收信息 LllegalAcceptEntity acceptEntity = new LllegalAcceptEntity(); acceptEntity.LLLEGALID = applicationId; lllegalacceptbll.SaveForm("", acceptEntity); #endregion #region 推进流程 wfentity.businessid = applicationId; //主键 wfentity.argument3 = userInfo.DepartmentId; //当前部门id wfentity.startflow = wzentity.FLOWSTATE; wfentity.submittype = "提交"; wfentity.rankid = null; wfentity.spuser = userInfo; wfentity.mark = "厂级违章流程"; wfentity.organizeid = wzentity.BELONGDEPARTID; //对应电厂id //获取下一流程的操作人 result = wfcontrolbll.GetWfControl(wfentity); //处理成功 if (result.code == WfCode.Sucess) { participant = result.actionperson; wfFlag = result.wfflag; //提交流程到下一节点 if (!string.IsNullOrEmpty(participant)) { int count = htworkflowbll.SubmitWorkFlow(wfentity, result, applicationId, participant, wfFlag, userInfo.UserId); if (count > 0) { htworkflowbll.UpdateFlowStateByObjectId("bis_lllegalregister", "flowstate", applicationId); //更新业务流程状态 } } resultMsg = "已成功转为违章,并进入对应流程,请知晓"; } else { isSucessful = false; resultMsg = result.message; } #endregion } catch (Exception ex) { isSucessful = false; resultMsg = ex.Message; } #endregion break; //转问题 case 2: applicationType = "wt"; #region 转问题 try { #region 基础信息 QuestionInfoEntity qtEntity = new QuestionInfoEntity(); qtEntity.QUESTIONNUMBER = questioninfobll.GenerateCode("bis_questioninfo", "questionnumber", 4); qtEntity.CREATEUSERID = userInfo.UserId; qtEntity.CREATEUSERNAME = userInfo.RealName; qtEntity.CREATEUSERDEPTCODE = userInfo.DepartmentCode; qtEntity.CREATEUSERORGCODE = userInfo.OrganizeCode; qtEntity.BELONGDEPTID = userInfo.OrganizeId; qtEntity.BELONGDEPTNAME = userInfo.OrganizeName; qtEntity.QUESTIONPIC = Guid.NewGuid().ToString(); foreach (FileInfoEntity fentity in filelist) { string sourcefile = Server.MapPath(fentity.FilePath); string targetFileName = Guid.NewGuid().ToString() + "." + fentity.FileType; string targetUrl = fentity.FilePath.Substring(0, fentity.FilePath.LastIndexOf("/")); if (System.IO.File.Exists(sourcefile)) { System.IO.FileInfo sfileInfo = new System.IO.FileInfo(sourcefile); string targetDir = sfileInfo.DirectoryName; string targetFile = targetDir + "\\" + targetFileName; System.IO.File.Copy(sourcefile, targetFile); } FileInfoEntity newfileEntity = new FileInfoEntity(); newfileEntity = fentity; newfileEntity.FilePath = targetUrl + "/" + targetFileName; newfileEntity.FileId = string.Empty; newfileEntity.RecId = qtEntity.QUESTIONPIC; fileinfobll.SaveForm("", newfileEntity); } qtEntity.QUESTIONDESCRIBE = entity.QUESTIONCONTENT; qtEntity.CHECKDATE = DateTime.Now; qtEntity.CHECKPERSONID = userInfo.UserId; qtEntity.CHECKPERSONNAME = userInfo.RealName; qtEntity.CHECKDEPTID = userInfo.DepartmentId; qtEntity.CHECKDEPTNAME = userInfo.DeptName; //qtEntity.CHECKTYPE = dataitemdetailbll.GetDataItemListByItemCode("'SaftyCheckType'").Where(p => p.ItemName.Contains("日常")).FirstOrDefault().ItemDetailId; //检查类型 questioninfobll.SaveForm("", qtEntity); applicationId = qtEntity.ID; #endregion #region 创建流程 workFlow = "09"; //问题处理 isSucess = htworkflowbll.CreateWorkFlowObj(workFlow, applicationId, userInfo.UserId); if (isSucess) { htworkflowbll.UpdateFlowStateByObjectId("bis_questioninfo", "flowstate", applicationId); //更新业务流程状态 } #endregion #region 整改信息 QuestionReformEntity qtreformEntity = new QuestionReformEntity(); qtreformEntity.QUESTIONID = applicationId; questionreformbll.SaveForm("", qtreformEntity); #endregion //极光消息推送 JPushApi.PushMessage(userInfo.Account, userInfo.RealName, "WT001", "您有一条问题需完善,请到问题登记进行处理", "您" + entity.CREATEDATE.Value.ToString("yyyy-MM-dd") + "发现的问题已确定为问题,请您到问题登记下对该问题进行完善并指定对应整改责任人。", applicationId); resultMsg = "已成功转为问题,并进入对应流程,请知晓"; } catch (Exception ex) { isSucessful = false; resultMsg = ex.Message; } #endregion break; } try { if (isSucessful) { //评估阶段转 if (entity.FLOWSTATE == "评估") { #region 推进发现问题流程 wfentity = new WfControlObj(); wfentity.businessid = keyValue; // wfentity.startflow = entity.FLOWSTATE; wfentity.submittype = "提交"; wfentity.rankid = string.Empty; wfentity.user = curUser; wfentity.spuser = null; wfentity.mark = "发现问题流程"; wfentity.organizeid = entity.ORGANIZEID; //对应电厂id //获取下一流程的操作人 result = wfcontrolbll.GetWfControl(wfentity); //处理成功 if (result.code == WfCode.Sucess) { participant = result.actionperson; wfFlag = result.wfflag; //提交流程到下一节点 if (!string.IsNullOrEmpty(participant)) { int count = htworkflowbll.SubmitWorkFlow(wfentity, result, keyValue, participant, wfFlag, curUser.UserId); if (count > 0) { //返回成功的结果 #region 返回成功的结果 FindQuestionHandleEntity qentity = new FindQuestionHandleEntity(); if (mode == 0) { qentity.HANDLESTATUS = "已转隐患"; } else if (mode == 1) { qentity.HANDLESTATUS = "已转违章"; } else if (mode == 2) { qentity.HANDLESTATUS = "已转问题"; } qentity.HANDLEDATE = DateTime.Now; qentity.HANDLERID = curUser.UserId; qentity.HANDLERNAME = curUser.UserName; qentity.QUESTIONID = keyValue; qentity.RELEVANCEID = applicationId; qentity.RELEVANCETYPE = applicationType; qentity.APPSIGN = "Web"; findquestionhandlebll.SaveForm("", qentity); #endregion htworkflowbll.UpdateFlowStateByObjectId("bis_findquestioninfo", "flowstate", keyValue); //更新业务流程状态 } } return(Success(resultMsg)); } else { return(Error(result.message)); } #endregion } else //结束阶段转 列表转 { //返回成功的结果 #region 返回成功的结果 FindQuestionHandleEntity qentity = new FindQuestionHandleEntity(); if (mode == 0) { qentity.HANDLESTATUS = "已转隐患"; } else if (mode == 1) { qentity.HANDLESTATUS = "已转违章"; } else if (mode == 2) { qentity.HANDLESTATUS = "已转问题"; } qentity.HANDLEDATE = DateTime.Now; qentity.HANDLERID = curUser.UserId; qentity.HANDLERNAME = curUser.UserName; qentity.QUESTIONID = keyValue; qentity.RELEVANCEID = applicationId; qentity.RELEVANCETYPE = applicationType; qentity.APPSIGN = "Web"; findquestionhandlebll.SaveForm("", qentity); #endregion return(Success(resultMsg)); } } else { return(Error(resultMsg)); } } catch (Exception ex) { return(Error(ex.Message)); } }
public object SaveOrCommitData() { try { string res = HttpContext.Current.Request["json"]; dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; string deleteids = dy.data.deleteids; //删除附件id集合 OperatorProvider.AppUserId = userId; //设置当前用户 var user = ERCHTMS.Code.OperatorProvider.Provider.Current(); //string delsafelist = dy.data.delsafelist; //观察记录实体 string obsRecordEntity = JsonConvert.SerializeObject(dy.data.obsrecordentity); var recordEntity = JsonConvert.DeserializeObject <ObserverecordEntity>(obsRecordEntity); //观察类别 string observecategory = JsonConvert.SerializeObject(dy.data.observecategory); List <ObservecategoryEntity> listCategory = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ObservecategoryEntity> >(observecategory); //安全行为与不安全行为 string safetyList = JsonConvert.SerializeObject(dy.data.safetylist); List <ObservesafetyEntity> listSafety = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ObservesafetyEntity> >(safetyList); observerecordbll.SaveForm(recordEntity.ID, recordEntity, listCategory, listSafety); string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl"); //处理附件 if (!string.IsNullOrEmpty(deleteids)) { DeleteFile(deleteids); } ////处理删除的安全行为与不安全行为 //if (!string.IsNullOrEmpty(delsafelist)) //{ // DeleSafeList(delsafelist); //} HttpFileCollection files = HttpContext.Current.Request.Files; if (files.Count > 0) { for (int i = 0; i < files.AllKeys.Length; i++) { HttpPostedFile file = files[i]; //原始文件名 string fileName = System.IO.Path.GetFileName(file.FileName); long filesize = file.ContentLength; string FileEextension = Path.GetExtension(fileName); string fileGuid = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Guid.NewGuid().ToString(); string dir = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\Upfile"; string newFileName = fileGuid + FileEextension; string newFilePath = dir + "\\" + newFileName; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } FileInfoEntity fileInfoEntity = new FileInfoEntity(); if (!System.IO.File.Exists(newFilePath)) { //保存文件 file.SaveAs(newFilePath); //文件信息写入数据库 fileInfoEntity.Create(); fileInfoEntity.FileId = fileGuid; fileInfoEntity.RecId = recordEntity.ID; fileInfoEntity.FileName = fileName; fileInfoEntity.FilePath = "~/Resource/Upfile/" + newFileName; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = FileEextension; fileInfoEntity.FileType = FileEextension.TrimStart('.'); FileInfoBLL fileInfoBLL = new FileInfoBLL(); fileInfoBLL.SaveForm("", fileInfoEntity); } } } return(new { Code = 0, Count = 0, Info = "操作成功" }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public ActionResult UploadFileNew1(string uptype, string id) { IList <FileInfoEntity> fl = fileBll.GetFilesByRecIdNew(id).Where(x => x.Description == uptype).ToList(); foreach (FileInfoEntity fe in fl) { string filepath = fileBll.Delete(fe.FileId); if (!string.IsNullOrEmpty(filepath) && System.IO.File.Exists(Server.MapPath("~" + filepath))) { System.IO.File.Delete(Server.MapPath("~" + filepath)); } } HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; //没有文件上传,直接返回 if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName)) { return(HttpNotFound()); } string FileEextension = Path.GetExtension(files[0].FileName); string type = files[0].ContentType; if (uptype == "0" && !type.Contains("image")) //图片 { return(Success("1")); } if (uptype == "1" && !type.Contains("mp4")) { return(Success("1")); } if (uptype == "2" && !type.Contains("pdf")) { return(Success("1")); } string Id = OperatorProvider.Provider.Current().UserId; Id = Guid.NewGuid().ToString(); string virtualPath = string.Format("~/Content/toolfile/{0}{1}", Id, FileEextension); string fullFileName = Server.MapPath(virtualPath); //创建文件夹,保存文件 string path = Path.GetDirectoryName(fullFileName); Directory.CreateDirectory(path); files[0].SaveAs(fullFileName); FileInfoEntity fi = new FileInfoEntity { FileId = Id, FolderId = id, RecId = id, FileName = System.IO.Path.GetFileName(files[0].FileName), FilePath = virtualPath, FileType = FileEextension.Substring(1, FileEextension.Length - 1), FileExtensions = FileEextension, FileSize = files[0].ContentLength.ToString(), DeleteMark = 0, Description = uptype }; fileBll.SaveForm(fi); return(Success("上传成功。", new { path = virtualPath.TrimStart('~'), name = fi.FileName })); }
/// <summary> /// 新增或修改人员证书 /// </summary> /// <param name="userId"></param> /// <returns></returns> public object SaveUserCert() { try { string res = HttpContext.Current.Request["json"]; dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string id = ""; //var keys = HttpContext.Current.Request.Form.AllKeys; //Hashtable ht = new Hashtable(); //foreach(string key in keys) //{ // ht.Add(key, HttpContext.Current.Request.Form[key]); //} var content = Newtonsoft.Json.JsonConvert.SerializeObject(dy.data); CertificateEntity cert = Newtonsoft.Json.JsonConvert.DeserializeObject <CertificateEntity>(content); if (string.IsNullOrWhiteSpace(cert.Id)) { id = Guid.NewGuid().ToString(); } else { id = cert.Id; } string path = itemBll.GetItemValue("imgPath"); string remark = ""; if (!string.IsNullOrWhiteSpace(cert.Remark)) { remark = cert.Remark; cert.Remark = ""; } bool result = certificatebll.SaveForm(id, cert); FileInfoBLL fileInfoBLL = new FileInfoBLL(); if (result) { HttpFileCollection files = HttpContext.Current.Request.Files; for (int i = 0; i < files.AllKeys.Length; i++) { HttpPostedFile file = files[i]; //获取文件完整文件名(包含绝对路径) //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名} string fileGuid = Guid.NewGuid().ToString(); long filesize = file.ContentLength; string FileEextension = Path.GetExtension(file.FileName); string uploadDate = DateTime.Now.ToString("yyyyMMdd"); string virtualPath = string.Format("~/Resource/cert/{0}/{1}{2}", uploadDate, fileGuid, FileEextension); string virtualPath1 = string.Format("\\Resource\\cert\\{0}\\{1}{2}", uploadDate, fileGuid, FileEextension); string fullFileName = path + virtualPath1; //创建文件夹 string path1 = Path.GetDirectoryName(fullFileName); Directory.CreateDirectory(path1); FileInfoEntity fileInfoEntity = new FileInfoEntity(); if (!System.IO.File.Exists(fullFileName)) { //保存文件 file.SaveAs(fullFileName); } //文件信息写入数据库 fileInfoEntity.FileId = fileGuid; fileInfoEntity.RecId = id; //关联ID fileInfoEntity.FolderId = "cert"; fileInfoEntity.FileName = file.FileName; fileInfoEntity.FilePath = virtualPath; fileInfoEntity.FileSize = filesize.ToString(); fileInfoEntity.FileExtensions = FileEextension; fileInfoEntity.FileType = FileEextension.Replace(".", ""); fileInfoBLL.SaveForm("", fileInfoEntity); } if (!string.IsNullOrWhiteSpace(remark)) { deptBll.ExecuteSql(string.Format("delete from base_fileinfo where recid='{0}' and fileid in('{1}')", id, remark.Replace(",", "','"))); } return(new { code = 0, info = "操作成功", data = cert }); } else { return(new { code = 1, info = "操作失败" }); } } catch (Exception ex) { return(new { code = 1, info = ex.Message }); } }
public object SaveModifyRecord() { try { string res = HttpContext.Current.Request["json"]; dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; string deleteids = dy.data.deleteids; //删除附件id集合 OperatorProvider.AppUserId = userId; //设置当前用户 var user = ERCHTMS.Code.OperatorProvider.Provider.Current(); //消息实体 string entitystr = JsonConvert.SerializeObject(dy.data.entity); var entity = JsonConvert.DeserializeObject <HseObserveEntity>(entitystr); //处理附件 if (!string.IsNullOrEmpty(deleteids)) { DeleteFile(deleteids); } if (string.IsNullOrEmpty(entity.Id)) { entity.Id = Guid.NewGuid().ToString(); entity.CREATEDATE = DateTime.Now; entity.CREATEUSERDEPT = user.DeptName; entity.CREATEUSERID = user.UserId; entity.CREATEUSERNAME = user.UserName; entity.CREATEUSERDEPTCODE = user.DeptCode; entity.CREATEUSERORGCODE = user.OrganizeCode; entity.MODIFYDATE = DateTime.Now; entity.MODIFYUSERID = user.UserId; entity.MODIFYUSERNAME = user.UserName; hseobservebll.SaveForm("", entity); } else { entity.MODIFYDATE = DateTime.Now; entity.MODIFYUSERID = user.UserId; entity.MODIFYUSERNAME = user.UserName; hseobservebll.SaveForm(entity.Id, entity); } HttpFileCollection files = HttpContext.Current.Request.Files; if (files.Count > 0) { for (int i = 0; i < files.AllKeys.Length; i++) { HttpPostedFile file = files[i]; //原始文件名 string fileName = System.IO.Path.GetFileName(file.FileName); long filesize = file.ContentLength; string FileEextension = Path.GetExtension(fileName); string fileGuid = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Guid.NewGuid().ToString(); string dir = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\HseObserve"; string newFileName = fileGuid + FileEextension; string newFilePath = dir + "\\" + newFileName; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } FileInfoEntity fileInfoEntity = new FileInfoEntity(); if (!System.IO.File.Exists(newFilePath)) { //保存文件 file.SaveAs(newFilePath); //文件信息写入数据库 fileInfoEntity.Create(); fileInfoEntity.FileId = fileGuid; fileInfoEntity.RecId = entity.Id; fileInfoEntity.FileName = fileName; fileInfoEntity.FilePath = "~/Resource/HseObserve/" + newFileName; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = FileEextension; fileInfoEntity.FileType = FileEextension.TrimStart('.'); FileInfoBLL fileInfoBLL = new FileInfoBLL(); fileInfoBLL.SaveForm("", fileInfoEntity); } } } return(new { code = 0, count = 0, info = "操作成功" }); } catch (Exception ex) { return(new { code = -1, count = 0, info = ex.Message }); } }
public string ImportSWP(string belongtypecode) { int error = 0; string message = "请选择格式正确的文件再导入!"; string falseMessage = ""; int count = HttpContext.Request.Files.Count; if (count > 0) { HttpPostedFileBase file = HttpContext.Request.Files[0]; if (string.IsNullOrEmpty(file.FileName)) { return(message); } if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx"))) { return(message); } string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName); file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName)); DataTable dt = ExcelHelper.ExcelImport(Server.MapPath("~/Resource/temp/" + fileName)); int order = 1; if (Directory.Exists(Server.MapPath("~/Resource/ht/images/swp")) == false)//如果不存在就创建file文件夹 { Directory.CreateDirectory(Server.MapPath("~/Resource/ht/images/swp")); } for (int i = 1; i < dt.Rows.Count; i++) { order = i; //文件名称 string filename = dt.Rows[i][0].ToString(); //文件编号 string filecode = dt.Rows[i][1].ToString(); //颁发部门 string iuusedept = dt.Rows[i][2].ToString(); //发布日期 string publishdate = dt.Rows[i][3].ToString(); //实施日期 string carrydate = dt.Rows[i][4].ToString(); //---****值存在空验证*****-- if (string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(filecode) || string.IsNullOrEmpty(iuusedept) || string.IsNullOrEmpty(carrydate) || string.IsNullOrEmpty(publishdate)) { falseMessage += "</br>" + "第" + (i + 2) + "行值存在空,未能导入."; error++; continue; } WrittenWorkEntity sl = new WrittenWorkEntity(); sl.FileName = filename; sl.FileCode = filecode; sl.IssueDept = iuusedept; sl.BelongTypeCode = belongtypecode;//所属单位 sl.FilesId = Guid.NewGuid().ToString(); FileInfoEntity fileEntity = new FileInfoEntity(); fileEntity.RecId = sl.FilesId; fileEntity.EnabledMark = 1; fileEntity.DeleteMark = 0; fileEntity.FilePath = "~/Resource/ht/images/swp/" + filename; fileEntity.FileName = sl.FileName; fileEntity.FolderId = "ht/images"; try { sl.CarryDate = DateTime.Parse(DateTime.Parse(carrydate).ToString("yyyy-MM-dd")); sl.PublishDate = DateTime.Parse(DateTime.Parse(publishdate).ToString("yyyy-MM-dd")); } catch { falseMessage += "</br>" + "第" + (i + 2) + "行时间有误,未能导入."; error++; continue; } try { writtenworkbll.SaveForm("", sl); fileInfoBLL.SaveForm("", fileEntity); } catch { error++; } } count = dt.Rows.Count - 1; message = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条"; message += "</br>" + falseMessage; } return(message); }
public string ImportAccidentCase() { int error = 0; string message = "请选择格式正确的文件再导入!"; string falseMessage = ""; int count = HttpContext.Request.Files.Count; if (count > 0) { HttpPostedFileBase file = HttpContext.Request.Files[0]; if (string.IsNullOrEmpty(file.FileName)) { return(message); } if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx"))) { return(message); } string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName); file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName)); DataTable dt = ExcelHelper.ExcelImport(Server.MapPath("~/Resource/temp/" + fileName)); int order = 1; if (Directory.Exists(Server.MapPath("~/Resource/ht/images/channel")) == false)//如果不存在就创建file文件夹 { Directory.CreateDirectory(Server.MapPath("~/Resource/ht/images/channel")); } for (int i = 1; i < dt.Rows.Count; i++) { order = i; //文件名称 string filename = dt.Rows[i][0].ToString(); //事故时间 string time = dt.Rows[i][1].ToString(); //备注 string remark = dt.Rows[i][2].ToString(); //---****值存在空验证*****-- if (string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(time)) { falseMessage += "</br>" + "第" + (i + 2) + "行值存在空,未能导入."; error++; continue; } AccidentCaseLawEntity sl = new AccidentCaseLawEntity(); sl.FileName = filename; sl.AccRange = "2"; sl.Remark = remark; sl.FilesId = Guid.NewGuid().ToString(); FileInfoEntity fileEntity = new FileInfoEntity(); fileEntity.RecId = sl.FilesId; fileEntity.EnabledMark = 1; fileEntity.DeleteMark = 0; fileEntity.FilePath = "~/Resource/ht/images/channel/" + filename; fileEntity.FileName = sl.FileName; fileEntity.FolderId = "ht/images"; try { sl.AccTime = DateTime.Parse(DateTime.Parse(time).ToString("yyyy-MM-dd HH:mm")); } catch { falseMessage += "</br>" + "第" + (i + 2) + "行时间有误,未能导入."; error++; continue; } try { accidentcaselawbll.SaveForm("", sl); fileInfoBLL.SaveForm("", fileEntity); } catch { error++; } } count = dt.Rows.Count - 1; message = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条"; message += "</br>" + falseMessage; } return(message); }
public JsonResult ImportEditPush(string keyvalue) { var success = true; var message = string.Empty; try { FileInfoBLL fileInfoBLL = new FileInfoBLL(); string newFilePath = ""; if (this.Request.Files.Count == 0) { throw new Exception("请上传文件"); } var file = this.Request.Files[0]; string fileName = System.IO.Path.GetFileName(file.FileName); //if (!fileName.Contains(".pdf")) //{ // throw new Exception("请检查文件格式!"); //} var fileListold = fileInfoBLL.GetFilesByRecIdNew(keyvalue); for (int i = 0; i < fileListold.Count; i++) { fileInfoBLL.DeleteFile(fileListold[i].RecId, fileListold[i].FileName, fileListold[i].FilePath); } string fileGuid = Guid.NewGuid().ToString(); long filesize = file.ContentLength; string FileEextension = Path.GetExtension(fileName); string uploadDate = DateTime.Now.ToString("yyyyMMdd"); string dir = string.Format("~/Resource/{0}/{1}", "Emergency", uploadDate); string newFileName = fileGuid + FileEextension; newFilePath = dir + "/" + newFileName; if (!Directory.Exists(Server.MapPath(dir))) { Directory.CreateDirectory(Server.MapPath(dir)); } FileInfoEntity fileInfoEntity = new FileInfoEntity(); if (!System.IO.File.Exists(Server.MapPath(newFilePath))) { //保存文件 file.SaveAs(Server.MapPath(newFilePath)); //文件信息写入数据库 fileInfoEntity.Create(); fileInfoEntity.FolderId = "Emergency"; fileInfoEntity.FileId = fileGuid; fileInfoEntity.RecId = keyvalue; fileInfoEntity.FileName = fileName; fileInfoEntity.FilePath = dir + "/" + newFileName; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = FileEextension; fileInfoEntity.FileType = FileEextension.TrimStart('.'); fileInfoBLL.SaveForm("", fileInfoEntity); } message = fileInfoEntity.FileName; } catch (Exception ex) { success = false; message = HttpUtility.JavaScriptStringEncode(ex.Message); } return(Json(new { success, message })); }
public string ImportStandard(string standardtype, string categorycode) { if (OperatorProvider.Provider.Current().IsSystem) { return("超级管理员无此操作权限"); } string orgId = OperatorProvider.Provider.Current().OrganizeId;//所属公司 int error = 0; string message = "请选择文件格式正确的文件再导入!"; string falseMessage = ""; int count = HttpContext.Request.Files.Count; if (count > 0) { if (HttpContext.Request.Files.Count != 2) { return("请按正确的方式导入两个文件."); } HttpPostedFileBase file = HttpContext.Request.Files[0]; HttpPostedFileBase file2 = HttpContext.Request.Files[1]; if (string.IsNullOrEmpty(file.FileName) || string.IsNullOrEmpty(file2.FileName)) { return(message); } Boolean isZip1 = file.FileName.Substring(file.FileName.IndexOf('.')).Contains("zip"); //第一个文件是否为Zip格式 Boolean isZip2 = file2.FileName.Substring(file2.FileName.IndexOf('.')).Contains("zip"); //第二个文件是否为Zip格式 if ((isZip1 || isZip2) == false || (isZip1 && isZip2) == true) { return(message); } string fileName1 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName); file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName1)); string fileName2 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file2.FileName); file2.SaveAs(Server.MapPath("~/Resource/temp/" + fileName2)); string decompressionDirectory = Server.MapPath("~/Resource/decompression/") + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "\\"; Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); if (isZip1) { UnZip(Server.MapPath("~/Resource/temp/" + fileName1), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName2)); } else { UnZip(Server.MapPath("~/Resource/temp/" + fileName2), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName1)); } Aspose.Cells.Cells cells = wb.Worksheets[0].Cells; DataTable dt = cells.ExportDataTable(2, 0, cells.MaxDataRow - 1, cells.MaxColumn + 1, false); for (int i = 1; i < dt.Rows.Count; i++) { //文件名称 string filename = dt.Rows[i][0].ToString(); //文件路径 string filepath = dt.Rows[i][1].ToString(); //相应元素 string relevantelement = ""; string relevantelementname = ""; string relevantelementid = ""; //实施日期 string carrydate = ""; if (standardtype == "1" || standardtype == "2" || standardtype == "3" || standardtype == "4" || standardtype == "5" || standardtype == "6") { relevantelement = dt.Rows[i][2].ToString(); carrydate = dt.Rows[i][3].ToString(); } //文学字号 string dispatchcode = ""; //颁布部门 string publishdept = ""; if (standardtype == "6") { dispatchcode = dt.Rows[i][4].ToString(); publishdept = dt.Rows[i][5].ToString(); } string dutyid = ""; string dutyName = ""; //---****值存在空验证*****-- if (string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(filepath)) { falseMessage += "</br>" + "第" + (i + 3) + "行值存在空,未能导入."; error++; continue; } //---****文件格式验证*****-- if (!(filepath.Substring(filepath.IndexOf('.')).Contains("doc") || filepath.Substring(filepath.IndexOf('.')).Contains("docx") || filepath.Substring(filepath.IndexOf('.')).Contains("pdf"))) { falseMessage += "</br>" + "第" + (i + 3) + "行附件格式不正确,未能导入."; error++; continue; } //---****文件是否存在验证*****-- if (!System.IO.File.Exists(decompressionDirectory + filepath)) { falseMessage += "</br>" + "第" + (i + 3) + "行附件不存在,未能导入."; error++; continue; } //--**验证岗位是否存在 * *-- int startnum = 4; if (standardtype == "1" || standardtype == "2" || standardtype == "3" || standardtype == "4" || standardtype == "5") { startnum = 4; } else if (standardtype == "6") { startnum = 6; } else if (standardtype == "7" || standardtype == "8" || standardtype == "9") { startnum = 2; } for (int j = startnum; j < dt.Columns.Count; j++) { if (!dt.Rows[i][j].IsEmpty()) { foreach (var item in dt.Rows[i][j].ToString().Split(',')) { DepartmentEntity dept = DepartmentBLL.GetList().Where(t => t.OrganizeId == orgId && t.FullName == dt.Rows[0][j].ToString()).FirstOrDefault(); if (dept == null) { continue; } RoleEntity re = postBLL.GetList().Where(a => a.FullName == item.ToString() && a.OrganizeId == orgId && a.DeleteMark == 0 && a.EnabledMark == 1 && a.DeptId == dept.DepartmentId).FirstOrDefault(); if (re == null) { //falseMessage += "</br>" + "第" + (i + 3) + "行岗位有误,未能导入."; //error++; continue; } else { dutyid += re.RoleId + ","; dutyName += re.FullName + ","; } } } } dutyid = dutyid.Length > 0 ? dutyid.Substring(0, dutyid.Length - 1) : ""; dutyName = dutyName.Length > 0 ? dutyName.Substring(0, dutyName.Length - 1) : ""; StandardsystemEntity standard = new StandardsystemEntity(); try { if (!string.IsNullOrEmpty(carrydate)) { standard.CARRYDATE = DateTime.Parse(DateTime.Parse(carrydate).ToString("yyyy-MM-dd")); } } catch { falseMessage += "</br>" + "第" + (i + 3) + "行时间有误,未能导入."; error++; continue; } if (!string.IsNullOrEmpty(relevantelement)) { foreach (var item in relevantelement.Split(',')) { ElementEntity re = elementBLL.GetList("").Where(a => a.NAME == item.ToString()).FirstOrDefault(); if (re == null) { //falseMessage += "</br>" + "第" + (i + 2) + "行相应元素有误,未能导入."; //error++; continue; } else { relevantelementname += re.NAME + ","; relevantelementid += re.ID + ","; } } } relevantelementname = string.IsNullOrEmpty(relevantelementname) ? "" : relevantelementname.Substring(0, relevantelementname.Length - 1); relevantelementid = string.IsNullOrEmpty(relevantelementid) ? "" : relevantelementid.Substring(0, relevantelementid.Length - 1); standard.FILENAME = filename; standard.STATIONID = dutyid; standard.STATIONNAME = dutyName; standard.RELEVANTELEMENTNAME = relevantelementname; standard.RELEVANTELEMENTID = relevantelementid; standard.DISPATCHCODE = dispatchcode; standard.PUBLISHDEPT = publishdept; standard.STANDARDTYPE = standardtype; standard.CATEGORYCODE = categorycode; standard.CONSULTNUM = 0; standard.ID = Guid.NewGuid().ToString(); var fileinfo = new FileInfo(decompressionDirectory + filepath); FileInfoEntity fileInfoEntity = new FileInfoEntity(); string fileguid = Guid.NewGuid().ToString(); fileInfoEntity.Create(); fileInfoEntity.RecId = standard.ID; //关联ID fileInfoEntity.FileName = filepath; fileInfoEntity.FilePath = "~/Resource/StandardSystem/" + fileguid + fileinfo.Extension; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = fileinfo.Extension; fileInfoEntity.FileType = fileinfo.Extension.Replace(".", ""); TransportRemoteToServer(Server.MapPath("~/Resource/StandardSystem/"), decompressionDirectory + filepath, fileguid + fileinfo.Extension); fileinfobll.SaveForm("", fileInfoEntity); try { standardsystembll.SaveForm(standard.ID, standard); } catch { error++; } } count = dt.Rows.Count - 1; message = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条"; message += "</br>" + falseMessage; } return(message); }
public string ImportReserverplanData() { try { if (OperatorProvider.Provider.Current().IsSystem) { return("超级管理员无此操作权限"); } int error = 0; string message = "请选择格式正确的文件再导入!"; string falseMessage = ""; int count = HttpContext.Request.Files.Count; if (count > 0) { count = 0; if (HttpContext.Request.Files.Count != 2) { return("请按正确的方式导入两个文件."); } HttpPostedFileBase file = HttpContext.Request.Files[0]; HttpPostedFileBase file2 = HttpContext.Request.Files[1]; if (string.IsNullOrEmpty(file.FileName) || string.IsNullOrEmpty(file2.FileName)) { return(message); } Boolean isZip1 = file.FileName.Substring(file.FileName.IndexOf('.')).Contains("zip"); //第一个文件是否为Zip格式 Boolean isZip2 = file2.FileName.Substring(file2.FileName.IndexOf('.')).Contains("zip"); //第二个文件是否为Zip格式 if ((isZip1 || isZip2) == false || (isZip1 && isZip2) == true) { return(message); } string fileName1 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName); file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName1)); string fileName2 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file2.FileName); file2.SaveAs(Server.MapPath("~/Resource/temp/" + fileName2)); string decompressionDirectory = Server.MapPath("~/Resource/decompression/") + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "\\"; Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); if (isZip1) { UnZip(Server.MapPath("~/Resource/temp/" + fileName1), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName2)); } else { UnZip(Server.MapPath("~/Resource/temp/" + fileName2), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName1)); } Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); var sheet = wb.Worksheets[0]; if (sheet.Cells[1, 0].StringValue != "应急预案名称" || sheet.Cells[1, 1].StringValue != "应急预案类型" || sheet.Cells[1, 2].StringValue != "编制部门" || sheet.Cells[1, 4].StringValue != "编制时间" || sheet.Cells[1, 5].StringValue != "审核部门" || sheet.Cells[1, 6].StringValue != "审核人" || sheet.Cells[1, 7].StringValue != "审核时间" || sheet.Cells[1, 8].StringValue != "单位性质" || sheet.Cells[1, 9].StringValue != "是否评审" || sheet.Cells[1, 10].StringValue != "附件") { return(message); } for (int i = 2; i <= sheet.Cells.MaxDataRow; i++) { count++; if (string.IsNullOrWhiteSpace(sheet.Cells[i, 0].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 1].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 2].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 4].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 6].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 6].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 7].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 8].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 9].StringValue) || string.IsNullOrWhiteSpace(sheet.Cells[i, 10].StringValue)) { falseMessage += "</br>" + "第" + (i + 1) + "行未按模板要求填写,未能导入."; error++; continue; } ReserverplanEntity planEntity = new ReserverplanEntity(); planEntity.NAME = sheet.Cells[i, 0].StringValue; planEntity.PLANTYPENAME = sheet.Cells[i, 1].StringValue; var dataItem1 = new DataItemDetailBLL().GetDataItemListByItemCode("'MAE_PlanType'").Where(x => x.ItemName == sheet.Cells[i, 1].StringValue).ToList().FirstOrDefault(); if (dataItem1 != null) { planEntity.PLANTYPE = dataItem1.ItemValue; } //编制部门 var dept = new DepartmentBLL().GetList().Where(x => x.FullName == sheet.Cells[i, 2].StringValue).ToList().FirstOrDefault(); if (dept == null) { falseMessage += "</br>" + "第" + (i + 1) + "行编制部门不正确,未能导入."; error++; continue; } planEntity.DEPARTID_BZ = dept.DepartmentId; planEntity.DEPARTNAME_BZ = dept.FullName; //编制人 planEntity.USERNAME_BZ = sheet.Cells[i, 3].StringValue; //var userEntity = new UserBLL().GetList().Where(x => x.RealName == sheet.Cells[2, 3].StringValue).ToList().FirstOrDefault(); //if (userEntity != null) { // planEntity.USERID_BZ = userEntity.UserId; //} //审核部门 var auditDept = new DepartmentBLL().GetList().Where(x => x.FullName == sheet.Cells[i, 5].StringValue).ToList().FirstOrDefault(); if (auditDept == null) { falseMessage += "</br>" + "第" + (i + 1) + "行审核部门不正确,未能导入."; error++; continue; } planEntity.DEPARTID_SH = auditDept.DepartmentId; planEntity.DEPARTNAME_SH = auditDept.FullName; planEntity.USERNAME_SH = sheet.Cells[i, 6].StringValue; var userEntity1 = new UserBLL().GetList().Where(x => x.RealName == sheet.Cells[i, 6].StringValue).ToList().FirstOrDefault(); if (userEntity1 != null) { planEntity.USERID_SH = userEntity1.UserId; } DateTime s = new DateTime(); try { s = DateTime.Parse(sheet.Cells[i, 4].StringValue); planEntity.DATATIME_BZ = s; } catch (Exception) { falseMessage += "</br>" + "第" + (i + 1) + "行编制时间格式不正确,未能导入."; error++; continue; } try { s = DateTime.Parse(sheet.Cells[i, 7].StringValue); planEntity.DATATIME_SH = s; } catch (Exception) { falseMessage += "</br>" + "第" + (i + 1) + "行审核时间格式不正确,未能导入."; error++; continue; } planEntity.ORGXZTYPE = sheet.Cells[i, 8].StringValue == "单位内部" ? 1 : 2; planEntity.ORGXZNAME = sheet.Cells[i, 8].StringValue; planEntity.ISAUDITNAME = sheet.Cells[i, 9].StringValue; var dataItem = new DataItemDetailBLL().GetDataItemListByItemCode("'MAE_IsAudit'").Where(x => x.ItemName == sheet.Cells[i, 9].StringValue).ToList().FirstOrDefault(); if (dataItem != null) { planEntity.ISAUDIT = dataItem.ItemValue; } planEntity.ID = Guid.NewGuid().ToString(); //文件路径 string filepath = sheet.Cells[i, 10].StringValue; var fileinfo = new FileInfo(decompressionDirectory + filepath); FileInfoEntity fileInfoEntity = new FileInfoEntity(); string fileguid = Guid.NewGuid().ToString(); fileInfoEntity.Create(); fileInfoEntity.RecId = planEntity.ID; //关联ID fileInfoEntity.FileName = filepath; fileInfoEntity.FilePath = "~/Resource/Reserverplan/" + fileguid + fileinfo.Extension; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = fileinfo.Extension; fileInfoEntity.FileType = fileinfo.Extension.Replace(".", ""); TransportRemoteToServer(Server.MapPath("~/Resource/Reserverplan/"), decompressionDirectory + filepath, fileguid + fileinfo.Extension); fileinfobll.SaveForm("", fileInfoEntity); planEntity.FILES = fileInfoEntity.RecId; try { reserverplanbll.SaveForm(planEntity.ID, planEntity); } catch { error++; } } message = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条。"; if (error > 0) { message += "</br>" + falseMessage; } } return(message); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// 图片上传 /// </summary> /// <param name="folderId"></param> /// <param name="Filedata"></param> public void UploadifyFile(string folderId, string foldername, HttpFileCollection fileList) { try { if (fileList.Count > 0) { for (int i = 0; i < fileList.AllKeys.Length; i++) { HttpPostedFile file = fileList[i]; if (fileList.AllKeys[i].Contains(foldername)) { //获取文件完整文件名(包含绝对路径) //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名} string userId = OperatorProvider.Provider.Current().UserId; string fileGuid = Guid.NewGuid().ToString(); long filesize = file.ContentLength; string FileEextension = Path.GetExtension(file.FileName); string uploadDate = DateTime.Now.ToString("yyyyMMdd"); string virtualPath = string.Format("~/Resource/ht/images/{0}/{1}{2}", uploadDate, fileGuid, FileEextension); string virtualPath1 = string.Format("/Resource/ht/images/{0}/{1}{2}", uploadDate, fileGuid, FileEextension); string fullFileName = dataitemdetailbll.GetItemValue("imgPath") + virtualPath1; //创建文件夹 string path = Path.GetDirectoryName(fullFileName); Directory.CreateDirectory(path); FileInfoEntity fileInfoEntity = new FileInfoEntity(); if (!System.IO.File.Exists(fullFileName)) { //保存文件 file.SaveAs(fullFileName); } //文件信息写入数据库 fileInfoEntity.Create(); fileInfoEntity.FileId = fileGuid; fileInfoEntity.RecId = folderId; //关联ID fileInfoEntity.FolderId = "ht/images"; fileInfoEntity.FileName = file.FileName; fileInfoEntity.FilePath = virtualPath; fileInfoEntity.FileSize = filesize.ToString(); fileInfoEntity.FileExtensions = FileEextension; fileInfoEntity.FileType = FileEextension.Replace(".", ""); fileInfoBLL.SaveForm("", fileInfoEntity); } } } } catch (Exception ex) { LogEntity logEntity = new LogEntity(); logEntity.CategoryId = 4; logEntity.OperateTypeId = ((int)OperationType.Exception).ToString(); logEntity.OperateType = EnumAttribute.GetDescription(OperationType.Exception); logEntity.OperateAccount = curUser.UserName; logEntity.OperateUserId = curUser.UserId; logEntity.ExecuteResult = -1; logEntity.ExecuteResultJson = ex.Message; logEntity.Module = SystemInfo.CurrentModuleName; logEntity.ModuleId = SystemInfo.CurrentModuleId; logEntity.WriteLog(); } }
public object ApproveForm() { try { string res = HttpContext.Current.Request["json"]; dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userid = dy.userid; string keyValue = dy.data.keyvalue; Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current(); AptitudeinvestigateauditEntity aentity = new AptitudeinvestigateauditEntity { AUDITRESULT = dy.data.auditresult, AUDITTIME = Convert.ToDateTime(dy.data.audittime), AUDITPEOPLE = dy.data.auditpeople, AUDITPEOPLEID = dy.data.auditpeopleid, AUDITDEPTID = dy.data.auditdeptid, AUDITDEPT = dy.data.auditdept, AUDITOPINION = dy.data.auditopinion, AUDITSIGNIMG = dy.data.auditsignimg }; string state = string.Empty; string moduleName = "日常考核"; DailyexamineEntity entity = dailyexaminebll.GetEntity(keyValue); /// <param name="currUser">当前登录人</param> /// <param name="state">是否有权限审核 1:能审核 0 :不能审核</param> /// <param name="moduleName">模块名称</param> /// <param name="createdeptid">创建人部门ID</param> ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, entity.CreateUserDeptId); #region //审核信息表 AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity(); aidEntity.AUDITRESULT = aentity.AUDITRESULT; //通过 aidEntity.AUDITTIME = Convert.ToDateTime(aentity.AUDITTIME.Value.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss")); //审核时间 aidEntity.AUDITPEOPLE = aentity.AUDITPEOPLE; //审核人员姓名 aidEntity.AUDITPEOPLEID = aentity.AUDITPEOPLEID; //审核人员id aidEntity.APTITUDEID = keyValue; //关联的业务ID aidEntity.AUDITDEPTID = aentity.AUDITDEPTID; //审核部门id aidEntity.AUDITDEPT = aentity.AUDITDEPT; //审核部门 aidEntity.AUDITOPINION = aentity.AUDITOPINION; //审核意见 aidEntity.AUDITSIGNIMG = string.IsNullOrWhiteSpace(aentity.AUDITSIGNIMG) ? "" : aentity.AUDITSIGNIMG.ToString().Replace(new DataItemDetailBLL().GetItemValue("imgUrl"), ""); if (null != mpcEntity) { aidEntity.REMARK = (mpcEntity.AUTOID.Value - 1).ToString(); //备注 存流程的顺序号 } else { aidEntity.REMARK = "7"; } HttpFileCollection files = HttpContext.Current.Request.Files; if (files.Count > 0) { for (int i = 0; i < files.AllKeys.Length; i++) { HttpPostedFile file = files[i]; string fileOverName = System.IO.Path.GetFileName(file.FileName); string fileName = System.IO.Path.GetFileNameWithoutExtension(file.FileName); string FileEextension = Path.GetExtension(file.FileName); //if (fileName == aidEntity.ID) //{ string dir = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\sign"; string newFileName = fileName + FileEextension; string newFilePath = dir + "\\" + newFileName; file.SaveAs(newFilePath); aidEntity.AUDITSIGNIMG = "/Resource/sign/" + fileOverName; break; //} } } aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity); #endregion #region //保存日常考核 //审核通过 if (aentity.AUDITRESULT == "0") { //0表示流程未完成,1表示流程结束 if (null != mpcEntity) { entity.FlowDept = mpcEntity.CHECKDEPTID; entity.FlowDeptName = mpcEntity.CHECKDEPTNAME; entity.FlowRole = mpcEntity.CHECKROLEID; entity.FlowRoleName = mpcEntity.CHECKROLENAME; entity.IsSaved = 1; entity.IsOver = 0; entity.FlowName = mpcEntity.CHECKDEPTNAME + "审核中"; } else { entity.FlowDept = ""; entity.FlowDeptName = ""; entity.FlowRole = ""; entity.FlowRoleName = ""; entity.IsSaved = 1; entity.IsOver = 1; entity.FlowName = ""; } } else //审核不通过 { entity.FlowDept = ""; entity.FlowDeptName = ""; entity.FlowRole = ""; entity.FlowRoleName = ""; entity.IsOver = 0; //处于登记阶段 entity.IsSaved = 0; //是否完成状态赋值为未完成 entity.FlowName = ""; } //更新日常考核基本状态信息 dailyexaminebll.SaveForm(keyValue, entity); #endregion #region //审核不通过 if (aentity.AUDITRESULT == "1") { //添加历史记录 HistorydailyexamineEntity hsentity = new HistorydailyexamineEntity(); hsentity.CreateUserId = entity.CreateUserId; hsentity.CreateUserDeptCode = entity.CreateUserDeptCode; hsentity.CreateUserOrgCode = entity.CreateUserOrgCode; hsentity.CreateDate = entity.CreateDate; hsentity.CreateUserName = entity.CreateUserName; hsentity.CreateUserDeptId = entity.CreateUserDeptId; hsentity.ModifyDate = entity.ModifyDate; hsentity.ModifyUserId = entity.ModifyUserId; hsentity.ModifyUserName = entity.ModifyUserName; hsentity.ExamineCode = entity.ExamineCode; hsentity.ExamineDept = entity.ExamineDept; hsentity.ExamineDeptId = entity.ExamineDeptId; hsentity.ExamineToDeptId = entity.ExamineToDeptId; hsentity.ExamineToDept = entity.ExamineToDept; hsentity.ExamineType = entity.ExamineType; //关联ID hsentity.ExamineMoney = Convert.ToDouble(entity.ExamineMoney); hsentity.ExaminePerson = entity.ExaminePerson; hsentity.ExaminePersonId = entity.ExaminePersonId; //关联ID hsentity.ExamineTime = entity.ExamineTime; hsentity.ExamineContent = entity.ExamineContent; hsentity.ExamineBasis = entity.ExamineBasis; hsentity.Remark = entity.Remark; hsentity.ContractId = entity.Id;//关联ID hsentity.IsSaved = 2; hsentity.IsOver = entity.IsOver; hsentity.FlowDeptName = entity.FlowDeptName; hsentity.FlowDept = entity.FlowDept; hsentity.FlowRoleName = entity.FlowRoleName; hsentity.FlowRole = entity.FlowRole; hsentity.FlowName = entity.FlowName; hsentity.Id = ""; historydailyexaminebll.SaveForm(hsentity.Id, hsentity); //获取当前业务对象的所有审核记录 var shlist = aptitudeinvestigateauditbll.GetAuditList(keyValue); //批量更新审核记录关联ID foreach (AptitudeinvestigateauditEntity mode in shlist) { mode.APTITUDEID = hsentity.Id; //对应新的ID aptitudeinvestigateauditbll.SaveForm(mode.ID, mode); } //批量更新附件记录关联ID var flist = fileinfobll.GetImageListByObject(keyValue); foreach (FileInfoEntity fmode in flist) { fmode.RecId = hsentity.Id; //对应新的ID fileinfobll.SaveForm("", fmode); } } #endregion return(new { Code = 0, Count = 0, Info = "保存成功" }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public string ImportStandard(string refid, string refname, string deptcode, string refcode) { try { if (OperatorProvider.Provider.Current().IsSystem) { return("超级管理员无此操作权限"); } string orgId = OperatorProvider.Provider.Current().OrganizeId;//所属公司 int error = 0; int success = 0; string message = "请选择文件格式正确的文件再导入!"; string falseMessage = ""; int count = HttpContext.Request.Files.Count; if (count > 0) { if (HttpContext.Request.Files.Count != 2) { return("请按正确的方式导入两个文件."); } HttpPostedFileBase file = HttpContext.Request.Files[0]; HttpPostedFileBase file2 = HttpContext.Request.Files[1]; if (string.IsNullOrEmpty(file.FileName) || string.IsNullOrEmpty(file2.FileName)) { return(message); } Boolean isZip1 = file.FileName.Substring(file.FileName.IndexOf('.')).Contains("zip"); //第一个文件是否为Zip格式 Boolean isZip2 = file2.FileName.Substring(file2.FileName.IndexOf('.')).Contains("zip"); //第二个文件是否为Zip格式 if ((isZip1 || isZip2) == false || (isZip1 && isZip2) == true) { return(message); } string fileName1 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName); file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName1)); string fileName2 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file2.FileName); file2.SaveAs(Server.MapPath("~/Resource/temp/" + fileName2)); string decompressionDirectory = Server.MapPath("~/Resource/decompression/") + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "\\"; Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); if (isZip1) { UnZip(Server.MapPath("~/Resource/temp/" + fileName1), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName2)); } else { UnZip(Server.MapPath("~/Resource/temp/" + fileName2), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName1)); } Aspose.Cells.Cells cells = wb.Worksheets[0].Cells; DataTable dt = cells.ExportDataTable(1, 0, cells.MaxDataRow, cells.MaxColumn, false); for (int i = 0; i < dt.Rows.Count; i++) { FileManageEntity standard = new FileManageEntity(); standard.ID = Guid.NewGuid().ToString(); //文件名称 string filename = dt.Rows[i][0].ToString(); //文件编号 string fileno = dt.Rows[i][1].ToString(); //---****值存在空验证*****-- if (string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(dt.Rows[i][2].ToString())) { falseMessage += "</br>" + "第" + (i + 1) + "行值存在空,未能导入."; error++; continue; } var user = ERCHTMS.Code.OperatorProvider.Provider.Current(); var oldList = filemanagebll.GetList(String.Format(" and createuserorgcode='{0}' and fileno='{1}' and id<>'{2}'", user.OrganizeCode, fileno, standard.ID)).ToList(); var r = oldList.Count > 0; if (r) { falseMessage += "</br>" + "第" + (i + 1) + "行存在相同文件编号,未能导入."; error++; continue; } bool conbool = false; //文件路径 string[] filepaths = dt.Rows[i][2].ToString().Split(';'); var filepath = ""; for (int j = 0; j < filepaths.Length; j++) { filepath = filepaths[j]; if (string.IsNullOrEmpty(filepath)) { continue; } string strPath = filepath.Substring(filepath.IndexOf('.')); //---****文件格式验证*****-- if (!(strPath.Contains("doc") || strPath.Contains("docx") || strPath.Contains("pdf") || strPath.Contains("ppt") || strPath.Contains("xlsx") || strPath.Contains("xls") || strPath.Contains("png") || strPath.Contains("jpg") || strPath.Contains("jpeg"))) { falseMessage += "</br>" + "第" + (i + 1) + "行指定附件格式不正确,未能导入."; error++; conbool = true; continue; } //---****文件是否存在验证*****-- if (!System.IO.File.Exists(decompressionDirectory + filepath)) { falseMessage += "</br>" + "第" + (i + 1) + "行指定附件不存在,未能导入."; error++; conbool = true; continue; } var fileinfo = new FileInfo(decompressionDirectory + filepath); FileInfoEntity fileInfoEntity = new FileInfoEntity(); string fileguid = Guid.NewGuid().ToString(); fileInfoEntity.Create(); fileInfoEntity.RecId = standard.ID; //关联ID fileInfoEntity.FileName = filepath; fileInfoEntity.FilePath = "~/Resource/FileManageSystem/" + fileguid + fileinfo.Extension; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = fileinfo.Extension; fileInfoEntity.FileType = fileinfo.Extension.Replace(".", ""); TransportRemoteToServer(Server.MapPath("~/Resource/FileManageSystem/"), decompressionDirectory + filepath, fileguid + fileinfo.Extension); fileinfobll.SaveForm("", fileInfoEntity); } if (conbool) { continue; } standard.FileName = filename; standard.FileNo = fileno; standard.FileTypeId = refid; standard.FileTypeName = refname; standard.FileTypeCode = refcode; DepartmentEntity deptEntity = deptBll.GetEntityByCode(deptcode); if (deptEntity != null) { standard.ReleaseDeptId = deptEntity.DepartmentId; standard.ReleaseDeptName = deptEntity.FullName; } else { standard.ReleaseDeptId = OperatorProvider.Provider.Current().DeptId; standard.ReleaseDeptName = OperatorProvider.Provider.Current().DeptName; } if (!string.IsNullOrEmpty(dt.Rows[i][3].ToString())) { standard.ReleaseTime = Convert.ToDateTime(dt.Rows[i][3].ToString()); } standard.Remark = !string.IsNullOrEmpty(dt.Rows[i][4].ToString()) ? dt.Rows[i][4].ToString() : ""; try { filemanagebll.SaveForm(standard.ID, standard); success++; } catch { error++; } } message = "共有" + dt.Rows.Count + "条记录,成功导入" + success + "条,失败" + error + "条"; message += "</br>" + falseMessage; } return(message); } catch (Exception e) { return("导入的Excel数据格式不正确,请下载标准模板重新填写!"); } }
public string ImportStandard(string treeId, string treeName, string treeCode) { try { if (OperatorProvider.Provider.Current().IsSystem) { return("超级管理员无此操作权限"); } string orgId = OperatorProvider.Provider.Current().OrganizeId;//所属公司 int error = 0; int success = 0; string message = "请选择文件格式正确的文件再导入!"; string falseMessage = ""; int count = HttpContext.Request.Files.Count; if (count > 0) { if (HttpContext.Request.Files.Count != 2) { return("请按正确的方式导入两个文件."); } HttpPostedFileBase file = HttpContext.Request.Files[0]; HttpPostedFileBase file2 = HttpContext.Request.Files[1]; if (string.IsNullOrEmpty(file.FileName) || string.IsNullOrEmpty(file2.FileName)) { return(message); } Boolean isZip1 = file.FileName.Substring(file.FileName.IndexOf('.')).Contains("zip"); //第一个文件是否为Zip格式 Boolean isZip2 = file2.FileName.Substring(file2.FileName.IndexOf('.')).Contains("zip"); //第二个文件是否为Zip格式 if ((isZip1 || isZip2) == false || (isZip1 && isZip2) == true) { return(message); } string fileName1 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName); file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName1)); string fileName2 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file2.FileName); file2.SaveAs(Server.MapPath("~/Resource/temp/" + fileName2)); string decompressionDirectory = Server.MapPath("~/Resource/decompression/") + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "\\"; Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(); if (isZip1) { UnZip(Server.MapPath("~/Resource/temp/" + fileName1), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName2)); } else { UnZip(Server.MapPath("~/Resource/temp/" + fileName2), decompressionDirectory, "", true); wb.Open(Server.MapPath("~/Resource/temp/" + fileName1)); } Aspose.Cells.Cells cells = wb.Worksheets[0].Cells; DataTable dt = cells.ExportDataTable(1, 0, cells.MaxDataRow, cells.MaxColumn, false); for (int i = 0; i < dt.Rows.Count; i++) { SafeStandardsEntity entity = new SafeStandardsEntity(); entity.Id = Guid.NewGuid().ToString(); entity.FilesId = Guid.NewGuid().ToString(); //文件名称 string filename = dt.Rows[i][0].ToString(); //文件编号 string filecode = dt.Rows[i][1].ToString(); //发布单位 string issuedept = dt.Rows[i][4].ToString(); //发布时间 string releasedate = dt.Rows[i][5].ToString(); //修订时间 string revisedate = dt.Rows[i][6].ToString(); //实施时间 string carrydate = dt.Rows[i][7].ToString(); //备注 string Remark = dt.Rows[i][8].ToString(); //---****值存在空验证*****-- if (string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(filecode)) { falseMessage += "</br>" + "第" + (i + 1) + "行值存在空,未能导入."; error++; continue; } bool conbool = false; //正文附件路径 string[] filepaths = dt.Rows[i][2].ToString().Split(';'); var filepath = ""; for (int j = 0; j < filepaths.Length; j++) { filepath = filepaths[j]; if (string.IsNullOrEmpty(filepath)) { continue; } string strPath = filepath.Substring(filepath.IndexOf('.')); //---****文件格式验证*****-- if (!(strPath.Contains("doc") || strPath.Contains("docx") || strPath.Contains("pdf"))) { falseMessage += "</br>" + "第" + (i + 1) + "行指定正文附件格式不正确,未能导入."; error++; conbool = true; continue; } //---****文件是否存在验证*****-- if (!System.IO.File.Exists(decompressionDirectory + filepath)) { falseMessage += "</br>" + "第" + (i + 1) + "行指定正文附件不存在,未能导入."; error++; conbool = true; continue; } var fileinfo = new FileInfo(decompressionDirectory + filepath); FileInfoEntity fileInfoEntity = new FileInfoEntity(); string fileguid = Guid.NewGuid().ToString(); fileInfoEntity.Create(); fileInfoEntity.RecId = entity.FilesId; //关联ID fileInfoEntity.FileName = filepath; fileInfoEntity.FilePath = "~/Resource/StandardsSystem/" + fileguid + fileinfo.Extension; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = fileinfo.Extension; fileInfoEntity.FileType = fileinfo.Extension.Replace(".", ""); TransportRemoteToServer(Server.MapPath("~/Resource/StandardsSystem/"), decompressionDirectory + filepath, fileguid + fileinfo.Extension); fileinfobll.SaveForm("", fileInfoEntity); } if (conbool) { continue; } //正文附件路径 filepaths = dt.Rows[i][3].ToString().Split(';'); filepath = ""; for (int j = 0; j < filepaths.Length; j++) { filepath = filepaths[j]; if (string.IsNullOrEmpty(filepath)) { continue; } string strPath = filepath.Substring(filepath.IndexOf('.')); //---****文件格式验证*****-- if (!(strPath.Contains("doc") || strPath.Contains("docx") || strPath.Contains("pdf") || strPath.Contains("ppt") || strPath.Contains("xlsx") || strPath.Contains("xls") || strPath.Contains("png") || strPath.Contains("jpg") || strPath.Contains("jpeg"))) { falseMessage += "</br>" + "第" + (i + 1) + "行指定附件格式不正确,未能导入."; error++; conbool = true; continue; } //---****文件是否存在验证*****-- if (!System.IO.File.Exists(decompressionDirectory + filepath)) { falseMessage += "</br>" + "第" + (i + 1) + "行指定附件不存在,未能导入."; error++; conbool = true; continue; } var fileinfo = new FileInfo(decompressionDirectory + filepath); FileInfoEntity fileInfoEntity = new FileInfoEntity(); string fileguid = Guid.NewGuid().ToString(); fileInfoEntity.Create(); fileInfoEntity.RecId = entity.Id; //关联ID fileInfoEntity.FileName = filepath; fileInfoEntity.FilePath = "~/Resource/StandardsSystem/" + fileguid + fileinfo.Extension; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = fileinfo.Extension; fileInfoEntity.FileType = fileinfo.Extension.Replace(".", ""); TransportRemoteToServer(Server.MapPath("~/Resource/StandardsSystem/"), decompressionDirectory + filepath, fileguid + fileinfo.Extension); fileinfobll.SaveForm("", fileInfoEntity); } entity.FileName = filename; entity.FileCode = filecode; entity.IssueDept = issuedept; entity.LawTypeId = treeId; entity.LawTypeName = treeName; entity.LawTypeCode = treeCode; if (!string.IsNullOrEmpty(releasedate)) { entity.ReleaseDate = Convert.ToDateTime(releasedate); } if (!string.IsNullOrEmpty(revisedate)) { entity.ReviseDate = Convert.ToDateTime(revisedate); } if (!string.IsNullOrEmpty(carrydate)) { entity.CarryDate = Convert.ToDateTime(carrydate); } entity.Remark = !string.IsNullOrEmpty(Remark) ? Remark : ""; try { safestandardsbll.SaveForm(entity.Id, entity); success++; } catch { error++; } } message = "共有" + dt.Rows.Count + "条记录,成功导入" + success + "条,失败" + error + "条"; message += "</br>" + falseMessage; } return(message); } catch (Exception e) { return("导入的Excel数据格式不正确,请下载标准模板重新填写!"); } }
public object CarryOutTrain() { try { string res = HttpContext.Current.Request["json"]; dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; string deleteids = dy.data.deleteids; //删除附件id集合 OperatorProvider.AppUserId = userId; //设置当前用户 Operator currUser = OperatorProvider.Provider.Current(); string measuresJson = JsonConvert.SerializeObject(dy.data.measuresJson); List <TrainmeasuresEntity> ListMeasures = Newtonsoft.Json.JsonConvert.DeserializeObject <List <TrainmeasuresEntity> >(measuresJson);//管理措施集合 string riskJson = JsonConvert.SerializeObject(dy.data.riskEntity); RisktrainEntity riskEntity = JsonConvert.DeserializeObject <RisktrainEntity>(riskJson); //提交时先查询数据,判断是否还能训练 RisktrainEntity oldRiskTrain = riskBll.GetEntity(riskEntity.Id); if (oldRiskTrain != null) { //训练已经完成此条数据不允许提交 if (oldRiskTrain.Status == 1) { return(new { code = -1, count = 0, info = "此训练已经结束!无法继续提交!" }); } } if (riskEntity.WorkFzrId == currUser.Account) { riskEntity.Status = 1; } for (int i = 0; i < ListMeasures.Count; i++) { ListMeasures[i].Id = Guid.NewGuid().ToString(); ListMeasures[i].WorkId = riskEntity.Id; } riskBll.SaveForm(riskEntity.Id, riskEntity, ListMeasures); if (!string.IsNullOrEmpty(deleteids)) { DeleteFile(deleteids); } HttpFileCollection files = HttpContext.Current.Request.Files; if (files.Count > 0) { for (int i = 0; i < files.AllKeys.Length; i++) { HttpPostedFile file = files[i]; //原始文件名 string fileName = System.IO.Path.GetFileName(file.FileName); long filesize = file.ContentLength; string FileEextension = Path.GetExtension(fileName); string fileGuid = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Guid.NewGuid().ToString(); string dir = new DataItemDetailBLL().GetItemValue("imgPath") + "\\Resource\\Upfile"; string newFileName = fileGuid + FileEextension; string newFilePath = dir + "\\" + newFileName; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } FileInfoEntity fileInfoEntity = new FileInfoEntity(); if (!System.IO.File.Exists(newFilePath)) { //保存文件 file.SaveAs(newFilePath); //文件信息写入数据库 fileInfoEntity.Create(); fileInfoEntity.FileId = fileGuid; if (file.ContentType.Contains("image")) { fileInfoEntity.RecId = riskEntity.Id + "02"; } else { fileInfoEntity.RecId = riskEntity.Id + "01"; } fileInfoEntity.FileName = fileName; fileInfoEntity.FilePath = "~/Resource/Upfile/" + newFileName; fileInfoEntity.FileSize = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = FileEextension; fileInfoEntity.FileType = FileEextension.TrimStart('.'); FileInfoBLL fileInfoBLL = new FileInfoBLL(); fileInfoBLL.SaveForm("", fileInfoEntity); } } } return(new { code = 0, count = 1, info = "提交成功" }); } catch (Exception ex) { return(new { code = -1, count = 0, info = ex.Message }); } }
public JsonResult DoImport(CostRecordEntity record) { var success = true; var message = "保存成功!"; var user = OperatorProvider.Provider.Current(); if (this.Request.Files.Count > 0) { var book = default(Workbook); try { book = new Workbook(this.Request.Files[0].InputStream); } catch (Exception e) { return(Json(new AjaxResult() { type = ResultType.error, message = "无法识别的文件!" })); } try { var sheet = book.Worksheets[0]; var titleIndex = this.GetTitleRow(sheet, record.Category); var dataindex = this.GetDataIndex(sheet, titleIndex); var costbll = new CostBLL(); var costitems = this.GetCostData(sheet, titleIndex, dataindex); record.CostItems = costitems; record.RecordId = Guid.NewGuid(); costbll.AddCost(record); var filename = this.Request.Files[0].FileName; var path = Path.Combine(Server.MapPath("~/Resource"), "Budget"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var id = Guid.NewGuid().ToString(); this.Request.Files[0].SaveAs(Path.Combine(path, id + Path.GetExtension(filename))); var fileinfo = new FileInfoEntity() { FileId = id, FilePath = "~/Resource/Budget/" + id + Path.GetExtension(filename), FileName = filename, CreateDate = DateTime.Now, CreateUserId = user.UserId, CreateUserName = user.UserName, DeleteMark = 0, EnabledMark = 1, FileExtensions = Path.GetExtension(filename), FileSize = this.Request.Files[0].ContentLength.ToString(), ModifyDate = DateTime.Now, ModifyUserId = user.UserId, ModifyUserName = user.UserName, RecId = record.RecordId.ToString() }; var filebll = new FileInfoBLL(); filebll.SaveForm(null, fileinfo); } catch (Exception e) { success = false; message = e.Message; } } return(Json(new AjaxResult() { type = success ? ResultType.success : ResultType.error, message = message })); }
public ActionResult ApporveForm(string keyValue, AptitudeinvestigateauditEntity aentity) { Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current(); string state = string.Empty; string moduleName = "日常考核"; DailyexamineEntity entity = dailyexaminebll.GetEntity(keyValue); /// <param name="currUser">当前登录人</param> /// <param name="state">是否有权限审核 1:能审核 0 :不能审核</param> /// <param name="moduleName">模块名称</param> /// <param name="createdeptid">创建人部门ID</param> ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, entity.CreateUserDeptId); #region //审核信息表 AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity(); aidEntity.AUDITRESULT = aentity.AUDITRESULT; //通过 aidEntity.AUDITTIME = Convert.ToDateTime(aentity.AUDITTIME.Value.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss")); //审核时间 aidEntity.AUDITPEOPLE = aentity.AUDITPEOPLE; //审核人员姓名 aidEntity.AUDITPEOPLEID = aentity.AUDITPEOPLEID; //审核人员id aidEntity.APTITUDEID = keyValue; //关联的业务ID aidEntity.AUDITDEPTID = aentity.AUDITDEPTID; //审核部门id aidEntity.AUDITDEPT = aentity.AUDITDEPT; //审核部门 aidEntity.AUDITOPINION = aentity.AUDITOPINION; //审核意见 aidEntity.FlowId = entity.FlowID; aidEntity.AUDITSIGNIMG = HttpUtility.UrlDecode(aidEntity.AUDITSIGNIMG); aidEntity.AUDITSIGNIMG = string.IsNullOrWhiteSpace(aentity.AUDITSIGNIMG) ? "" : aentity.AUDITSIGNIMG.ToString().Replace("../..", ""); if (null != mpcEntity) { aidEntity.REMARK = (mpcEntity.AUTOID.Value - 1).ToString(); //备注 存流程的顺序号 } else { aidEntity.REMARK = "7"; } aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity); #endregion #region //保存日常考核 //审核通过 if (aentity.AUDITRESULT == "0") { //0表示流程未完成,1表示流程结束 if (null != mpcEntity) { entity.FlowDept = mpcEntity.CHECKDEPTID; entity.FlowDeptName = mpcEntity.CHECKDEPTNAME; entity.FlowRole = mpcEntity.CHECKROLEID; entity.FlowRoleName = mpcEntity.CHECKROLENAME; entity.IsSaved = 1; entity.IsOver = 0; entity.FlowID = mpcEntity.ID; entity.FlowName = mpcEntity.CHECKDEPTNAME + "审核中"; } else { entity.FlowDept = ""; entity.FlowDeptName = ""; entity.FlowRole = ""; entity.FlowRoleName = ""; entity.IsSaved = 1; entity.IsOver = 1; entity.FlowName = ""; } } else //审核不通过 { entity.FlowDept = ""; entity.FlowDeptName = ""; entity.FlowRole = ""; entity.FlowRoleName = ""; entity.IsOver = 0; //处于登记阶段 entity.IsSaved = 0; //是否完成状态赋值为未完成 entity.FlowName = ""; entity.FlowID = ""; } //更新日常考核基本状态信息 dailyexaminebll.SaveForm(keyValue, entity); #endregion #region //审核不通过 if (aentity.AUDITRESULT == "1") { //添加历史记录 HistorydailyexamineEntity hsentity = new HistorydailyexamineEntity(); hsentity.CreateUserId = entity.CreateUserId; hsentity.CreateUserDeptCode = entity.CreateUserDeptCode; hsentity.CreateUserOrgCode = entity.CreateUserOrgCode; hsentity.CreateDate = entity.CreateDate; hsentity.CreateUserName = entity.CreateUserName; hsentity.CreateUserDeptId = entity.CreateUserDeptId; hsentity.ModifyDate = entity.ModifyDate; hsentity.ModifyUserId = entity.ModifyUserId; hsentity.ModifyUserName = entity.ModifyUserName; hsentity.ExamineCode = entity.ExamineCode; hsentity.ExamineDept = entity.ExamineDept; hsentity.ExamineDeptId = entity.ExamineDeptId; hsentity.ExamineToDeptId = entity.ExamineToDeptId; hsentity.ExamineToDept = entity.ExamineToDept; hsentity.ExamineType = entity.ExamineType; //关联ID hsentity.ExamineMoney = entity.ExamineMoney; hsentity.ExaminePerson = entity.ExaminePerson; hsentity.ExaminePersonId = entity.ExaminePersonId; //关联ID hsentity.ExamineTime = entity.ExamineTime; hsentity.ExamineContent = entity.ExamineContent; hsentity.ExamineBasis = entity.ExamineBasis; hsentity.Remark = entity.Remark; hsentity.ContractId = entity.Id;//关联ID hsentity.IsSaved = 2; hsentity.IsOver = entity.IsOver; hsentity.FlowDeptName = entity.FlowDeptName; hsentity.FlowDept = entity.FlowDept; hsentity.FlowRoleName = entity.FlowRoleName; hsentity.FlowRole = entity.FlowRole; hsentity.FlowName = entity.FlowName; hsentity.Project = entity.Project; hsentity.ProjectId = entity.ProjectId; hsentity.Id = ""; historydailyexaminebll.SaveForm(hsentity.Id, hsentity); //获取当前业务对象的所有审核记录 var shlist = aptitudeinvestigateauditbll.GetAuditList(keyValue); //批量更新审核记录关联ID foreach (AptitudeinvestigateauditEntity mode in shlist) { mode.APTITUDEID = hsentity.Id; //对应新的ID aptitudeinvestigateauditbll.SaveForm(mode.ID, mode); } //批量更新附件记录关联ID var flist = fileinfobll.GetImageListByObject(keyValue); foreach (FileInfoEntity fmode in flist) { fmode.RecId = hsentity.Id; //对应新的ID fileinfobll.SaveForm("", fmode); } } #endregion return(Success("操作成功!")); }
/// <summary> /// 文件上传 /// </summary> /// <returns></returns> public ActionResult UploadFile(string folderId) { try { var file = Request.Files[0]; //获取选中文件 var filecombin = file.FileName.Split('.'); if (file == null || string.IsNullOrEmpty(file.FileName) || file.ContentLength == 0 || filecombin.Length < 2) { return(Json(new { fileid = 0, src = "", name = "", msg = "上传出错 请检查文件名 或 文件内容" })); } //获取文件完整文件名(包含绝对路径) //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名} string account = OperatorProvider.Provider.Current().Account; string fileGuid = file.FileName;//Guid.NewGuid().ToString() long filesize = file.ContentLength; string FileEextension = Path.GetExtension(file.FileName); string fileName = Path.GetFileNameWithoutExtension(file.FileName); string uploadDate = DateTime.Now.ToString("yyyyMMdd"); string virtualPath = string.Format("~/Resource/DocumentFile/{0}/{1}/{2}{3}", account, uploadDate, fileName, FileEextension); string fullFileName = this.Server.MapPath(virtualPath); var tmpIndex = 0; var addFileName = fileName; //判断是否存在相同文件名的文件 相同累加1继续判断 while (System.IO.File.Exists(fullFileName)) { addFileName = fileName + ++tmpIndex; virtualPath = string.Format("~/Resource/DocumentFile/{0}/{1}/{2}{3}", account, uploadDate, addFileName, FileEextension); fullFileName = this.Server.MapPath(virtualPath); } //创建文件夹 string path = Path.GetDirectoryName(fullFileName); Directory.CreateDirectory(path); if (!System.IO.File.Exists(fullFileName)) { //保存文件 file.SaveAs(fullFileName); //文件信息写入数据库 FileInfoEntity fileInfoEntity = new FileInfoEntity(); fileInfoEntity.Create(); //fileInfoEntity.FileId = fileGuid; if (!string.IsNullOrEmpty(folderId)) { fileInfoEntity.FolderId = folderId; } else { fileInfoEntity.FolderId = "0"; } fileInfoEntity.FileName = addFileName + FileEextension; fileInfoEntity.FilePath = virtualPath; fileInfoEntity.FileSize = filesize.ToString(); fileInfoEntity.FileExtensions = FileEextension; fileInfoEntity.FileType = FileEextension.Replace(".", ""); fileInfoBLL.SaveForm("", fileInfoEntity); } //return Success("上传成功。"); ////定义本地路径位置 //string local = "Upload\\Contract"; //string filePathName = string.Empty; //string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, local); //var tmpName = Server.MapPath("~/Upload/Contract/"); //var tmp = file.FileName; //var tmpIndex = 0; ////判断是否存在相同文件名的文件 相同累加1继续判断 //while (System.IO.File.Exists(tmpName + tmp)) //{ // tmp = filecombin[0] + "_" + ++tmpIndex + "." + filecombin[1]; //} ////不带路径的最终文件名 //filePathName = tmp; //if (!System.IO.Directory.Exists(localPath)) // System.IO.Directory.CreateDirectory(localPath); //string localURL = Path.Combine(local, filePathName); //file.SaveAs(Path.Combine(localPath, filePathName)); //保存图片(文件夹) return(Json(new { src = virtualPath.Trim().Replace("~", ""), name = addFileName + FileEextension, // 获取文件名不含后缀名 msg = "上传成功" })); } catch { } return(Json(new { src = "", name = "", // 获取文件名不含后缀名 msg = "上传出错" })); }
public ActionResult SaveFileForm(string keyValue, FileInfoEntity fileInfoEntity) { fileInfoBLL.SaveForm(keyValue, fileInfoEntity); return(Success("操作成功。")); }
public HttpResponseMessage SaveTrailRecord(string ticket, string keyValue, TrailRecordModel model) { UserEntity userEntity = GetCurrent(ticket); if (userEntity != null) { try { TrailRecordEntity entity = new TrailRecordEntity(); entity.Contact = model.Contact; entity.StartTime = model.StartTime; entity.EndTime = model.EndTime; entity.FollowUpMode = model.FollowUpMode; entity.ObjectId = model.ObjectId; entity.ObjectName = model.ObjectName; entity.ObjectSort = model.ObjectSort; entity.SaleStageName = model.SaleStageName; entity.SaleStageId = model.SaleStageId; entity.TrackContent = model.TrackContent; entity.Description = model.Description; entity.TrailType = model.TrailType;//跟进类型 #region 新增客户 if (string.IsNullOrWhiteSpace(keyValue)) { entity.TrailId = Guid.NewGuid().ToString(); entity.EnabledMark = 1; entity.DeleteMark = 0; entity.CreateDate = DateTime.Now; entity.CreateUserId = userEntity.UserId; entity.CreateUserName = userEntity.RealName; entity.ModifyDate = DateTime.Now; if (model.ObjectSort == 2) { entity.ObjectName = customerBLL.GetEntity(model.ObjectId).FullName; } } #endregion #region 更新客户信息 else { entity.TrailId = keyValue; entity.ModifyDate = DateTime.Now; entity.ModifyUserId = userEntity.UserId; entity.ModifyUserName = userEntity.RealName; } #endregion trailRecordBLL.AppSaveForm(keyValue, entity); if (!string.IsNullOrWhiteSpace(model.FilesPath)) { //相关文件 string[] files = model.FilesPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in files) { var fileInfoEntity = fileInfoBLL.GetEntity(item); if (fileInfoEntity != null) { fileInfoEntity.ObjectId = entity.TrailId; fileInfoBLL.SaveForm(fileInfoEntity.FileId, fileInfoEntity); } } } return(Success("成功")); } catch (Exception ex) { return(Error(ex.Message)); } } else { return(Error("票据验证失败")); } }