/// <summary> /// 管理员重发凭证邮件 /// </summary> /// <param name="inn"></param> /// <param name="b_Employee"></param> /// <param name="recordNo"></param> public static void ExpenseAccountantCheckSendEmail(Innovator inn, string b_Employee, string recordNo) { //邮箱列表 List <string> listEmail = new List <string>(); List <string> names = new List <string>(); string subject = ""; string body = ""; //获取申请人邮箱 Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Employee); if (!applicantIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names); } subject = "您单号为[" + recordNo + "]的费用报销单已通过财务分析员审核,请将报销单打印并附上报销凭证,交到财务部门进行费用审核。——如已打印并交到财务部,请忽略此邮件。"; body = "您单号为[" + recordNo + "]的费用报销单已通过财务分析员审核,请将报销单打印并附上报销凭证,交到财务部门进行费用审核。——如已打印并交到财务部,请忽略此邮件。<br/>"; body += "打印方式:进入 https://oa.bordrin.com ,打开菜单 报销管理->查询费用报销,找到对应申请单,单击单号后面的打印按钮打印申请单。"; listEmail = new List <string>(); listEmail.Add("*****@*****.**"); listEmail.Add("*****@*****.**"); listEmail.Add("Kai.Feng @bordrin.com"); //异步执行 new Task(() => { MailOperator.SendMail(listEmail, subject, body); }).Start(); }
/// <summary> /// 保存行政代订 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult SaveBookingStaffing(BookingStaffingModel model) { var retModel = new JsonReturnModel(); try { //验证输入的员工名称是否存在 //验证高级经理 if (!string.IsNullOrEmpty(model.b_UserName)) { Item UserNameObj = IdentityDA.GetIdentityByKeyedName(inn, model.b_UserName); if (UserNameObj.isError()) { retModel.AddError("errorMessage", "找不到对应的员工名称!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } var BookingStaffing = inn.newItem("b_BookingStaffing", "add"); BookingStaffing.setProperty("b_username", model.b_UserName); var result = BookingStaffing.apply(); if (result.isError()) { retModel.AddError("errorMessage", result.getErrorString()); } } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 添加节点审核 /// </summary> /// <param name="inn"></param> /// <param name="id"></param> /// <param name="activityName"></param> /// <param name="tableName"></param> /// <param name="AuditStr"></param> public static void AddActivityAudit(Innovator inn, string id, string activityName, string tableName, List <string> AuditStr) { List <string> activityNames = new List <string> { activityName }; List <string> ids = new List <string>(); if (AuditStr != null && AuditStr.Count > 0) { foreach (var item in AuditStr) { Item identity = IdentityDA.GetIdentityByKeyedName(inn, item); if (!identity.isError() && identity.getItemCount() > 0) { string identityId = identity.getProperty("id"); ids.Add(identityId); } } } ids = ids.Distinct().ToList(); if (ids.Count > 0) { foreach (var identityId in ids) { ActivityBll.AddActivityAuth(inn, id, identityId, activityNames, tableName); } } }
/// <summary> /// 当财务总监审核通过后,发送邮件 /// </summary> /// <param name="inn"></param> /// <param name="proposer"></param> /// <param name="recordNo"></param> public static void SendEmailToProposer(Innovator inn, string proposer, string recordNo) { //邮箱列表 List <string> listEmail = new List <string>(); List <string> names = new List <string>(); string subject = ""; string body = ""; //获取申请人邮箱 Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, proposer); if (!applicantIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names); } subject = "Your expense reimbursement application <" + recordNo + "> has been approved by financial analyst, Please hand in your application and receipts to finance department."; body = "您单号为< " + recordNo + " >的费用报销单已通过财务分析员审核,请将报销单打印并附上报销凭证,交到财务部门进行费用审核。<br/>"; body += "Your expense reimbursement application < " + recordNo + " > has been approved by financial analyst, Please hand in your application and receipts to finance department."; listEmail = new List <string>(); listEmail.Add("*****@*****.**"); listEmail.Add("*****@*****.**"); //listEmail.Add("*****@*****.**"); //异步执行 new Task(() => { MailOperator.SendMail(listEmail, subject, body); }).Start(); }
/// <summary> /// 保存数据 /// </summary> /// <returns></returns> public JsonResult SaveAgentSet(AgentSetModel model) { var retModel = new JsonReturnModel(); try { //限制输入的代理人不能为自己 if (model.b_AgentName == Userinfo.UserName) { retModel.AddError("errorMessage", "代理人选择不能为自己!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } var b_AgentName = IdentityDA.GetIdentityByKeyedName(inn, model.b_AgentName); if (b_AgentName.isError()) { retModel.AddError("errorMessage", "找不到对应的代理人!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } if (model.AgentModuleList == null || model.AgentModuleList.Count == 0) { retModel.AddError("errorMessage", "请您选择授权模块!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } string value = string.Join(";", model.AgentModuleList.ToArray()) + ";"; model.b_AgentContent = value; //验证输入的时间是否正确 string b_StartDate = !string.IsNullOrEmpty(model.b_StartDateMinute) ? model.b_StartDate + " " + model.b_StartDateMinute : model.b_StartDate; string b_EndDate = !string.IsNullOrEmpty(model.b_EndDateMinute) ? model.b_EndDate + " " + model.b_EndDateMinute : model.b_EndDate; DateTime StartDate; if (!DateTime.TryParse(b_StartDate, out StartDate)) { retModel.AddError("errorMessage", "输入的生效时间错误!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } DateTime EndDate; if (!DateTime.TryParse(b_EndDate, out EndDate)) { retModel.AddError("errorMessage", "输入的终止时间错误!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } Item item = null; if (string.IsNullOrEmpty(model.id)) { item = inn.newItem("b_AgentSet", "add"); } else { item = inn.newItem("b_AgentSet", "edit"); item.setAttribute("id", model.id); } item.setProperty("b_delegatename", model.b_DelegateName); item.setProperty("b_agentname", model.b_AgentName); item.setProperty("b_startdate", model.b_StartDate); item.setProperty("b_startdateminute", model.b_StartDateMinute); item.setProperty("b_enddate", model.b_EndDate); item.setProperty("b_enddateminute", model.b_EndDateMinute); item.setProperty("b_agentcontent", model.b_AgentContent); item.setProperty("b_isvalid", model.b_IsValid); item.setProperty("b_agentreason", model.b_AgentReason); var result = item.apply(); if (result.isError()) { retModel.AddError("errorMessage", result.getErrorString()); } else { if (model.b_IsValid == "1") { string agentContext = ""; if (model.AgentModuleList.Count > 0) { foreach (var agentModule in model.AgentModuleList) { string moduleStr = EnumDescription.GetFieldText(EnumDescription.GetEnumByTextUseDefault <AgentModule>(agentModule)); agentContext = agentContext + moduleStr + ";"; } } WorkFlowBll.SendAgentEmail(inn, model.b_DelegateName, model.b_AgentName, StartDate, EndDate, agentContext); } } } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
private static List <TripReimbursementModel> GetSearchTripReimbursementList(Innovator inn, List <string> roles, out int total, DataTableParameter para, DateTime?startTime, DateTime?endTime, string searchValue, string status, string employee) { //获取的权限TRReader Item identityItem = IdentityDA.GetIdentityByKeyedName(inn, "TRReader"); string TRReaderId = ""; if (identityItem != null && identityItem.getItemCount() > 0) { TRReaderId = identityItem.getProperty("id"); } using (InnovatorSolutionsEntities db = new InnovatorSolutionsEntities()) { IQueryable <TripReimbursementModel> datas = (from g in db.B_TRIPREIMBURSEMENTFORM join t in db.WORKFLOW on g.id equals t.SOURCE_ID join y in db.WORKFLOW_PROCESS on t.RELATED_ID equals y.ID join u in db.WORKFLOW_PROCESS_ACTIVITY on y.ID equals u.SOURCE_ID join i in db.ACTIVITY on u.RELATED_ID equals i.ID join o in db.ACTIVITY_ASSIGNMENT on i.ID equals o.SOURCE_ID join p in db.IDENTITY on o.RELATED_ID equals p.ID where (roles.Contains(p.ID) || g.B_EMPLOYEE == employee || roles.Contains(TRReaderId)) && (g.B_RECORDNO.Contains(searchValue) || g.B_DEPT.Contains(searchValue) || g.B_EMPLOYEE.Contains(searchValue)) select new TripReimbursementModel { id = g.id, b_RecordNo = g.B_RECORDNO, nb_ApplicationDate = g.CREATED_ON, b_Dept = g.B_DEPT, b_Employee = g.B_EMPLOYEE, b_AmountInTotal = g.B_AMOUNTINTOTAL, status = (from z in db.B_TRIPREIMBURSEMENTFORM join x in db.WORKFLOW on z.id equals x.SOURCE_ID join c in db.WORKFLOW_PROCESS on x.RELATED_ID equals c.ID join v in db.WORKFLOW_PROCESS_ACTIVITY on c.ID equals v.SOURCE_ID join b in db.ACTIVITY on v.RELATED_ID equals b.ID join n in db.ACTIVITY_ASSIGNMENT on b.ID equals n.SOURCE_ID join m in db.IDENTITY on n.RELATED_ID equals m.ID where b.STATE == "active" && z.id == g.id select b).FirstOrDefault().KEYED_NAME }).Distinct(); //时间查询 if (startTime != null) { datas = datas.Where(x => x.nb_ApplicationDate >= startTime); } if (endTime != null) { datas = datas.Where(x => x.nb_ApplicationDate <= endTime); } if (!string.IsNullOrEmpty(status)) { if (status != "End") { datas = datas.Where(x => x.status == status); } else { datas = datas.Where(x => x.status == null); } } //总条数 total = datas.Count(); if (para != null) { //排序 if (para.sSortType == "asc") { datas = Common.OrderBy(datas, para.iSortTitle, false); } else { datas = Common.OrderBy(datas, para.iSortTitle, true); } //分页 datas = datas.Skip(para.iDisplayStart).Take(para.iDisplayLength); } return(datas.ToList()); } }
/// <summary> /// 发送邮件 /// </summary> /// <param name="inn"></param> /// <param name="emailEntity"></param> public static void SendEmailByOperation(Innovator inn, EmailEntity emailEntity, WORKFLOW_PROCESS_PATH choicePath) { //邮箱列表 List <string> listEmail = new List <string>(); List <string> names = new List <string>(); string nameStr = ""; string subject = ""; string body = ""; Item activity = ActivityDA.GetActivityById(inn, choicePath.RELATED_ID); string keyedName = activity.getProperty("keyed_name").Trim(); //获取邮件需要发送的人员信息 Item identitys = IdentityDA.GetIdentityByActivityId(inn, choicePath.RELATED_ID); //获取邮箱信息 UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names); if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } if (choicePath.NAME.Contains("Return")) { subject = "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been rejected."; body = "Dear " + nameStr + ",<br/><br/>"; body += "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been rejected.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index"; } else if (keyedName == "End") { //获取申请人邮箱 Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, emailEntity.ApplicantName); if (!applicantIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names); } if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } subject = "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been approved."; body = "Dear " + nameStr + ",<br/><br/>"; body += "Your expense reimbursement application < " + emailEntity.RecordNo + " > has been approved.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index"; } else { subject = "<" + emailEntity.ApplicantDepartment + "> " + emailEntity.ApplicantName + " has submitted an expense reimbursement application < " + emailEntity.RecordNo + " > for your approval."; body += "Dear " + nameStr + ",<br/><br/>"; body += "<" + emailEntity.ApplicantDepartment + "> " + emailEntity.ApplicantName + " has submitted an expense reimbursement application < " + emailEntity.RecordNo + " > for your approval.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/ExpenseReimbursement/Index"; } listEmail = new List <string>(); listEmail.Add("*****@*****.**"); listEmail.Add("*****@*****.**"); //listEmail.Add("*****@*****.**"); //异步执行 new Task(() => { MailOperator.SendMail(listEmail, subject, body); }).Start(); }
/// <summary> /// 获取数据列表 /// </summary> /// <returns></returns> private static List <PrManageModel> GetSearchPrManageList(Innovator inn, List <string> roles, out int total, DataTableParameter para, string searchValue, DateTime?startTime, DateTime?endTime, string status) { //获取的权限PRReader Item identityItem = IdentityDA.GetIdentityByKeyedName(inn, "PRReader"); string PRReaderId = ""; if (identityItem != null && identityItem.getItemCount() > 0) { PRReaderId = identityItem.getProperty("id"); } using (InnovatorSolutionsEntities db = new InnovatorSolutionsEntities()) { IQueryable <PrManageModel> datas = (from g in db.B_PRMANAGE join t in db.WORKFLOW on g.id equals t.SOURCE_ID join y in db.WORKFLOW_PROCESS on t.RELATED_ID equals y.ID join u in db.WORKFLOW_PROCESS_ACTIVITY on y.ID equals u.SOURCE_ID join i in db.ACTIVITY on u.RELATED_ID equals i.ID join o in db.ACTIVITY_ASSIGNMENT on i.ID equals o.SOURCE_ID join p in db.IDENTITY on o.RELATED_ID equals p.ID where (roles.Contains(p.ID) || roles.Contains(PRReaderId)) && (g.B_PRRECORDNO.Contains(searchValue) || g.B_PROJECTNAME.Contains(searchValue) || g.B_BUSINESSDEPARTMENT.Contains(searchValue) || g.B_APPLICANT.Contains(searchValue) || g.B_BUYER.Contains(searchValue) || g.B_PURCHASECONTENT.Contains(searchValue)) select new PrManageModel { id = g.id, b_PrRecordNo = g.B_PRRECORDNO, b_ProjectName = g.B_PROJECTNAME, b_PurchaseContent = g.B_PURCHASECONTENT, b_BusinessDepartment = g.B_BUSINESSDEPARTMENT, nb_RaisedDate = g.CREATED_ON, b_Applicant = g.B_APPLICANT, b_Buyer = g.B_BUYER, b_Budget = g.B_BUDGET, b_BudgetCode = g.B_BUDGETCODE, b_VersionNo = g.B_VERSIONNO, status = (from z in db.B_PRMANAGE join x in db.WORKFLOW on z.id equals x.SOURCE_ID join c in db.WORKFLOW_PROCESS on x.RELATED_ID equals c.ID join v in db.WORKFLOW_PROCESS_ACTIVITY on c.ID equals v.SOURCE_ID join b in db.ACTIVITY on v.RELATED_ID equals b.ID join n in db.ACTIVITY_ASSIGNMENT on b.ID equals n.SOURCE_ID join m in db.IDENTITY on n.RELATED_ID equals m.ID where b.STATE == "active" && z.id == g.id select b).FirstOrDefault().KEYED_NAME }).Distinct(); if (!string.IsNullOrEmpty(status)) { if (status != "End") { datas = datas.Where(x => x.status == status); } else { datas = datas.Where(x => x.status == null); } } // 时间查询 if (startTime != null) { datas = datas.Where(x => x.nb_RaisedDate >= startTime); } if (endTime != null) { datas = datas.Where(x => x.nb_RaisedDate <= endTime); } total = datas.Count(); if (para != null) { //排序 if (para.sSortType == "asc") { datas = Common.OrderBy(datas, para.iSortTitle, false); } else { datas = Common.OrderBy(datas, para.iSortTitle, true); } //分页 datas = datas.Skip(para.iDisplayStart).Take(para.iDisplayLength); } return(datas.ToList()); } }
/// <summary> /// 单据状态 /// </summary> /// <param name="status"></param> public static void SendEmailByOperation(Innovator inn, string b_prRecordNo, string b_Applicant, string b_Buyer, WORKFLOW_PROCESS_PATH choicePath, string itemId = "") { //邮箱列表 List <string> listEmail = new List <string>(); List <string> names = new List <string>(); string nameStr = ""; string subject = ""; string body = ""; Item activity = ActivityDA.GetActivityById(inn, choicePath.RELATED_ID); string keyedName = activity.getProperty("keyed_name").Trim(); //获取邮件需要发送的人员信息 Item identitys = IdentityDA.GetIdentityByActivityId(inn, choicePath.RELATED_ID); //获取邮箱信息 UserDA.GetEmailByIdentitys(inn, identitys, listEmail, names); if (choicePath.NAME.Contains("Return")) { SendReturnFinancialAnalystMail(inn, keyedName, choicePath, listEmail, itemId); } if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } if (choicePath.NAME.Contains("Return")) { subject = "Your purchase request [" + b_prRecordNo + "] has been rejected."; body = "Dear " + nameStr + ",<br/><br/>"; body += "Your purchase request [" + b_prRecordNo + "] has been rejected.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index"; } else if (keyedName == "End") { //获取申请人邮箱 Item applicantIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Applicant); if (!applicantIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, applicantIdentity, listEmail, names); } //获取采购人员邮箱 Item buyerIdentity = IdentityDA.GetIdentityByKeyedName(inn, b_Buyer); if (!buyerIdentity.isError()) { UserDA.GetEmailByIdentitys(inn, buyerIdentity, listEmail, names); } if (names != null && names.Count > 0) { for (int i = 0; i < names.Count; i++) { if (i != names.Count - 1) { nameStr += names[i] + "、"; } else { nameStr += names[i]; } } } subject = "Your purchase request [" + b_prRecordNo + "] has been approved."; body = "Dear " + nameStr + ",<br/><br/>"; body += " Your purchase request [" + b_prRecordNo + "] has been approved.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index"; } else { subject = b_Applicant + " has submitted a purchase request [" + b_prRecordNo + "] for your approval."; body += "Dear " + nameStr + ",<br/><br/>"; body += b_Applicant + " has submitted a purchase request [" + b_prRecordNo + "]" + " for your approval.<br/>"; body += "Doc link: " + ConfigurationManager.AppSettings["OASite"] + "/PrManage/Index"; } listEmail = new List <string>(); listEmail.Add("*****@*****.**"); listEmail.Add("*****@*****.**"); //listEmail.Add("*****@*****.**"); //异步执行 new Task(() => { MailOperator.SendMail(listEmail, subject, body); }).Start(); }
/// <summary> /// 保存加签 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult SaveWorkflowActivitySign(CompleteActivityModel model) { var retModel = new JsonReturnModel(); try { List <string> authIds = new List <string>(); List <string> oldAuthIds = new List <string>(); List <string> addAuthIds = new List <string>(); List <string> listEmail = new List <string>(); //验证输入的加签用户是否存在!并且获取IdentityId; List <string> listName = model.PersonList.Split(';').Where(x => x != "" && x != null).Select(x => x.Trim()).Distinct().ToList(); if (listName != null && listName.Count() > 0) { for (int i = 0; i < listName.Count; i++) { string textValue = listName[i]; USER user = UserDA.GetUserByFirstName(textValue); if (user == null) { retModel.AddError("errorMessage", "输入的人员在系统中不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } else { listEmail.Add(user.EMAIL); Item identity = IdentityDA.GetIdentityByKeyedName(inn, textValue); if (!identity.isError() && identity.getItemCount() > 0) { string identityId = identity.getProperty("id"); authIds.Add(identityId); } } } } //获取当前活动的名称 Item activity = ActivityDA.GetActivityById(inn, model.activityId); string keyedName = activity.getProperty("keyed_name").Trim(); List <string> activityNames = new List <string> { keyedName }; //获取现有的审核权限 Item activityAssignments = ActivityAssignmentDA.GetActivityAssignment(inn, model.activityId); if (!activityAssignments.isError() && activityAssignments.getItemCount() > 0) { for (int i = 0; i < activityAssignments.getItemCount(); i++) { Item activityAssignmentItem = activityAssignments.getItemByIndex(i); string id = activityAssignmentItem.getProperty("id"); string related_id = activityAssignmentItem.getProperty("related_id"); oldAuthIds.Add(related_id); //删除现有审核权限 ActivityAssignmentDA.deleteActivityAssignment(inn, id); } } //添加该活动的审核权限 addAuthIds.AddRange(authIds); addAuthIds.AddRange(oldAuthIds); addAuthIds = addAuthIds.Distinct().ToList(); if (addAuthIds.Count > 0) { int voting_weight = Common.CalculationWeight(addAuthIds.Count); foreach (var id in addAuthIds) { ActivityBll.AddActivityAuth(inn, model.itemId, id, activityNames, model.operateTable, voting_weight, "Active"); } } //加签成功发送邮件 string nameStr = ""; listEmail = listEmail.Distinct().ToList(); if (listName != null && listName.Count > 0) { for (int i = 0; i < listName.Count; i++) { if (i != listName.Count - 1) { nameStr += listName[i] + "、"; } else { nameStr += listName[i]; } } } WorkFlowBll.WorkflowActivitySignSendEmail(Userinfo.UserName, nameStr, model.recordNo, model.linkStr, listEmail); } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存用户信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult SaveUser(UserModel model) { var retModel = new JsonReturnModel(); try { //判断中心部门是否存在 if (!string.IsNullOrEmpty(model.b_Centre)) { var centreItem = OrganizationalStructureDA.GetOrganizationalStructureByParam(inn, model.b_Centre, 2); if (!centreItem.isError() && centreItem.getItemCount() <= 0) { retModel.AddError("errorMessage", "填写的中心不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(model.b_Department)) { //获取中心部门节点代号 string centreNodeCode = centreItem.getProperty("b_nodecode"); //判断部门是否在中心部门下存在 List <B_ORGANIZATIONALSTRUCTURE> organizationalStructureList = new List <B_ORGANIZATIONALSTRUCTURE>(); //获取组织架构 List <B_ORGANIZATIONALSTRUCTURE> dataList = OrganizationalStructureBll.GetOrganizationalStructureList(); OrganizationalStructureBll.GetChildByParent(inn, centreNodeCode, organizationalStructureList, dataList); int count = organizationalStructureList.Where(x => x.B_NODENAME == model.b_Department).Count(); if (count <= 0) { retModel.AddError("errorMessage", "填写的部门在中心下不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } } //判断输入的高级经理是否存在 if (!string.IsNullOrEmpty(model.b_SeniorManager)) { var itemSeniorManager = IdentityDA.GetIdentityByKeyedName(inn, model.b_SeniorManager); if (itemSeniorManager.isError()) { retModel.AddError("errorMessage", "输入的高级经理不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } //判断输入的总监是否存在 if (!string.IsNullOrEmpty(model.b_Director)) { var itemDirector = IdentityDA.GetIdentityByKeyedName(inn, model.b_Director); if (itemDirector.isError()) { retModel.AddError("errorMessage", "输入的总监不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } //判断输入的VP是否存在 if (!string.IsNullOrEmpty(model.b_VP)) { var itemVP = IdentityDA.GetIdentityByKeyedName(inn, model.b_VP); if (itemVP.isError()) { retModel.AddError("errorMessage", "输入的VP不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } Innovator adminInn = WorkFlowBll.GetAdminInnovator(); if (adminInn != null) { var item = adminInn.newItem("User", "edit"); item.setAttribute("id", model.Id); item.setProperty("b_jobnumber", model.b_JobNumber); item.setProperty("b_chinesename", model.b_ChineseName); item.setProperty("b_englishname", model.b_EnglishName); item.setProperty("email", model.Email); item.setProperty("telephone", model.Telephone); item.setProperty("b_centre", model.b_Centre); item.setProperty("b_department", model.b_Department); item.setProperty("b_idnumber", model.b_IdNumber); item.setProperty("b_seniormanager", model.b_SeniorManager); item.setProperty("b_director", model.b_Director); item.setProperty("b_vp", model.b_VP); item.setProperty("b_affiliatedcompany", model.b_AffiliatedCompany); var result = item.apply(); if (result.isError()) { retModel.AddError("errorMessage", result.getErrorString()); } } } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 上传项目信息 /// </summary> /// <returns></returns> public JsonResult UploadProjectManageFile() { var retModel = new JsonReturnModel(); try { if (Request.Files == null || Request.Files.Count == 0) { retModel.AddError("errorMessage", Common.GetLanguageValueByParam("请选择您要上传的附件!", "PRCommon", "PRItemType", Userinfo.language)); return(Json(retModel, JsonRequestBehavior.AllowGet)); } HttpPostedFileBase prfile = Request.Files[0]; string fileName = prfile.FileName.Substring(prfile.FileName.LastIndexOf("\\") + 1, prfile.FileName.Length - (prfile.FileName.LastIndexOf("\\")) - 1); if (!fileName.ToLower().Contains(".xls") && !fileName.ToLower().Contains(".xlsx")) { retModel.AddError("errorMessage", "只能上传Excel文件!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //保存上传文件到指定目录 string filePath = ConfigurationManager.AppSettings["UploadPath"] + fileName; prfile.SaveAs(filePath); //获取数据库 所有用户信息 List <USER> allUser = UserBll.GetAllUserInfo(); List <B_PROJECTMANAGE> allProject = ProjectManageBll.GetAllProjectInfo(); List <B_PROJECTMANAGE> list = new List <B_PROJECTMANAGE>(); using (FileStream fs = new FileStream(filePath, FileMode.Open)) { IWorkbook workbook = null; if (fileName.ToLower().Contains(".xlsx")) { workbook = new XSSFWorkbook(fs); } else { workbook = new HSSFWorkbook(fs); } ISheet sheet = workbook.GetSheetAt(0); int rowNum = sheet.PhysicalNumberOfRows; //获取整个项目信息 List <B_ORGANIZATIONALSTRUCTURE> dataList = OrganizationalStructureBll.GetOrganizationalStructureList(); for (int i = 0; i < rowNum; i++) { IRow row = sheet.GetRow(i); if (i != 0) { B_PROJECTMANAGE model = new B_PROJECTMANAGE(); model.B_PROJECTRECORDNO = row.GetCell(0) != null?row.GetCell(0).ToString().Trim() : ""; model.B_PROJECTNAME = row.GetCell(1) != null?row.GetCell(1).ToString().Trim() : ""; model.B_PMTORPATLEADER = row.GetCell(2) != null?row.GetCell(2).ToString().Trim() : ""; model.B_PROJECTMANAGER = row.GetCell(3) != null?row.GetCell(3).ToString().Trim() : ""; model.B_PROJECTDIRECTOR = row.GetCell(4) != null?row.GetCell(4).ToString().Trim() : ""; model.B_PROJECTVP = row.GetCell(5) != null?row.GetCell(5).ToString().Trim() : ""; model.B_ISINUSE = row.GetCell(6) != null?row.GetCell(6).ToString().Trim() : ""; //判断输入的项目编号是否存在 if (ProjectManageDA.isExistProjectRecordNo(inn, model.B_PROJECTRECORDNO, model.id)) { retModel.AddError("errorMessage", i + 1 + "行1列输入的项目编号已经存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //验证输入的项目名称是否已经存在 if (ProjectManageDA.GetProjectManageByName(inn, model.B_PROJECTNAME, model.id)) { retModel.AddError("errorMessage", i + 1 + "行2列输入的项目名称已经存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //判断的PMT/PAT Leader是否存在 if (!string.IsNullOrEmpty(model.B_PMTORPATLEADER)) { var Leader = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_PMTORPATLEADER.ToUpper()).FirstOrDefault(); if (Leader == null) { retModel.AddError("errorMessage", i + 1 + "行3列上传的PMT/PAT经理不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } else { model.B_PMTORPATLEADER = Leader.FIRST_NAME; var itemLeader = IdentityDA.GetIdentityByKeyedName(inn, model.B_PMTORPATLEADER); model.B_PMTORPATLEADERID = itemLeader.getProperty("id"); } } //判断项目经理是否存在 if (!string.IsNullOrEmpty(model.B_PROJECTMANAGER)) { var Leader = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_PROJECTMANAGER.ToUpper()).FirstOrDefault(); if (Leader == null) { retModel.AddError("errorMessage", i + 1 + "行4列上传的项目经理不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } else { model.B_PROJECTMANAGER = Leader.FIRST_NAME; var itemManager = IdentityDA.GetIdentityByKeyedName(inn, model.B_PROJECTMANAGER); model.B_PROJECTMANAGERID = itemManager.getProperty("id"); } } //判断上传的总监是否存在 if (!string.IsNullOrEmpty(model.B_PROJECTDIRECTOR)) { var Leader = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_PROJECTDIRECTOR.ToUpper()).FirstOrDefault(); if (Leader == null) { retModel.AddError("errorMessage", i + 1 + "行5列上传的总监不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } else { model.B_PROJECTDIRECTOR = Leader.FIRST_NAME; var itemDirector = IdentityDA.GetIdentityByKeyedName(inn, model.B_PROJECTDIRECTOR); model.B_PROJECTDIRECTORID = itemDirector.getProperty("id"); } } //判断上传的VP是否存在 if (!string.IsNullOrEmpty(model.B_PROJECTVP)) { var Leader = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_PROJECTVP.ToUpper()).FirstOrDefault(); if (Leader == null) { retModel.AddError("errorMessage", i + 1 + "行6列上传的VP不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } else { model.B_PROJECTVP = Leader.FIRST_NAME; } } list.Add(model); } } list = list.Distinct().ToList(); //把数据添加到数据库中 if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { var item = list[i]; B_PROJECTMANAGE ProManagerObj = allProject.Where(x => item.B_PROJECTRECORDNO.ToUpper() == item.B_PROJECTNAME.ToUpper()).First(); var promanager = inn.newItem("b_ProjectManage", "add"); promanager.setProperty("b_projectrecordno", item.B_PROJECTRECORDNO); promanager.setProperty("b_projectname", item.B_PROJECTNAME); promanager.setProperty("b_pmtorpatleaderid", item.B_PMTORPATLEADERID); promanager.setProperty("b_pmtorpatleader", item.B_PMTORPATLEADER); promanager.setProperty("b_projectmanagerid", item.B_PROJECTMANAGERID); promanager.setProperty("b_projectmanager", item.B_PROJECTMANAGER); promanager.setProperty("b_projectdirectorid", item.B_PROJECTDIRECTORID); promanager.setProperty("b_projectdirector", item.B_PROJECTDIRECTOR); promanager.setProperty("b_projectvp", item.B_PROJECTVP); promanager.setProperty("b_isinuse", item.B_ISINUSE); var result = promanager.apply(); } } } } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存数据 /// </summary> /// <returns></returns> public JsonResult SaveProjectManage(ProjectManageModel model) { var retModel = new JsonReturnModel(); try { //判断输入的项目编号是否存在 if (ProjectManageDA.isExistProjectRecordNo(inn, model.b_ProjectRecordNo, model.id)) { retModel.AddError("errorMessage", "输入的项目编号已经存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //验证输入的项目名称是否已经存在 if (ProjectManageDA.GetProjectManageByName(inn, model.b_ProjectName, model.id)) { retModel.AddError("errorMessage", "输入的项目名称已经存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //验证输入的PMT/PAT Leader 是否存在 var itemLeader = IdentityDA.GetIdentityByKeyedName(inn, model.b_PmtOrPatLeader); if (itemLeader.isError()) { retModel.AddError("errorMessage", "输入的PMT/PAT Leader不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.b_PmtOrPatLeaderId = itemLeader.getProperty("id"); //验证输入的项目经理是否存在 var projectManager = IdentityDA.GetIdentityByKeyedName(inn, model.b_ProjectManager); if (projectManager.isError()) { retModel.AddError("errorMessage", "输入的项目经理不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.b_ProjectManagerId = projectManager.getProperty("id"); //验证输入的项目总监 是否存在 var itemDirector = IdentityDA.GetIdentityByKeyedName(inn, model.b_ProjectDirector); if (itemDirector.isError()) { retModel.AddError("errorMessage", "输入的项目总监不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.b_ProjectDirectorId = itemDirector.getProperty("id"); //验证输入的项目VP 是否存在 var itemProjectVp = IdentityDA.GetIdentityByKeyedName(inn, model.b_ProjectVP); if (itemProjectVp.isError()) { retModel.AddError("errorMessage", "输入的项目VP不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } Item item = null; if (string.IsNullOrEmpty(model.id)) { item = inn.newItem("B_PROJECTMANAGE", "add"); } else { item = inn.newItem("B_PROJECTMANAGE", "edit"); item.setAttribute("id", model.id); } item.setProperty("b_projectrecordno", model.b_ProjectRecordNo); item.setProperty("b_projectname", model.b_ProjectName); item.setProperty("b_pmtorpatleader", model.b_PmtOrPatLeader); item.setProperty("b_projectdirector", model.b_ProjectDirector); item.setProperty("b_projectdirectorid", model.b_ProjectDirectorId); item.setProperty("b_pmtorpatleaderid", model.b_PmtOrPatLeaderId); item.setProperty("b_projectmanagerid", model.b_ProjectManagerId); item.setProperty("b_projectmanager", model.b_ProjectManager); item.setProperty("b_isinuse", model.b_IsInUse); item.setProperty("b_projectvp", model.b_ProjectVP); item.setProperty("b_sort", model.b_Sort.ToString()); item.setProperty("b_applicablecompany", model.b_ApplicableCompany); var result = item.apply(); if (result.isError()) { retModel.AddError("errorMessage", result.getErrorString()); } } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }