public ActionResult ShowCheck(int id)
        {
            var instance = WF_InstanceService.GetEntities(u => u.DelFlag == DeleteFlag.DelflagNormal && u.ID == id).FirstOrDefault();

            ViewData.Model = instance;
//            ViewData["flowTo"] =
//               UserInfoService.GetEntities(u => u.DelFlag == delflagNormal).ToList()
//                              .Select(u => new SelectListItem() { Selected = false, Text = u.UName, Value = u.ID.ToString() });

            var temp            = WF_TempService.GetEntities(u => u.ID == instance.WF_TempID).FirstOrDefault();
            var flowToUserInfos = GetFlowToRoleUserInfos(temp.ID);

            if (flowToUserInfos != null && flowToUserInfos.Count > 0)
            {
                ViewData["flowTo"] = (from u in flowToUserInfos
                                      select new SelectListItem()
                {
                    Selected = false, Text = u.UName, Value = u.ID + ""
                })
                                     .ToList();
            }
            else
            {
                ViewData["flowTo"] = UserInfoService.GetEntities(u => u.DelFlag == DeleteFlag.DelflagNormal && u.DelFlag == delflagNormal).ToList()
                                     .Select(u => new SelectListItem()
                {
                    Selected = false, Text = u.UName, Value = u.ID.ToString()
                });
            }
            return(View());
        }
示例#2
0
        public ActionResult ShowCheck(int id)
        {
            ViewData.Model     = WF_InstanceService.GetEntities(u => u.Id == id).FirstOrDefault();
            ViewData["flowTo"] =
                UserInfoService.GetEntities(u => u.DelFlag == this.delFlagNormal).ToList()
                .Select(u => new SelectListItem()
            {
                Selected = false, Text = u.UName, Value = u.Id.ToString()
            });

            return(View());
        }
        public ActionResult Add(WF_Instance wfInstance, int id, int flowTo)
        {
            var currentUserId = 1;

            // 1. Add the new data into workflow-instance
            wfInstance.DelFlag      = (short)DelFlagEnum.Normal;
            wfInstance.StartTime    = DateTime.Now;
            wfInstance.FilePath     = string.Empty;
            wfInstance.SenderId     = currentUserId;
            wfInstance.Level        = 0;
            wfInstance.Status       = (short)WF_InstanceEnum.Processing;
            wfInstance.WFInstanceId = Guid.Empty;
            wfInstance.WF_TempId    = id;
            WF_InstanceService.Add(wfInstance);

            // 2. Start the workflow
            var wfApp = WorkflowApplicationHelper.CreateWorkflowApp(new FinanceActivity(), null);

            wfInstance.WFInstanceId = wfApp.Id;     // save the workflow id
            WF_InstanceService.Update(wfInstance);

            // 3. Add two new procedures to the workflow procedure
            // The first produce handler is self
            WF_Procedure startProcedure = new WF_Procedure();

            startProcedure.WF_InstanceId    = wfInstance.Id;
            startProcedure.SubTime          = DateTime.Now;
            startProcedure.ProcedureName    = "Submit the approval table";
            startProcedure.IsEndProcedure   = false;
            startProcedure.IsStartProcedure = true;
            startProcedure.HandleBy         = currentUserId;
            startProcedure.ProcessComment   = "submit approval";
            startProcedure.ProcessResult    = "pass";
            startProcedure.ProcessStatus    = (short)WF_InstanceEnum.Processing;
            WF_ProcedureService.Add(startProcedure);

            // Initial the next procedure handler
            WF_Procedure nextProcedure = new WF_Procedure();

            nextProcedure.WF_InstanceId  = wfInstance.Id;
            nextProcedure.SubTime        = DateTime.Now;
            nextProcedure.ProcessTime    = DateTime.Now;
            nextProcedure.ProcessComment = string.Empty;

            nextProcedure.IsEndProcedure   = false;
            nextProcedure.IsStartProcedure = false;
            nextProcedure.HandleBy         = flowTo;

            nextProcedure.ProcessResult = "";
            nextProcedure.ProcessStatus = (short)WF_InstanceEnum.Unprocess;
            WF_ProcedureService.Add(nextProcedure);
            return(RedirectToAction("showMyCheck"));
        }
        public ActionResult ShowMyUnCheck()
        {
            // Get all unprocess Procedure whitch should be handle by the current user
            var procedure = WF_ProcedureService.GetEntities(u => u.ProcessStatus == (short)WF_InstanceEnum.Unprocess && u.HandleBy == 1).ToList();

            // Get the corresponding instance id
            var instanceIds = (from p in procedure
                               select p.WF_InstanceId).Distinct();
            // Get the corresponding intance
            var data = WF_InstanceService.GetEntities(i => instanceIds.Contains(i.Id) && i.Status == (short)WF_InstanceEnum.Processing).ToList();

            return(View(data));
        }
示例#5
0
        public ActionResult Add(WF_Instance instance, int id, int flowTo)
        {
            var currentUserId = LoginUser.Id;

            //在工作流实例表添加一条数据
            instance.DelFlag      = this.delFlagNormal;
            instance.StartTime    = DateTime.Now;
            instance.FilePath     = string.Empty;
            instance.StartBy      = currentUserId;
            instance.Level        = 0;
            instance.Status       = (short)Wei.OA.Model.Enum.WF_InstanceEnum.Processing;
            instance.WFInstanceId = Guid.Empty;
            instance.WF_TempId    = id;
            WF_InstanceService.Add(instance);
            //启动工作流
            var wfApp = WorkflowApplictionHelper.CreateWorkflowApp(new FinancialActivity(), null); //可以通过反射,更灵活的添加不同的activity

            instance.WFInstanceId = wfApp.Id;
            WF_InstanceService.Update(instance);
            //在步骤表中添加两个步骤,一个当前已经处理完的步骤
            WF_Step startStep = new WF_Step();

            startStep.WF_InstanceId  = instance.Id;
            startStep.SubTime        = DateTime.Now;
            startStep.StepName       = "提交审批表单";
            startStep.IsEndStep      = false;
            startStep.IsStartStep    = true;
            startStep.ProcessBy      = currentUserId;
            startStep.ProcessComment = "提交申请";
            startStep.ProcessResult  = "通过";
            startStep.ProcessTime    = DateTime.Now;
            startStep.StepStatus     = (short)Wei.OA.Model.Enum.WFStepEnum.Processed;

            WF_StepService.Add(startStep);

            //下一步谁审批的步骤
            WF_Step nextStep = new WF_Step();

            nextStep.WF_InstanceId  = instance.Id;
            nextStep.SubTime        = DateTime.Now;
            nextStep.ProcessTime    = DateTime.Now;
            nextStep.ProcessComment = String.Empty;
            nextStep.IsEndStep      = false;
            nextStep.IsStartStep    = false;
            nextStep.ProcessBy      = flowTo;
            nextStep.ProcessResult  = "";
            nextStep.StepName       = "";
            nextStep.StepStatus     = (short)Wei.OA.Model.Enum.WFStepEnum.UnProcess;
            WF_StepService.Add(nextStep);
            return(RedirectToAction("ShowMyCheck"));
        }
示例#6
0
        //我已审批
        public ActionResult ShowMyChecked()
        {
            var runEnum      = (short)Wei.OA.Model.Enum.WFStepEnum.UnProcess;
            var instanceEnum = (short)Wei.OA.Model.Enum.WF_InstanceEnum.Processed;


            var steps = WF_StepService.GetEntities(s => s.StepStatus == runEnum && s.ProcessBy == LoginUser.Id).ToList();

            var instanceIds = (from s in steps
                               select s.WF_InstanceId).Distinct();
            var data = WF_InstanceService.GetEntities(i => instanceIds.Contains(i.Id)).ToList();

            return(View(data));
        }
示例#7
0
        //待审批(需要我审批的)
        public ActionResult ShowMyUnCheck()
        {
            var runEnum      = (short)Wei.OA.Model.Enum.WFStepEnum.UnProcess;
            var instanceEnum = (short)Wei.OA.Model.Enum.WF_InstanceEnum.Processing;
            //拿到当前用户未处理的步骤
            var steps = WF_StepService.GetEntities(s => s.StepStatus == runEnum && s.ProcessBy == LoginUser.Id)
                        .ToList();
            //通过未处理的步骤拿到流程实例id
            var instanceId = (from s in steps select s.WF_InstanceId).Distinct();
            //根据流程实例id、拿到所有流程
            var data = WF_InstanceService.GetEntities(i => instanceId.Contains(i.Id) && i.Status == instanceEnum)
                       .ToList();

            return(this.View(data));
        }
        //显示待审批
        public ActionResult ShowMyUnCheck()
        {
            var runEnum      = (short)Heima8.OA.Model.Enum.WFStepEnum.UnProecess;
            var instanceEnum = (short)Heima8.OA.Model.Enum.WF_InstanceEnum.Processing;
            //拿到当前用户未处理的 步骤
            var steps = WF_StepService.GetEntities(s => s.StepStatus == runEnum && s.ProcessBy == LoginUser.ID).ToList();

            //通过我没有处理的步骤拿到流程的实例id
            var instanceIds = (from s in steps
                               select s.WF_InstanceID).Distinct();
            //流程实例的id拿到所有的流程。
            var data = WF_InstanceService.GetEntities(
                i => i.DelFlag == DeleteFlag.DelflagNormal && instanceIds.Contains(i.ID) && i.Status == instanceEnum).ToList();

            return(View(data));
        }
示例#9
0
 public ActionResult ShowInstance(int id)
 {
     ViewData.Model = WF_InstanceService.GetEntities(u => u.Id == id).FirstOrDefault();
     return(View());
 }
示例#10
0
        //我发起的审批请求
        public ActionResult ShowMyCheck()
        {
            var data = WF_InstanceService.GetEntities(i => i.StartBy == LoginUser.Id).ToList();

            return(this.View(data));
        }
示例#11
0
        public ActionResult ShowMyCheck()
        {
            var data = WF_InstanceService.GetEntities(i => i.SenderId == 1).ToList();

            return(View(data));
        }
 public WF_Instance GetWfInstance(WF_Step step)
 {
     return(WF_InstanceService.GetEntities(i => i.DelFlag == DeleteFlag.DelflagNormal && i.ID == step.WF_InstanceID)
            .FirstOrDefault());
 }
 public ActionResult ShowInstance(int id)
 {
     ViewData.Model = WF_InstanceService.GetEntities(u => u.DelFlag == DeleteFlag.DelflagNormal && u.ID == id).FirstOrDefault();
     return(View());
 }
        public ActionResult Add(WF_Instance instance, int id, int flowTo)
        {
            var currentUserId = LoginUser.ID;

            //在工作流实例表添加一条数据:
            instance.DelFlag   = delflagNormal;
            instance.StartTime = DateTime.Now;
            instance.FilePath  = string.Empty;

            instance.StartBy      = currentUserId;
            instance.Level        = 0;
            instance.Status       = (short)Heima8.OA.Model.Enum.WF_InstanceEnum.Processing;
            instance.WFInstanceId = Guid.Empty;
            instance.WF_TempID    = id;
            WF_InstanceService.Add(instance);
            //第二点:启动工作流
            //1、获得工作流类型
            var temp     = GetWfTemp(instance);
            var activity = WorkflowFactory.GetActivity(temp.ActityType);
            WorkflowApplication wfApp = null;

            //2、家具产品对应的逻辑
            if (activity is ProductFlow)
            {
                //家具逻辑中,设计之后数控和小锯是二选一
                var designRole =
                    RoleInfoService.GetEntities(r => r.DelFlag == delflagNormal && r.RoleName.Contains("设计"))
                    .FirstOrDefault();
                string flowToKeyWord = GetRoleHelper.GetFlowToRoleKeyWord(designRole, id);
                wfApp = WorkflowApplicationHelper.CreateWorkflowApp(activity,
                                                                    new Dictionary <string, object>()
                {
                    { "AfterDesignFlowTo", flowToKeyWord }
                });
            }//else if{ 其他工作流的逻辑}
            else
            {//没有对应的工作流提前结束
                return(RedirectToAction("ShowMyCheck"));
            }

            instance.WFInstanceId = wfApp.Id;
            WF_InstanceService.Update(instance);

            //第三点:在步骤表里面添加两条步骤。一个当前已经处理的完成步骤。
            WF_Step startStep = new WF_Step();

            startStep.WF_InstanceID  = instance.ID;
            startStep.SubTime        = DateTime.Now;
            startStep.StepName       = "提交审批表单";
            startStep.IsEndStep      = false;
            startStep.IsStartStep    = true;
            startStep.ProcessBy      = currentUserId;
            startStep.PorcessComment = "提交申请";
            startStep.ProcessResult  = "通过";
            startStep.ProcessTime    = DateTime.Now;
//            startStep.StepName = "提交审批表单";
            startStep.StepStatus = (short)Heima8.OA.Model.Enum.WFStepEnum.Processed;


            WF_StepService.Add(startStep);

            //二个步骤:下一步谁审批的步骤。  项目经理审批
            WF_Step nextStep = new WF_Step();

            nextStep.WF_InstanceID  = instance.ID;
            nextStep.SubTime        = DateTime.Now;
            nextStep.ProcessTime    = DateTime.Now;
            nextStep.PorcessComment = string.Empty;

            nextStep.IsEndStep   = false;
            nextStep.IsStartStep = false;
            nextStep.ProcessBy   = flowTo;

            nextStep.ProcessResult = "";

            nextStep.StepName   = "";
            nextStep.StepStatus = (short)Heima8.OA.Model.Enum.WFStepEnum.UnProecess;
            WF_StepService.Add(nextStep);
            return(RedirectToAction("ShowMyCheck"));
        }