GetActivityInstance() public method

获取活动实例数据
public GetActivityInstance ( int activityInstanceID ) : ActivityInstanceEntity
activityInstanceID int
return Slickflow.Engine.Business.Entity.ActivityInstanceEntity
Esempio n. 1
0
        public ActivityInstanceEntity GetActivityInstance()
        {
            IWorkflowService service = new WorkflowService();
            var instance = service.GetActivityInstance(100);

            return instance;
        }
        //送往下一步
        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>");
            }
        }
        protected void InitFlowInfo()
        {
            int AppInstanceID = Request.QueryString["AppInstanceID"] == null ? 0 : Helper.ConverToInt32(Request.QueryString["AppInstanceID"].ToString());
            string ProcessGUID = Request.QueryString["ProcessGUID"] == null ? string.Empty : Request.QueryString["ProcessGUID"].ToString();
            int ActivityInstanceID = Request.QueryString["ActivityInstanceID"] == null ? 0 : Helper.ConverToInt32(Request.QueryString["ActivityInstanceID"].ToString());
            if (AppInstanceID > 0)
            {
                HrsLeaveEntity hrsLeaveEntity = WorkFlows.GetHrsLeaveModel(AppInstanceID);
                if (hrsLeaveEntity != null && hrsLeaveEntity.ID > 0)
                {
                    selectLeaveType.Value = hrsLeaveEntity.LeaveType.ToString();
                    selectLeaveType.Disabled = true;
                    txtDays.Value = hrsLeaveEntity.Days.ToString();
                    txtFromDate.Value = hrsLeaveEntity.FromDate.ToString("yyyy-MM-dd");
                    txtToDate.Value = hrsLeaveEntity.ToDate.ToString("yyyy-MM-dd");
                    hiddenInstanceId.Value = hrsLeaveEntity.ID.ToString();
                    hiddenActivityInstanceID.Value = ActivityInstanceID.ToString();

                    this.txtDepmanagerRemark.Value = hrsLeaveEntity.DepManagerRemark;
                    this.txtDirectorRemark.Value = hrsLeaveEntity.DirectorRemark;//主管总监
                    this.txtDeputyGeneralRemark.Value = hrsLeaveEntity.DeputyGeneralRemark;//副总经理
                    this.txtGeneralManagerRemark.Value = hrsLeaveEntity.GeneralManagerRemark;//总经理

                    //权限设置
                    IWorkflowService service = new WorkflowService();
                    ProcessEntity processEntity = service.GetProcessById(ProcessGUID);
                    if (processEntity != null)
                    {
                        this.txtProcessGUID.Value = processEntity.ProcessGUID.ToString();

                        ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(ActivityInstanceID);
                        if (activityInstanceEntity != null)
                        {
                            ActivityEntity activityEntity = service.GetActivityEntity(ProcessGUID, activityInstanceEntity.ActivityGUID);
                            if (activityEntity != null && activityEntity.Roles != null && activityEntity.Roles.Count > 0)
                            {
                                foreach (var role in activityEntity.Roles)
                                {
                                    if (role.ID == LoginRoleID)
                                    {
                                        switch (role.ID)
                                        {
                                            case 2://部门经理
                                                this.txtDepmanagerRemark.Disabled = false;
                                                hiddenPerformField.Value = "DepManager";
                                                break;

                                            case 4://主管总监
                                                this.txtDirectorRemark.Disabled = false;
                                                hiddenPerformField.Value = "Director";
                                                break;

                                            case 7://副总经理
                                                this.txtDeputyGeneralRemark.Disabled = false;
                                                hiddenPerformField.Value = "Deputy";
                                                break;

                                            case 8://总经理
                                                this.txtGeneralManagerRemark.Disabled = false;
                                                hiddenPerformField.Value = "General";
                                                break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        //送往下一步
        protected void btnSendNext_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime now = DateTime.Now;
                string CurrentActivityText = string.Empty;
                string currentOpinionRemark = string.Empty;
                string processGUID = this.txtProcessGUID.Value.ToString();
                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 strNextActivityPerformers = hiddenNextActivityPerformers.Value.ToString().Trim();
                IDictionary<string, PerformerList> nextActivityPerformers = NextActivityPerformers(strNextActivityPerformers);
                if (nextActivityPerformers == null)
                {
                    base.RegisterStartupScript("", "<script>alert('请选择办理步骤或办理人员');</script>");
                    return;
                }
                switch (hiddenPerformField.Value.ToString())
                {
                    case "DepManager"://部门经理
                        currentOpinionRemark = this.txtDepmanagerRemark.Value;
                        break;

                    case "Director"://主管总监
                        currentOpinionRemark = this.txtDirectorRemark.Value;
                        break;
                    case "Deputy"://副总经理
                        currentOpinionRemark = this.txtDeputyGeneralRemark.Value;
                        break;
                    case "General"://总经理
                        currentOpinionRemark = this.txtGeneralManagerRemark.Value;
                        break;
                }

                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));
                    initiator.NextActivityPerformers = nextActivityPerformers;
                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
                        return;
                    }

                    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}(ID:{1}) {2}", LoginUserName, LoginUserID, currentOpinionRemark);
                        AppFlowEntity.ChangedTime = now;
                        AppFlowEntity.ChangedUserID = LoginUserID.ToString();
                        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>");
            }
        }
Esempio n. 5
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 = "执行成功"
            });
        }
Esempio n. 6
0
        public ActionResult List(int id = 1, string processGuid = "", int activityInstanceID = 0)
        {
            if (id == 1)
            {
                ViewBag.Message = "非法链接";
                return View();
            }
            else
            {
                if (string.IsNullOrEmpty(processGuid))
                {
                    WorkFlowManager work = new WorkFlowManager();
                    LeaveEntity entity = work.FindById(id);
                    string s = @"<table class='table table-bordered'>"
                                + "<tr><td>部门经理</td><td>" + entity.DepManagerRemark + "</td></tr>"
                                + "<tr><td>主管总监 </td><td>" + entity.DirectorRemark + "</td></tr>"
                                + "<tr><td>副总经理</td><td>" + entity.DeputyGeneralRemark + "</td></tr>"
                                + "<tr><td>总经理</td><td>" + entity.GeneralManagerRemark + "</td> </tr></table>";
                    ViewBag.Shenpi = s;
                    return View(entity);
                }
                else
                {
                    WorkFlowManager work = new WorkFlowManager();
                    LeaveEntity entity = work.FindById(id);
                    //权限设置
                    IWorkflowService service = new WorkflowService();
                    ProcessEntity processEntity = service.GetProcessById(processGuid);
                    if (processEntity != null)
                    {
                        ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(activityInstanceID);
                        string s = "";
                        if (activityInstanceEntity != null)
                        {
                            ActivityEntity activityEntity = service.GetActivityEntity(processGuid, activityInstanceEntity.ActivityGUID);
                            if (activityEntity != null && activityEntity.Roles != null && activityEntity.Roles.Count > 0)
                            {
                                //用户角色列表
                                IList<string> roleUser = UserManager.GetRoles(Convert.ToInt32(User.Identity.GetUserId()));

                                foreach (var role in activityEntity.Roles)
                                {
                                    //为方便起见这里只取第一个角色,开发人员可以自行调整
                                    if (role.RoleCode == roleUser[0].ToString())
                                    {
                                        switch (role.ID)
                                        {
                                            case 2:
                                                //部门经理审批
                                                s = @"<table class='table table-bordered'>" +
                                               "<tr><td>部门经理</td><td><input type='text'class='form-control' name='DepManagerRemark'></td></tr>" +
                                               "<tr><td>主管总监 </td><input type='text' class='form-control' name='DirectorRemark' style='display:none'></td></tr>" +
                                               "<tr><td>副总经理</td><td><input type='text' class='form-control' name='DeputyGeneralRemark' style='display:none'></td></tr>" +
                                               "<tr><td>总经理</td><td><input class='form-control' name='GeneralManagerRemark'  style='display:none' type='text' /> </td> </tr>"
                                                ;
                                                break;
                                            case 3:
                                                //主管总监审批
                                                s = @"<table class='table table-bordered'>" +
                                               "<tr><td>部门经理</td><td>" + entity.DepManagerRemark + "<input type='text'class='form-control'  style='display:none' name='DepManagerRemark' value='" + entity.DepManagerRemark + "'></td></tr>" +
                                               "<tr><td>主管总监 </td><input type='text' class='form-control' name='DirectorRemark' ></td></tr>" +
                                               "<tr><td>副总经理</td><td><input type='text' class='form-control' name='DeputyGeneralRemark' style='display:none'></td></tr>" +
                                               "<tr><td>总经理</td><td><input class='form-control' name='GeneralManagerRemark'  style='display:none' type='text' /> </td> </tr>"
                                                                                   ;
                                                break;
                                            case 7:
                                                //副总经理审批
                                                s = @"<table class='table table-bordered'>" +
                                               "<tr><td>部门经理</td><td>" + entity.DepManagerRemark + "<input type='text'class='form-control' style='display:none' name='DepManagerRemark' value='" + entity.DepManagerRemark + "'></td></tr>" +
                                               "<tr><td>主管总监 </td><td>" + entity.DirectorRemark + "<input type='text' class='form-control' name='DirectorRemark' value='" + entity.DirectorRemark + "' ></td></tr>" +
                                               "<tr><td>副总经理</td><td><input type='text' class='form-control' name='DeputyGeneralRemark' style='display:none'></td></tr>" +
                                               "<tr><td>总经理</td><td><input class='form-control' name='GeneralManagerRemark'  style='display:none' type='text' /> </td> </tr>";
                                                break;
                                            case 8:
                                                //总经理审批
                                                s = @"<table class='table table-bordered'>" +
  "<tr><td>部门经理</td><td>" + entity.DepManagerRemark + "<input type='text'class='form-control' style='display:none' name='DepManagerRemark' value='" + entity.DepManagerRemark + "'></td></tr>" +
  "<tr><td>主管总监 </td><td>" + entity.DirectorRemark + "<input type='text' class='form-control' name='DirectorRemark' value='" + entity.DirectorRemark + "' ></td></tr>" +
  "<tr><td>副总经理</td><td><input type='text' class='form-control' name='DeputyGeneralRemark' style='display:none' value='" + entity.DeputyGeneralRemark + "'></td></tr>" +
  "<tr><td>总经理</td><td><input class='form-control' name='GeneralManagerRemark' type='text' /> </td> </tr>"
                                      ;
                                                break;
                                        }
                                    }
                                }
                            }
                        }
                        //获取当前角色      
                        ViewBag.Shenpi = "<form action='' id='Remark'>" + s + "</table></form><button class='btn btn-primary' id='agree'>同意</button><button class='btn btn-primary' id='return'>退回</button>";
                        ViewBag.processGUID = processGuid;
                        ViewBag.days = entity.Days;
                        return View(entity);
                    }
                }
            }
            //表示出现错误
            return View();
        }