private List <AssignResult> GetApproveActions(Context ctx, string formId, string pKValue, string receiverName) { DataSet ds = DBUtils.ExecuteDataSet(ctx, @"select b.FASSIGNID,b.FAPPROVALASSIGNID,a.FRECEIVERNAMES from t_wf_assign a join T_WF_APPROVALASSIGN b on a.fassignid=b.fassignid where b.Fobjecttypeid=@FormID and b.Fkeyvalue=@pKValue and a.FSTATUS=0", new List <SqlParam> { new SqlParam("@FormID", DbType.String, formId), new SqlParam("@pKValue", DbType.String, pKValue) }); DataRow row = ds.Tables[0].Rows.Cast <DataRow>().FirstOrDefault(dr => dr["FRECEIVERNAMES"].ToString().Split(',').Any(r => r == receiverName)); if (row == null) { return new List <AssignResult> { } } ; string assignId = row["FASSIGNID"].ToString(); string approvalAssignId = row["FAPPROVALASSIGNID"].ToString(); string _approvalItemId = AssignmentServiceHelper.OpenApprovalItem(ctx, ctx.UserId, assignId, false); var _approvalItem = AssignmentServiceHelper.GetApprovalItemById(ctx, _approvalItemId); return(_approvalItem.Actions.ToList()); }
/// <summary> /// 获取当前处理人审批项 /// </summary> /// <param name="ctx"></param> /// <param name="formId">业务对象标识</param> /// <param name="pKValue">业务对象内码</param> /// <param name="receiverName">接收人</param> private string items(Context ctx, string formId, string pKValue, string receiverName) { DataSet ds = DBUtils.ExecuteDataSet(ctx, @"select b.FASSIGNID,b.FAPPROVALASSIGNID,a.FRECEIVERNAMES from t_wf_assign a join T_WF_APPROVALASSIGN b on a.fassignid=b.fassignid where b.Fobjecttypeid=@FormID and b.Fkeyvalue=@pKValue and a.FSTATUS=0", new List <SqlParam> { new SqlParam("@FormID", DbType.String, formId), new SqlParam("@pKValue", DbType.String, pKValue) }); DataRow row = ds.Tables[0].Rows.Cast <DataRow>().FirstOrDefault(dr => dr["FRECEIVERNAMES"].ToString().Split(',').Any(r => r == receiverName)); if (row == null) { return("待办任务没有找到审批项"); } string assignId = row["FASSIGNID"].ToString(); string approvalAssignId = row["FAPPROVALASSIGNID"].ToString(); string _approvalItemId = AssignmentServiceHelper.OpenApprovalItem(ctx, ctx.UserId, assignId, false); var _approvalItem = AssignmentServiceHelper.GetApprovalItemById(ctx, _approvalItemId); List <AssignResult> list = _approvalItem.Actions.ToList(); string result = string.Empty; JArray entrys = new JArray(); foreach (AssignResult item in list) { JObject mBEntry = new JObject(); mBEntry.Add("ApprovalItem", item.Name.ToString()); entrys.Add(mBEntry); } return(JsonConvert.SerializeObject(entrys)); }
private string SubmitWorkflow(Context ctx, string formId, string pKValue, string receiverName, string actionResult, string disposition, bool isApprovalFlow) { string reason = ""; DataSet ds = DBUtils.ExecuteDataSet(ctx, @"select b.FASSIGNID,b.FAPPROVALASSIGNID,a.FACTINSTID,a.FRECEIVERNAMES from t_wf_assign a join T_WF_APPROVALASSIGN b on a.fassignid=b.fassignid where b.Fobjecttypeid=@FormID and b.Fkeyvalue=@pKValue and a.FSTATUS=0", new List <SqlParam> { new SqlParam("@FormID", DbType.String, formId), new SqlParam("@pKValue", DbType.String, pKValue) }); DataRow row = ds.Tables[0].Rows.Cast <DataRow>().FirstOrDefault(dr => dr["FRECEIVERNAMES"].ToString().Split(',').Any(r => r == receiverName)); if (row == null) { reason = "未找到待办任务"; return(reason); } string assignId = row["FASSIGNID"].ToString(); string approvalAssignId = row["FAPPROVALASSIGNID"].ToString(); string _approvalItemId = AssignmentServiceHelper.OpenApprovalItem(ctx, ctx.UserId, assignId, false); FormMetadata formMetadata = MetaDataServiceHelper.GetFormMetaData(ctx, formId); DynamicObject ObjData = BusinessDataServiceHelper.LoadSingle(ctx, pKValue, formMetadata.BusinessInfo.GetDynamicObjectType()); BusinessInfo businessInfo = formMetadata.BusinessInfo; var _approvalItem = AssignmentServiceHelper.GetApprovalItemById(ctx, _approvalItemId); if (_approvalItem == null) { reason = "待办任务所在的流程实例不在运行中,不能进行处理!"; return(reason); } _approvalItem.ObjData = ObjData; _approvalItem.ReceiverPostId = 0; _approvalItem.ActionResult = actionResult; _approvalItem.Disposition = disposition.ToString(); AssignResult assignResult = _approvalItem.Actions != null?_approvalItem.Actions.FirstOrDefault(i => i.Id == actionResult) : null; AssignResultApprovalType approvalType = assignResult != null ? assignResult.ApprovalType : AssignResultApprovalType.None; _approvalItem.ActionResultType = approvalType; _approvalItem.Status = ApprovalItemStatus.Completed; DateTime timeNow = TimeServiceHelper.GetSystemDateTime(ctx); _approvalItem.CompletedTime = timeNow; ObjectActivityInstance _activityInstance = AssignmentServiceHelper.ConvertActivityModel( ctx, businessInfo, approvalAssignId, _approvalItem); var option = OperateOption.Create(); if (isApprovalFlow) { ApprovalAssignmentContext assignCtx = new ApprovalAssignmentContext() { ApprovalItems = new List <ApprovalItem>() { _approvalItem }, Info = businessInfo, Option = option }; assignCtx.NextActHandler = null; assignCtx.RejectReturn = false; assignCtx.ActivityInstance = _activityInstance; if (actionResult == AssignResultApprovalType.Reject.ToString()) { var _policy = AssignmentServiceHelper.GetApprovalAssignByAssignId(ctx, assignId); var nextHandleWrapper = new Kingdee.BOS.ApprovalFlow.PlugIns.Mobile.MobNextHandleWrapper(assignId, ctx, _policy); assignCtx.Target = nextHandleWrapper.RejectActivityModel.ActivityId; } ApprovalAssignmentServiceHelper.SubmitApprovalItem(ctx, assignCtx); reason = ""; return(reason); } else { ApprovalAssignmentContext assignCtx = new ApprovalAssignmentContext() { ApprovalItems = new List <ApprovalItem>() { _approvalItem }, Info = businessInfo, Option = option }; assignCtx.NextActHandler = null; assignCtx.RejectReturn = false; assignCtx.ActivityInstance = _activityInstance; ApprovalAssignmentServiceHelper.SubmitApprovalItem(ctx, assignCtx); reason = ""; return(reason); } //if (actionResult == AssignResultApprovalType.Reject.ToString()) //{ // string actInstId = row["FACTINSTID"].ToString(); // Kingdee.BOS.Workflow.App.Core.ProcInstService procInstService = new Kingdee.BOS.Workflow.App.Core.ProcInstService(); // var rejectActivityIds = procInstService.GetBackActInstList(ctx, actInstId, true).Select(r => r.ActivityId); // if (!rejectActivityIds.Any()) // { // reason = "无驳回节点"; // return reason; // } // assignCtx.Target = rejectActivityIds.FirstOrDefault(); //} }