/// <summary> /// 获取查询Select流程状态数据 /// </summary> /// <param name="para"></param> /// <param name="item_Id"></param> /// <returns></returns> public JsonResult GetWorkflowStatusList() { var retModel = new JsonReturnModel(); try { List <SelectModel> list = new List <SelectModel>(); var result = WorkFlowBll.GetWorkflowStatusList(inn, "b_BusinessTravelWorkFlow"); if (!result.isError() && result.getItemCount() > 0) { for (int i = 0; i < result.getItemCount(); i++) { SelectModel model = new SelectModel(); var item = result.getItemByIndex(i); model.value = item.getProperty("keyed_name"); if (!string.IsNullOrEmpty(model.value)) { model.text = Common.GetChineseValueByParam(model.value, "BTManageWorkFlow", "WorkFlow", Userinfo.language); } list.Add(model); } } retModel.data = list; } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存转办 /// </summary> /// <returns></returns> public JsonResult SaveWorkflowTurnToDo(CompleteActivityModel model) { var retModel = new JsonReturnModel(); try { var user = UserDA.GetUserByFirstName(model.delegateToName); if (user == null) { retModel.AddError("errorMessage", "选择的转办不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } if (model.delegateToName == Userinfo.UserName) { retModel.AddError("errorMessage", "转办人不能选择自己!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } IDENTITY dentity = IdentityDA.GetIdentityByActivityAssignmentId(model.activityAssignmentId); string identityName = dentity.KEYED_NAME; if (identityName.Trim() != Userinfo.UserName) { retModel.AddError("errorMessage", "代理权限不能进行转办!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } string errorString = ActivityDA.CompleteActivity(inn, model.activityId, model.activityAssignmentId, "", "Delegate", model.delegateToName, Userinfo.UserName + "转办到:" + model.delegateToName, Userinfo); if (string.IsNullOrEmpty(errorString)) { WorkFlowBll.TurnToDoSendEmail(Userinfo.UserName, model.delegateToName, model.recordNo, model.linkStr, user.EMAIL); } } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
/// <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)); }
/// <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 CompleteActivity(CompleteActivityModel model) { var retModel = new JsonReturnModel(); try { WORKFLOW_PROCESS_PATH path = new WORKFLOW_PROCESS_PATH(); Item itemPrManage = inn.newItem("B_PRMANAGE", "get"); itemPrManage.setAttribute("id", model.itemId); itemPrManage = itemPrManage.apply(); string prRecordNo = itemPrManage.getProperty("b_prrecordno"); string b_BusinessDepartment = itemPrManage.getProperty("b_businessdepartment"); string b_Applicant = itemPrManage.getProperty("b_applicant"); if (string.IsNullOrEmpty(model.comments)) { retModel.AddError("errorMessage", @OABordrinCommon.Common.GetLanguageValueByParam("退回必须填写备注!", "ERCommon", "ERItemType", ViewBag.language)); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //获取当前退回人员权重 var ActivityAssignmentItem = ActivityAssignmentDA.GetActivityAssignmentById(inn, model.activityAssignmentId); if (!ActivityAssignmentItem.isError() && ActivityAssignmentItem.getItemCount() > 0) { int voting_weight = int.Parse(ActivityAssignmentItem.getItemByIndex(0).getProperty("voting_weight")); //修改权重 if (voting_weight < 100) { //获取Admin的Aras 连接 var adminInn = WorkFlowBll.GetAdminInnovator(); if (adminInn != null) { //获取Admin 对当前任务权限数据 Item activityItem = ActivityDA.GetActivityByItemId(adminInn, model.itemId, "Administrators", "B_PrManage"); if (!activityItem.isError()) { string activityId = activityItem.getProperty("activityid"); string activityAssignmentId = activityItem.getProperty("activityassignmentid"); ActivityDA.CompleteActivity(adminInn, activityId, activityAssignmentId, model.pathId, "", "", Userinfo.UserName + "对单据进行了退回操作! 备注:" + model.comments); } } } else { string result = ActivityDA.CompleteActivity(inn, model.activityId, model.activityAssignmentId, model.pathId, "", "", model.comments); if (!string.IsNullOrEmpty(result)) { retModel.AddError("errorMessage", result); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } } path = WorkflowProcessPathDA.GetWorkflowProcessPathById(model.pathId); PrManageBll.SendEmailByOperation(inn, prRecordNo, b_Applicant, "", path, model.itemId); string b_remark = PrManageBll.AddRemark(inn, model.comments, model.itemId, Userinfo.UserName); var itemRoot = inn.newItem("B_PRMANAGE", "edit"); itemRoot.setAttribute("id", model.itemId); itemRoot.setProperty("b_remark", b_remark); itemRoot = itemRoot.apply(); } catch (Exception ex) { retModel.AddError("errorMessage", ex.Message); } return(Json(retModel, JsonRequestBehavior.AllowGet)); }
//上传人员信息 public JsonResult UploadUserFile() { 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 <USER> list = new List <USER>(); 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) { USER model = new USER(); if (row.GetCell(0) != null) { model.B_JOBNUMBER = row.GetCell(0) != null?row.GetCell(0).ToString().Trim() : ""; model.B_CHINESENAME = row.GetCell(1) != null?row.GetCell(1).ToString().Trim() : ""; model.B_ENGLISHNAME = row.GetCell(2) != null?row.GetCell(2).ToString().Trim() : ""; model.B_CENTRE = row.GetCell(3) != null?row.GetCell(3).ToString().Trim() : ""; model.B_DEPARTMENT = row.GetCell(4) != null?row.GetCell(4).ToString().Trim() : ""; model.B_SENIORMANAGER = row.GetCell(5) != null?row.GetCell(5).ToString().Trim() : ""; model.B_DIRECTOR = row.GetCell(6) != null?row.GetCell(6).ToString().Trim() : ""; model.B_VP = row.GetCell(7) != null?row.GetCell(7).ToString().Trim() : ""; model.B_AFFILIATEDCOMPANY = row.GetCell(8) != null?row.GetCell(8).ToString().Trim() : ""; //根据用户名称判断用户是否存在 int count = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_ENGLISHNAME.ToUpper()).Count(); if (count == 0) { retModel.AddError("errorMessage", i + 1 + "行上传的用户不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //判断中心是否存在 B_ORGANIZATIONALSTRUCTURE centreObj = dataList.Where(x => x.B_NODENAME == model.B_CENTRE && x.B_NODELEVEL == 2).FirstOrDefault(); if (centreObj == null) { retModel.AddError("errorMessage", i + 1 + "行上传的中心不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } //判断部门是否存在 List <B_ORGANIZATIONALSTRUCTURE> organizationalStructureList = new List <B_ORGANIZATIONALSTRUCTURE>(); if (!string.IsNullOrEmpty(model.B_DEPARTMENT)) { OrganizationalStructureBll.GetChildByParent(inn, centreObj.B_NODECODE, organizationalStructureList, dataList); int countDepartment = organizationalStructureList.Where(x => x.B_NODENAME == model.B_DEPARTMENT).Count(); if (countDepartment == 0) { retModel.AddError("errorMessage", i + 1 + "行上传的部门不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } //判断上传的高级经理是否存在 if (!string.IsNullOrEmpty(model.B_SENIORMANAGER)) { var itemSeniorManager = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_SENIORMANAGER.ToUpper()).FirstOrDefault(); if (itemSeniorManager == null) { retModel.AddError("errorMessage", i + 1 + "行上传的高级经理不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.B_SENIORMANAGER = itemSeniorManager.FIRST_NAME; } //判断上传的总监是否存在 if (!string.IsNullOrEmpty(model.B_DIRECTOR)) { var itemDirector = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_DIRECTOR.ToUpper()).FirstOrDefault(); if (itemDirector == null) { retModel.AddError("errorMessage", i + 1 + "行上传的总监不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.B_DIRECTOR = itemDirector.FIRST_NAME; } //判断上传的VP是否存在 if (!string.IsNullOrEmpty(model.B_VP)) { var itemVP = allUser.Where(x => x.LOGIN_NAME.ToUpper() == model.B_VP.ToUpper()).FirstOrDefault(); if (itemVP == null) { retModel.AddError("errorMessage", i + 1 + "行上传的VP不存在!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } model.B_VP = itemVP.FIRST_NAME; } //判断上传所属公司是否正确 if (!string.IsNullOrEmpty(model.B_AFFILIATEDCOMPANY)) { List <string> arrList = model.B_AFFILIATEDCOMPANY.Split(';').Where(x => x != "").ToList(); foreach (var item in arrList) { if (item != "博郡" && item != "思致") { retModel.AddError("errorMessage", i + 1 + "行上传的所属公司不正确!"); return(Json(retModel, JsonRequestBehavior.AllowGet)); } } } list.Add(model); } } } Innovator adminInn = WorkFlowBll.GetAdminInnovator(); //修改数据库中的数据 if (list != null && list.Count > 0 && adminInn != null) { for (int i = 0; i < list.Count; i++) { var item = list[i]; //string userName = item.B_ENGLISHNAME.ToUpper() + " " + "(" + item.B_CHINESENAME + ")"; USER userObj = allUser.Where(x => x.LOGIN_NAME.ToUpper() == item.B_ENGLISHNAME.ToUpper()).First(); var user = adminInn.newItem("User", "edit"); user.setAttribute("id", userObj.ID); user.setProperty("b_jobnumber", item.B_JOBNUMBER); user.setProperty("b_chinesename", item.B_CHINESENAME); user.setProperty("b_englishname", item.B_ENGLISHNAME); user.setProperty("b_centre", item.B_CENTRE); user.setProperty("b_department", item.B_DEPARTMENT); user.setProperty("b_seniormanager", item.B_SENIORMANAGER); user.setProperty("b_director", item.B_DIRECTOR); user.setProperty("b_vp", item.B_VP); user.setProperty("b_affiliatedcompany", item.B_AFFILIATEDCOMPANY); var result = user.apply(); } } } } 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)); }