public ActionResult Edit(Epm_TzPeopleChgApply model) { Result <int> result = new Result <int>(); string fileDataJson = Request.Form["fileDataJsonFile"]; //获取上传文件json字符串 string tzPeopleChgApplyItem = Request.Form["tzPeopleChgApplyItem"]; //获取人员变更情况json字符串 if (!string.IsNullOrEmpty(fileDataJson)) { model.TzAttachs = JsonConvert.DeserializeObject <List <Epm_TzAttachs> >(fileDataJson);//将文件信息json字符 } if (!string.IsNullOrEmpty(tzPeopleChgApplyItem)) { model.TzPeopleChgApplyItem = JsonConvert.DeserializeObject <List <Epm_TzPeopleChgApplyItem> >(tzPeopleChgApplyItem); } using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request))) { result = proxy.UpdateTzPeopleChgApply(model); } return(Json(result.ToResultView())); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddTzPeopleChgApply(Epm_TzPeopleChgApply model) { Result <int> result = new Result <int>(); try { model = SetCurrentUser(model); model = SetCreateUser(model); #region 建设工程项目管理人员变更申请流程 var XtWorkFlow = System.Configuration.ConfigurationManager.AppSettings.Get("XtWorkFlow"); if (model.State == (int)PreProjectApprovalState.WaitApproval && XtWorkFlow == "1") { TzPeopleChgApplyView view = new TzPeopleChgApplyView(); if (model.ApplicantId != null) { var baseUser = DataOperateBasic <Base_User> .Get().GetModel(model.ApplicantId.Value); if (baseUser == null) { throw new Exception("未找到申请人相关信息!"); } view.hr_sqr = baseUser.ObjeId; } if (model.DepartmentId != null) { var company = DataOperateBasic <Base_Company> .Get().GetModel(model.DepartmentId.Value); if (company == null) { throw new Exception("未获取到申请部门信息!"); } view.dep_sqbm = company.ObjeId; } else { throw new Exception("请选择申请部门!"); } if (model.CompanyId != null) { var company = DataOperateBasic <Base_Company> .Get().GetModel(model.CompanyId.Value); if (company == null) { throw new Exception("未获取到申请单位信息!"); } view.sub_sqdw = company.ObjeId; } else { throw new Exception("请选择申请单位!"); } view.date_sqrq = string.Format("{0:yyyy-MM-dd}", DateTime.Now); view.txt_xmmc = model.ProjectName; view.txt_jsdz = model.ConstructionAddress; view.sub_sgdw = model.WorkUnit; view.txt_fzr = model.Leader; if (model.LeaderId != null) { var baseUserHeaderID = DataOperateBasic <Base_User> .Get().GetModel(model.LeaderId.Value); if (baseUserHeaderID == null) { throw new Exception("未找到分管领导相关信息!"); } view.hr_fgld = baseUserHeaderID.ObjeId; } if (model.DepLeaderId != null) { var baseUserLeaderID = DataOperateBasic <Base_User> .Get().GetModel(model.DepLeaderId.Value); if (baseUserLeaderID == null) { throw new Exception("未找到部门负责人相关信息!"); } view.hr_bmfzr = baseUserLeaderID.ObjeId; } //明细表信息 if (model.TzPeopleChgApplyItem != null && model.TzPeopleChgApplyItem.Any()) { view.list = new List <TzPeopleChgApplyView.TzPeopleChgApplyItem>(); foreach (var temp in model.TzPeopleChgApplyItem) { TzPeopleChgApplyView.TzPeopleChgApplyItem itemview = new TzPeopleChgApplyView.TzPeopleChgApplyItem(); itemview.txt_bgqzyzsmc = temp.ChgCertiNameBefore; itemview.txt_bghzyzsmc = temp.ChgCertiNameAfter; itemview.txt_bggw = temp.ChgPost; itemview.txt_bgqry = temp.ChgPeopleBefore; itemview.txt_bghry = temp.ChgPeopleAfter; itemview.txt_bgqzyzsh = temp.ChgCertiNoBefore; itemview.txt_bghzyzsh = temp.ChgCertiNoAfter; view.list.Add(itemview); } } //附件 if (model.TzAttachs != null && model.TzAttachs.Any()) { //string baseFaleUrl = System.Configuration.ConfigurationManager.AppSettings.Get("XtDownloadUrl"); //foreach (var item in model.TzAttachs) //{ // string fileUrl = string.Format("{0}?fileId={1}&type={2}", baseFaleUrl, item.Id, item.TypeNo); // switch (item.TypeNo) // { // case "RYBGFJ": // view.fj = fileUrl + '|' + view.fj; ; // break; // default: // break; // } //} //if (view.fj != null) //{ // view.fj = view.fj.Substring(view.fj.Length - 1); //} var fileList = model.TzAttachs.Where(p => p.TypeNo == "RYBGFJ").ToList(); view.fj = XtWorkFlowSubmitService.CreateXtAttachPath(fileList); } model.WorkFlowId = XtWorkFlowService.CreateTzPeopleChgApplyWorkFlow(view); } #endregion var rows = DataOperateBusiness <Epm_TzPeopleChgApply> .Get().Add(model); if (model.TzPeopleChgApplyItem != null && model.TzPeopleChgApplyItem.Any()) { model.TzPeopleChgApplyItem.ForEach(item => { item.ChangeApplyId = model.Id; item = SetCurrentUser(item); item = SetCreateUser(item); }); DataOperateBusiness <Epm_TzPeopleChgApplyItem> .Get().AddRange(model.TzPeopleChgApplyItem); } //上传附件 if (model.TzAttachs != null && model.TzAttachs.Any()) { AddFilesBytzTable(model, model.TzAttachs); } result.Data = rows; result.Flag = EResultFlag.Success; //WriteLog(AdminModule.TzPeopleChgApply.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddTzPeopleChgApply"); } return(result); }