Exemple #1
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 void Cleanup()
 {
     WorkflowQueryForm form = new WorkflowQueryForm
     {
         ID = "11",
     };
     dao.Delete(form);
     dao.Delete(new WorkflowQueryForm { ID = "22" });
     dao.Delete(new WorkflowQueryForm { ID = "33" });
 }
        /// <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 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);
        }
        public void TestWorkflowUpdate()
        {
            WorkflowQueryForm form = new WorkflowQueryForm
            {
                ID = "11",
            };
            var list = dao.Query(form);
            WorkflowUpdateForm updateform = new WorkflowUpdateForm
            {
                Entity = new Workflow
                {
                    Status = 1
                },
                WorkflowQueryForm = new WorkflowQueryForm
                {
                    ID = list[0].ID,
                },
            };

            var statement = dao.Mapper.GetMappedStatement("UpdateWorkflow");
            if (!dao.Mapper.IsSessionStarted)
            {
                dao.Mapper.OpenConnection();
            }
            RequestScope scope = statement.Statement.Sql.GetRequestScope(statement, updateform, dao.Mapper.LocalSession);
            string result = scope.PreparedStatement.PreparedSql;
            dao.Update(updateform);
            list = dao.Query(form);
            Assert.AreEqual(1, list[0].Status);
        }
 public void TestWorkflowQuery()
 {
     WorkflowQueryForm form = new WorkflowQueryForm
     {
         ID = "11",
     };
     var list = dao.Query(form);
     Assert.AreEqual(1, list.Count);
     Assert.AreEqual("testing", list[0].Name);
     Assert.AreEqual("1", list[0].WorkflowDefinitionID);
     Assert.AreEqual("test", list[0].Creator);
 }
 public void TestWorkflowDelete()
 {
     Workflow wf = new Workflow
     {
         Creator = "test for delete",
         Name = "testing for delete",
         Status = 0,
         CreateTime = DateTime.Now,
         WorkflowDefinitionID = "1",
     };
     dao.Add(wf);
     WorkflowQueryForm form = new WorkflowQueryForm
     {
         ID = wf.ID,
     };
     var list = dao.Query(form);
     Assert.AreEqual(1, list.Count);
     dao.Delete(form);
     list = dao.Query(form);
     Assert.AreEqual(0, list.Count);
 }