Example #1
0
        private void btn仓库签字_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            //第一步任务承担者,登录后要找到自己的任务
            appRunner.AppName = "officeIn";
            appRunner.UserID = "1";
            appRunner.UserName = "******";
            IWorkflowService wfService = new WorkflowService();

            //外部变量条件
            Dictionary<string, string> dictCondition = new Dictionary<string, string>();
            dictCondition.Add("surplus", cBoxSurplus.Text);
            appRunner.Conditions = dictCondition;

            //动态获取下一跳转后的节点
            NodeView nv = wfService.GetNextActivity(appRunner, dictCondition);
            //指定对象执行者
            PerformerList list = new PerformerList();
            list.Add(new Performer("3", "user3"));
            Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>();
            dictPerformer.Add(nv.ActivityGUID, list);
            appRunner.NextActivityPerformers = dictPerformer;

            var result = wfService.RunProcessApp(appRunner);
            var msg = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message);
            tBoxResult.Text += msg;
        }
        internal static IDictionary<string, PerformerList> CreateNextActivityPerformers(string activityGUID,
            string userID,
            string userName)
        {
            var performerList = new PerformerList();
            performerList.Add(new Performer(userID, userName));
            IDictionary<string, PerformerList> nextActivityPerformers = new Dictionary<string, PerformerList>();
            nextActivityPerformers.Add(activityGUID, performerList);

            return nextActivityPerformers;
        }
Example #3
0
        public ResponseResult <IDictionary <Guid, PerformerList> > GetNextActivityPerformers()
        {
            var performers = new PerformerList();

            performers.Add(new Performer("10", "Long"));

            IDictionary <Guid, PerformerList> nexts = new Dictionary <Guid, PerformerList>();

            nexts[Guid.Parse("10f7481a-ad1a-40f6-aeaa-8d32ceb1fcab")] = performers;

            return(ResponseResult <IDictionary <Guid, PerformerList> > .Success(nexts));
        }
Example #4
0
        internal static IDictionary <string, PerformerList> CreateNextActivityPerformers(string activityGUID,
                                                                                         string userID,
                                                                                         string userName)
        {
            var performerList = new PerformerList();

            performerList.Add(new Performer(userID, userName));
            IDictionary <string, PerformerList> nextActivityPerformers = new Dictionary <string, PerformerList>();

            nextActivityPerformers.Add(activityGUID, performerList);

            return(nextActivityPerformers);
        }
Example #5
0
        private void btn仓库签字_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();

            appRunner.ProcessGUID   = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            //第一步任务承担者,登录后要找到自己的任务
            appRunner.AppName  = "officeIn";
            appRunner.UserID   = "1";
            appRunner.UserName = "******";
            IWorkflowService wfService = new WorkflowService();

            //外部变量条件
            Dictionary <string, string> dictCondition = new Dictionary <string, string>();

            dictCondition.Add("surplus", cBoxSurplus.Text);
            appRunner.Conditions = dictCondition;
            //动态获取下一跳转后的节点
            var nodeViewList = wfService.GetNextActivityTree(appRunner, dictCondition);
            //指定对象执行者
            PerformerList list3 = new PerformerList();

            list3.Add(new Performer("3", "user3"));

            PerformerList list4 = new PerformerList();

            list4.Add(new Performer("4", "user4"));

            Dictionary <String, PerformerList> dictPerformer = new Dictionary <String, PerformerList>();
            int i = 3;

            foreach (NodeView nv in nodeViewList)
            {
                if (i == 3)
                {
                    dictPerformer.Add(nv.ActivityGUID, list3);
                }
                else
                {
                    dictPerformer.Add(nv.ActivityGUID, list4);
                }

                i++;
            }
            appRunner.NextActivityPerformers = dictPerformer;

            var result = wfService.RunProcessApp(appRunner);
            var msg    = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message);

            tBoxResult.Text += msg;
        }
Example #6
0
        /// <summary>
        /// 获取任务办理人列表
        /// </summary>
        /// <param name="processInstanceID"></param>
        /// <param name="roles"></param>
        /// <returns></returns>
        public PerformerList GetPerformerList(int processInstanceID, List<Role> roles)
        {
            PerformerList performers = null;

            //获取流程发起人信息,在xml定义中有role变量:-1
            if (roles.Count == 1 && roles[0].RoleCode == "-1")
            {
                IWorkflowService service = new WorkflowService();
                Performer initiator = service.GetProcessInitiator(processInstanceID);
                performers = new PerformerList();
                performers.Add(initiator);
            }

            return performers;
        }
Example #7
0
        /// <summary>
        /// 获取节点上的执行者列表
        /// </summary>
        /// <param name="nextNode"></param>
        /// <returns></returns>
        public PerformerList GetPerformerList(NodeView nextNode)
        {
            var roleIDs       = nextNode.Roles.Select(x => x.ID).ToArray();
            var userList      = ResourceService.GetUserListByRoles(roleIDs);
            var performerList = new PerformerList();

            foreach (var user in userList)
            {
                var performer = new Performer(user.UserID.ToString(), user.UserName);

                performerList.Add(performer);
            }

            return(performerList);
        }
Example #8
0
        /// <summary>
        /// 获取任务办理人列表
        /// </summary>
        /// <param name="processInstanceID"></param>
        /// <param name="roles"></param>
        /// <returns></returns>
        public PerformerList GetPerformerList(int processInstanceID, List <Role> roles)
        {
            PerformerList performers = null;

            //获取流程发起人信息,在xml定义中有role变量:-1
            if (roles.Count == 1 && roles[0].RoleCode == "-1")
            {
                IWorkflowService service   = new WorkflowService();
                Performer        initiator = service.GetProcessInitiator(processInstanceID);
                performers = new PerformerList();
                performers.Add(initiator);
            }

            return(performers);
        }
Example #9
0
        /// <summary>
        /// 由节点分配的人员信息生成PerformerList数据结构
        /// </summary>
        /// <param name="activityInstance">活动实例</param>
        /// <returns>人员列表</returns>
        protected PerformerList AntiGenerateActivityPerformerList(ActivityInstanceEntity activityInstance)
        {
            var performerList = new PerformerList();

            if (!string.IsNullOrEmpty(activityInstance.AssignedToUserIDs) &&
                !string.IsNullOrEmpty(activityInstance.AssignedToUserNames))
            {
                var assignedToUserIDs   = activityInstance.AssignedToUserIDs.Split(',');
                var assignedToUserNames = activityInstance.AssignedToUserNames.Split(',');

                for (var i = 0; i < assignedToUserIDs.Count(); i++)
                {
                    performerList.Add(new Performer(assignedToUserIDs[i], assignedToUserNames[i]));
                }
            }
            return(performerList);
        }
Example #10
0
        /// <summary>
        /// 由节点分配的人员信息生成PerformerList数据结构
        /// </summary>
        /// <param name="activityInstance">活动实例</param>
        /// <returns>人员列表</returns>
        protected PerformerList AntiGenerateActivityPerformerList(WfActivityInstance activityInstance)
        {
            var performerList = new PerformerList();

            if (!string.IsNullOrEmpty(activityInstance.AssignedToUserIds) &&
                !string.IsNullOrEmpty(activityInstance.AssignedToUserNames))
            {
                var assignedToUserIDs   = activityInstance.AssignedToUserIds.Split(',');
                var assignedToUserNames = activityInstance.AssignedToUserNames.Split(',');

                for (var i = 0; i < assignedToUserIDs.Length; i++)
                {
                    performerList.Add(new Performer {
                        UserId = assignedToUserIDs[i], UserName = assignedToUserNames[i]
                    });
                }
            }
            return(performerList);
        }
Example #11
0
        /// <summary>
        /// 获取任务节点审批人
        /// </summary>
        /// <param name="activityId"></param>
        /// <returns></returns>
        public PerformerList GetActivityPerformers(string activityId)
        {
            IList <Participant> participants = GetActivityParticipants(activityId);
            PerformerList       performers   = new PerformerList();

            if (participants.Any())
            {
                foreach (var pp in participants)
                {
                    if (pp.Type == ParticipantTypeEnum.User)
                    {
                        Performer pf = new Performer();
                        pf.UserId   = pp.ID;
                        pf.UserName = pp.Name;
                        performers.Add(pf);
                    }
                    else if (pp.Type == ParticipantTypeEnum.Role)
                    {
                        var ps = GetPerformerByRole(pp.ID);
                        if (ps.Any())
                        {
                            performers.AddRange(ps);
                        }
                    }
                    else if (pp.Type == ParticipantTypeEnum.DynRole)
                    {
                        IDictionary <string, object> bizData = ProcessEntity.BizData as IDictionary <string, object>;
                        var ps = GetPerformerByDynRole(pp.ID, pp.BindField, bizData);
                        if (ps.Any())
                        {
                            performers.AddRange(ps);
                        }
                    }
                    else if (pp.Type == ParticipantTypeEnum.Other)
                    {
                        //同其他节点审批人
                        PerformerList others = GetActivityPerformers(pp.ID);
                        performers.AddRange(others);
                    }
                }
            }
            return(performers);
        }
Example #12
0
        /// <summary>
        /// 创建下一步的执行人员列表
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        private IDictionary <String, PerformerList> CreateNextActivityPerformers(NodeView view)
        {
            var       nextDict = new Dictionary <String, PerformerList>();
            UserModel um       = new UserModel();

            PerformerList pl = new PerformerList();

            foreach (Role role in view.Roles)
            {
                var a = um.GetUsersByRoleCode(role.RoleCode);      //根据角色代码获取人员
                foreach (var u in a)
                {
                    pl.Add(new Performer(u.UserID, u.UserName));
                }
            }
            nextDict[view.ActivityGUID] = pl;

            return(nextDict);
        }
Example #13
0
        /// <summary>
        /// 下一步活动
        /// 内部测试时用到此方法
        /// 特别注意:正式生产环境,不要使用该方法
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="userName">用户名称</param>
        /// <returns>服务类</returns>
        public IWorkflowService NextStepInt(string userID, string userName)
        {
            var performerList = new PerformerList();

            performerList.Add(new Performer(userID, userName));

            var nextStep = new Dictionary <string, PerformerList>();
            var nodeList = GetNextActivityTree(_wfAppRunner.TaskID.Value, _wfAppRunner.Conditions);

            foreach (var node in nodeList)
            {
                if (node.ActivityType == ActivityTypeEnum.TaskNode)
                {
                    nextStep.Add(node.ActivityGUID, performerList);
                }
            }
            _wfAppRunner.NextActivityPerformers = nextStep;

            return(this);
        }
Example #14
0
        /// <summary>
        /// 获取审批人通过业务角色
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        private PerformerList GetPerformerByRole(string roleId)
        {
            PerformerList     plist = new PerformerList();
            DynamicParameters param = new DynamicParameters();

            param.Add("RoleUid", roleId);
            IEnumerable <FapBizRoleEmployee> employees = _dataAccessor.QueryWhere <FapBizRoleEmployee>("BizRoleUid=@RoleUid", param, true);

            if (employees != null && employees.Count() > 0)
            {
                foreach (var employee in employees)
                {
                    Performer pf = new Performer();
                    pf.UserId   = employee.EmpUid;
                    pf.UserName = employee.EmpUidMC;
                    plist.Add(pf);
                }
            }
            return(plist);
        }
Example #15
0
        /// <summary>
        /// 创建下一步的执行人员列表
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        private IDictionary <String, PerformerList> CreateNextActivityPerformers(IList <NodeView> nextStepList)
        {
            var       nextDict = new Dictionary <String, PerformerList>();
            UserModel um       = new UserModel();

            foreach (NodeView view in nextStepList)
            {
                PerformerList pl = new PerformerList();
                foreach (Role role in view.Roles)
                {
                    var a = um.GetUsersByRoleCode(role.RoleCode);      //根据角色代码获取人员
                    foreach (UserEntity u in a)
                    {
                        pl.Add(new Performer(u.ID.ToString(), u.UserName));
                    }
                }
                nextDict[view.ActivityGUID] = pl;
            }

            return(nextDict);
        }
Example #16
0
        private void btn综合部签字_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            //第一步任务承担者,登录后要找到自己的任务
            appRunner.AppName = "officeIn";
            appRunner.UserID = "3";
            appRunner.UserName = "******";
            IWorkflowService wfService = new WorkflowService();

            PerformerList list = new PerformerList();
            list.Add(new Performer("4", "user4"));
            NodeView nv = wfService.GetNextActivity(appRunner);
            Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>();
            dictPerformer.Add(nv.ActivityGUID, list);
            appRunner.NextActivityPerformers = dictPerformer;
            var result = wfService.RunProcessApp(appRunner);
            var msg = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message);
            tBoxResult.Text += msg;
        }
Example #17
0
        public IDictionary <string, PerformerList> NextActivityPerformers(string nextActivityPerformers)
        {
            IDictionary <string, PerformerList> nextActivityPerformersDictionary = new Dictionary <string, PerformerList>();

            string[] array = nextActivityPerformers.Split(',');
            foreach (string items in array)
            {
                string stepId = GetValueOfNodeIdList(items, "step");
                if (!string.IsNullOrWhiteSpace(stepId) && stepId != "0")
                {
                    string userId = GetValueOfNodeIdList(items, "member");

                    Performer performer = null;
                    if (!string.IsNullOrWhiteSpace(userId) && userId != "0" && userId.Length > 0)
                    {
                        SysUserEntity userEntity = WorkFlows.GetSysUserModel(Convert.ToInt32(userId));
                        if (userEntity != null && userEntity.ID > 0)
                        {
                            performer = new Performer(userId, userEntity.UserName);
                        }
                    }
                    if (performer == null)
                    {
                        performer = new Performer("0", string.Empty);
                    }

                    if (nextActivityPerformersDictionary.ContainsKey(stepId))
                    {
                        (nextActivityPerformersDictionary[stepId]).Add(performer);
                    }
                    else
                    {
                        PerformerList pList = new PerformerList();
                        pList.Add(performer);
                        nextActivityPerformersDictionary.Add(stepId, pList);
                    }
                }
            }
            return(nextActivityPerformersDictionary);
        }
Example #18
0
        /// <summary>
        /// 退回流程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBackward_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            appRunner.AppName = "WallwaOrder";
            appRunner.UserID = "1";
            appRunner.UserName = "******";

            //下一步执行人
            PerformerList list = new PerformerList();
            Performer p = new Performer("13", "andun");//下一步人ID,Name
            list.Add(p);
            Dictionary<String, PerformerList> dict = new Dictionary<String, PerformerList>();
            dict.Add("fc8c71c5-8786-450e-af27-9f6a9de8560f", list); //print activity:"fc8c71c5-8786-450e-af27-9f6a9de8560f"下一步节点的标识ID
            appRunner.NextActivityPerformers = dict;

            IWorkflowService wfService = new WorkflowService();
            var result = wfService.JumpProcess(appRunner);

            var msg = string.Format("流程跳转回退结果:{0}\r\n", result.Status);
            textBox1.Text += msg;
        }
Example #19
0
        private void btn总经理签字_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();

            appRunner.ProcessGUID   = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            //第一步任务承担者,登录后要找到自己的任务
            appRunner.AppName  = "officeIn";
            appRunner.UserID   = "5";
            appRunner.UserName = "******";
            IWorkflowService wfService = new WorkflowService();
            PerformerList    list      = new PerformerList();

            list.Add(new Performer("5", "user5"));
            NodeView nv = wfService.GetNextActivity(appRunner);
            Dictionary <String, PerformerList> dictPerformer = new Dictionary <String, PerformerList>();

            dictPerformer.Add(nv.ActivityGUID, list);
            appRunner.NextActivityPerformers = dictPerformer;
            var result = wfService.RunProcessApp(appRunner);
            var msg    = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message);

            tBoxResult.Text += msg;
        }
Example #20
0
        public ResponseResult<IDictionary<Guid, PerformerList>> GetNextActivityPerformers()
        {
            var performers = new PerformerList();
            performers.Add(new Performer("10", "Long"));

            IDictionary<Guid, PerformerList> nexts = new Dictionary<Guid, PerformerList>();
            nexts[Guid.Parse("10f7481a-ad1a-40f6-aeaa-8d32ceb1fcab")] = performers;

            return ResponseResult<IDictionary<Guid, PerformerList>>.Success(nexts);
        }
        /// <summary>
        /// 由节点分配的人员信息生成PerformerList数据结构
        /// </summary>
        /// <param name="activityInstance"></param>
        /// <returns></returns>
        protected PerformerList AntiGenerateActivityPerformerList(ActivityInstanceEntity activityInstance)
        {
            var performerList = new PerformerList();

            if (!string.IsNullOrEmpty(activityInstance.AssignedToUserIDs)
                && !string.IsNullOrEmpty(activityInstance.AssignedToUserNames))
            {
                var assignedToUserIDs = activityInstance.AssignedToUserIDs.Split(',');
                var assignedToUserNames = activityInstance.AssignedToUserNames.Split(',');

                for (var i = 0; i < assignedToUserIDs.Count(); i++)
                {
                    performerList.Add(new Performer(assignedToUserIDs[i], assignedToUserNames[i]));
                }
            }
            return performerList;
        }
        /// <summary>
        /// 创建下一步的执行人员列表
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        private IDictionary<String, PerformerList> CreateNextActivityPerformers(NodeView view)
        {
            var nextDict = new Dictionary<String, PerformerList>();
            UserModel um = new UserModel();

            PerformerList pl = new PerformerList();
            foreach (Role role in view.Roles)
            {
                var a = um.GetUsersByRoleCode(role.RoleCode);      //根据角色代码获取人员
                foreach (UserEntity u in a)
                {
                    pl.Add(new Performer(u.ID.ToString(), u.UserName));
                }
            }
            nextDict[view.ActivityGUID] = pl;

            return nextDict;
        }
Example #23
0
        public IDictionary<string, PerformerList> NextActivityPerformers(string nextActivityPerformers)
        {
            IDictionary<string, PerformerList> nextActivityPerformersDictionary = new Dictionary<string, PerformerList>();
            string[] array = nextActivityPerformers.Split(',');
            foreach (string items in array)
            {
                string stepId = GetValueOfNodeIdList(items, "step");
                if (!string.IsNullOrWhiteSpace(stepId) && stepId != "0")
                {
                    string userId = GetValueOfNodeIdList(items, "member");

                    Performer performer = null;
                    if (!string.IsNullOrWhiteSpace(userId) && userId != "0" && userId.Length > 0)
                    {
                        SysUserEntity userEntity = WorkFlows.GetSysUserModel(Convert.ToInt32(userId));
                        if (userEntity != null && userEntity.ID > 0)
                        {
                            performer = new Performer(userId, userEntity.UserName);
                        }
                    }
                    if (performer == null)
                        performer = new Performer("0", string.Empty);

                    if (nextActivityPerformersDictionary.ContainsKey(stepId))
                    {
                        (nextActivityPerformersDictionary[stepId]).Add(performer);
                    }
                    else
                    {
                        PerformerList pList = new PerformerList();
                        pList.Add(performer);
                        nextActivityPerformersDictionary.Add(stepId, pList);
                    }
                }
            }
            return nextActivityPerformersDictionary;
        }
Example #24
0
        public async Task <ActionResult> Approval(string type = "agree", string processGUID = "", int instanceId = 0, double days = 0)
        {
            var resolveRequest = HttpContext.Request;

            resolveRequest.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
            string jsonString = new System.IO.StreamReader(resolveRequest.InputStream).ReadToEnd();

            try
            {
                IWorkflowService service = new WorkflowService();
                WfAppRunner      runner  = new WfAppRunner();
                runner.AppInstanceID = instanceId.ToString();
                runner.ProcessGUID   = processGUID;
                runner.UserID        = User.Identity.GetUserId();
                IList <NodeView> NodeViewList = service.GetNextActivityTree(runner, GetCondition("days-" + days));
                var leave = JsonConvert.DeserializeObject <LeaveEntity>(jsonString);
                leave.ID = instanceId;
                //调用流程
                WfAppRunner initiator = new WfAppRunner();
                initiator.AppName       = "请假流程";
                initiator.AppInstanceID = instanceId.ToString();
                initiator.ProcessGUID   = processGUID;
                initiator.UserID        = User.Identity.GetUserId();
                initiator.UserName      = User.Identity.GetUserName();
                initiator.Conditions    = GetCondition(string.Format("days-{0}", days)); //后续节点不用传入条件表达式

                //获取下一步审批人信息
                //下一步角色ID审批者
                PerformerList pList = new PerformerList();
                if (NodeViewList[0].Roles.Count > 0)
                {
                    string outerId = NodeViewList[0].Roles[0].ID.ToString();
                    //这里只取第一个审批者,WebDemo 是弹窗形式选择
                    //审批用户id
                    IEnumerable <int> userId = RoleManager.FindById(Convert.ToInt32(outerId)).Users.Select(t => t.UserId);
                    ApplicationUser   user   = await UserManager.FindByIdAsync(Convert.ToInt32(userId.ToList()[0]));

                    //送往下一步

                    pList.Add(new Performer(user.Id.ToString(), user.RealName));
                }

                initiator.NextActivityPerformers = new Dictionary <String, PerformerList>();
                initiator.NextActivityPerformers.Add(NodeViewList[0].ActivityGUID, pList);
                WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                if (runAppResult.Status != WfExecutedStatus.Success)
                {
                }
                ProcessEntity processEntity = service.GetProcessById(processGUID);
                if (processEntity != null)
                {
                    ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(instanceId);
                    if (activityInstanceEntity != null)
                    {
                        //CurrentActivityText = activityInstanceEntity.ActivityName;
                    }
                }
                new WorkFlowManager().UpdateHrsLeave(leave);
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
            return(Json(new
            {
                success = true,
                message = "执行成功"
            }));
        }
Example #25
0
        public void StartupParalleled()
        {
            IDbConnection conn = new SqlConnection(DBConfig.ConnectionString);

            conn.Open();

            //StarterA:
            //{"UserID":"10","UserName":"******","AppName":"SamplePrice","AppInstanceID":"100","ProcessGUID":"072af8c3-482a-4b1c-890b-685ce2fcc75d"}
            var starterA = new WfAppRunner();

            starterA.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            starterA.UserID      = 10;
            starterA.UserName    = "******";

            var runnerA = new WfAppRunner();

            runnerA.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            runnerA.UserID      = 10;
            runnerA.UserName    = "******";

            PerformerList pList = new PerformerList();

            pList.Add(new Performer(20, "Xiao"));

            runnerA.NextActivityPerformers = new Dictionary <Guid, PerformerList>();
            runnerA.NextActivityPerformers.Add(Guid.Parse("fc8c71c5-8786-450e-af27-9f6a9de8560f"), pList);

            IWorkflowService serviceA;
            IDbTransaction   trans = null;

            //STARTUP 2000 TIMES
            //for (var i = 0; i < 2000; i++)
            //{
            //    serviceA = new WorkflowService();
            //    starterA.AppName = "price";
            //    starterA.AppInstanceID = i;
            //    try
            //    {
            //        trans = conn.BeginTransaction();
            //        serviceA.StartProcess(conn, starterA, trans);
            //        trans.Commit();
            //    }
            //    catch
            //    {
            //        trans.Rollback();
            //        throw;
            //    }
            //    finally
            //    {
            //        trans.Dispose();
            //    }
            //}

            ////RUN process 2000 TIMES
            for (var i = 0; i < 2000; i++)
            {
                serviceA = new WorkflowService();
                runnerA.AppInstanceID = i;
                runnerA.AppName       = "price";
                try
                {
                    trans = conn.BeginTransaction();
                    serviceA.RunProcessApp(conn, runnerA, trans);
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
                finally
                {
                    trans.Dispose();
                }
            }

            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
Example #26
0
        /// <summary>
        /// XML节点预定义跳转
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSkip_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            appRunner.AppName = "WallwaOrder";
            appRunner.UserID = "13";
            appRunner.UserName = "******";

            IWorkflowService wfService = new WorkflowService();
            var nodeViewList = wfService.GetNextActivityTree(appRunner);
            if (nodeViewList != null && nodeViewList.Count() == 1)
            {
                var nodeView = nodeViewList[0];
                if (nodeView.IsSkipTo == true)
                {
                    //下一步执行人
                    PerformerList list = new PerformerList();
                    Performer p = new Performer("1", "admin");//下一步人ID,Name
                    list.Add(p);
                    Dictionary<String, PerformerList> dict = new Dictionary<String, PerformerList>();
                    dict.Add(nodeView.ActivityGUID, list); //nodeView.ID  下一步节点的标识ID
                    appRunner.NextActivityPerformers = dict;

                    var result = wfService.JumpProcess(appRunner);
                    var msg = string.Format("流程跳转结果:{0}\r\n", result.Status);
                    textBox1.Text += msg;
                }
            }
        }
Example #27
0
        //提交请假信息
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string  processGUID = this.txtProcessGUID.Value.ToString();
                string  stepGuid    = this.hiddenStepGuid.Value.ToString();
                int     stepUserID  = Helper.ConverToInt32(this.hiddenStepUser.Value.ToString().Trim());
                decimal days        = Helper.ConverToDecimal(this.txtDays.Value);
                int     leaveType   = Helper.ConverToInt32(selectLeaveType.Value);

                int    nextUserID   = 0;
                string nextUserName = string.Empty;

                SysUserEntity userEntity = WorkFlows.GetSysUserModel(stepUserID);
                if (userEntity != null && userEntity.ID > 0)
                {
                    nextUserID   = userEntity.ID;
                    nextUserName = userEntity.UserName;
                }

                DateTime now = DateTime.Now;

                //请假业务数据
                HrsLeaveEntity hrsLeaveEntity = new HrsLeaveEntity();
                hrsLeaveEntity.LeaveType = leaveType;
                hrsLeaveEntity.Days      = days;
                try
                {
                    hrsLeaveEntity.FromDate = Helper.ConvertToDateTime(this.txtFromDate.Value, now);
                }
                catch (Exception ex)
                {
                    hrsLeaveEntity.FromDate = now;
                }
                try
                {
                    hrsLeaveEntity.ToDate = Helper.ConvertToDateTime(this.txtToDate.Value, now);
                }
                catch (Exception ex)
                {
                    hrsLeaveEntity.ToDate = now;
                }
                hrsLeaveEntity.CurrentActivityText = string.Empty;
                hrsLeaveEntity.Status          = 0;
                hrsLeaveEntity.CreatedUserID   = LoginUserID;
                hrsLeaveEntity.CreatedUserName = this.LoginUserName;
                hrsLeaveEntity.CreatedDate     = now;

                int instanceId = WorkFlows.AddHrsLeave(hrsLeaveEntity);
                if (instanceId > 0)
                {
                    //调用流程
                    IWorkflowService service = new WorkflowService();

                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName       = "请假流程";
                    initiator.AppInstanceID = instanceId.ToString();
                    initiator.ProcessGUID   = processGUID;
                    initiator.UserID        = LoginUserID.ToString();
                    initiator.UserName      = LoginUserName;
                    initiator.Conditions    = GetCondition(string.Format("days-{0}", days));
                    WfExecutedResult startedResult = service.StartProcess(initiator);
                    if (startedResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + startedResult.Message + "');</script>");
                        return;
                    }

                    //送往下一步
                    PerformerList pList = new PerformerList();
                    pList.Add(new Performer(nextUserID.ToString(), nextUserName));

                    initiator.NextActivityPerformers = new Dictionary <String, PerformerList>();
                    initiator.NextActivityPerformers.Add(stepGuid, pList);

                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
                        return;
                    }

                    //保存业务数据
                    BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity();
                    AppFlowEntity.AppName         = "流程发起";
                    AppFlowEntity.AppInstanceID   = instanceId.ToString();
                    AppFlowEntity.ActivityName    = "流程发起";
                    AppFlowEntity.Remark          = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName);
                    AppFlowEntity.ChangedTime     = now;
                    AppFlowEntity.ChangedUserID   = LoginUserID;
                    AppFlowEntity.ChangedUserName = LoginUserName;

                    WorkFlows.AddBizAppFlow(AppFlowEntity);

                    base.RegisterStartupScript("", "<script>alert('流程发起成功');window.location.href='FlowList.aspx';</script>");
                }
            }
            catch (Exception ex)
            {
                base.RegisterStartupScript("", "<script>alert('流程发起出现异常 EXCEPTION:" + ex.ToString() + "');</script>");
            }
        }
Example #28
0
        /// <summary>
        /// 创建子流程节点数据以及子流程记录
        /// </summary>
        /// <param name="toActivity">目的活动</param>
        /// <param name="processInstance">流程实例</param>
        /// <param name="fromActivityInstance">来源活动实例</param>
        /// <param name="transitionGUID">转移GUID</param>
        /// <param name="transitionType">转移类型</param>
        /// <param name="flyingType">飞跃类型</param>
        /// <param name="activityResource">活动资源</param>
        /// <param name="performer">执行者</param>
        /// <param name="session">会话</param>
        private void CreateSubProcessNode(ActivityEntity toActivity,
                                          ProcessInstanceEntity processInstance,
                                          ActivityInstanceEntity fromActivityInstance,
                                          string transitionGUID,
                                          TransitionTypeEnum transitionType,
                                          TransitionFlyingTypeEnum flyingType,
                                          ActivityResource activityResource,
                                          Performer performer,
                                          IDbSession session)
        {
            WfExecutedResult startedResult = WfExecutedResult.Default();

            //实例化Activity
            var toActivityInstance = CreateActivityInstanceObject(toActivity, processInstance, activityResource.AppRunner);

            //进入运行状态
            toActivityInstance.ActivityState = (short)ActivityStateEnum.Ready;
            if (performer != null)
            {
                //并行容器中的子流程节点,每个人发起一个子流程
                toActivityInstance.AssignedToUserIDs   = performer.UserID;
                toActivityInstance.AssignedToUserNames = performer.UserName;
                //插入活动实例数据
                base.ActivityInstanceManager.Insert(toActivityInstance, session);
                //插入任务数据
                this.TaskManager.Insert(toActivityInstance, performer, activityResource.AppRunner, session);
            }
            else
            {
                toActivityInstance = GenerateActivityAssignedUserInfo(toActivityInstance, activityResource);
                //插入活动实例数据
                base.ActivityInstanceManager.Insert(toActivityInstance, session);
                //插入任务数据
                base.CreateNewTask(toActivityInstance, activityResource, session);
            }

            //插入转移数据
            var newTransitionInstanceID = InsertTransitionInstance(processInstance,
                                                                   transitionGUID,
                                                                   fromActivityInstance,
                                                                   toActivityInstance,
                                                                   transitionType,
                                                                   flyingType,
                                                                   activityResource.AppRunner,
                                                                   session);

            //启动子流程
            var subProcessNode = (SubProcessNode)toActivity.Node;

            subProcessNode.ActivityInstance = toActivityInstance;

            WfAppRunner subRunner     = null;
            var         performerList = new PerformerList();

            if (performer != null)
            {
                subRunner = CopyActivityForwardRunner(activityResource.AppRunner,
                                                      new Performer(performer.UserID,
                                                                    performer.UserName),
                                                      subProcessNode);
                performerList.Add(performer);
            }
            else
            {
                subRunner = CopyActivityForwardRunner(activityResource.AppRunner,
                                                      new Performer(activityResource.AppRunner.UserID,
                                                                    activityResource.AppRunner.UserName),
                                                      subProcessNode);
                performerList = activityResource.NextActivityPerformers[toActivity.ActivityGUID];
            }

            var runtimeInstance = WfRuntimeManagerFactory.CreateRuntimeInstanceStartupSub(subRunner,
                                                                                          processInstance,
                                                                                          subProcessNode,
                                                                                          performerList,
                                                                                          session,
                                                                                          ref startedResult);

            runtimeInstance.OnWfProcessExecuted += runtimeInstance_OnWfProcessStarted;
            runtimeInstance.Execute(session);

            void runtimeInstance_OnWfProcessStarted(object sender, WfEventArgs args)
            {
                startedResult = args.WfExecutedResult;
            }
        }
Example #29
0
        //提交请假信息
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string processGUID = this.txtProcessGUID.Value.ToString();
                string stepGuid = this.hiddenStepGuid.Value.ToString();
                int stepUserID = Helper.ConverToInt32(this.hiddenStepUser.Value.ToString().Trim());
                decimal days = Helper.ConverToDecimal(this.txtDays.Value);
                int leaveType = Helper.ConverToInt32(selectLeaveType.Value);

                int nextUserID = 0;
                string nextUserName = string.Empty;

                SysUserEntity userEntity = WorkFlows.GetSysUserModel(stepUserID);
                if (userEntity != null && userEntity.ID > 0)
                {
                    nextUserID = userEntity.ID;
                    nextUserName = userEntity.UserName;
                }

                DateTime now = DateTime.Now;

                //请假业务数据
                HrsLeaveEntity hrsLeaveEntity = new HrsLeaveEntity();
                hrsLeaveEntity.LeaveType = leaveType;
                hrsLeaveEntity.Days = days;
                try
                {
                    hrsLeaveEntity.FromDate = Helper.ConvertToDateTime(this.txtFromDate.Value, now);
                }
                catch (Exception ex)
                {
                    hrsLeaveEntity.FromDate = now;
                }
                try
                {
                    hrsLeaveEntity.ToDate = Helper.ConvertToDateTime(this.txtToDate.Value, now);
                }
                catch (Exception ex)
                {
                    hrsLeaveEntity.ToDate = now;
                }
                hrsLeaveEntity.CurrentActivityText = string.Empty;
                hrsLeaveEntity.Status = 0;
                hrsLeaveEntity.CreatedUserID = LoginUserID;
                hrsLeaveEntity.CreatedUserName = this.LoginUserName;
                hrsLeaveEntity.CreatedDate = now;

                int instanceId = WorkFlows.AddHrsLeave(hrsLeaveEntity);
                if (instanceId > 0)
                {
                    //调用流程
                    IWorkflowService service = new WorkflowService();

                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName = "请假流程";
                    initiator.AppInstanceID = instanceId.ToString();
                    initiator.ProcessGUID = processGUID;
                    initiator.UserID = LoginUserID.ToString();
                    initiator.UserName = LoginUserName;
                    initiator.Conditions = GetCondition(string.Format("days-{0}", days));
                    WfExecutedResult startedResult = service.StartProcess(initiator);
                    if (startedResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + startedResult.Message + "');</script>");
                        return;
                    }

                    //送往下一步
                    PerformerList pList = new PerformerList();
                    pList.Add(new Performer(nextUserID.ToString(), nextUserName));

                    initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
                    initiator.NextActivityPerformers.Add(stepGuid, pList);

                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
                        return;
                    }

                    //保存业务数据
                    BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity();
                    AppFlowEntity.AppName = "流程发起";
                    AppFlowEntity.AppInstanceID = instanceId.ToString();
                    AppFlowEntity.ActivityName = "流程发起";
                    AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName);
                    AppFlowEntity.ChangedTime = now;
                    AppFlowEntity.ChangedUserID = LoginUserID;
                    AppFlowEntity.ChangedUserName = LoginUserName;

                    WorkFlows.AddBizAppFlow(AppFlowEntity);

                    base.RegisterStartupScript("", "<script>alert('流程发起成功');window.location.href='FlowList.aspx';</script>");

                }
            }
            catch (Exception ex)
            {
                base.RegisterStartupScript("", "<script>alert('流程发起出现异常 EXCEPTION:" + ex.ToString() + "');</script>");
            }
        }
Example #30
0
        public async Task<ActionResult> Add(LeaveViewModel leave)
        {
            string processGUID = leave.ProcessGUID;
            //验证不通过,重新填写表单
            if (!ModelState.IsValid)
            {
                return View();
            }
            IWorkflowService service = new WorkflowService();
            //流程开始第一步
            ActivityEntity firstActivity = service.GetFirstActivity(leave.ProcessGUID);

            //该处较上一版本有变化,上一版本为GUID类型
            string firstActivityGUID = firstActivity.ActivityGUID;
            IList<NodeView> nextActivity = service.GetNextActivity(leave.ProcessGUID, firstActivityGUID, GetCondition("days-" + leave.Days));
            //表示有下一位审批者
            if (nextActivity.Count() > 0)
            {
                //下一步角色ID审批者
                string outerId = nextActivity[0].Roles[0].ID.ToString();
                //这里只取第一个审批者,WebDemo 是弹窗形式选择
                //审批用户id
                IEnumerable<int> userId = RoleManager.FindById(Convert.ToInt32(outerId)).Users.Select(t => t.UserId);
                ApplicationUser user = await UserManager.FindByIdAsync(Convert.ToInt32(userId.ToList()[0]));
                //提交请假信息
                LeaveEntity leaveE = new LeaveEntity()
                {
                    FromDate = leave.BeginTime,
                    ToDate = leave.EndTime,
                    Days = leave.Days,
                    LeaveType = leave.LeaveType,
                    CurrentActivityText = "",
                    Status = 0,
                    CreatedUserID = Convert.ToInt32(User.Identity.GetUserId()),
                    CreatedUserName = User.Identity.Name,
                    CreatedDate = DateTime.Now
                };
                HrsLeaveResult result = new WorkFlowManager().Insert(leaveE);
                if (result.Successed)
                {
                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName = "请假流程";
                    initiator.AppInstanceID = result.ResultIdentities.ToString();
                    initiator.ProcessGUID = processGUID;
                    initiator.UserID = User.Identity.GetUserId();
                    initiator.UserName = User.Identity.Name;
                    initiator.Conditions = GetCondition(string.Format("days-{0}", leave.Days));
                    WfExecutedResult startedResult = service.StartProcess(initiator);
                    if (startedResult.Status != WfExecutedStatus.Success)
                    {
                        //给出提示
                    }
                    //送往下一步
                    PerformerList pList = new PerformerList();
                    //这里使用真实姓名代替
                    pList.Add(new Performer(user.Id.ToString(), user.RealName));
                    initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
                    initiator.NextActivityPerformers.Add(nextActivity[0].ActivityGUID, pList);
                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        this.Content("<script>alert('" + runAppResult.Message + "');</script>");
                    }
                    //保存业务数据
                    BizAppFlowEntity AppFlowEntity = new BizAppFlowEntity();
                    AppFlowEntity.AppName = "流程发起";
                    AppFlowEntity.AppInstanceID = result.ResultIdentities.ToString();
                    AppFlowEntity.ActivityName = "流程发起";
                    AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", User.Identity.GetUserId(), User.Identity.Name);
                    AppFlowEntity.ChangedTime = DateTime.Now;
                    AppFlowEntity.ChangedUserID = User.Identity.GetUserId();
                    AppFlowEntity.ChangedUserName = User.Identity.Name;
                    HrsLeaveResult resultBiz = new WorkFlowManager().Insert(AppFlowEntity);
                    if (resultBiz.Successed)
                    {
                        //给出前台提示
                        this.Content("", "<script>alert('流程发起成功');</script>");
                    }
                }
            }
            else
            {
                //显示前台错误,人事人员审批失败
                ModelState.AddModelError("Human", "该用户暂时不可提交审批,未查询到该用户的下一位审批者");
                return View();
            }
            return RedirectToAction("MySlickflow", "Slickflow");
        }
Example #31
0
        public void StartupRunEnd()
        {
            IDbConnection conn = new SqlConnection(DBConfig.ConnectionString);
            conn.Open();

            ////StarterA:
            ////{"UserID":"10","UserName":"******","AppName":"SamplePrice","AppInstanceID":"100","ProcessGUID":"072af8c3-482a-4b1c-890b-685ce2fcc75d"}
            var initiator = new WfAppRunner();
            initiator.AppName = "SamplePrice";
            initiator.AppInstanceID = 100;
            initiator.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            initiator.UserID = 10;
            initiator.UserName = "******";

            IWorkflowService service = new WorkflowService();

            //流程开始->业务员提交
            IDbTransaction trans = conn.BeginTransaction();
            try
            {
                service.StartProcess(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //业务员提交->板房签字
            var banFangNodeGuid = "fc8c71c5-8786-450e-af27-9f6a9de8560f";
            PerformerList pList = new PerformerList();
            pList.Add(new Performer(20, "Zhang"));

            initiator.NextActivityPerformers = new Dictionary<Guid, PerformerList>();
            initiator.NextActivityPerformers.Add(Guid.Parse(banFangNodeGuid), pList);

            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //板房签字->业务员签字
            //登录用户身份
            initiator.UserID = 20;
            initiator.UserName = "******";

            var salesGuid = "39c71004-d822-4c15-9ff2-94ca1068d745";
            pList.Clear();
            pList.Add(new Performer(10, "Long"));

            initiator.NextActivityPerformers.Clear();
            initiator.NextActivityPerformers.Add(Guid.Parse(salesGuid), pList);
            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //业务员签字->结束
            //登录用户身份
            initiator.UserID = 10;
            initiator.UserName = "******";

            var endGuid = "b70e717a-08da-419f-b2eb-7a3d71f054de";
            pList.Clear();
            pList.Add(new Performer(10, "Long"));

            initiator.NextActivityPerformers.Clear();
            initiator.NextActivityPerformers.Add(Guid.Parse(endGuid), pList);
            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            if (conn.State == ConnectionState.Open)
                conn.Close();
        }
        //送往下一步
        protected void btnSendNext_Click(object sender, EventArgs e)
        {
            try
            {
                string  processGUID          = this.txtProcessGUID.Value.ToString();
                string  stepGuid             = this.hiddenStepGuid.Value.ToString();
                int     stepUserID           = Helper.ConverToInt32(this.hiddenStepUser.Value.ToString().Trim());
                decimal days                 = Helper.ConverToDecimal(this.txtDays.Value);
                string  instanceId           = this.hiddenInstanceId.Value;
                string  DepManagerRemark     = this.txtDepmanagerRemark.Value;
                string  DirectorRemark       = this.txtDirectorRemark.Value;
                string  DeputyGeneralRemark  = this.txtDeputyGeneralRemark.Value;
                string  GeneralManagerRemark = this.txtGeneralManagerRemark.Value;
                int     activityInstanceID   = Helper.ConverToInt32(hiddenActivityInstanceID.Value);

                string CurrentActivityText = string.Empty;;

                int    nextUserID   = 0;
                string nextUserName = string.Empty;

                SysUserEntity userEntity = WorkFlows.GetSysUserModel(stepUserID);
                if (userEntity != null && userEntity.ID > 0)
                {
                    nextUserID   = userEntity.ID;
                    nextUserName = userEntity.UserName;
                }

                DateTime now = DateTime.Now;

                if (!string.IsNullOrEmpty(instanceId))
                {
                    //调用流程
                    IWorkflowService service = new WorkflowService();

                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName       = "请假流程";
                    initiator.AppInstanceID = instanceId;
                    initiator.ProcessGUID   = processGUID;
                    initiator.UserID        = LoginUserID.ToString();
                    initiator.UserName      = LoginUserName;
                    initiator.Conditions    = GetCondition(string.Format("days-{0}", days));

                    //送往下一步
                    PerformerList pList = new PerformerList();
                    pList.Add(new Performer(nextUserID.ToString(), nextUserName));

                    initiator.NextActivityPerformers = new Dictionary <String, PerformerList>();
                    initiator.NextActivityPerformers.Add(stepGuid, pList);

                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
                        return;
                    }


                    ProcessEntity processEntity = service.GetProcessById(processGUID);
                    if (processEntity != null)
                    {
                        ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(activityInstanceID);
                        if (activityInstanceEntity != null)
                        {
                            CurrentActivityText = activityInstanceEntity.ActivityName;
                        }
                    }

                    try
                    {
                        //保存业务数据
                        BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity();
                        AppFlowEntity.AppName         = "请假流程";
                        AppFlowEntity.AppInstanceID   = instanceId.ToString();
                        AppFlowEntity.ActivityName    = CurrentActivityText;
                        AppFlowEntity.Remark          = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName) + CurrentActivityText;
                        AppFlowEntity.ChangedTime     = now;
                        AppFlowEntity.ChangedUserID   = LoginUserID;
                        AppFlowEntity.ChangedUserName = LoginUserName;
                        WorkFlows.AddBizAppFlow(AppFlowEntity);
                    }
                    catch (Exception ex)
                    { }

                    try
                    {
                        HrsLeaveEntity hrsLeaveEntity = new Entity.HrsLeaveEntity();
                        hrsLeaveEntity.ID = Helper.ConverToInt32(instanceId);
                        hrsLeaveEntity.DepManagerRemark     = DepManagerRemark;
                        hrsLeaveEntity.DirectorRemark       = DirectorRemark;
                        hrsLeaveEntity.DeputyGeneralRemark  = DeputyGeneralRemark;
                        hrsLeaveEntity.GeneralManagerRemark = GeneralManagerRemark;
                        hrsLeaveEntity.CurrentActivityText  = CurrentActivityText;
                        WorkFlows.UpdateHrsLeave(hrsLeaveEntity);
                    }
                    catch (Exception ex)
                    { }

                    base.RegisterStartupScript("", "<script>alert('办理成功');window.location.href='FlowList.aspx';</script>");
                }
            }
            catch (Exception ex)
            {
                base.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('流程发起出现异常 EXCEPTION:" + ex.ToString() + "');</script>");
            }
        }
Example #33
0
        public void StartupParalleled()
        {
            IDbConnection conn = new SqlConnection(DBConfig.ConnectionString);
            conn.Open();

            //StarterA:
            //{"UserID":"10","UserName":"******","AppName":"SamplePrice","AppInstanceID":"100","ProcessGUID":"072af8c3-482a-4b1c-890b-685ce2fcc75d"}
            var starterA = new WfAppRunner();
            starterA.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            starterA.UserID = 10;
            starterA.UserName = "******";

            var runnerA = new WfAppRunner();
            runnerA.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            runnerA.UserID = 10;
            runnerA.UserName = "******";

            PerformerList pList = new PerformerList();
            pList.Add(new Performer(20, "Xiao"));

            runnerA.NextActivityPerformers = new Dictionary<Guid, PerformerList>();
            runnerA.NextActivityPerformers.Add(Guid.Parse("fc8c71c5-8786-450e-af27-9f6a9de8560f"), pList);

            IWorkflowService serviceA;
            IDbTransaction trans = null;

            //STARTUP 2000 TIMES
            //for (var i = 0; i < 2000; i++)
            //{
            //    serviceA = new WorkflowService();
            //    starterA.AppName = "price";
            //    starterA.AppInstanceID = i;
            //    try
            //    {
            //        trans = conn.BeginTransaction();
            //        serviceA.StartProcess(conn, starterA, trans);
            //        trans.Commit();
            //    }
            //    catch
            //    {
            //        trans.Rollback();
            //        throw;
            //    }
            //    finally
            //    {
            //        trans.Dispose();
            //    }
            //}

            ////RUN process 2000 TIMES
            for (var i = 0; i < 2000; i++)
            {
                serviceA = new WorkflowService();
                runnerA.AppInstanceID = i;
                runnerA.AppName = "price";
                try
                {
                    trans = conn.BeginTransaction();
                    serviceA.RunProcessApp(conn, runnerA, trans);
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
                finally
                {
                    trans.Dispose();
                }
            }

            if (conn.State == ConnectionState.Open)
                conn.Close();
        }
Example #34
0
        public async Task <ActionResult> Add(LeaveViewModel leave)
        {
            string processGUID = leave.ProcessGUID;

            //验证不通过,重新填写表单
            if (!ModelState.IsValid)
            {
                return(View());
            }
            IWorkflowService service = new WorkflowService();
            //流程开始第一步
            ActivityEntity firstActivity = service.GetFirstActivity(leave.ProcessGUID);

            //该处较上一版本有变化,上一版本为GUID类型
            string           firstActivityGUID = firstActivity.ActivityGUID;
            IList <NodeView> nextActivity      = service.GetNextActivity(leave.ProcessGUID, firstActivityGUID, GetCondition("days-" + leave.Days));

            //表示有下一位审批者
            if (nextActivity.Count() > 0)
            {
                //下一步角色ID审批者
                string outerId = nextActivity[0].Roles[0].ID.ToString();
                //这里只取第一个审批者,WebDemo 是弹窗形式选择
                //审批用户id
                IEnumerable <int> userId = RoleManager.FindById(Convert.ToInt32(outerId)).Users.Select(t => t.UserId);
                ApplicationUser   user   = await UserManager.FindByIdAsync(Convert.ToInt32(userId.ToList()[0]));

                //提交请假信息
                LeaveEntity leaveE = new LeaveEntity()
                {
                    FromDate            = leave.BeginTime,
                    ToDate              = leave.EndTime,
                    Days                = leave.Days,
                    LeaveType           = leave.LeaveType,
                    CurrentActivityText = "",
                    Status              = 0,
                    CreatedUserID       = Convert.ToInt32(User.Identity.GetUserId()),
                    CreatedUserName     = User.Identity.Name,
                    CreatedDate         = DateTime.Now
                };
                HrsLeaveResult result = new WorkFlowManager().Insert(leaveE);
                if (result.Successed)
                {
                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName       = "请假流程";
                    initiator.AppInstanceID = result.ResultIdentities.ToString();
                    initiator.ProcessGUID   = processGUID;
                    initiator.UserID        = User.Identity.GetUserId();
                    initiator.UserName      = User.Identity.Name;
                    initiator.Conditions    = GetCondition(string.Format("days-{0}", leave.Days));
                    WfExecutedResult startedResult = service.StartProcess(initiator);
                    if (startedResult.Status != WfExecutedStatus.Success)
                    {
                        //给出提示
                    }
                    //送往下一步
                    PerformerList pList = new PerformerList();
                    //这里使用真实姓名代替
                    pList.Add(new Performer(user.Id.ToString(), user.RealName));
                    initiator.NextActivityPerformers = new Dictionary <String, PerformerList>();
                    initiator.NextActivityPerformers.Add(nextActivity[0].ActivityGUID, pList);
                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        this.Content("<script>alert('" + runAppResult.Message + "');</script>");
                    }
                    //保存业务数据
                    BizAppFlowEntity AppFlowEntity = new BizAppFlowEntity();
                    AppFlowEntity.AppName         = "流程发起";
                    AppFlowEntity.AppInstanceID   = result.ResultIdentities.ToString();
                    AppFlowEntity.ActivityName    = "流程发起";
                    AppFlowEntity.Remark          = string.Format("申请人:{0}-{1}", User.Identity.GetUserId(), User.Identity.Name);
                    AppFlowEntity.ChangedTime     = DateTime.Now;
                    AppFlowEntity.ChangedUserID   = User.Identity.GetUserId();
                    AppFlowEntity.ChangedUserName = User.Identity.Name;
                    HrsLeaveResult resultBiz = new WorkFlowManager().Insert(AppFlowEntity);
                    if (resultBiz.Successed)
                    {
                        //给出前台提示
                        this.Content("", "<script>alert('流程发起成功');</script>");
                    }
                }
            }
            else
            {
                //显示前台错误,人事人员审批失败
                ModelState.AddModelError("Human", "该用户暂时不可提交审批,未查询到该用户的下一位审批者");
                return(View());
            }
            return(RedirectToAction("MySlickflow", "Slickflow"));
        }
Example #35
0
        public async Task<ActionResult> Approval(string type = "agree", string processGUID = "", int instanceId = 0, double days = 0)
        {
            var resolveRequest = HttpContext.Request;
            resolveRequest.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
            string jsonString = new System.IO.StreamReader(resolveRequest.InputStream).ReadToEnd();
            try
            {
                IWorkflowService service = new WorkflowService();
                WfAppRunner runner = new WfAppRunner();
                runner.AppInstanceID = instanceId.ToString();
                runner.ProcessGUID = processGUID;
                runner.UserID = User.Identity.GetUserId();
                IList<NodeView> NodeViewList = service.GetNextActivityTree(runner, GetCondition("days-" + days));
                var leave = JsonConvert.DeserializeObject<LeaveEntity>(jsonString);
                leave.ID = instanceId;
                //调用流程
                WfAppRunner initiator = new WfAppRunner();
                initiator.AppName = "请假流程";
                initiator.AppInstanceID = instanceId.ToString();
                initiator.ProcessGUID = processGUID;
                initiator.UserID = User.Identity.GetUserId();
                initiator.UserName = User.Identity.GetUserName();
                initiator.Conditions = GetCondition(string.Format("days-{0}", days)); //后续节点不用传入条件表达式

                //获取下一步审批人信息
                //下一步角色ID审批者
                PerformerList pList = new PerformerList();
                if (NodeViewList[0].Roles.Count > 0)
                {
                    string outerId = NodeViewList[0].Roles[0].ID.ToString();
                    //这里只取第一个审批者,WebDemo 是弹窗形式选择
                    //审批用户id
                    IEnumerable<int> userId = RoleManager.FindById(Convert.ToInt32(outerId)).Users.Select(t => t.UserId);
                    ApplicationUser user = await UserManager.FindByIdAsync(Convert.ToInt32(userId.ToList()[0]));
                    //送往下一步
                    
                    pList.Add(new Performer(user.Id.ToString(), user.RealName));
                }

                initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
                initiator.NextActivityPerformers.Add(NodeViewList[0].ActivityGUID, pList);
                WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                if (runAppResult.Status != WfExecutedStatus.Success)
                {
                }
                ProcessEntity processEntity = service.GetProcessById(processGUID);
                if (processEntity != null)
                {
                    ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(instanceId);
                    if (activityInstanceEntity != null)
                    {
                        //CurrentActivityText = activityInstanceEntity.ActivityName;
                    }
                }
                new WorkFlowManager().UpdateHrsLeave(leave);
            }
            catch (Exception ex)
            {
                return Json(new
                {
                    success = false,
                    message = ex.Message
                });
            }
            return Json(new
            {
                success = true,
                message = "执行成功"
            });
        }
Example #36
0
        public void StartupRunEnd()
        {
            IDbConnection conn = new SqlConnection(DBConfig.ConnectionString);

            conn.Open();


            ////StarterA:
            ////{"UserID":"10","UserName":"******","AppName":"SamplePrice","AppInstanceID":"100","ProcessGUID":"072af8c3-482a-4b1c-890b-685ce2fcc75d"}
            var initiator = new WfAppRunner();

            initiator.AppName       = "SamplePrice";
            initiator.AppInstanceID = 100;
            initiator.ProcessGUID   = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            initiator.UserID        = 10;
            initiator.UserName      = "******";

            IWorkflowService service = new WorkflowService();

            //流程开始->业务员提交
            IDbTransaction trans = conn.BeginTransaction();

            try
            {
                service.StartProcess(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //业务员提交->板房签字
            var           banFangNodeGuid = "fc8c71c5-8786-450e-af27-9f6a9de8560f";
            PerformerList pList           = new PerformerList();

            pList.Add(new Performer(20, "Zhang"));

            initiator.NextActivityPerformers = new Dictionary <Guid, PerformerList>();
            initiator.NextActivityPerformers.Add(Guid.Parse(banFangNodeGuid), pList);

            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //板房签字->业务员签字
            //登录用户身份
            initiator.UserID   = 20;
            initiator.UserName = "******";

            var salesGuid = "39c71004-d822-4c15-9ff2-94ca1068d745";

            pList.Clear();
            pList.Add(new Performer(10, "Long"));

            initiator.NextActivityPerformers.Clear();
            initiator.NextActivityPerformers.Add(Guid.Parse(salesGuid), pList);
            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //业务员签字->结束
            //登录用户身份
            initiator.UserID   = 10;
            initiator.UserName = "******";

            var endGuid = "b70e717a-08da-419f-b2eb-7a3d71f054de";

            pList.Clear();
            pList.Add(new Performer(10, "Long"));

            initiator.NextActivityPerformers.Clear();
            initiator.NextActivityPerformers.Add(Guid.Parse(endGuid), pList);
            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
        //送往下一步
        protected void btnSendNext_Click(object sender, EventArgs e)
        {
            try
            {
                string processGUID = this.txtProcessGUID.Value.ToString();
                string stepGuid = this.hiddenStepGuid.Value.ToString();
                int stepUserID = Helper.ConverToInt32(this.hiddenStepUser.Value.ToString().Trim());
                decimal days = Helper.ConverToDecimal(this.txtDays.Value);
                string instanceId = this.hiddenInstanceId.Value;
                string DepManagerRemark = this.txtDepmanagerRemark.Value;
                string DirectorRemark = this.txtDirectorRemark.Value;
                string DeputyGeneralRemark = this.txtDeputyGeneralRemark.Value;
                string GeneralManagerRemark = this.txtGeneralManagerRemark.Value;
                int activityInstanceID = Helper.ConverToInt32(hiddenActivityInstanceID.Value);

                string CurrentActivityText = string.Empty; ;

                int nextUserID = 0;
                string nextUserName = string.Empty;

                SysUserEntity userEntity = WorkFlows.GetSysUserModel(stepUserID);
                if (userEntity != null && userEntity.ID > 0)
                {
                    nextUserID = userEntity.ID;
                    nextUserName = userEntity.UserName;
                }

                DateTime now = DateTime.Now;

                if (!string.IsNullOrEmpty(instanceId))
                {
                    //调用流程
                    IWorkflowService service = new WorkflowService();

                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName = "请假流程";
                    initiator.AppInstanceID = instanceId;
                    initiator.ProcessGUID = processGUID;
                    initiator.UserID = LoginUserID.ToString();
                    initiator.UserName = LoginUserName;
                    initiator.Conditions = GetCondition(string.Format("days-{0}", days));

                    //送往下一步
                    PerformerList pList = new PerformerList();
                    pList.Add(new Performer(nextUserID.ToString(), nextUserName));

                    initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
                    initiator.NextActivityPerformers.Add(stepGuid, pList);

                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
                        return;
                    }

                    ProcessEntity processEntity = service.GetProcessById(processGUID);
                    if (processEntity != null)
                    {
                        ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(activityInstanceID);
                        if (activityInstanceEntity != null)
                        {
                            CurrentActivityText = activityInstanceEntity.ActivityName;
                        }
                    }

                    try
                    {
                        //保存业务数据
                        BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity();
                        AppFlowEntity.AppName = "请假流程";
                        AppFlowEntity.AppInstanceID = instanceId.ToString();
                        AppFlowEntity.ActivityName = CurrentActivityText;
                        AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName) + CurrentActivityText;
                        AppFlowEntity.ChangedTime = now;
                        AppFlowEntity.ChangedUserID = LoginUserID;
                        AppFlowEntity.ChangedUserName = LoginUserName;
                        WorkFlows.AddBizAppFlow(AppFlowEntity);
                    }
                    catch (Exception ex)
                    { }

                    try
                    {
                        HrsLeaveEntity hrsLeaveEntity = new Entity.HrsLeaveEntity();
                        hrsLeaveEntity.ID = Helper.ConverToInt32(instanceId);
                        hrsLeaveEntity.DepManagerRemark = DepManagerRemark;
                        hrsLeaveEntity.DirectorRemark = DirectorRemark;
                        hrsLeaveEntity.DeputyGeneralRemark = DeputyGeneralRemark;
                        hrsLeaveEntity.GeneralManagerRemark = GeneralManagerRemark;
                        hrsLeaveEntity.CurrentActivityText = CurrentActivityText;
                        WorkFlows.UpdateHrsLeave(hrsLeaveEntity);
                    }
                    catch (Exception ex)
                    { }

                    base.RegisterStartupScript("", "<script>alert('办理成功');window.location.href='FlowList.aspx';</script>");

                }
            }
            catch (Exception ex)
            {
                base.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('流程发起出现异常 EXCEPTION:" + ex.ToString() + "');</script>");
            }
        }