/// <summary> /// 获取流程数据添加页面 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1"></param> /// <param name="P2"></param> /// <param name="UserInfo"></param> public void GETWFDATA(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { try { int PDID = int.Parse(P1); if (PDID > 0) { Yan_WF_PD pdmodel = new Yan_WF_PDB().GetEntity(d => d.ID == PDID); if (pdmodel != null) { var dtList = new Yan_WF_TDB().GetEntities(d => d.ProcessDefinitionID == pdmodel.ID).OrderBy(d => d.Taskorder); msg.Result = dtList; msg.Result1 = pdmodel; if (!string.IsNullOrEmpty(pdmodel.Files)) { msg.Result2 = new FT_FileB().GetDTByCommand("SELECT * FROM FT_File WHERE ID IN (" + pdmodel.Files + ") "); } } } } catch (Exception ex) { msg.ErrorMsg = ex.Message; } }
public void GETFORMFILEDS(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { var PDS = new Yan_WF_PDB().GetEntities(D => D.ComId == UserInfo.User.ComId); JArray arrs = new JArray(); foreach (var item in PDS) { List <JH_Auth_ExtendMode> ExtendModes = new List <JH_Auth_ExtendMode>(); ExtendModes = new JH_Auth_ExtendModeB().GetEntities(D => D.ComId == UserInfo.User.ComId && D.PDID == item.ID).ToList(); JObject obj = JObject.FromObject(new { value = item.ID, label = item.ProcessName, children = from p in ExtendModes select new { value = p.TableFiledColumn, label = p.TableFiledName, } }); arrs.Add(obj); } msg.Result = arrs; }
/// <summary> /// 更新表单模板 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1"></param> /// <param name="P2"></param> /// <param name="UserInfo"></param> public void SETPDTEMP(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { int Id = 0; int.TryParse(P1, out Id); string strFormop = context.Request("formop") ?? ""; string strfmdata = context.Request("fmdata") ?? ""; Yan_WF_PD PD = new Yan_WF_PDB().GetEntity(d => d.ID == Id && d.ComId == UserInfo.User.ComId); PD.Tempcontent = P2.Replace("null", "''"); PD.Poption = strFormop; PD.fmdata = strfmdata; JArray filds = JArray.Parse(P2); List <JH_Auth_ExtendMode> ListNew = new List <JH_Auth_ExtendMode>(); foreach (JObject item in filds) { List <string> ListNofiled = new List <string>() { "qjLine" }; string strComponentName = (string)item["component"]; if (!ListNofiled.Contains(strComponentName)) { //有几个组件是不需要存到字段里得 JH_Auth_ExtendMode Model = new JH_Auth_ExtendMode(); Model.ComId = UserInfo.User.ComId; Model.CRDate = DateTime.Now; Model.CRUser = UserInfo.User.UserName; Model.PDID = PD.ID; Model.TableFiledColumn = ((string)item["wigdetcode"]).Trim(); Model.TableFiledName = ((string)item["title"]).Trim(); string strFileType = "Str"; if ((string)item["eltype"] == "number") { strFileType = "Num"; } if ((string)item["eltype"] == "date" || (string)item["eltype"] == "datetime") { strFileType = "Date"; } if ((string)item["eltype"] == "qjTable") { strFileType = "Table"; } Model.TableFileType = strFileType; Model.TableName = "LCSP"; ListNew.Add(Model); } } new JH_Auth_ExtendModeB().Delete(d => d.PDID == PD.ID); new JH_Auth_ExtendModeB().Insert(ListNew); new Yan_WF_PDB().Update(PD); //保存模板得时候顺便保存扩展字段 }
public void GETSQLDATA(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { DataTable dt = new DataTable(); string SQL = CommonHelp.Filter(P1); dt = new Yan_WF_PDB().GetDTByCommand(SQL); msg.Result = dt; }
public void GETBDTJDATA(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { int pdid = 0; int.TryParse(P1, out pdid); string strSDate = context.Request("sdate") ?? DateTime.Now.AddYears(-20).ToString("yyyy-MM-dd"); string strEDate = context.Request("edate") ?? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"); List <JH_Auth_ExtendMode> ExtendModes = new List <JH_Auth_ExtendMode>(); ExtendModes = new JH_Auth_ExtendModeB().GetEntities(D => D.ComId == UserInfo.User.ComId && D.PDID == pdid).ToList(); string strWhere = ""; if (P2 != "") { JArray datas = (JArray)JsonConvert.DeserializeObject(P2); foreach (JObject item in datas) { string filed = (string)item["filed"]; if (ExtendModes.Select(D => D.TableFiledColumn).ToList().Contains(filed)) { string qtype = (string)item["qtype"]; string qvalue = (string)item["qvalue"]; strWhere = CommonHelp.CreateqQsql(filed, qtype, qvalue); } } } string strISGD = context.Request("isGD") ?? ""; if (strISGD != "") { strWhere = strWhere + " AND ISGD='" + strISGD.FilterSpecial() + "'"; } string pdfields = context.Request("pdfields") ?? ""; if (pdfields != "") { ExtendModes = ExtendModes.Where(d => d.TableFiledColumn == pdfields).ToList(); } if (ExtendModes.Count > 0) { string strTempSQL = new Yan_WF_PDB().GetDTHZL(ExtendModes.Select(D => D.TableFiledColumn).ToList().ListTOString(','), pdid.ToString()); string strSQL = strTempSQL + " WHERE CRDATE BETWEEN '" + strSDate + " 01:01:01' AND '" + strEDate + " 23:59:59' " + strWhere; DataTable dt = new Yan_WF_PDB().GetDTByCommand(strSQL); msg.Result = dt; msg.Result1 = ExtendModes; } }
public void GETMANGWFDATA(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { try { int PIID = int.Parse(P1); if (PIID > 0) { Yan_WF_PI PIMODEL = new Yan_WF_PIB().GetEntity(d => d.ID == PIID); if (PIMODEL == null) { msg.ErrorMsg = "流程数据已清除"; return; } else { DataTable dtList = new Yan_WF_TDB().GetEntities(d => d.ProcessDefinitionID == PIMODEL.PDID.Value).OrderBy(d => d.Taskorder).ToDataTable(); dtList.Columns.Add("userrealname"); dtList.Columns.Add("EndTime"); dtList.Columns.Add("TaskUserView"); dtList.Columns.Add("state"); foreach (DataRow dr in dtList.Rows) { string tdCode = dr["TDCODE"].ToString(); Yan_WF_TI tiModel = new Yan_WF_TIB().GetEntity(d => d.PIID == PIID && d.TDCODE == tdCode && d.EndTime != null);// if (tiModel != null) { dr["userrealname"] = new JH_Auth_UserB().GetUserRealName(UserInfo.QYinfo.ComId, tiModel.TaskUserID); dr["EndTime"] = tiModel.EndTime; dr["TaskUserView"] = tiModel.TaskUserView; dr["state"] = tiModel.TaskState; } } msg.Result = dtList; Yan_WF_PD pdmodel = new Yan_WF_PDB().GetEntity(d => d.ID == PIMODEL.PDID); msg.Result1 = pdmodel; msg.Result2 = "{ \"ISCANSP\":\"" + new Yan_WF_PIB().isCanSP(UserInfo.User.UserName, int.Parse(P1)) + "\",\"ISCANCEL\":\"" + new Yan_WF_PIB().isCanCancel(UserInfo.User.UserName, PIMODEL) + "\"}"; msg.Result3 = PIMODEL;//可修改字段 if (!string.IsNullOrEmpty(pdmodel.Files)) { msg.Result4 = new FT_FileB().GetDTByCommand("SELECT * FROM FT_File WHERE ID IN (" + pdmodel.Files + ") "); } } } } catch (Exception ex) { msg.ErrorMsg = ex.Message; } }
/// <summary> /// 获取流程信息 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1"></param> /// <param name="P2"></param> /// <param name="UserInfo"></param> public void GETPROCESSBYID(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { int Id = int.Parse(P1); Yan_WF_PD PD = new Yan_WF_PDB().GetEntity(d => d.ID == Id && d.ComId == UserInfo.User.ComId); if (PD != null) { msg.Result = PD; if (!string.IsNullOrEmpty(PD.Files)) { msg.Result1 = new FT_FileB().GetDTByCommand("SELECT * FROM FT_File WHERE ID IN (" + PD.Files + ") "); } } }
/// <summary> /// 获取流程列表 P1==""流程设置列表,P1!="" 自定义流程添加选择列表 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1"></param> /// <param name="P2"></param> /// <param name="UserInfo"></param> public void GETWFPDLIST(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { if (P1 != "") { //授权管理用户,角色能看到的表单数据 int lcs = int.Parse(P1); string strSql = string.Format(@"SELECT * from Yan_WF_PD where lcstatus='{0}' and ComId={1} and IsSuspended= 'Y' and " + SqlHelp.concat("','+ManageUser+','") + " like '%,{2},%'", lcs, UserInfo.User.ComId, UserInfo.User.UserName); string strRoleSQL = ""; foreach (var item in UserInfo.UserRoleCode.Split(',')) { strRoleSQL = strRoleSQL + string.Format(@"SELECT * from Yan_WF_PD where lcstatus='{0}' and ComId={1} and IsSuspended= 'Y' and " + SqlHelp.concat("','+ManageRole+','") + " like '%,{2},%'", lcs, UserInfo.User.ComId, item); strRoleSQL = strRoleSQL + " UNION "; } if (strRoleSQL.Length > 5) { strRoleSQL = strRoleSQL.TrimEnd(); strRoleSQL = strRoleSQL.Substring(0, strRoleSQL.Length - 5); strSql = strSql + " UNION " + strRoleSQL; } DataTable dtData = new Yan_WF_PDB().GetDTByCommand(strSql); msg.Result = dtData; } else { //授权管理用户能看到的表单模板 string strWhere = " ( wfpd.CRUser='******' OR wfpd.SQUser='******') and wfpd.ComId=" + UserInfo.User.ComId; string strContent = context.Request("Content") ?? ""; strContent = strContent.TrimEnd(); if (strContent != "") { strWhere += string.Format(" And ( wfpd.ProcessName like '%{0}%' )", strContent); } string strLB = context.Request("LB") ?? ""; strLB = strLB.TrimEnd(); if (strLB != "") { strWhere += string.Format(" And ( wfpd.ProcessClass like '%{0}%' )", strLB); } string strSql = string.Format(@"SELECT DISTINCT wfpd.ProcessClass, wfpd.ProcessName,wfpd.ManageUser,wfpd.ID,count(wfpi.ID) formCount,wfpd.lcstatus,wfpd.IsSuspended from Yan_WF_PD wfpd LEFT join Yan_WF_PI wfpi on wfpd.ID=wfpi.PDID where wfpd.isTemp='1' and {0} group by wfpd.ProcessClass, wfpd.ProcessName,wfpd.ID,wfpd.lcstatus,wfpd.IsSuspended,wfpd.ManageUser", strWhere, UserInfo.User.UserName); msg.Result = new Yan_WF_PDB().GetDTByCommand(strSql); } }
public void SAVEEXDATA(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { int piId = 0; int.TryParse(P1, out piId); int PDID = 0; int.TryParse(P2, out PDID); Yan_WF_PI lcsp = new Yan_WF_PIB().GetEntity(d => d.ID == piId); Yan_WF_PD pd = new Yan_WF_PDB().GetEntity(d => d.ID == PDID); JArray datas = (JArray)JsonConvert.DeserializeObject(lcsp.Content); var dt = new Dictionary <string, object>(); dt.Add("CRUser", UserInfo.User.UserName); dt.Add("CRDate", DateTime.Now); dt.Add("ComID", UserInfo.User.ComId.Value); dt.Add("intProcessStanceid", piId); try { List <JH_Auth_ExtendData> ListNew = new List <JH_Auth_ExtendData>(); foreach (JObject item in datas) { JH_Auth_ExtendData Model = new JH_Auth_ExtendData(); Model.ComId = UserInfo.User.ComId; Model.BranchNo = UserInfo.User.BranchCode; Model.DataID = piId; Model.PDID = PDID; Model.TableName = "LCSP"; Model.ExFiledColumn = (string)item["wigdetcode"]; Model.ExFiledName = (string)item["title"]; string strValue = ""; strValue = (string)item["value"]; Model.ExtendDataValue = strValue.Trim(','); Model.CRUser = UserInfo.User.UserName; Model.CRDate = DateTime.Now; Model.CRUserName = UserInfo.User.UserRealName; Model.BranchNo = UserInfo.BranchInfo.DeptCode; Model.BranchName = UserInfo.BranchInfo.DeptName; ListNew.Add(Model); string strglfiled = (string)item["glfiled"] ?? ""; if (strglfiled != "") { dt.Add(strglfiled, strValue); } } new JH_Auth_ExtendDataB().Delete(d => d.DataID == piId && d.PDID == PDID); new JH_Auth_ExtendDataB().Insert(ListNew); if (!string.IsNullOrEmpty(pd.RelatedTable)) { int intcount = new Yan_WF_PDB().GetDTByCommand("SELECT * FROM " + pd.RelatedTable + " WHERE intProcessStanceid='" + piId.ToString() + "'").Rows.Count; DBFactory db = new BI_DB_SourceB().GetDB(0); if (intcount > 0) { //更新 } else { //新增 db.InserData(dt, pd.RelatedTable); } } } catch (Exception ex) { } }
/// <summary> /// 开始流程 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1">启动流程的应用Code</param> /// <param name="P2">审核人信息</param> /// <param name="UserInfo"></param> public void STARTWF(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { try { string strModelCode = P1; string strCSR = context.Request("csr") ?? ""; string strZSR = context.Request("zsr") ?? ""; string strContent = context.Request("content") ?? ""; int PDID = 0; int.TryParse(context.Request("PDID") ?? "0", out PDID); Yan_WF_PD PD = new Yan_WF_PDB().GetEntity(d => d.ID == PDID && d.ComId == UserInfo.User.ComId); if (PD == null) { //没有流程,直接返回 return; } Yan_WF_PIB PIB = new Yan_WF_PIB(); List <string> ListNextUser = new List <string>();//获取下一任务的处理人 Yan_WF_PI PI = new Yan_WF_PI(); PI.CRUserName = UserInfo.User.UserRealName; PI.BranchName = UserInfo.BranchInfo.DeptName; PI.BranchNO = UserInfo.BranchInfo.DeptCode; PI.Content = strContent; PI.PDID = PD.ID; PI.WFFormNum = new Yan_WF_PIB().CreateWFNum(PI.PDID.ToString()); PI.ComId = PD.ComId; PI.StartTime = DateTime.Now; PI.CRUser = UserInfo.User.UserName; PI.CRDate = DateTime.Now; PI.PITYPE = PD.ProcessType; PI.ChaoSongUser = strCSR; PI.isGD = "N"; new Yan_WF_PIB().Insert(PI); Yan_WF_TI TI = PIB.StartWF(PD, strModelCode, UserInfo.User.UserName, strZSR, strCSR, PI, ref ListNextUser); //返回新增的任务 msg.Result = PI; msg.Result1 = TI; //发送消息给审核人员 string jsr = ListNextUser.ListTOString(','); if (!string.IsNullOrEmpty(jsr)) { SZHL_TXSX TX = new SZHL_TXSX(); TX.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); TX.APIName = "FORMBI"; TX.ComId = UserInfo.User.ComId; TX.FunName = "LCSPCHECK"; TX.intProcessStanceid = TI.PIID; TX.CRUserRealName = UserInfo.User.UserRealName; TX.MsgID = TI.PIID.ToString(); TX.TXContent = UserInfo.User.UserRealName + "发起了一个" + PD.ProcessName + ",请您查阅审核"; TX.TXUser = jsr; TX.TXMode = strModelCode; TX.CRUser = UserInfo.User.UserName; TXSXAPI.AddALERT(TX); //时间为发送时间 } //发送消息 } catch (Exception ex) { msg.ErrorMsg = ex.Message; } }
public void MANAGEWF(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { try { string strShUser = context.Request("SHUser") ?? ""; string strCSUser = context.Request("csr") ?? ""; string modelcode = context.Request("formcode") ?? ""; string strContent = context.Request("content") ?? ""; int PID = int.Parse(P1); Yan_WF_PIB PIB = new Yan_WF_PIB(); if (PIB.isCanSP(UserInfo.User.UserName, PID) == "Y")//先判断用户能不能处理此流程 { List <string> ListNextUser = new List <string>(); PIB.MANAGEWF(UserInfo.User.UserName, PID, P2, ref ListNextUser, strShUser);//处理任务 Yan_WF_PI PI = PIB.GetEntity(d => d.ID == PID); //更新抄送人 PI.ChaoSongUser = strCSUser; PIB.Update(PI); //更新抄送人 Yan_WF_PD PD = new Yan_WF_PDB().GetEntity(d => d.ID == PI.PDID.Value); string content = PI.CRUserName + "发起了" + PD.ProcessName + "表单,等待您审阅"; string strTXUser = ListNextUser.ListTOString(','); string funName = "LCSPCHECK"; //添加消息提醒 string strIsComplete = ListNextUser.Count() == 0 ? "Y" : "N"; //结束流程,找不到人了 if (strIsComplete == "Y") //找不到下家就结束流程,并且给流程发起人发送消息 { PIB.ENDWF(PID); msg.Result = "Y";//已结束 content = UserInfo.User.UserRealName + "审批完成了您发起的" + PD.ProcessName + "表单"; strTXUser = PI.CRUser; funName = "LCSPCHECK"; //发送消息给抄送人 if (!string.IsNullOrEmpty(PI.ChaoSongUser)) { SZHL_TXSX CSTX = new SZHL_TXSX(); CSTX.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); CSTX.APIName = "FORMBI"; CSTX.ComId = UserInfo.User.ComId; CSTX.FunName = "LCSPCHECK"; CSTX.intProcessStanceid = PID; CSTX.CRUserRealName = UserInfo.User.UserRealName; CSTX.MsgID = PID.ToString(); CSTX.TXContent = new JH_Auth_UserB().GetEntity(p => p.ComId == PI.ComId && p.UserName == PI.CRUser).UserRealName + "抄送一个" + PD.ProcessName + ",请您查阅接收"; CSTX.ISCS = "Y"; CSTX.TXUser = PI.ChaoSongUser; CSTX.TXMode = modelcode; CSTX.CRUser = UserInfo.User.UserName; TXSXAPI.AddALERT(CSTX); //时间为发送时间 } } SZHL_TXSX TX = new SZHL_TXSX(); TX.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); TX.APIName = "FORMBI"; TX.ComId = UserInfo.User.ComId; TX.FunName = funName; TX.intProcessStanceid = PID; TX.CRUser = PI.CRUser; TX.CRUserRealName = UserInfo.User.UserRealName; TX.MsgID = PID.ToString(); TX.TXContent = content; TX.TXUser = strTXUser; TX.TXMode = modelcode; TXSXAPI.AddALERT(TX); //时间为发送时间 } else { msg.ErrorMsg = "该流程已被处理,您已无法处理此流程"; } } catch (Exception ex) { msg.ErrorMsg = ex.Message; } }
public ActionResult <string> EXPORTWORD() { var context = _accessor.HttpContext; var tokenHeader = context.Request.Cookies["szhlcode"].ToString().Replace("Bearer ", ""); TokenModelJWT tokenModel = JwtHelper.SerializeJWT(tokenHeader); JH_Auth_UserB.UserInfo UserInfo = new JH_Auth_UserB().GetUserInfo(10334, tokenModel.UserName); string P1 = context.Request.Query["P1"].ToString(); string P2 = context.Request.Query["P2"].ToString(); int pdid = 0; int.TryParse(P1, out pdid); int piid = 0; int.TryParse(P2, out piid); Yan_WF_PD PD = new Yan_WF_PDB().GetEntity(d => d.ID == pdid && d.ComId == UserInfo.User.ComId); Yan_WF_PI PI = new Yan_WF_PIB().GetEntity(d => d.ID == piid && d.ComId == UserInfo.User.ComId); if (PD.ExportFile == null) { return(""); } int fileID = int.Parse(PD.ExportFile); FT_File MBFile = new FT_FileB().GetEntities(d => d.ID == fileID).FirstOrDefault(); Dictionary <string, string> dictSource = new Dictionary <string, string>(); List <JH_Auth_ExtendMode> ExtendModes = new List <JH_Auth_ExtendMode>(); ExtendModes = new JH_Auth_ExtendModeB().GetEntities(D => D.ComId == UserInfo.User.ComId && D.PDID == pdid).ToList(); foreach (JH_Auth_ExtendMode item in ExtendModes) { string strValue = new JH_Auth_ExtendDataB().GetFiledValue(item.TableFiledColumn, pdid, piid); dictSource.Add("qj_" + item.TableFiledColumn, strValue); } dictSource.Add("qj_CRUser", PI.CRUserName); dictSource.Add("qj_BranchName", PI.BranchName); dictSource.Add("qj_CRDate", PI.CRDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); dictSource.Add("qj_PINUM", PI.ID.ToString()); List <Yan_WF_TI> tiModels = new Yan_WF_TIB().GetEntities(d => d.PIID == piid).ToList(); for (int i = 0; i < tiModels.Count; i++) { dictSource.Add("qj_Task" + i + ".TaskUser", new JH_Auth_UserB().GetUserRealName(UserInfo.User.ComId.Value, tiModels[i].TaskUserID)); dictSource.Add("qj_Task" + i + ".TaskUserView", tiModels[i].TaskUserView); if (tiModels[i].EndTime != null) { dictSource.Add("qj_Task" + i + ".EndTime", tiModels[i].EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); } } string strFileUrl = UserInfo.QYinfo.FileServerUrl + "/" + UserInfo.QYinfo.QYCode + "/document/" + MBFile.zyid; Aspose.Words.Document doc = new Aspose.Words.Document(strFileUrl); //使用文本方式替换 foreach (string name in dictSource.Keys) { doc.Range.Replace(name, dictSource[name]); } #region 使用书签替换模式 #endregion string Filepath = hostingEnv.WebRootPath + "/Export/"; string strFileName = PD.ProcessName + DateTime.Now.ToString("yyMMddHHss") + ".doc"; doc.Save(Filepath + strFileName, Aspose.Words.Saving.DocSaveOptions.CreateSaveOptions(SaveFormat.Doc)); return(File("~/excels/report.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "report.xlsx")); }