示例#1
0
        public ActionResult Save()
        {
            //当前登录人员信息
            var userInfo = Session[CommonSession.CurrentUser] as SysUser;

            if (userInfo != null)
            {
                //request.CreateTime = DateTime.Now;
                //1.保存请假单
                //context.LeaveRequests.AddOrUpdate(request);

                var Bid = Guid.NewGuid(); //业务Id

                //2.创建工作流
                var flowInstance = new FlowInstance
                {
                    //工作流当前节点
                    NodeNumber = _flowNodeService.GetFlowNodeByNodeName("发起申请").Result.NodeNumber,
                    NodeName   = "发起申请",
                    //申请处理状态
                    StatusName = "已申请",
                    //申请人(流程发起人)
                    StartUserId = userInfo.Id,
                    StartUser   = userInfo.RealName,
                    //当前操作者
                    OperatingUserId = userInfo.Id,
                    OperatingUser   = userInfo.RealName,
                    //下一个节点处理人
                    ToDoUserId = _flowNodeService.GetFlowNodeByNodeName("部门经理审批").Result.OperateUserId,
                    ToDoUser   = _flowNodeService.GetFlowNodeByNodeName("部门经理审批").Result.OperateUser,
                    ////申请单ID
                    RequisitionId = Bid,
                    UpdateTime    = DateTime.Now,
                    CreateTime    = DateTime.Now,
                    //已操作过的人
                    OperatedUserId = userInfo.Id,
                    OperatedUser   = userInfo.RealName
                };

                //添加
                _flowInstanceSvc.CreateFlowInstance(flowInstance);

                ////3.新建流操作记录
                var flowRecord = new FlowRecord
                {
                    WorkId            = flowInstance.Id,         //流程实例Id
                    OperateUser       = userInfo.RealName,       //当前处理人
                    OperateUserId     = userInfo.Id,
                    CurrentNodeNumber = flowInstance.NodeNumber, ////当前节点
                    CurrentNode       = flowInstance.NodeName,
                    IsRead            = true,                    ////是否已读
                    IsPass            = true,                    ////是否通过
                    UpdateTime        = DateTime.Now
                };
            }
            return(View());
        }
示例#2
0
        public ActionResult FlowSubmit(int flowType, int flowInstanceId)
        {
            switch (flowType)
            {
            case 1: break;

            case 2: break;

            case 3: break;

            case 4: break;
            }

            //当前登录人员信息
            var userInfo = Session[CommonSession.CurrentUser] as SysUser;

            if (userInfo != null)
            {
                //2.创建工作流
                var flowInstance = new FlowInstance
                {
                    //工作流当前节点
                    NodeNumber = _flowNodeService.GetFlowNodeByNodeName("工程申请计划").Result.Id,
                    //申请处理状态
                    StatusName = "已申请",
                    //申请人(流程发起人)
                    StartUserId = userInfo.Id,
                    //当前操作者
                    OperatingUserId = userInfo.Id,
                    //下一个节点处理人
                    ToDoUserId = _flowNodeService.GetFlowNodeByNodeName("工程审核计划").Result.SysRoleId,
                    UpdateTime = DateTime.Now,
                    CreateTime = DateTime.Now,
                    //已操作过的人
                    OperatedUserId = userInfo.Id
                };

                //添加
                _flowInstanceSvc.CreateFlowInstance(flowInstance);

                ////3.新建流操作记录
                var flowRecord = new FlowRecord
                {
                    FlowInstanceId = flowInstance.Id, //流程实例Id
                    IsRead         = true,            ////是否已读
                    IsPass         = true,            ////是否通过
                    UpdateTime     = DateTime.Now
                };
            }
            return(View());
        }
示例#3
0
        public ActionResult CreateProject(ProjectCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                //添加项目
                var project = new Project()
                {
                    ProjectName      = model.ProjectName,
                    WBSCode          = model.WBSCode,
                    SmallProjectName = model.SmallProjectName,
                    SmallWBSCode     = model.SmallWBSCode,
                    Funds            = model.Funds,
                    VoltageGrade     = model.VoltageGrade,
                    SysDepartId      = model.SysDepartId,
                    PickingPeople    = model.PickingPeople,
                    ContactNumber    = model.ContactNumber
                };

                //添加计划
                var plan = new Plan()
                {
                    Project    = project, //添加项目
                    UpdateTime = DateTime.Now,
                    CreateTime = DateTime.Now
                };

                //添加流程实体
                var flowInstance = new FlowInstance()
                {
                    NodeNumber = _flowNodeService.GetFlowNodeByNodeName("工程申请计划").Result.Id,
                    StatusName = "待提交",
                    Plan       = plan,
                    UpdateTime = DateTime.Now,
                    CreateTime = DateTime.Now
                };

                //插入数据库
                _flowInstanceSvc.CreateFlowInstance(flowInstance);

                return(RedirectToAction(nameof(ProjectList)));
            }
            return(View());
        }