public ActionResult WordToPdf(string fileid) { try { DataTable fie = fileInfoBLL.GetFiles(fileid); if (fie != null && fie.Rows.Count > 0) { string path = fie.Rows[0]["FilePath"].ToString(); string[] str = path.Split('/'); if (str[str.Length - 1].EndsWith(".pdf")) { return(ToJsonResult(path)); } else { path = Server.MapPath(path); string str1 = "~/Resource/Temp/" + str[str.Length - 1].Replace("docx", "pdf").Replace("doc", "pdf"); string savePath = Server.MapPath(str1); if (!System.IO.File.Exists(savePath)) { System.IO.File.Copy(path, savePath); Aspose.Words.Document doc = new Aspose.Words.Document(savePath); doc.Save(savePath, Aspose.Words.SaveFormat.Pdf); } return(ToJsonResult(str1)); } } return(ToJsonResult(0)); } catch (Exception ex) { return(ToJsonResult(0)); } }
public object getLawDetail([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string fileid = dy.data.fileid; SafetyLawEntity entity = safetylawbll.GetEntity(fileid); DataTable cdt = fileInfoBLL.GetFiles(entity.FilesId); IList <Photo> cfiles = new List <Photo>(); //资料文件 foreach (DataRow item in cdt.Rows) { Photo p = new Photo(); p.id = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); cfiles.Add(p); } return(new { Code = 0, Count = -1, Info = "获取数据成功", data = new { fileid = entity.Id, filename = entity.FileName, lawarea = entity.LawArea, filecode = entity.FileCode, issuedept = entity.IssueDept, carrydate = string.IsNullOrEmpty(entity.CarryDate.ToString()) ? "" : Convert.ToDateTime(entity.CarryDate).ToString("yyyy-MM-dd"), validversions = entity.ValidVersions, cfiles = cfiles } }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public ActionResult GetFilesByRecId(string recId) { var data = fileInfoBLL.GetFiles(recId); if (data != null) { foreach (DataRow item in data.Rows) { var path = item.Field <string>("FilePath"); var url = Url.Content(path); item.SetField <string>("FilePath", url); } } return(ToJsonResult(data)); }
public ActionResult GetFiles(string keyValue) { FileInfoBLL file = new FileInfoBLL(); var dt = file.GetFiles(keyValue);//先获取上传的附件 return(ToJsonResult(dt)); }
public object RemoveObsRecord([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; string obsId = dy.data.obsid; //附件 var filelist = fileinfobll.GetFiles(obsId); if (filelist.Rows.Count > 0) { for (int i = 0; i < filelist.Rows.Count; i++) { fileinfobll.RemoveForm(filelist.Rows[i]["fileid"].ToString()); } } //观察记录 observerecordbll.RemoveForm(obsId); return(new { Code = 0, Count = 0, Info = "操作成功" }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public object GetDetectionEntity([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); //获取用户Id string userId = dy.userid; OperatorProvider.AppUserId = userId; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, count = 0, info = "请求失败,请登录!" }); } string id = dy.data.Id;//ID DetectionRecordEntity entity = detectionrecordbll.GetEntity(id); dynamic obj = new ExpandoObject(); obj.Id = entity.Id; obj.EquipmentId = entity.EquipmentId; obj.DetectionPerson = entity.DetectionPerson; obj.DetectionDate = entity.DetectionDate; obj.Describe = entity.Describe; obj.Project = entity.Project; obj.Conclusion = entity.Conclusion; obj.DetectionPersonId = entity.DetectionPersonId; obj.Remark = entity.Remark; obj.Content = entity.Content; IList <Photo> pList = new List <Photo>(); //附件 DataTable file = fileInfoBLL.GetFiles(entity.Id); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pList.Add(p); } obj.file = pList; return(new { Code = 0, Count = 1, Info = "获取数据成功", data = obj }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public ActionResult SaveForm(string keyValue, string strentity, string Users, string UserIds, bool isNew) { OccupatioalstaffEntity userEntity = strentity.ToObject <OccupatioalstaffEntity>(); #region 处理体检员工表 //先查询出患病的用户 OccupationalstaffdetailBLL occupationalstaffdetailbll = new OccupationalstaffdetailBLL(); IEnumerable <OccupationalstaffdetailEntity> odlist = occupationalstaffdetailbll.GetList(keyValue, 1); //查询出所有填写的患病记录 IEnumerable <OccupationalstaffdetailEntity> yclist = occupationalstaffdetailbll.GetList(keyValue, 2); //查询出所有填写的异常记录 occupationalstaffdetailbll.UpdateTime((DateTime)(userEntity.InspectionTime), keyValue); //先将所有的病人体检时间纠正过来 if (!isNew) //修改模式 { occupationalstaffdetailbll.Delete(keyValue, 0); //先把健康人员记录删除再重新添加 } //获取到所有体检用户 string[] UserGroup = UserIds.Split(','); string[] UsersGroup = Users.Split(','); if (odlist != null) { for (int i = 0; i < UserGroup.Length; i++) { if (!IsTrue(odlist, yclist, UserGroup[i])) { //判断为健康员工 OccupationalstaffdetailEntity occ = new OccupationalstaffdetailEntity(); occ.UserId = UserGroup[i]; occ.UserName = UsersGroup[i]; occ.UserNamePinYin = Str.PinYin(UsersGroup[i]); occ.Note = ""; occ.Issick = 0; occ.InspectionTime = userEntity.InspectionTime; occ.OccId = keyValue; occ.SickType = "无"; occupationalstaffdetailbll.SaveForm("", occ); } } } #endregion FileInfoBLL file = new FileInfoBLL(); DataTable dt = file.GetFiles(keyValue);//先获取上传的附件 if (dt != null && dt.Rows.Count > 0) { userEntity.IsAnnex = 1;//有附件 } else { userEntity.IsAnnex = 0;//没有附件 } userEntity.OccId = keyValue; userEntity.InspectionNum = UserGroup.Length; userEntity.PatientNum = odlist.Count(); userEntity.UnusualNum = yclist.Count(); occupatioalstaffbll.SaveForm(isNew, userEntity); return(Success("操作成功。")); }
public object getEngineeringDetail([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string engineeringid = dy.data.engineeringid; PerilEngineeringEntity entity = perilengineeringbll.GetEntity(engineeringid); DataTable cdt = fileInfoBLL.GetFiles(entity.ConstructFiles); IList <Photo> cfiles = new List <Photo>(); //方案文件 foreach (DataRow item in cdt.Rows) { Photo p = new Photo(); p.id = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); cfiles.Add(p); } DataTable tfile = fileInfoBLL.GetFiles(entity.TaskFiles); IList <Photo> tfiles = new List <Photo>(); //交底文件 foreach (DataRow item in tfile.Rows) { Photo p = new Photo(); p.id = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); tfiles.Add(p); } return(new { Code = 0, Count = -1, Info = "获取数据成功", data = new { engineeringid = entity.Id, engineeringname = entity.EngineeringName, engineeringtype = getName(entity.EngineeringType), engineeringspot = entity.EngineeringSpot, estarttime = string.IsNullOrEmpty(entity.EStartTime.ToString()) ? "" : Convert.ToDateTime(entity.EStartTime).ToString("yyyy-MM-dd"), EFinishTime = string.IsNullOrEmpty(entity.EFinishTime.ToString()) ? "" : Convert.ToDateTime(entity.EFinishTime).ToString("yyyy-MM-dd"), belongdeptname = entity.BelongDeptName, examineperson = entity.ExaminePerson, ExamineTime = string.IsNullOrEmpty(entity.ExamineTime.ToString()) ? "" : Convert.ToDateTime(entity.ExamineTime).ToString("yyyy-MM-dd"), taskperson = entity.TaskPerson, TaskTime = string.IsNullOrEmpty(entity.TaskTime.ToString()) ? "" : Convert.ToDateTime(entity.TaskTime).ToString("yyyy-MM-dd"), taskcontent = entity.TaskContent, evolvecase = entity.EvolveCase, remark = entity.Remark, writedate = string.IsNullOrEmpty(entity.WriteDate.ToString()) ? "" : Convert.ToDateTime(entity.WriteDate).ToString("yyyy-MM-dd"), writeusername = entity.WriteUserName, cfiles = cfiles, tfiles = tfiles } }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public ActionResult GetFiles(string fileId) { FileInfoBLL fi = new FileInfoBLL(); var data = fi.GetFiles(fileId); foreach (DataRow item in data.Rows) { var path = item.Field <string>("FilePath"); var url = Url.Content(path); item.SetField <string>("FilePath", url); } return(ToJsonResult(data)); }
public ActionResult GetEmailFormJson(string keyValue) { var data = emailContentBLL.GetEntity(keyValue); string strJson = data.ToJson(); strJson = strJson.Insert(1, "\"SenderTimeName\":\"" + Time.GetChineseDateTime(data.SenderTime.ToDate()) + "\","); FileInfoBLL fi = new FileInfoBLL(); List <FileInfoEntity> dt = fi.GetFiles(data.ContentId); if (dt != null && dt.Count > 0) { strJson = strJson.Insert(1, "\"Files\":" + Newtonsoft.Json.JsonConvert.SerializeObject(dt) + ","); } return(Content(strJson)); }
public object GetAnnouncement([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); //获取用户Id string userId = dy.userid; OperatorProvider.AppUserId = userId; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, count = 0, info = "请求失败,请登录!" }); } string id = dy.data.AnnouncementId;//通知公告记录ID AnnouncementEntity entity = announcementbll.GetEntity(id); if (entity == null) { throw new ArgumentException("未找到信息"); } //未开放 //else //{ // if (entity.IsSend == "0") // { // //更改状态 // announcementbll.UpdateStatus(id); // } //} string jsondata = JsonConvert.SerializeObject(entity); NoticeData model = JsonConvert.DeserializeObject <NoticeData>(jsondata); List <Photo> pList = new List <Photo>(); //附件 DataTable file = fileInfoBLL.GetFiles(entity.Id); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pList.Add(p); } model.file = pList; JsonSerializerSettings settings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm", //格式化日期 }; return(new { code = 0, info = "获取数据成功", data = JObject.Parse(JsonConvert.SerializeObject(model, Formatting.None, settings)) }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public ActionResult GetFileNameByKeyValue(string keyValue) { FileInfoBLL fileInfoBLL = new FileInfoBLL(); if (string.IsNullOrEmpty(keyValue)) { return(Content("")); } DataTable data = null; data = fileInfoBLL.GetFiles(keyValue); if (data == null || data.Rows.Count == 0) { return(Content("")); } string name = string.IsNullOrEmpty(data.Rows[0]["FileName"].ToString()) ? Server.UrlDecode(data.Rows[0]["FileName"].ToString()) : Server.UrlDecode(data.Rows[0]["FileName"].ToString());//返回客户端文件名称 return(Content(name)); }
public void DownloadFileForKeyValue(string keyValue) { FileInfoBLL fileInfoBLL = new FileInfoBLL(); if (string.IsNullOrEmpty(keyValue)) { return; } DataTable data = null; data = fileInfoBLL.GetFiles(keyValue); if (data != null && data.Rows.Count > 0) { string name = string.IsNullOrEmpty(data.Rows[0]["FileName"].ToString()) ? Server.UrlDecode(data.Rows[0]["FileName"].ToString()) : Server.UrlDecode(data.Rows[0]["FileName"].ToString());//返回客户端文件名称 string filepath = this.Server.MapPath(data.Rows[0]["FilePath"].ToString()); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } } }
public object GetFilesByRecId(string RecId) { try { FileInfoBLL fileInfoBLL = new FileInfoBLL(); var data = fileInfoBLL.GetFiles(RecId); if (data != null) { foreach (DataRow item in data.Rows) { var path = item.Field <string>("FilePath"); var url = Url.Content(path); item.SetField <string>("FilePath", url); } } return(new { Code = 0, Count = data.Rows.Count, Info = "获取数据成功", data = data }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public object GetSafetyWorkSuperviseEntity([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userid = dy.userid; //用户ID OperatorProvider.AppUserId = userid; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, count = 0, info = "身份票据已失效,请重新登录!" }); } string webUrl = dataitemdetailbll.GetItemValue("imgUrl"); string id = dy.data.safetyworkid;//安全重点工作督办id //string fid = dy.data.historyid;//历史记录id var data = safetyworksupervisebll.GetEntityByT(id, ""); List <SuperviseEntity> list = new List <SuperviseEntity>(); SuperviseEntity entity = new SuperviseEntity(); dynamic resdata = new ExpandoObject(); if (data != null && data.Rows.Count > 0) { list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SuperviseEntity> >(data.ToJson()); } if (list.Count > 0) { entity = list[0]; if (!string.IsNullOrEmpty(entity.SignUrl)) { entity.SignUrl = webUrl + entity.SignUrl.ToString().Replace("../../", "/"); } if (!string.IsNullOrEmpty(entity.SignUrlT)) { entity.SignUrlT = webUrl + entity.SignUrlT.ToString().Replace("../../", "/"); } //会议资料附件 DataTable file = fileInfoBLL.GetFiles(entity.Fid); IList <Photo> rList = new List <Photo>(); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = webUrl + dr["filepath"].ToString().Substring(1); rList.Add(p); } resdata = new { id = entity.Id, createdate = !string.IsNullOrEmpty(entity.CreateDate.ToString()) ? entity.CreateDate.Value.ToString("yyyy-MM-dd") : "", createusername = entity.CreateUserName, supervisedate = !string.IsNullOrEmpty(entity.SuperviseDate.ToString()) ? entity.SuperviseDate.Value.ToString("yyyy-MM-dd") : "", worktask = entity.WorkTask, dutydeptname = entity.DutyDeptName, dutydeptid = entity.DutyDeptId, dutydeptcode = entity.DutyDeptCode, dutyperson = entity.DutyPerson, dutypersonid = entity.DutyPersonId, superviseperson = entity.SupervisePerson, supervisepersonid = entity.SupervisePersonId, finishdate = !string.IsNullOrEmpty(entity.FinishDate.ToString()) ? entity.FinishDate.Value.ToString("yyyy-MM-dd") : "", flowstate = entity.FlowState, remark = entity.Remark, fid = entity.Fid, btgnum = entity.btgnum, cid = entity.Cid, finishinfo = entity.FinishInfo, feedbackdate = !string.IsNullOrEmpty(entity.FeedbackDate.ToString()) ? entity.FeedbackDate.Value.ToString("yyyy-MM-dd") : "", superviseresult = entity.SuperviseResult, superviseopinion = entity.SuperviseOpinion, confirmationdate = !string.IsNullOrEmpty(entity.ConfirmationDate.ToString())? entity.ConfirmationDate.Value.ToString("yyyy-MM-dd"): "", signurl = entity.SignUrl, signurlt = entity.SignUrlT, supervisedeptname = entity.SuperviseDeptName, filelist = rList }; } return(new { Code = 0, Info = "获取数据成功", data = resdata }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public object GetForm([FromBody] JObject json) { try { string res = json.Value <string>("json"); var dy = JsonConvert.DeserializeAnonymousType(res, new { userid = string.Empty, data = new { id = string.Empty } }); //获取用户Id OperatorProvider.AppUserId = dy.userid; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, info = "请求失败,请登录!" }); } if (dy.data == null) { throw new ArgumentException("缺少参数:data为空"); } if (string.IsNullOrEmpty(dy.data.id)) { throw new ArgumentException("缺少参数:id为空"); } var fireWaterEntity = firewaterbll.GetEntity(dy.data.id); if (fireWaterEntity == null) { throw new ArgumentException("未找到信息"); } string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl"); string jsondata = JsonConvert.SerializeObject(fireWaterEntity); FireWaterModel model = JsonConvert.DeserializeObject <FireWaterModel>(jsondata); if (model.SpecialtyType != null) { model.SpecialtyTypeName = scaffoldbll.getName(fireWaterEntity.SpecialtyType, "SpecialtyType"); } model.FireWaterAudits = scaffoldauditrecordbll.GetList(fireWaterEntity.Id); foreach (var item in model.FireWaterAudits) { item.AuditSignImg = string.IsNullOrWhiteSpace(item.AuditSignImg) ? "" : webUrl + item.AuditSignImg.ToString().Replace("../../", "/"); } DataTable cdt = fileInfoBLL.GetFiles(model.Id); IList <Photo> cfiles = new List <Photo>(); foreach (DataRow item in cdt.Rows) { Photo p = new Photo(); p.fileid = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); cfiles.Add(p); } model.cfiles = cfiles; DataTable conditionfile = fileInfoBLL.GetFiles(model.Id + "01"); IList <Photo> conditionFiles = new List <Photo>(); foreach (DataRow item in conditionfile.Rows) { Photo p = new Photo(); p.fileid = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); conditionFiles.Add(p); } model.conditionFiles = conditionFiles; model.conditionEntity = firewaterbll.GetConditionEntity(model.Id); model.RiskRecord = highriskrecordbll.GetList(model.Id).ToList(); string moduleName = string.Empty; string projectid = ""; if (fireWaterEntity.WorkDeptType == "0")//单位内部 { moduleName = "消防水使用-内部审核"; } else { moduleName = "消防水使用-外部审核"; projectid = fireWaterEntity.EngineeringId; } var nodelist = firewaterbll.GetAppFlowList(fireWaterEntity.Id, moduleName); model.CheckFlow = nodelist; #region 获取执行情况 IList <FireWaterCondition> conditionlist = firewaterbll.GetConditionList(fireWaterEntity.Id).OrderBy(t => t.CreateDate).ToList(); for (int i = 0; i < conditionlist.Count; i++) { var item = conditionlist[i]; List <FileInfoEntity> piclist = fileInfoBLL.GetFileList(item.Id); IList <ERCHTMS.Entity.HighRiskWork.ViewModel.Photo> temppiclist = new List <ERCHTMS.Entity.HighRiskWork.ViewModel.Photo>(); foreach (var temp in piclist) { ERCHTMS.Entity.HighRiskWork.ViewModel.Photo pic = new ERCHTMS.Entity.HighRiskWork.ViewModel.Photo(); pic.filename = temp.FileName; pic.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + temp.FilePath.Substring(1); pic.fileid = temp.FileId; temppiclist.Add(pic); } item.piclist = temppiclist; List <FileInfoEntity> filelist = fileInfoBLL.GetFileList(item.Id + "_02"); IList <ERCHTMS.Entity.HighRiskWork.ViewModel.Photo> tempfilelist = new List <ERCHTMS.Entity.HighRiskWork.ViewModel.Photo>(); foreach (var temp in filelist) { ERCHTMS.Entity.HighRiskWork.ViewModel.Photo pic = new ERCHTMS.Entity.HighRiskWork.ViewModel.Photo(); pic.filename = temp.FileName; pic.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + temp.FilePath.Substring(1); pic.fileid = temp.FileId; tempfilelist.Add(pic); } item.filelist = tempfilelist; item.num = i / 2 + 1; } model.conditionlist = conditionlist; #endregion Dictionary <string, string> dict_props = new Dictionary <string, string>(); JsonSerializerSettings settings = new JsonSerializerSettings { ContractResolver = new LowercaseContractResolver(dict_props), //转小写,并对指定的列进行自定义名进行更换 DateFormatString = "yyyy-MM-dd HH:mm" }; return(new { code = 0, info = "获取数据成功", data = JObject.Parse(JsonConvert.SerializeObject(model, Formatting.None, settings)) }); } catch (Exception ex) { return(new { code = -1, data = "", info = ex.Message }); } }
public object GetEntity([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); //获取用户Id string userId = dy.userid; OperatorProvider.AppUserId = userId; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, count = 0, info = "请求失败,请登录!" }); } string id = dy.data.ID;//ID SafetyActivityEntity entity = SafetyActivitybll.GetEntity(id); var data = outsouringengineerbll.GetEntity(entity.EngineerId); var proData = outProjectbll.GetOutProjectInfo(data.OUTPROJECTID); dynamic obj = new ExpandoObject(); obj.Id = entity.ID; obj.CREATEUSERID = entity.CREATEUSERID; obj.CREATEUSERDEPTCODE = entity.CREATEUSERDEPTCODE; obj.CREATEUSERORGCODE = entity.CREATEUSERORGCODE; obj.CREATEDATE = entity.CREATEDATE.Value.ToString("yyyy-MM-dd HH:mm"); obj.CREATEUSERNAME = entity.CREATEUSERNAME; obj.MODIFYDATE = entity.MODIFYDATE; obj.MODIFYUSERID = entity.MODIFYUSERID; obj.MODIFYUSERNAME = entity.MODIFYUSERNAME; obj.EngineerId = entity.EngineerId; obj.StartTime = entity.StartTime.Value.ToString("yyyy-MM-dd HH:mm"); obj.EndTime = entity.EndTime.Value.ToString("yyyy-MM-dd HH:mm"); obj.PeopleNum = entity.PeopleNum; obj.PracticalPeopleNum = entity.PracticalPeopleNum; obj.Condition = entity.Condition; obj.StudyRecord = entity.StudyRecord; obj.StudyDetails = entity.StudyDetails; obj.EngineerletDept = data.ENGINEERLETDEPT; obj.OutsourcingName = proData.OUTSOURCINGNAME; obj.OutprojectId = data.OUTPROJECTID; obj.UnitSuper = data.UnitSuper; obj.EngineerName = data.ENGINEERNAME; IList <Photo> pList = new List <Photo>(); //附件 DataTable file = fileInfoBLL.GetFiles(entity.ID + "01"); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pList.Add(p); } obj.SafetyActivityFile = pList; IList <Photo> pList1 = new List <Photo>(); //附件 DataTable file1 = fileInfoBLL.GetFiles(entity.ID); foreach (DataRow dr in file1.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pList1.Add(p); } obj.SafetyActivityPic = pList1; return(new { Code = 0, Count = 1, Info = "获取数据成功", data = obj }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public object GetForm([FromBody] JObject json) { try { string res = json.Value <string>("json"); var dy = JsonConvert.DeserializeAnonymousType(res, new { userid = string.Empty, data = new LifthoistViewModel() }); //获取用户Id string userId = dy.userid; OperatorProvider.AppUserId = userId; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, info = "请求失败,请登录!" }); } if (dy.data == null) { return(new { code = -1, info = "请求失败,data参数为空!" }); } LifthoistViewModel retData = new LifthoistViewModel(); string[] pops = null; if (dy.data.pagetype == "1") { #region 凭吊证详情处理 //需要排的除段 pops = new string[] { "deletefileids", "qualitytype", "guardianid", "guardianname", "hoistcontent", "liftschemes" }; LifthoistcertEntity certEntity = lifthoistcertbll.GetEntity(dy.data.id); if (certEntity == null) { throw new ArgumentException("无法找到当前业务信息,请检查参数是否有误!"); } retData = JsonConvert.DeserializeObject <LifthoistViewModel>(JsonConvert.SerializeObject(certEntity)); //取人员资料 DataTable persondatas = fileInfoBLL.GetFiles(certEntity.ID + "1"); if (persondatas != null && persondatas.Rows.Count > 0) { retData.persondatas = new List <Photo>(); foreach (DataRow item in persondatas.Rows) { Photo p = new Photo(); p.fileid = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); retData.persondatas.Add(p); } } //取设备资料 DataTable driverdatas = fileInfoBLL.GetFiles(certEntity.ID + "2"); if (driverdatas != null && driverdatas.Rows.Count > 0) { retData.driverdatas = new List <Photo>(); foreach (DataRow item in driverdatas.Rows) { Photo p = new Photo(); p.fileid = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); retData.driverdatas.Add(p); } } string[] signs = null; string urls = string.Empty; //处理签字 if (!string.IsNullOrEmpty(retData.chargepersonsign)) { signs = retData.chargepersonsign.Split(','); urls = string.Empty; foreach (var s in signs) { if (!string.IsNullOrEmpty(s)) { if (s.Contains("http://")) { urls += "," + s; } else { urls += "," + dataitemdetailbll.GetItemValue("imgUrl") + s.Substring(1); } } } if (!string.IsNullOrEmpty(urls)) { retData.chargepersonsign = urls.Substring(1); } } if (!string.IsNullOrEmpty(retData.hoistareapersonsigns)) { signs = retData.hoistareapersonsigns.Split(','); urls = string.Empty; foreach (var s in signs) { if (!string.IsNullOrEmpty(s)) { if (s.Contains("http://")) { urls += "," + s; } else { urls += "," + dataitemdetailbll.GetItemValue("imgUrl") + s.Substring(1); } } } if (!string.IsNullOrEmpty(urls)) { retData.hoistareapersonsigns = urls.Substring(1); } } //安全措施 var safetys = lifthoistsafetybll.GetList(string.Format("LIFTHOISTCERTID = '{0}'", certEntity.ID)); if (safetys != null) { retData.safetys = safetys.ToList(); } #endregion } else { #region 起重吊装作业详情处理 //需要排的除段 pops = new string[] { "lifthoistjobid", "deletefileids", "drivername", "drivernumber", "fulltimename", "fulltimenumber", "persondatas", "driverdatas", "safetys", "chargepersonsign", "hoistareapersonnames", "hoistareapersonids", "hoistareapersonsigns" }; LifthoistjobEntity jobEntity = lifthoistjobbll.GetEntity(dy.data.id); if (jobEntity == null) { throw new ArgumentException("无法找到当前业务信息,请检查参数是否有误!"); } retData = JsonConvert.DeserializeObject <LifthoistViewModel>(JsonConvert.SerializeObject(jobEntity)); //取起吊方案 DataTable liftschemes = fileInfoBLL.GetFiles(jobEntity.ID); if (liftschemes != null && liftschemes.Rows.Count > 0) { retData.liftschemes = new List <Photo>(); foreach (DataRow item in liftschemes.Rows) { Photo p = new Photo(); p.fileid = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); retData.liftschemes.Add(p); } } DataTable liftfazls = fileInfoBLL.GetFiles(jobEntity.FAZLFILES); if (liftfazls != null && liftfazls.Rows.Count > 0) { retData.liftfazls = new List <Photo>(); foreach (DataRow item in liftfazls.Rows) { Photo p = new Photo(); p.fileid = item[0].ToString(); p.filename = item[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + item[2].ToString().Substring(1); retData.liftfazls.Add(p); } } #endregion #region 流程 string modulename = string.Empty; if (jobEntity.QUALITYTYPE == "0") { modulename = "(起重吊装作业30T以下)审核"; } else { modulename = "(起重吊装作业30T以上)审核"; } var nodelist = lifthoistjobbll.GetAppFlowList(jobEntity.ID, modulename); retData.CheckFlow = nodelist; #endregion } //审核记录 var records = lifthoistauditrecordbll.GetList(dy.data.id); if (records != null) { string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl"); foreach (var item in records) { item.AUDITSIGNIMG = item.AUDITSIGNIMG.Replace("../../", webUrl + "/"); } retData.auditrecords = records.ToList(); } //作业安全风险分析 var riskrecord = highriskrecordbll.GetList(dy.data.id).ToList(); if (riskrecord != null) { retData.riskrecord = riskrecord.ToList(); } //起重吊装人员信息 var lifthoistperson = lifthoistpersonbll.GetRelateList(dy.data.id).ToList(); if (lifthoistperson != null) { foreach (var item in lifthoistperson) { DataTable liftfazls = fileInfoBLL.GetFiles(item.Id); if (liftfazls != null && liftfazls.Rows.Count > 0) { List <Photo> files = new List <Photo>(); foreach (DataRow rowitem in liftfazls.Rows) { Photo p = new Photo(); p.fileid = rowitem[0].ToString(); p.filename = rowitem[1].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + rowitem[2].ToString().Substring(1); files.Add(p); } item.lifthoistpersonfile = files; } //var liftfazls = fileInfoBLL.GetFileList(item.Id); //foreach (var file in liftfazls) //{ // file.FilePath = dataitemdetailbll.GetItemValue("imgUrl") + file.FilePath.Substring(1); //} } retData.lifthoistperson = lifthoistperson.ToList(); } JsonSerializerSettings settings = new JsonSerializerSettings { ContractResolver = new LowercaseContractResolver(null, pops, false), DateFormatString = "yyyy-MM-dd HH:mm", //格式化日期 }; string retDataJson = JsonConvert.SerializeObject(retData, Formatting.Indented, settings); return(new { code = 0, info = string.Empty, data = JObject.Parse(retDataJson) }); } catch (Exception ex) { return(new { code = -1, info = ex.Message }); } }
public object GetDetial([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userid = dy.userid; string id = dy.data ?? ""; //获取用户基本信息 OperatorProvider.AppUserId = userid; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, count = 0, info = "请求失败,请登录!", data = new object() }); } var entity = workMeetingbll.GetEntity(id); if (entity != null) { //外包单位 OutsouringengineerBLL engneerBll = new OutsouringengineerBLL(); var engneer = engneerBll.GetEntity(entity.ENGINEERID); if (engneer != null) { entity.OUTPROJECTNAME = new DepartmentBLL().GetEntity(engneer.OUTPROJECTID).FullName; } if (!string.IsNullOrWhiteSpace(engneer.OUTPROJECTID)) { var dept = deptbll.GetEntity(engneer.OUTPROJECTID); entity.OUTPROJECTCODE = dept.EnCode; entity.OUTPROJECTNAME = dept.FullName; } Dictionary <string, List <Photo> > files = new Dictionary <string, List <Photo> >(); //内容1附件 DataTable file = fileInfoBLL.GetFiles(entity.ID + "c1"); var pC1 = new List <Photo>(); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pC1.Add(p); } files.Add("c1", pC1); //内容2附件 file = fileInfoBLL.GetFiles(entity.ID + "c2"); var pC2 = new List <Photo>(); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pC2.Add(p); } files.Add("c2", pC2); //内容3附件 file = fileInfoBLL.GetFiles(entity.ID + "c3"); var pC3 = new List <Photo>(); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pC3.Add(p); } files.Add("c3", pC3); //签名附件 file = fileInfoBLL.GetFiles(entity.ID); var pList = new List <Photo>(); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pList.Add(p); } files.Add("sign", pList); entity.FILES = files; //return json(new //{ // code = 0, // info = "获取数据成功", // count = 0, // data = entity //}, new jsonserializersettings() { dateformatstring = "yyyy-mm-dd hh:mm:ss" }); JsonSerializerSettings settings = new JsonSerializerSettings { //ContractResolver = new LowercaseContractResolver(dict_props), //转小写,并对指定的列进行自定义名进行更换 DateFormatString = "yyyy-MM-dd HH:mm:ss", //格式化日期 //NullValueHandling = NullValueHandling.Ignore 值为空则在JSON中体现 }; return(new { code = 0, info = "获取数据成功", count = 0, data = JObject.Parse(JsonConvert.SerializeObject(entity, Formatting.None, settings)) }); } else { return(new { code = -1, count = 0, info = "获取失败,记录不存在。", data = new object() }); } } catch (Exception ex) { return(new { code = -1, count = 0, info = "获取失败,错误:" + ex.Message, data = new object() }); } }
public object GetFileList([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); //获取用户Id string userId = dy.userid; //获取文件类型ID string filetypeid = dy.data.filetypeid; //获取文件名称 string filename = dy.data.filename; //是否包含子节点数据,0否,1是 string type = dy.data.type; if (null == curUser) { return(new { code = -1, count = 0, info = "请求失败,请登录!" }); } //获取页数和条数 int page = Convert.ToInt32(dy.data.pageNum), rows = Convert.ToInt32(dy.data.pageSize); Pagination pagination = new Pagination(); pagination.p_kid = "ID"; pagination.p_fields = "FileName,FileNo,FileTypeName,ReleaseDeptName,to_char(ReleaseTime,'yyyy-Mm-dd') as ReleaseTime,Remark"; pagination.p_tablename = "bis_filemanage t"; pagination.page = page; //页数 pagination.rows = rows; //行数 pagination.sidx = "ReleaseTime"; //排序字段 pagination.sord = "desc"; //排序方式 pagination.conditionJson = string.Format(" CreateUserOrgCode='{0}'", curUser.OrganizeCode); if (!string.IsNullOrEmpty(filetypeid)) { if (type == "1") { pagination.conditionJson = string.Format("FileTypeCode like '{0}%'", filetypeid); } else { pagination.conditionJson = string.Format("FileTypeCode='{0}'", filetypeid); } } if (!string.IsNullOrEmpty(filename)) { pagination.conditionJson += string.Format(" and filename like '%{0}%' ", filename); } DataTable dt = FileManage.GetList(pagination, "app"); List <object> data = new List <object>(); foreach (DataRow dr in dt.Rows) { dynamic entity = new ExpandoObject(); entity.filename = dr["FileName"].ToString(); //文件名称 entity.fileno = dr["FileNo"].ToString(); //文件编号 entity.filetypename = dr["FileTypeName"].ToString(); //文件类型 entity.releasedeptname = dr["ReleaseDeptName"].ToString(); //发布单位 entity.releasetime = dr["ReleaseTime"].ToString(); //发布时间 entity.remark = dr["remark"].ToString(); //备注 IList <Photo> rList = new List <Photo>(); //附件 DataTable file = fileInfoBLL.GetFiles(dr["ID"].ToString()); foreach (DataRow drs in file.Rows) { Photo p = new Photo(); p.id = drs["fileid"].ToString(); p.filename = drs["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + drs["filepath"].ToString().Substring(1); rList.Add(p); } entity.file = rList; data.Add(entity); } return(new { code = 0, info = "获取数据成功", count = pagination.records, data = data }); } catch (Exception ex) { return(new { code = -1, info = ex.Message, count = 0 }); } }
public ActionResult ExportData(string queryJson) { try { Pagination pagination = new Pagination(); pagination.page = 1; pagination.rows = 1000000000; pagination.p_kid = "a.Id"; pagination.p_fields = "EngineeringName,ProgrammeCategory as EngineeringType,BelongDeptName,case when UnitType = 1 then '单位内部' else '外包单位' end as UnitType,EStartTime,EFinishTime,ConstructFiles,TaskFiles,EvolveCase"; pagination.p_tablename = " bis_perilengineering a left join bis_engineeringsetting b on a.EngineeringType = b.id"; Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); string authType = new AuthorizeBLL().GetOperAuthorzeType(user, HttpContext.Request.Cookies["currentmoduleId"].Value, "search"); if (!string.IsNullOrEmpty(authType)) { switch (authType) { case "1": pagination.conditionJson += " a.createuserid='" + user.UserId + "'"; break; case "2": pagination.conditionJson += string.Format(" belongdeptid in (select departmentid from base_department where encode='{0}' union select ORGANIZEID from BASE_ORGANIZE where encode='{0}')", user.OrganizeCode); break; case "3": pagination.conditionJson += string.Format(" belongdeptid in (select departmentid from base_department where encode like '{0}%' union select ORGANIZEID from BASE_ORGANIZE where encode like '{0}%')", user.DeptCode); break; case "4": pagination.conditionJson += string.Format(" belongdeptid in (select departmentid from base_department where encode like '{0}%' union select ORGANIZEID from BASE_ORGANIZE where encode like '{0}%')", user.OrganizeCode); break; } } else { pagination.conditionJson += " 0=1"; } DataTable exportTable = perilengineeringbll.GetPageList(pagination, queryJson); foreach (DataRow item in exportTable.Rows) { var dt = fileInfoBLL.GetFiles(item["ConstructFiles"].ToString()); if (dt.Rows.Count > 0) { item["ConstructFiles"] = "有"; } else { item["ConstructFiles"] = "无"; } var dt1 = fileInfoBLL.GetFiles(item["TaskFiles"].ToString()); if (dt1.Rows.Count > 0) { item["TaskFiles"] = "有"; } else { item["TaskFiles"] = "无"; } } //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "危大工程信息"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 16; excelconfig.FileName = "危大工程信息导出.xls"; excelconfig.IsAllSizeColumn = true; List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); excelconfig.ColumnEntity = listColumnEntity; ColumnEntity columnentity = new ColumnEntity(); //需跟数据源列顺序保持一致 excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "engineeringname", ExcelColumn = "工程名称", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "engineeringtype", ExcelColumn = "工程类别", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "belongdeptname", ExcelColumn = "所属单位", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "unittype", ExcelColumn = "单位类别", Width = 15 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "estarttime", ExcelColumn = "开始时间", Width = 10 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "efinishtime", ExcelColumn = "结束时间", Width = 10 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "constructfiles", ExcelColumn = "施工方案", Width = 10 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "taskfiles", ExcelColumn = "安全技术交底", Width = 12 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "evolvecase", ExcelColumn = "进展情况", Width = 15 }); //调用导出方法 ExcelHelper.ExcelDownload(exportTable, excelconfig); } catch (Exception ex) { } return(Success("导出成功。")); }
public ActionResult GetAptituInfoByOutProject(string outProjectId, string keyValue) { var zzData = aptitudeinvestigateinfobll.GetListByOutprojectId(outProjectId); if (zzData != null) { var data = new { BUSCODE = zzData.BUSCODE, BUSCERTIFICATE = zzData.BUSCERTIFICATE, BUSVALIDSTARTTIME = zzData.BUSVALIDSTARTTIME, BUSVALIDENDTIME = zzData.BUSVALIDENDTIME, SPLCODE = zzData.SPLCODE, SPLCERTIFICATE = zzData.SPLCERTIFICATE, SPLVALIDSTARTTIME = zzData.SPLVALIDSTARTTIME, SPLVALIDENDTIME = zzData.SPLVALIDENDTIME, UnitSuper = zzData.UnitSuper, UnitSuperPhone = zzData.UnitSuperPhone, ProjectManager = zzData.ProjectManager, ProjectManagerTel = zzData.ProjectManagerTel, SafetyModerator = zzData.SafetyModerator, SafetyModeratorTel = zzData.SafetyModeratorTel, //CQCODE = zzData.CQCODE, //CQORG = zzData.CQORG, //CQRANGE = zzData.CQRANGE, //CQLEVEL = zzData.CQLEVEL, //CQVALIDSTARTTIME = zzData.CQVALIDSTARTTIME, //CQVALIDENDTIME = zzData.CQVALIDENDTIME, ID = zzData.ID }; //编辑时同步上次通过审核的单位资质附件 //如果前面同步过其它的附件先删除后在同步 //保证与最近一次通过审核的资质审查信息一致 for (int i = 1; i <= 8; i++) { var id = zzData.ID + "0" + i; var file1 = filebll.GetFiles(id); if (file1.Rows.Count > 0) { var key = keyValue + "0" + i; var fileEdit1 = filebll.GetFiles(key); if (fileEdit1.Rows.Count > 0) { foreach (DataRow item in fileEdit1.Rows) { filebll.RemoveForm(item["FileId"].ToString()); } } foreach (DataRow item in file1.Rows) { FileInfoEntity itemFile = new FileInfoEntity(); //itemFile.FileId = Guid.NewGuid().ToString(); itemFile.FileName = item["FileName"].ToString(); itemFile.FilePath = item["filepath"].ToString(); itemFile.FileSize = item["filesize"].ToString(); itemFile.RecId = (keyValue + "0" + i).ToString(); filebll.SaveForm(itemFile.FileId, itemFile); } } } //查询资质证件信息并给当前新增的赋值 List<QualificationEntity> quaOldList = aptitudeinvestigateinfobll.GetZzzjList().Where(x => x.InfoId == keyValue).ToList(); if (quaOldList.Count > 0) { for (int i = 0; i < quaOldList.Count; i++) { aptitudeinvestigateinfobll.RemoveZzzjForm(quaOldList[i].ID); } } List<QualificationEntity> quaList = aptitudeinvestigateinfobll.GetZzzjList().Where(x => x.InfoId == zzData.ID).ToList(); for (int i = 0; i < quaList.Count; i++) { var file1 =new FileInfoBLL().GetFiles(quaList[i].ID); quaList[i].ID = ""; quaList[i].InfoId = keyValue; aptitudeinvestigateinfobll.SaveZzzjForm("", quaList[i]); if (file1.Rows.Count > 0) { var key = quaList[i].ID; foreach (DataRow item in file1.Rows) { FileInfoEntity itemFile = new FileInfoEntity(); itemFile.FileName = item["FileName"].ToString(); itemFile.FilePath = item["filepath"].ToString(); itemFile.FileSize = item["filesize"].ToString(); itemFile.RecId = key; new FileInfoBLL().SaveForm(itemFile.FileId, itemFile); } } } return ToJsonResult(data); } else { return ToJsonResult(null); } }
public ActionResult ExportInfo(string keyValue) { try { HttpResponse resp = System.Web.HttpContext.Current.Response; //报告对象 string fileName = "起重吊装作业_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc"; string strDocPath = Request.PhysicalApplicationPath + @"Resource\ExcelTemplate\起重吊装作业导出模板.docx"; Aspose.Words.Document doc = new Aspose.Words.Document(strDocPath); DocumentBuilder builder = new DocumentBuilder(doc); DataTable dt = new DataTable(); dt.Columns.Add("APPLYCODE"); //编号 dt.Columns.Add("CHARGEPERSONNAME"); //工作负责人 dt.Columns.Add("GUARDIANNAME"); //监护人 dt.Columns.Add("QUALITY"); //起吊重物质量 dt.Columns.Add("TOOLNAME"); //吊装工具名称 dt.Columns.Add("CONSTRUCTIONUNITNAME"); //吊装施工单位 dt.Columns.Add("CONSTRUCTIONADDRESS"); //吊装施工地点 dt.Columns.Add("HOISTCONTENT"); //吊装内容 dt.Columns.Add("WORKDATE"); //作业时间 dt.Columns.Add("APPLYCOMPANYNAME"); //申请单位 dt.Columns.Add("APPLYUSERNAME"); //申请人 dt.Columns.Add("APPLYDATE"); //申请日期 dt.Columns.Add("approve1"); //技术支持部专业 dt.Columns.Add("approvedate1"); dt.Columns.Add("approve2"); //技术支持部 dt.Columns.Add("approvedate2"); dt.Columns.Add("approve3"); //分管领导 dt.Columns.Add("approvedate3"); DataRow row = dt.NewRow(); LifthoistjobEntity entity = lifthoistjobbll.GetEntity(keyValue); row["APPLYCODE"] = entity.APPLYCODESTR; row["CHARGEPERSONNAME"] = entity.CHARGEPERSONNAME; row["GUARDIANNAME"] = entity.GUARDIANNAME; row["QUALITY"] = entity.QUALITY; row["TOOLNAME"] = dataitemdetailbll.GetItemName("ToolName", entity.TOOLNAME); row["CONSTRUCTIONUNITNAME"] = entity.CONSTRUCTIONUNITNAME; row["CONSTRUCTIONADDRESS"] = entity.CONSTRUCTIONADDRESS; row["HOISTCONTENT"] = entity.HOISTCONTENT; row["WORKDATE"] = "自" + Convert.ToDateTime(entity.WORKSTARTDATE).ToString("yyyy年MM月dd日HH时mm分") + "到" + Convert.ToDateTime(entity.WORKENDDATE).ToString("yyyy年MM月dd日HH时mm分"); row["APPLYCOMPANYNAME"] = entity.APPLYCOMPANYNAME; row["APPLYUSERNAME"] = entity.APPLYUSERNAME; row["APPLYDATE"] = Convert.ToDateTime(entity.APPLYDATE).ToString("yyyy-MM-dd HH:mm"); IList <LifthoistauditrecordEntity> auditlist = lifthoistauditrecordbll.GetList(keyValue).Where(t => t.DISABLE != 1).OrderBy(t => t.AUDITDATE).ToList(); for (int i = 0; i < auditlist.Count; i++) { var filepath = auditlist[i].AUDITSIGNIMG == null?Server.MapPath("~/content/Images/no_1.png") : (Server.MapPath("~/") + auditlist[i].AUDITSIGNIMG.ToString().Replace("../../", "").ToString()).Replace(@"\/", "/").ToString(); if (!System.IO.File.Exists(filepath)) { filepath = Server.MapPath("~/content/Images/no_1.png"); } var stime = Convert.ToDateTime(auditlist[i].AUDITDATE).ToString("yyyy-MM-dd HH:mm"); switch (i) { case 0: builder.MoveToMergeField("approve1"); builder.InsertImage(filepath, 80, 35); row["approvedate1"] = stime; break; case 1: builder.MoveToMergeField("approve2"); builder.InsertImage(filepath, 80, 35); row["approvedate2"] = stime; break; case 2: builder.MoveToMergeField("approve3"); builder.InsertImage(filepath, 80, 35); row["approvedate3"] = stime; break; default: break; } } dt.Rows.Add(row); doc.MailMerge.Execute(dt); DataTable dtperson = new DataTable("U"); dtperson.Columns.Add("BelongDeptName"); dtperson.Columns.Add("CertificateNum"); dtperson.Columns.Add("PersonName"); dtperson.Columns.Add("PersonType"); List <LifthoistpersonEntity> listperson = lifthoistpersonbll.GetRelateList(keyValue).ToList(); foreach (var item in listperson) { DataRow dtrow = dtperson.NewRow(); dtrow["BelongDeptName"] = item.BelongDeptName; dtrow["CertificateNum"] = item.CertificateNum; dtrow["PersonName"] = item.PersonName; dtrow["PersonType"] = item.PersonName; DataTable liftfazls = fileInfoBLL.GetFiles(item.Id); if (liftfazls != null && liftfazls.Rows.Count > 0) { foreach (DataRow rowitem in liftfazls.Rows) { string image = "ico,gif,jpeg,jpg,png,psd"; if (image.Contains(rowitem["filepath"].ToString().Split('.')[1].ToLower())) { var filepath = rowitem["filepath"] == null?Server.MapPath("~/content/Images/no_1.png") : (Server.MapPath("~/") + rowitem["filepath"].ToString().Replace("~/", "").ToString()).Replace(@"\/", "/").ToString(); if (!System.IO.File.Exists(filepath)) { filepath = Server.MapPath("~/content/Images/no_1.png"); } builder.MoveToMergeField("lifthoistpersonfile"); builder.InsertImage(filepath, 80, 35); } } } dtperson.Rows.Add(dtrow); } doc.MailMerge.ExecuteWithRegions(dtperson); doc.MailMerge.DeleteFields(); doc.Save(resp, Server.UrlEncode(fileName), ContentDisposition.Attachment, Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Doc)); return(Success("导出成功!")); } catch (Exception ex) { return(Error(ex.ToString())); } }