/// <summary> /// 删除该流程 /// </summary> public void Remove() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); string id = this.value.ID; var activities = activitydao.Query(new ActivityQueryForm { WorkflowID = id }); taskdao.Delete(new TaskQueryForm { WorkflowID = id }); wfdao.Delete(new WorkflowQueryForm { ID = id }); activitydao.Delete(new ActivityQueryForm { WorkflowID = id }); linkDao.Delete(new LinkQueryForm { WorkflowID = id }); approvalDao.Delete(new ApprovalQueryForm { WorkflowID = id }); authdao.Delete(new ActivityAuthQueryForm { WorkflowID = id }); }
public ActionResult Load() { string user = HttpContext.User.Identity.Name; var data = new ApprovalDao().load(user); return(Json(new { data = data }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 从数据库读取流程信息 /// </summary> /// <param name="workflowids"></param> /// <returns></returns> public static List <WorkflowModel> Load(WorkflowQueryForm form) { List <WorkflowModel> models = new List <WorkflowModel>(); if (form == null) { return(models); } #region query data ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); List <Activity> activityList = new List <Activity>(); List <Link> linkList = new List <Link>(); List <ActivityAuth> authList = new List <ActivityAuth>(); List <Approval> approvalList = new List <Approval>(); List <Task> taskList = new List <Task>(); List <Workflow> workflows = new List <Workflow>(); //先从缓存取值 //var item = cache.GetItem(id); //if (item != null) //{ // model = item.Value as WorkflowModel; // return model; //} workflows = wfdao.Query(form); var workflowids = (from wf in workflows select wf.ID).ToList(); activityList = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); linkList = linkDao.Query(new LinkQueryForm { WorkflowIDs = workflowids }); approvalList = approvalDao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); authList = authdao.Query(new ActivityAuthQueryForm { WorkflowIDs = workflowids }); taskList = taskdao.Query(new TaskQueryForm { WorkflowIDs = workflowids }); #endregion foreach (var workflow in workflows) { var model = BuildWorkflow(workflow, activityList, linkList, authList, approvalList, taskList); models.Add(model); } return(models); }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) throw new Exception("审批意见不能为null"); if (string.IsNullOrEmpty(approval.Remark)) throw new Exception("审批意见不能为空"); //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) return; ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Started; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //处理当前流程所有任务,设置为已处理 var task = activity.GetUserProcessingTask(processor); if (task == null) throw new Exception("环节中没有你的任务,无法进行审批操作"); task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = task.ProcessTime, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ActivityID = task.ActivityID }, }); //把所有活动点的状态清空 activity.OwnerWorkflow.Root.GetList().ForEach(t => t.Value.Status = activity.Value.Status); activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status }, ActivityQueryForm = new ActivityQueryForm { WorkflowID = activity.Value.WorkflowID } }); activity.OwnerWorkflow.Root.Value.Status = (int)ActivityProcessStatus.Processing; var root = activity.OwnerWorkflow.Root; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = root.Value.Status }, ActivityQueryForm = new ActivityQueryForm { ID = root.Value.ID }, }); //生成退回任务 Task roottask = new Task { ActivityID = root.Value.ID, Name = root.Value.Name, Title = root.Value.Title + "(退回)", UserID = activity.OwnerWorkflow.Value.Creator, WorkflowID = activity.OwnerWorkflow.Value.ID, Status = (int)TaskProcessStatus.Started, Creator = processor, }; root.Tasks.Add(roottask); taskdao.Add(roottask); }
public List <InitApprovalResultForm> Query(List <string> projectids, List <string> taskids, string currentuserid) { #region init dao List <InitApprovalResultForm> result = new List <InitApprovalResultForm>(); if (projectids == null || projectids.Count == 0) { return(new List <InitApprovalResultForm>()); } ISqlMapper mapper = Common.GetMapperFromSession(); ProjectDao dao = new ProjectDao(mapper); Customer_ProjectDao cpdao = new Customer_ProjectDao(mapper); Customer_AssetDao cadao = new Customer_AssetDao(mapper); Asset_ProjectDao apdao = new Asset_ProjectDao(mapper); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); ApprovalDao appvoraldao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); UserInfoDao uidao = new UserInfoDao(mapper); User_RoleDao urdao = new User_RoleDao(mapper); TrackingChangeOwnerDao tcodao = new TrackingChangeOwnerDao(mapper); TrackingMortgageDao tmdao = new TrackingMortgageDao(mapper); LinkDao linkdao = new LinkDao(mapper); Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper); ReturnBackConfirmDao rbcdao = new ReturnBackConfirmDao(mapper); CreditReceiverInfoDao cridao = new CreditReceiverInfoDao(mapper); #endregion #region 查询数据 List <Customer_Project> cps = new List <Customer_Project>(); List <Customer_Asset> cas = new List <Customer_Asset>(); List <Asset_Project> aps = new List <Asset_Project>(); List <Activity> activities = new List <Activity>(); List <Approval> approvals = new List <Approval>(); List <Task> tasks = new List <Task>(); List <TrackingChangeOwner> tco = new List <TrackingChangeOwner>(); List <TrackingMortgage> tm = new List <TrackingMortgage>(); List <string> projectidlist = new List <string>(); List <string> workflowids = new List <string>(); List <CreditReceiverInfo> criList = new List <CreditReceiverInfo>(); List <Link> links = new List <Link>(); List <ReturnBackConfirm> returnBackMoneyInfo = new List <ReturnBackConfirm>(); List <Workflow> workflows = null; List <Project> list = null; var rma = rmadao.Query(new Role_Module_ActionQueryForm { }); if (taskids != null && taskids.Count > 0) { tasks = taskdao.Query(new TaskQueryForm { IDs = taskids }); workflowids = (from t in tasks select t.WorkflowID).Distinct().ToList(); workflows = workflowdao.Query(new WorkflowQueryForm { IDs = workflowids }); activities = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); approvals = appvoraldao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); projectidlist = (from w in workflows select w.ProcessID).ToList(); list = dao.Query(new ProjectQueryForm { IDs = projectidlist }); } else if (projectids != null && projectids.Count > 0) { list = dao.Query(new ProjectQueryForm { IDs = projectids }); projectidlist = (from p in list select p.ID).ToList(); workflows = workflowdao.Query(new WorkflowQueryForm { ProcessIDs = projectidlist }); workflowids = (from w in workflows select w.ID).ToList(); if (workflowids.Count > 0) { activities = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); approvals = appvoraldao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); tasks = taskdao.Query(new TaskQueryForm { WorkflowIDs = workflowids }); } } else { return(result); } if (projectidlist.Count > 0) { cps = cpdao.Query(new Customer_ProjectQueryForm { ProjectIDs = projectidlist }); cas = cadao.Query(new Customer_AssetQueryForm { ProjectIDs = projectidlist }); aps = apdao.Query(new Asset_ProjectQueryForm { ProjectIDs = projectidlist }); } var users = uidao.Query(new UserInfoQueryForm { }); var userroles = urdao.Query(new User_RoleQueryForm { }); criList = cridao.Query(new CreditReceiverInfoQueryForm { ProjectIDs = projectids }); tco = tcodao.Query(new TrackingChangeOwnerQueryForm { ProjectIDs = projectidlist }); tm = tmdao.Query(new TrackingMortgageQueryForm { ProjectIDs = projectidlist }); returnBackMoneyInfo = rbcdao.Query(new ReturnBackConfirmQueryForm { ProjectIDs = projectidlist }); //从缓存中取得 var customers = TableCacheHelper.GetDataFromCache <Customer>(typeof(CustomerDao)); var assets = TableCacheHelper.GetDataFromCache <Asset>(typeof(AssetDao)); #endregion #region 处理废单权限 //处理废单权限 var hasDisplayDiscard = (from ur in userroles join r in rma on ur.RoleID equals r.RoleID where r.ModuleID == "4" && r.ActionID == "4" && ur.UserID == currentuserid select r).FirstOrDefault(); #endregion foreach (Project project in list) { var data = QueryDetail(project, customers, assets, cps, cas, aps, workflows, activities, approvals, tasks, users, userroles, tco, tm, returnBackMoneyInfo, criList, currentuserid); if (hasDisplayDiscard != null) { data.DisplayDiscard = true; } result.Add(data); } return(result); }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) { throw new Exception("审批意见不能为null"); } if (string.IsNullOrEmpty(approval.Remark)) { throw new Exception("审批意见不能为空"); } //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) { return; } ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Started; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //处理当前流程所有任务,设置为已处理 var task = activity.GetUserProcessingTask(processor); if (task == null) { throw new Exception("环节中没有你的任务,无法进行审批操作"); } task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = task.ProcessTime, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ActivityID = task.ActivityID }, }); //把所有活动点的状态清空 activity.OwnerWorkflow.Root.GetList().ForEach(t => t.Value.Status = activity.Value.Status); activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status }, ActivityQueryForm = new ActivityQueryForm { WorkflowID = activity.Value.WorkflowID } }); activity.OwnerWorkflow.Root.Value.Status = (int)ActivityProcessStatus.Processing; var root = activity.OwnerWorkflow.Root; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = root.Value.Status }, ActivityQueryForm = new ActivityQueryForm { ID = root.Value.ID }, }); //生成退回任务 Task roottask = new Task { ActivityID = root.Value.ID, Name = root.Value.Name, Title = root.Value.Title + "(退回)", UserID = activity.OwnerWorkflow.Value.Creator, WorkflowID = activity.OwnerWorkflow.Value.ID, Status = (int)TaskProcessStatus.Started, Creator = processor, }; root.Tasks.Add(roottask); taskdao.Add(roottask); }
/// <summary> /// 从数据库读取流程信息 /// </summary> /// <param name="workflowids"></param> /// <returns></returns> public static List<WorkflowModel> Load(WorkflowQueryForm form) { List<WorkflowModel> models = new List<WorkflowModel>(); if (form == null) return models; #region query data ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); List<Activity> activityList = new List<Activity>(); List<Link> linkList = new List<Link>(); List<ActivityAuth> authList = new List<ActivityAuth>(); List<Approval> approvalList = new List<Approval>(); List<Task> taskList = new List<Task>(); List<Workflow> workflows = new List<Workflow>(); //先从缓存取值 //var item = cache.GetItem(id); //if (item != null) //{ // model = item.Value as WorkflowModel; // return model; //} workflows = wfdao.Query(form); var workflowids = (from wf in workflows select wf.ID).ToList(); activityList = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); linkList = linkDao.Query(new LinkQueryForm { WorkflowIDs = workflowids }); approvalList = approvalDao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); authList = authdao.Query(new ActivityAuthQueryForm { WorkflowIDs = workflowids }); taskList = taskdao.Query(new TaskQueryForm { WorkflowIDs = workflowids }); #endregion foreach (var workflow in workflows) { var model = BuildWorkflow(workflow, activityList, linkList, authList, approvalList, taskList); models.Add(model); } return models; }
/// <summary> /// 删除该流程 /// </summary> public void Remove() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); string id = this.value.ID; var activities = activitydao.Query(new ActivityQueryForm { WorkflowID = id }); taskdao.Delete(new TaskQueryForm { WorkflowID = id }); wfdao.Delete(new WorkflowQueryForm { ID = id }); activitydao.Delete(new ActivityQueryForm { WorkflowID = id }); linkDao.Delete(new LinkQueryForm { WorkflowID = id }); approvalDao.Delete(new ApprovalQueryForm { WorkflowID = id }); authdao.Delete(new ActivityAuthQueryForm { WorkflowID = id }); }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) throw new Exception("审批意见不能为null"); if (string.IsNullOrEmpty(approval.Remark)) throw new Exception("审批意见不能为空"); //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) return; ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Processed; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //处理任务 var task = activity.GetUserProcessingTask(processor); if (task == null) throw new Exception("环节中没有你的任务,无法进行审批操作"); task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = DateTime.Now, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ID = task.ID }, }); //设置下个活动点的状态 if (activity.Children.Count > 0) { foreach (var next in activity.Children) { string nextactivityid = next.Value.ID; var nextActivityModel = next as ActivityModel; nextActivityModel.Value.Status = (int)ActivityProcessStatus.Processing; nextActivityModel.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = nextActivityModel.Value.Status, LastUpdator = nextActivityModel.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = nextactivityid }, }); List<string> useridList = auth.GetUserIDList(nextActivityModel.Auth); //新增下个活动点的任务 var tasklist = nextActivityModel.GetTask(processor, useridList); foreach (var t in tasklist) { taskdao.Add(t); nextActivityModel.Tasks.Add(t); } } } }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) { throw new Exception("审批意见不能为null"); } if (string.IsNullOrEmpty(approval.Remark)) { throw new Exception("审批意见不能为空"); } //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) { return; } ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Processed; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //处理任务 var task = activity.GetUserProcessingTask(processor); if (task == null) { throw new Exception("环节中没有你的任务,无法进行审批操作"); } task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = DateTime.Now, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ID = task.ID }, }); //设置下个活动点的状态 if (activity.Children.Count > 0) { foreach (var next in activity.Children) { string nextactivityid = next.Value.ID; var nextActivityModel = next as ActivityModel; nextActivityModel.Value.Status = (int)ActivityProcessStatus.Processing; nextActivityModel.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = nextActivityModel.Value.Status, LastUpdator = nextActivityModel.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = nextactivityid }, }); List <string> useridList = auth.GetUserIDList(nextActivityModel.Auth); //新增下个活动点的任务 var tasklist = nextActivityModel.GetTask(processor, useridList); foreach (var t in tasklist) { taskdao.Add(t); nextActivityModel.Tasks.Add(t); } } } }