Example #1
0
        public List <FullTask> Query(QueryMyTaskServiceForm form)
        {
            ISqlMapper          mapper      = Common.GetMapperFromSession();
            FullTaskDao         dao         = new FullTaskDao(mapper);
            WorkflowDao         wfdao       = new WorkflowDao(mapper);
            Customer_ProjectDao cpdao       = new Customer_ProjectDao(mapper);
            CustomerDao         customerdao = new CustomerDao(mapper);
            var tasks       = dao.QueryTaskByRelationship(form);
            var workflowids = (from t in tasks select t.WorkflowID).ToList();
            var workflows   = wfdao.Query(new WorkflowQueryForm {
                IDs = workflowids
            });
            var projectids = (from w in workflows select w.ProcessID).ToList();
            var cps        = cpdao.Query(new Customer_ProjectQueryForm {
                ProjectIDs = projectids
            });
            var customerids = (from cp in cps select cp.CustomerID).ToList();
            var customers   = customerdao.Query(new CustomerQueryForm {
                IDs = customerids
            });

            foreach (var task in tasks)
            {
                var customername = (from cp in cps join c in customers on cp.CustomerID equals c.ID join w in workflows on cp.ProjectID equals w.ProcessID
                                    where w.ID.Equals(task.WorkflowID) && (cp.Type == 1 || cp.Type == 2)
                                    select c.Name.Trim()).ToList();
                task.Title = String.Join(",", customername);
            }
            return(tasks);
        }
Example #2
0
        public List <Project> QueryMyProject(WorkflowProcessStatus processStatus)
        {
            ISqlMapper  mapper     = Common.GetMapperFromSession();
            TaskDao     taskdao    = new TaskDao(mapper);
            WorkflowDao wfdao      = new WorkflowDao(mapper);
            ProjectDao  projectdao = new ProjectDao(mapper);
            UserBLL     userbll    = new UserBLL();
            var         user       = userbll.GetCurrentUser();
            string      userid     = user.User.ID;
            //string userid = "13";
            var tasks = taskdao.Query(new TaskQueryForm {
                UserID = userid
            });
            List <string> workflowids = (from t in tasks
                                         select t.WorkflowID).Distinct().ToList();
            var workflows = wfdao.Query(new WorkflowQueryForm {
                IDs = workflowids, Status = (int)processStatus
            });
            List <string> projectids = (from wf in workflows
                                        select wf.ProcessID).ToList();

            return(projectdao.Query(new ProjectQueryForm {
                IDs = projectids
            }));
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            WorkflowDao dao = new WorkflowDao();
            var wf = new WorkflowQueryForm();
            wf.ID = "1c74c3e0ce2d4c5f983fab3dc6063223";
            var list = dao.Query(wf);

            WorkflowModel model = WorkflowModel.Load("1c74c3e0ce2d4c5f983fab3dc6063223");
        }
 public List<string> Handle(ActivityAuth auth)
 {
     ISqlMapper mapper = Common.GetMapperFromSession();
     WorkflowDao dao = new WorkflowDao(mapper);
     Workflow wf = dao.Query(new WorkflowQueryForm { ID = auth.WorkflowID }).FirstOrDefault();
     string userid = wf.Creator;
     UserleaderWorkflowAuthority authority = new UserleaderWorkflowAuthority();
     return authority.GetUserIDs(userid, Convert.ToInt32(auth.Value));
 }
Example #5
0
        /// <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);
        }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            WorkflowDao dao = new WorkflowDao();
            var         wf  = new WorkflowQueryForm();

            wf.ID = "1c74c3e0ce2d4c5f983fab3dc6063223";
            var list = dao.Query(wf);

            WorkflowModel model = WorkflowModel.Load("1c74c3e0ce2d4c5f983fab3dc6063223");
        }
        public List <string> Handle(ActivityAuth auth)
        {
            ISqlMapper  mapper = Common.GetMapperFromSession();
            WorkflowDao dao    = new WorkflowDao(mapper);
            Workflow    wf     = dao.Query(new WorkflowQueryForm {
                ID = auth.WorkflowID
            }).FirstOrDefault();
            string userid = wf.Creator;
            UserleaderWorkflowAuthority authority = new UserleaderWorkflowAuthority();

            return(authority.GetUserIDs(userid, Convert.ToInt32(auth.Value)));
        }
Example #8
0
        public void TestWorkflowAdd()
        {
            Workflow wf = new Workflow
            {
                Creator              = "test add",
                Name                 = "testing add",
                Status               = 0,
                CreateTime           = DateTime.Now,
                WorkflowDefinitionID = "1",
            };

            dao.Add(wf);
            WorkflowQueryForm form = new WorkflowQueryForm
            {
                ID = wf.ID,
            };

            var statement = dao.Mapper.GetMappedStatement("QueryWorkflow");

            if (!dao.Mapper.IsSessionStarted)
            {
                dao.Mapper.OpenConnection();
            }
            RequestScope scope  = statement.Statement.Sql.GetRequestScope(statement, form, dao.Mapper.LocalSession);
            string       result = scope.PreparedStatement.PreparedSql;
            var          list   = dao.Query(form);

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("testing add", list[0].Name);
            Assert.AreEqual("1", list[0].WorkflowDefinitionID);
            Assert.AreEqual("test add", list[0].Creator);
            Assert.AreEqual(0, list[0].Status);
            dao.Delete(form);
        }
Example #9
0
        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);
        }
Example #10
0
        /// <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;
        }
Example #11
0
        public string Add(AddProjectServiceForm form)
        {
            ISqlMapper mapper = Common.GetMapperFromSession();
            List <Customer_Project> customers       = new List <Customer_Project>();
            List <Customer>         updateCustomers = new List <Customer>();
            WorkflowDao             workflowdao     = new WorkflowDao(mapper);
            UserBLL userbll = new UserBLL();
            var     user    = userbll.GetCurrentUser();
            string  userid  = user.User.ID;

            form.Project.Report = form.Report;
            var result = bll.Save(form.Project, form.Assets, form.Buyers, form.Sellers, form.ThirdParty, form.Guarantor, form.Project.CreditReceiverInfo, userid);

            //处理流程
            WorkflowDefinitionModel wfdm = WorkflowDefinitionModel.LoadByName("额度申请");
            Workflow wf = workflowdao.Query(new WorkflowQueryForm {
                ProcessID = result
            }).FirstOrDefault();
            WorkflowModel workflow = null;

            if (wf == null)
            {
                workflow = wfdm.StartNew(user.User.ID, result, new WorkflowAuthority());
                //如果流程当前处理人等于申请人,就直接审批通过,进入下一个流程
                var task = workflow.CurrentActivity.Tasks.Find(t => t.UserID == userid);
                if (task != null)
                {
                    workflow.ProcessActivity(new Approval
                    {
                        Creator     = user.User.ID,
                        LastUpdator = user.User.ID,
                        Remark      = form.Report,
                        Status      = (int)ApprovalStatus.Agree,
                        ActivityID  = workflow.CurrentActivity.Value.ID,
                        WorkflowID  = workflow.Value.ID,
                    }, user.User.ID, new WorkflowAuthority());
                }
            }
            else
            {
                workflow = WorkflowModel.Load(wf.ID);
                //如果流程当前处理人等于申请人,就直接审批通过,进入下一个流程
                var task = workflow.CurrentActivity.Tasks.Find(t => t.UserID == userid);
                if (task != null)
                {
                    workflow.ProcessActivity(new Approval
                    {
                        Creator     = user.User.ID,
                        LastUpdator = user.User.ID,
                        Status      = (int)ApprovalStatus.None,
                        ActivityID  = workflow.CurrentActivity.Value.ID,
                        WorkflowID  = workflow.Value.ID,
                    }, user.User.ID, new WorkflowAuthority());
                    task = workflow.CurrentActivity.Tasks.Find(t => t.UserID == userid);
                    if (task != null)
                    {
                        workflow.ProcessActivity(new Approval
                        {
                            Creator     = user.User.ID,
                            LastUpdator = user.User.ID,
                            Remark      = form.Report,
                            Status      = (int)ApprovalStatus.Agree,
                            ActivityID  = workflow.CurrentActivity.Value.ID,
                            WorkflowID  = workflow.Value.ID,
                        }, user.User.ID, new WorkflowAuthority());
                    }
                }
            }

            return(result);
        }
Example #12
0
        public string Add(AddProjectServiceForm form)
        {
            ISqlMapper mapper = Common.GetMapperFromSession();
            List<Customer_Project> customers = new List<Customer_Project>();
            List<Customer> updateCustomers = new List<Customer>();
            WorkflowDao workflowdao = new WorkflowDao(mapper);
            UserBLL userbll = new UserBLL();
            var user = userbll.GetCurrentUser();
            string userid = user.User.ID;
            form.Project.Report = form.Report;
            var result = bll.Save(form.Project, form.Assets, form.Buyers, form.Sellers, form.ThirdParty, form.Guarantor, form.Project.CreditReceiverInfo, userid);

            //处理流程
            WorkflowDefinitionModel wfdm = WorkflowDefinitionModel.LoadByName("额度申请");
            Workflow wf = workflowdao.Query(new WorkflowQueryForm { ProcessID = result }).FirstOrDefault();
            WorkflowModel workflow = null;
            if (wf == null)
            {
                workflow = wfdm.StartNew(user.User.ID, result, new WorkflowAuthority());
                //如果流程当前处理人等于申请人,就直接审批通过,进入下一个流程
                var task = workflow.CurrentActivity.Tasks.Find(t => t.UserID == userid);
                if (task != null)
                {
                    workflow.ProcessActivity(new Approval
                    {
                        Creator = user.User.ID,
                        LastUpdator = user.User.ID,
                        Remark = form.Report,
                        Status = (int)ApprovalStatus.Agree,
                        ActivityID = workflow.CurrentActivity.Value.ID,
                        WorkflowID = workflow.Value.ID,
                    }, user.User.ID, new WorkflowAuthority());
                }
            }
            else
            {
                workflow = WorkflowModel.Load(wf.ID);
                //如果流程当前处理人等于申请人,就直接审批通过,进入下一个流程
                var task = workflow.CurrentActivity.Tasks.Find(t => t.UserID == userid);
                if (task != null)
                {
                    workflow.ProcessActivity(new Approval
                    {
                        Creator = user.User.ID,
                        LastUpdator = user.User.ID,
                        Status = (int)ApprovalStatus.None,
                        ActivityID = workflow.CurrentActivity.Value.ID,
                        WorkflowID = workflow.Value.ID,
                    }, user.User.ID, new WorkflowAuthority());
                    task = workflow.CurrentActivity.Tasks.Find(t => t.UserID == userid);
                    if (task != null)
                    {
                        workflow.ProcessActivity(new Approval
                        {
                            Creator = user.User.ID,
                            LastUpdator = user.User.ID,
                            Remark = form.Report,
                            Status = (int)ApprovalStatus.Agree,
                            ActivityID = workflow.CurrentActivity.Value.ID,
                            WorkflowID = workflow.Value.ID,
                        }, user.User.ID, new WorkflowAuthority());
                    }
                }
            }

            return result;
        }