using BP.DA; using BP.En; using BP.Sys; using BP.Web; using BP.WF; using BP.WF.Template; using System; using System.Collections; using System.Data; using System.Net.Http; using System.Web.Http; using System.Web.Http.Cors; namespace CCFlow.DataUser.API.Controllers { [EnableCors("*", "*", "*")] public class APIController : ApiController { /// /// 登录 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Portal_Login(string privateKey, string userNo) { OperateResult result = null; try { if (DataType.IsNullOrEmpty(userNo) == true) return ReturnMessage("err@账号不能为空"); string localKey = BP.Difference.SystemConfig.GetValByKey("PrivateKey", ""); if (DataType.IsNullOrEmpty(localKey) == true) localKey = "DiGuaDiGua,IamCCBPM"; if (localKey.Equals(privateKey) == false) return ReturnMessage("err@私约错误,请检查全局文件中配置 PrivateKey"); //执行本地登录. BP.WF.Dev2Interface.Port_Login(userNo); string token = BP.WF.Dev2Interface.Port_GenerToken(); Hashtable ht = new Hashtable(); ht.Add("No", WebUser.No); ht.Add("Name", WebUser.Name); ht.Add("FK_Dept", WebUser.FK_Dept); ht.Add("FK_DeptName", WebUser.FK_DeptName); ht.Add("OrgNo", WebUser.OrgNo); ht.Add("OrgName", WebUser.OrgName); ht.Add("Token", token); return ReturnMessage(BP.Tools.Json.ToJson(ht)); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 退出登录 /// /// [HttpGet, HttpPost] public HttpResponseMessage Portal_LoginOut() { try { BP.WF.Dev2Interface.Port_SigOut(); return ReturnMessage("退出成功"); } catch (Exception ex) { return ReturnMessage("err@" + ex.Message); } } #region 组织人员岗位维护 /// /// 人员信息保存 /// /// /// /// /// /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Port_Emp_Save(string token, string orgNo, string userNo, string userName, string deptNo, string kvs, string stats) { HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (WebUser.IsAdmin == false) return ReturnMessage("err@[" + BP.Web.WebUser.Name + "]不是管理员不能维护人员信息"); string msg = BP.Port.OrganizationAPI.Port_Emp_Save(orgNo, userNo, userName, deptNo, kvs, stats); return ReturnMessage(msg); } /// /// 人员删除 /// /// Token /// 组织编号 /// 人员编号 /// reutrn 1=成功, 其他的标识异常. [HttpGet, HttpPost] public HttpResponseMessage Port_Emp_Delete(string token, string userNo, string orgNo ="" ) { HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (WebUser.IsAdmin == false) return ReturnMessage("err@[" + BP.Web.WebUser.Name + "]不是管理员不能删除人员信息"); return ReturnMessage(BP.Port.OrganizationAPI.Port_Emp_Delete(orgNo, userNo)); } /// return 1 增加成功,其他的增加失败. /// /// 集团模式下同步组织以及管理员信息 /// /// Token /// 组织编号 /// 组织名称 /// 管理员账号 /// 管理员名字 /// 其他的值:@Leaer=zhangsan@Tel=12233333@Idx=1 /// [HttpGet, HttpPost] public HttpResponseMessage Port_Org_Save(string token, string orgNo, string name, string adminer,string adminerName, string keyVals="") { HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (WebUser.IsAdmin == false) return ReturnMessage("err@[" + BP.Web.WebUser.Name + "]不是管理员不能维护组织信息"); return ReturnMessage(BP.Port.OrganizationAPI.Port_Org_Save(orgNo, name, adminer, adminerName,keyVals)); } /// /// 保存部门,如果有此数据则修改,无此数据则增加. /// /// Token /// 部门编号 /// 名称 /// 父节点编号 /// 组织编号 /// 其他的值:@Leaer=zhangsan@Tel=18660153393@Idx=1 /// [HttpGet, HttpPost] public HttpResponseMessage Port_Dept_Save(string token, string no, string name, string parentNo, string orgNo="", string keyVals="") { HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (WebUser.IsAdmin == false) return ReturnMessage("err@[" + BP.Web.WebUser.Name + "]不是管理员不能维护部门信息"); return ReturnMessage(BP.Port.OrganizationAPI.Port_Dept_Save(orgNo, no, name, parentNo, keyVals)); } /// /// 删除部门 /// /// Token /// 要删除的部门编号 /// [HttpGet, HttpPost] public HttpResponseMessage Port_Dept_Delete(string token, string no) { HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (WebUser.IsAdmin == false) return ReturnMessage("err@[" + BP.Web.WebUser.Name + "]不是管理员不能删除部门信息"); return ReturnMessage(BP.Port.OrganizationAPI.Port_Dept_Delete(no)); } /// /// 保存岗位, 如果有此数据则修改,无此数据则增加. /// /// Token /// 组织编号 /// 岗位编号 /// 岗位名称 /// 其他值 /// [HttpGet, HttpPost] public HttpResponseMessage Port_Station_Save(string token, string orgNo, string no, string name, string keyVals) { HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (WebUser.IsAdmin == false) return ReturnMessage("err@[" + BP.Web.WebUser.Name + "]不是管理员不能维护岗位信息"); return ReturnMessage(BP.Port.OrganizationAPI.Port_Station_Save(orgNo, no, name, keyVals)); } /// /// 删除岗位. /// /// 删除指定的岗位编号 /// [HttpGet,HttpPost] public HttpResponseMessage Port_Station_Delete(string token, string no) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (WebUser.IsAdmin == false) return ReturnMessage("err@[" + BP.Web.WebUser.Name + "]不是管理员不能删除岗位信息"); return ReturnMessage(BP.Port.OrganizationAPI.Port_Station_Delete(no)); } #endregion 组织人员岗位维护 /// /// 可以发起的流程 /// /// /// 流程所属的域 /// [HttpGet,HttpPost] public HttpResponseMessage DB_Start(string token,string domain) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; //获取可以发起的列表 DataTable dt = BP.WF.Dev2Interface.DB_StarFlows(BP.Web.WebUser.No, domain); return ReturnMessage(BP.Tools.Json.ToJson(dt)); } /// /// 待办 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage DB_Todolist(string token, string domain) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; //获取可以发起的列表 DataTable dt = BP.WF.Dev2Interface.DB_GenerEmpWorksOfDataTable(BP.Web.WebUser.No, 0, null, domain, null, null); return ReturnMessage(BP.Tools.Json.ToJson(dt)); } /// /// 在途 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage DB_Runing(string token, string domain) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; //获取可以发起的列表 DataTable dt = BP.WF.Dev2Interface.DB_GenerRuning(BP.Web.WebUser.No, false, domain); ; return ReturnMessage(BP.Tools.Json.ToJson(dt)); } /// /// 草稿 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage DB_Draft(string token, string domain) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; //获取可以发起的列表 DataTable dt = BP.WF.Dev2Interface.DB_GenerDraftDataTable(null, domain); return ReturnMessage(BP.Tools.Json.ToJson(dt)); } /// /// 打开的表单 /// /// /// 工作实例WorkID /// 流程编号 /// 节点ID /// 父WorkID /// [HttpGet, HttpPost] public HttpResponseMessage GenerFrmUrl(string token, Int64 workID,string flowNo,int nodeID,Int64 fid) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; /* * 发起的url需要在该流程的开始节点的表单方案中,使用SDK表单,并把表单的url设置到里面去. * 设置步骤: * 1. 打开流程设计器. * 2. 在开始节点上右键,选择表单方案. * 3. 选择SDK表单,把url配置到文本框里去. * 比如: /App/F027QingJia.htm */ if (nodeID == 0) nodeID = int.Parse(flowNo + "01"); if (workID == 0) workID = BP.WF.Dev2Interface.Node_CreateBlankWork(flowNo, BP.Web.WebUser.No); string url = ""; Node nd = new Node(nodeID); if (nd.FormType == NodeFormType.SDKForm || nd.FormType == NodeFormType.SelfForm) { //. url = nd.FormUrl; if (url.Contains("?") == true) url += "&FK_Flow=" + flowNo + "&FK_Node=" + nodeID + "&WorkID=" + workID + "&Token=" + token + "&UserNo=" + BP.Web.WebUser.No; else url += "?FK_Flow=" + flowNo + "&FK_Node=" + nodeID + "&WorkID=" + workID + "&Token=" + token + "&UserNo=" + BP.Web.WebUser.No; } else { url = "/WF/MyFlow.htm?FK_Flow=" + flowNo + "&FK_Node=" + nodeID + "&WorkID=" + workID + "&Token=" + token; } return ReturnMessage(url); } /// /// 创建WorkID /// /// /// 流程编号 /// [HttpGet, HttpPost] public HttpResponseMessage Node_CreateBlankWorkID(string token, string flowNo) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { Int64 workid = Dev2Interface.Node_CreateBlankWork(flowNo, BP.Web.WebUser.No); return ReturnMessage(workid.ToString()); }catch(Exception ex) { return ReturnMessage(ex.Message); } } /// /// 是否可以处理当前的工作 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Node_IsCanDealWork(string token, Int64 workID) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { GenerWorkFlow gwf = new GenerWorkFlow(workID); string todoEmps = gwf.TodoEmps; bool isCanDo = false; if (gwf.FK_Node.ToString().EndsWith("01") == true) { if (gwf.Starter.Equals(BP.Web.WebUser.No) == false) isCanDo = false; //处理开始节点发送后,撤销的情况,第2个节点打开了,第1个节点撤销了,造成第2个节点也可以发送下去. else isCanDo = true; // 开始节点不判断权限. } else { isCanDo = todoEmps.Contains(";" + WebUser.No + ","); if (isCanDo == false) isCanDo = Dev2Interface.Flow_IsCanDoCurrentWork(workID, BP.Web.WebUser.No); } return ReturnMessage(isCanDo == true ? "1" : "0"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 设置草稿 /// /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Node_SetDraft(string token, Int64 workID, string flowNo) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { BP.WF.Dev2Interface.Node_SetDraft(flowNo, workID); return ReturnMessage("设置草稿成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 把当前工作移交给指定的人员 /// /// /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Node_Shift(string token, Int64 workID, string toEmpNo,string msg) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { msg = BP.WF.Dev2Interface.Node_Shift(workID, toEmpNo, msg); return ReturnMessage(msg); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 给当前的工作增加处理人 /// /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Node_AddTodolist(string token, Int64 workID, string empNo) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { BP.WF.Dev2Interface.Node_AddTodolist(workID, empNo); return ReturnMessage("增加人员成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 根据ID获取当前的流程实例信息 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Flow_GenerWorkFlow(string token, Int64 workID) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { GenerWorkFlow gwf = new GenerWorkFlow(workID); return ReturnMessage(gwf.ToJson()); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 保存参数到WF_GenerWorkFlow,用于方向条件的判断 /// /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Node_SaveParas(string token, Int64 workID, string paras) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { BP.WF.Dev2Interface.Flow_SaveParas(workID, paras); return ReturnMessage("参数保存成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 设置标题 /// /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Flow_SetTitle(string token,Int64 workID, string title) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { BP.WF.Dev2Interface.Flow_SetFlowTitle(null, workID, title); return ReturnMessage("标题设置成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 发送接口 /// /// /// 流程编号 /// 工作实例WorkID /// 到达的下一个节点 /// 下一个节点的接收人 /// 参数,保存到WF_GenerWorkFlow /// [HttpGet, HttpPost] public HttpResponseMessage Node_SendWork(string token, Int64 workID, string flowNo="", int toNodeID=0,string toEmps="",string paras="") { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if(DataType.IsNullOrEmpty(paras)==false) BP.WF.Dev2Interface.Flow_SaveParas(workID, paras); //执行发送. Hashtable ht = new Hashtable(); ht.Add("FK_Flow", flowNo); ht.Add("WorkID", workID); try { if (DataType.IsNullOrEmpty(flowNo) == true) flowNo = DBAccess.RunSQLReturnString("SELECT FK_Flow FROM WF_GenerWorkFlow WHERE WorkID=" + workID); //执行发送. SendReturnObjs objs = Dev2Interface.Node_SendWork(flowNo, workID, ht, null, toNodeID, toEmps); string msg = objs.ToMsgOfText(); return ReturnMessage(msg); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 根据流程编号获取流程实例 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage DB_GenerWorkFlow(string token, string flowNo) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { GenerWorkFlows gwfs = new GenerWorkFlows(); QueryObject qo = new QueryObject(gwfs); qo.AddWhere("FK_Flow", flowNo); qo.addAnd(); qo.AddWhere("WFState", ">", 1); qo.addOrderBy("RDT"); qo.DoQuery(); return ReturnMessage(gwfs.ToJson()); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 获取当前节点可以退回到的节点集合 /// /// /// 节点ID /// 工作实例WorkID /// 父WorkID /// [HttpGet, HttpPost] public HttpResponseMessage DB_GenerWillReturnNodes(string token, int nodeID,Int64 workID,Int64 fid) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { DataTable dt = Dev2Interface.DB_GenerWillReturnNodes(nodeID, workID, fid); return ReturnMessage(BP.Tools.Json.ToJson(dt)); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 当前节点执行退回操作 /// /// /// 工作实例WorkID /// 当前节点ID /// 退回到的节点 /// 退回到的接收人 /// 退回原因 /// 是否原路返回到当前节点 /// [HttpGet, HttpPost] public HttpResponseMessage Node_ReturnWork(string token, Int64 workID, int nodeID,int returnToNodeID,string returnToEmp,string msg,bool isBackToThisNode) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { if (returnToNodeID == 0) { DataTable dt = BP.WF.Dev2Interface.DB_GenerWillReturnNodes(nodeID, workID, 0); if (dt.Rows.Count == 1) { returnToNodeID = Int32.Parse(dt.Rows[0]["No"].ToString()); returnToEmp = dt.Rows[0]["Rec"].ToString(); } } //执行退回. string strs = Dev2Interface.Node_ReturnWork(workID, returnToNodeID, returnToEmp, msg, isBackToThisNode); return ReturnMessage(strs); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 催办 /// /// /// 工作实例的WorkID集合 /// 催办信息 /// [HttpGet, HttpPost] public HttpResponseMessage Flow_DoPress(string token, string workIDs,string msg) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@执行批量催办的WorkIDs不能为空"); } string[] strs = workIDs.Split(','); if (msg == null) msg = "需要您处理待办工作."; try { string info = ""; foreach (string workidStr in strs) { if (BP.DA.DataType.IsNullOrEmpty(workidStr) == true) continue; info += "@" + BP.WF.Dev2Interface.Flow_DoPress(int.Parse(workidStr), msg, true); } return ReturnMessage(info); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 批量审核 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage CC_BatchCheckOver(string token, string workIDs) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@执行批量审批的WorkIDs不能为空"); } try { string str = BP.WF.Dev2Interface.Node_CC_SetCheckOverBatch(workIDs); return ReturnMessage(str); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 批量删除流程 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Flow_BatchDeleteByFlag(string token, string workIDs) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@批量删除的WorkIDs不能为空"); } try { string[] strs = workIDs.Split(','); foreach (string workidStr in strs) { if (BP.DA.DataType.IsNullOrEmpty(workidStr) == true) continue; string st1r = BP.WF.Dev2Interface.Flow_DoDeleteFlowByFlag(Int64.Parse(workidStr), "删除", true); } return ReturnMessage("删除成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 批量删除 /// /// /// 工作实例WorkIDs /// 是否删除子流程 /// [HttpGet, HttpPost] public HttpResponseMessage Flow_BatchDeleteByReal(string token, string workIDs, bool isDeleteSubFlows) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@批量删除的WorkIDs不能为空"); } try { string[] strs = workIDs.Split(','); foreach (string workidStr in strs) { if (BP.DA.DataType.IsNullOrEmpty(workidStr) == true) continue; string st1r = BP.WF.Dev2Interface.Flow_DoDeleteFlowByReal(Int64.Parse(workidStr), isDeleteSubFlows); } return ReturnMessage("删除成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 批量恢复逻辑删除的流程 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Flow_BatchDeleteByFlagAndUnDone(string token, string workIDs) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@批量撤销删除的WorkIDs不能为空"); } try { string[] strs = workIDs.Split(','); foreach (string workidStr in strs) { if (BP.DA.DataType.IsNullOrEmpty(workidStr) == true) continue; string st1r = BP.WF.Dev2Interface.Flow_DoUnDeleteFlowByFlag(null, int.Parse(workidStr), "删除"); } return ReturnMessage("撤销删除成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 批量撤回 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Flow_DoUnSend(string token, string workIDs) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; //获取可以发起的列表 string[] strs = workIDs.Split(','); if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@批量撤回的WorkIDs不能为空"); } try { string info = ""; foreach (string workidStr in strs) { if (BP.DA.DataType.IsNullOrEmpty(workidStr) == true) continue; info += BP.WF.Dev2Interface.Flow_DoUnSend(null, Int64.Parse(workidStr), 0, 0); } return ReturnMessage(info); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 批量删除草稿 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Flow_DeleteDraft(string token, string workIDs) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; string[] strs = workIDs.Split(','); if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@批量删除草稿的WorkIDs不能为空"); } try { foreach (string workidStr in strs) { if (BP.DA.DataType.IsNullOrEmpty(workidStr) == true) continue; BP.WF.Dev2Interface.Node_DeleteDraft(Int64.Parse(workidStr)); } return ReturnMessage("删除成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 批量结束流程 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Flow_DoFlowOver(string token, string workIDs) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; string[] strs = workIDs.Split(','); if (DataType.IsNullOrEmpty(workIDs)) { return ReturnMessage("err@批量结束流程的WorkIDs不能为空"); } try { foreach (string workidStr in strs) { if (BP.DA.DataType.IsNullOrEmpty(workidStr) == true) continue; BP.WF.Dev2Interface.Flow_DoFlowOver(Int64.Parse(workidStr), "批量结束", 1); } return ReturnMessage("执行成功"); } catch (Exception ex) { return ReturnMessage(ex.Message); } } #region 批处理相关 /// /// 批量处理 /// /// /// [HttpGet, HttpPost] public HttpResponseMessage Batch_Init(string token) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { var handle = new BP.WF.HttpHandler.WF(); string str = handle.Batch_Init(); return ReturnMessage(str); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 根据NodeID获取节点信息 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage En_Node(string token,int nodeID) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { Node node = new Node(nodeID); return ReturnMessage(node.ToJson()); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 根据流程编号获取流程信息 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage En_Flow(string token, string flowNo) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { Flow flow = new Flow(flowNo); return ReturnMessage(flow.ToJson()); } catch (Exception ex) { return ReturnMessage(ex.Message); } } /// /// 根据流程编号获取流程信息 /// /// /// /// [HttpGet, HttpPost] public HttpResponseMessage WorkCheckModel_Init(string token, int nodeID) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { DataSet ds = new DataSet(); //获取节点信息 BP.WF.Node nd = new BP.WF.Node(nodeID); Flow fl = nd.HisFlow; ds.Tables.Add(nd.ToDataTableField("WF_Node")); string sql = ""; if (nd.IsSubThread == true) { sql = "SELECT a.*, b.Starter,b.StarterName,b.ADT,b.WorkID FROM " + fl.PTable + " a , WF_EmpWorks b WHERE a.OID=B.FID AND b.WFState Not IN (7) AND b.FK_Node=" + nd.NodeID + " AND b.FK_Emp='" + WebUser.No + "'"; } else { sql = "SELECT a.*, b.Starter,b.StarterName,b.ADT,b.WorkID FROM " + fl.PTable + " a , WF_EmpWorks b WHERE a.OID=B.WorkID AND b.WFState Not IN (7) AND b.FK_Node=" + nd.NodeID + " AND b.FK_Emp='" + WebUser.No + "'"; } //获取待审批的流程信息集合 DataTable dt = DBAccess.RunSQLReturnTable(sql); dt.TableName = "Works"; ds.Tables.Add(dt); //获取按钮权限 BtnLab btnLab = new BtnLab(nodeID); ds.Tables.Add(btnLab.ToDataTableField("Sys_BtnLab")); //获取字段属性 MapAttrs attrs = new MapAttrs("ND" + nodeID); //获取实际中需要展示的列. string batchParas = nd.GetParaString("BatchFields"); MapAttrs realAttr = new MapAttrs(); if (DataType.IsNullOrEmpty(batchParas) == false) { string[] strs = batchParas.Split(','); foreach (string str in strs) { if (string.IsNullOrEmpty(str) || str.Contains("@PFlowNo") == true) continue; foreach (MapAttr attr in attrs) { if (str != attr.KeyOfEn) continue; realAttr.AddEntity(attr); } } } ds.Tables.Add(realAttr.ToDataTableField("Sys_MapAttr")); return ReturnMessage(BP.Tools.Json.ToJson(ds)); } catch (Exception ex) { return ReturnMessage(ex.Message); } } [HttpGet, HttpPost] public HttpResponseMessage Batch_InitDDL(string token, int nodeID) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { GenerWorkFlow gwf = new GenerWorkFlow(); Node nd = new Node(nodeID); gwf.TodoEmps = WebUser.No + ","; DataTable mydt = BP.WF.Dev2Interface.Node_GenerDTOfToNodes(gwf, nd); return ReturnMessage(BP.Tools.Json.ToJson(mydt)); } catch (Exception ex) { return ReturnMessage(ex.Message); } } [HttpGet, HttpPost] public HttpResponseMessage WorkCheckModel_Send(string token, string flowNo) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { var handle = new BP.WF.HttpHandler.WF_WorkOpt_Batch(); string str = handle.WorkCheckModel_Send(); return ReturnMessage(str); } catch (Exception ex) { return ReturnMessage(ex.Message); } } [HttpGet, HttpPost] public HttpResponseMessage Batch_Delete(string token, string workIDs) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { if (DataType.IsNullOrEmpty(workIDs) == true) return ReturnMessage("err@没有选择需要处理的工作"); string msg = ""; GenerWorkFlows gwfs = new GenerWorkFlows(); gwfs.RetrieveIn("WorkID", workIDs); foreach (GenerWorkFlow gwf in gwfs) { msg += "@对工作(" + gwf.Title + ")处理情况如下。
"; string mes = BP.WF.Dev2Interface.Flow_DoDeleteFlowByFlag(gwf.WorkID, "批量删除", true); msg += mes; msg += "
"; } return ReturnMessage("批量删除成功" + msg); } catch (Exception ex) { return ReturnMessage(ex.Message); } } #endregion 批处理相关 /// /// 查询 /// /// 关键字 /// 日期从 /// 日期到 /// 范围 /// 分页 /// [HttpGet, HttpPost] public HttpResponseMessage Search_Init(string token,string key,string dtFrom,string dtTo,string scop,int pageIdx) { //根据token登录 HttpResponseMessage result = Port_GenerToken(token); if (result != null) return result; try { GenerWorkFlows gwfs = new GenerWorkFlows(); //创建查询对象. QueryObject qo = new QueryObject(gwfs); if (DataType.IsNullOrEmpty(key) == false) { qo.AddWhere(GenerWorkFlowAttr.Title, " LIKE ", "%" + key + "%"); qo.addAnd(); } //我参与的. if (scop.Equals("0") == true) qo.AddWhere(GenerWorkFlowAttr.Emps, "LIKE", "%@" + WebUser.No + ",%"); //我发起的. if (scop.Equals("1") == true) qo.AddWhere(GenerWorkFlowAttr.Starter, "=", WebUser.No); //我部门发起的. if (scop.Equals("2") == true) qo.AddWhere(GenerWorkFlowAttr.FK_Dept, "=", WebUser.FK_Dept); //任何一个为空. if (DataType.IsNullOrEmpty(dtFrom) == true || DataType.IsNullOrEmpty(dtTo) == true) { } else { qo.addAnd(); qo.AddWhere(GenerWorkFlowAttr.RDT, ">=", dtFrom); qo.addAnd(); qo.AddWhere(GenerWorkFlowAttr.RDT, "<=", dtTo); } var count = qo.GetCount(); //获得总数. qo.DoQuery("WorkID", 20, pageIdx); // qo.DoQuery(); // "WorkID", 20, pageIdx); DataTable dt = gwfs.ToDataTableField("gwls"); //创建容器. DataSet ds = new DataSet(); ds.Tables.Add(dt); //增加查询对象. //增加数量. DataTable mydt = new DataTable(); mydt.TableName = "count"; mydt.Columns.Add("CC"); DataRow dr = mydt.NewRow(); dr[0] = count.ToString(); //把数量加进去. mydt.Rows.Add(dr); ds.Tables.Add(mydt); return ReturnMessage(BP.Tools.Json.ToJson(ds)); } catch (Exception ex) { return ReturnMessage(ex.Message); } } private HttpResponseMessage Port_GenerToken(string token) { //根据token登录 try { BP.WF.Dev2Interface.Port_LoginByToken(token); } catch (Exception ex) { return ReturnMessage(ex.Message); } return null; } private HttpResponseMessage ReturnMessage(string message) { return new HttpResponseMessage { Content = new StringContent(message, System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; } } }