private VisaView EmpToView(Epm_Visa visa, List<Epm_VisaCompany> companys) { VisaView model = new VisaView(); model.ChangeId = visa.ChangeId; model.ChangeName = visa.ChangeName; model.CrtCompanyId = visa.CrtCompanyId; model.CrtCompanyName = visa.CrtCompanyName; model.Id = visa.Id; model.ProjectId = visa.ProjectId; model.ProjectName = visa.ProjectName; model.Remark = visa.Remark; model.State = visa.State; model.SubmitTime = visa.SubmitTime; model.SubmitUserId = visa.SubmitUserId; model.SubmitUserName = visa.SubmitUserName; model.VisaAmount = visa.VisaAmount; model.VisaContent = visa.VisaContent; model.VisaDays = visa.VisaDays; model.VisaEndTime = visa.VisaEndTime; model.VisaNo = visa.VisaNo; model.VisaResean = visa.VisaResean; model.VisaStartTime = visa.VisaStartTime; model.VisaTitle = visa.VisaTitle; model.CompanyIds = string.Join(",", companys.Select(t => t.CompanyId)); model.CompanyNames = string.Join(",", companys.Select(t => t.CompanyName)); model.Epm_VisaCompany = companys; model.VisaTypeName = visa.VisaTypeName ?? ""; model.CreateTime = visa.CreateTime; model.CreateUserId = visa.CreateUserId; model.CreateUserName = visa.CreateUserName; return model; }
public ActionResult Edit(VisaView model) { List <Base_Files> fileList = new List <Base_Files>(); string fileDataJson = Request.Form["fileDataJsonFile"];//获取上传文件json字符串 if (!string.IsNullOrEmpty(fileDataJson)) { fileList = JsonConvert.DeserializeObject <List <Base_Files> >(fileDataJson);//将文件信息json字符 } string dataVisaCompany = Request.Form["CompanyIds"]; if (!string.IsNullOrEmpty(dataVisaCompany)) { model.Epm_VisaCompany = JsonConvert.DeserializeObject <List <Epm_VisaCompany> >(dataVisaCompany); } Result <int> result = new Result <int>(); using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request))) { result = proxy.UpdateVisa(model, fileList); } return(Json(result.ToResultView())); }
private void ViewToEmp(VisaView view, out Epm_Visa visa, out List<Epm_VisaCompany> companys) { visa = new Epm_Visa(); base.SetCurrentUser(visa); visa.ChangeId = view.ChangeId ?? 0; visa.ChangeName = view.ChangeName ?? ""; visa.CrtCompanyId = CurrentCompanyID.ToLongReq(); visa.CrtCompanyName = CurrentCompanyName ?? ""; visa.Id = view.Id; visa.VisaAmount = view.VisaAmount ?? 0; visa.VisaTitle = view.VisaTitle ?? ""; visa.VisaContent = view.VisaContent ?? ""; visa.VisaDays = view.VisaDays ?? 0; visa.VisaEndTime = view.VisaEndTime; visa.VisaNo = view.VisaNo ?? ""; visa.VisaResean = view.VisaResean ?? ""; visa.VisaStartTime = view.VisaStartTime; visa.ProjectId = view.ProjectId ?? 0; visa.ProjectName = view.ProjectName ?? ""; visa.Remark = view.Remark ?? ""; visa.State = view.State; visa.SubmitUserId = view.SubmitUserId; visa.SubmitUserName = view.SubmitUserName ?? ""; visa.VisaTypeName = view.VisaTypeName ?? ""; companys = new List<Epm_VisaCompany>(); if (view.Epm_VisaCompany != null) { foreach (var item in view.Epm_VisaCompany) { var comany = new Epm_VisaCompany(); base.SetCurrentUser(comany); comany.CrtCompanyId = CurrentCompanyID.ToLongReq(); comany.CrtCompanyName = CurrentCompanyName; comany.CompanyId = item.CompanyId; comany.CompanyName = item.CompanyName; comany.VisaId = view.Id; comany.CompanyType = item.CompanyType; companys.Add(comany); } } }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result<int> AddVisa(VisaView model, List<Base_Files> fileList) { Result<int> result = new Result<int>(); try { Epm_Visa visa = new Epm_Visa(); List<Epm_VisaCompany> companys = new List<Epm_VisaCompany>(); model.Id = visa.Id; ViewToEmp(model, out visa, out companys); var rows = DataOperateBusiness<Epm_Visa>.Get().Add(visa); DataOperateBusiness<Epm_VisaCompany>.Get().AddRange(companys); if (model.State == (int)ApprovalState.WaitAppr) { if (companys.Any() && companys.Count > 0) { for (int i = 0; i < companys.Count; i++) { var comID = companys[i].CompanyId; var temp = DataOperateBusiness<Epm_ProjectStateTrack>.Get().GetList(t => t.CompanyId == comID).FirstOrDefault(); if (temp != null) { temp.Qty = (Convert.ToInt32(temp.Qty) + 1).ToString(); DataOperateBusiness<Epm_ProjectStateTrack>.Get().Update(temp); } } } #region 生成待办 var project = DataOperateBusiness<Epm_Project>.Get().GetModel(model.ProjectId.Value); List<Epm_Approver> list = new List<Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了隐蔽工程作业单,待审核"; app.Content = CurrentUserName + "提报了隐蔽工程作业单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Visa.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Visa.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = visa.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Visa.GetText(), SystemRight.Add.GetText(), "提交签证生成待办: " + visa.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提报了隐蔽工程作业单,待审核"; modelMsg.Content = CurrentUserName + "提报了隐蔽工程作业单,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Visa.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness<Epm_Massage>.Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterssm = new Dictionary<string, string>(); //parameterssm.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.VisaAdd, parameterssm); #endregion } if (fileList != null) { //新增附件 AddFilesByTable(visa, fileList); } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Visa.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddVisa"); } return result; }