示例#1
0
        /// <summary>
        /// 节点跃迁方法
        /// </summary>
        /// <param name="workflowName">工作流名称</param>
        /// <param name="dataid">业务数据主码</param>
        /// <param name="actionName">动作名称</param>
        /// <param name="operatorid">操作者ID</param>
        /// <param name="executer">执行者</param>
        /// <param name="remark">工作流执行备注</param>
        /// <param name="isRecordTrace">是否记录工作流操作日志(默认记录)</param>
        /// <returns>返回是否执行成功</returns>
        public bool trace(string workflowName, int dataid, string actionName, int operatorid, string executer, string remark, bool isRecordTrace = true)
        {
            workflowEx           workflowEx    = new workflowEx();
            workflow             wf            = workflowEx.getworkflow(workflowName);
            int                  instancesid   = 0;
            workflowinstancesEx  wfinstancesEx = new workflowinstancesEx();
            workflowinstances    wfinstances   = wfinstancesEx.getworkflowinstances(wf.id, dataid);
            workflownodeactionEx wfnaEx        = new workflownodeactionEx();
            workflownodeaction   wfna          = wfnaEx.getworkflownodeaction(wf.id, actionName);
            workflownodeEx       wfnEx         = new workflownodeEx();
            string               sql           = string.Empty;

            if (wfinstances != null)
            {
                int currentnodeid = wfna.nextnodeid;
                int?nodcodevalue  = 0;
                if (wfna.nodetype == 2)                                                      //会签节点跳跃
                {
                    List <workflownodeaction> wfnas = wfnaEx.getcountersignnodeaction(wfna); //会签动作集合
                    nodcodevalue = (wfinstances.nodcode | wfna.nodeactioncode) == wfna.nodeactioncode ? wfinstances.nodcode : (wfinstances.nodcode + wfna.nodeactioncode);
                    if (nodcodevalue != wfnas.Select(p => p.nodeactioncode).Sum())
                    {
                        currentnodeid = wfna.currentnodeid;
                    }
                }
                //更新Trace表节点信息
                sql = string.Format(@"update {0} 
                                       set currentnodeid={1},
                                                  nodcode={2}
                                                 where id={3}",
                                    wf.wfinstancestable, currentnodeid, nodcodevalue, wfinstances.id);
                instancesid = wfinstances.id;
                db.SqlQueryDynamic(sql);
                //更新业务表工作流字段值

                workflownode wfn    = wfnEx.getworkflownode(wfna.nextnodeid);
                string       sqlstr = string.Format("update {0} set {1}={2} where id={3}", wf.wfownertable, wf.wffieldname, wfn.wfnodememo);
                db.SqlQueryDynamic(sqlstr);
            }
            else
            {
                instancesid = insert(wf, instancesid, wfna, dataid);
                //更新业务表工作流字段值
                workflownode wfn    = wfnEx.getworkflownode(wfna.nextnodeid);
                string       sqlstr = string.Format("update {0} set {1}='{2}' where id={3}", wf.wfownertable, wf.wffieldname, wfn.wfnodememo, dataid);
                db.SqlQueryDynamic(sqlstr);
            }
            if (isRecordTrace)
            {
                workflowinstancetracingsEx wfinstancetringEx = new workflowinstancetracingsEx();
                wfinstancetringEx.insert(executer, instancesid, wfna);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="executer"></param>
        /// <param name="instancesid"></param>
        /// <param name="wfna"></param>
        /// <returns></returns>
        public int insert(string executer, int instancesid, workflownodeaction wfna)
        {
            workflownodeEx           wfEx      = new workflownodeEx();
            workflownode             startnode = wfEx.getworkflownode(wfna.currentnodeid);
            workflownode             endnode   = wfEx.getworkflownode(wfna.nextnodeid);
            workflowinstancetracings wfiting   = new workflowinstancetracings();

            wfiting.instanceid    = instancesid;
            wfiting.startnode     = startnode.wfnodememo;
            wfiting.endnode       = endnode.wfnodememo;
            wfiting.executer      = executer;
            wfiting.executeaction = wfna.nodeactionmemo;
            wfiting.executetime   = DateTime.Now;
            workflowinstancetracingsEx wfinstancetracingEx = new workflowinstancetracingsEx();

            return(wfinstancetracingEx.insert(wfiting).ObjToInt());
        }