Example #1
0
        /// <summary>
        /// 编辑工作流规则
        /// </summary>
        /// <param name="workflow"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool EditWorkflow(sys_workflow workflow, long userId)
        {
            sys_workflow wf    = dal.FindById(workflow.id);
            sys_workflow wfOld = dal.FindById(workflow.id);

            if (wf.workflow_object_id != workflow.workflow_object_id)   // 编辑不能修改对象类型
            {
                return(false);
            }

            wf.update_time      = Tools.Date.DateHelper.ToUniversalTimeStamp();
            wf.update_user_id   = userId;
            wf.name             = workflow.name;
            wf.description      = workflow.description;
            wf.is_active        = workflow.is_active;
            wf.use_default_tmpl = workflow.use_default_tmpl;
            wf.notify_tmpl_id   = workflow.notify_tmpl_id;
            wf.notify_subject   = workflow.notify_subject;
            wf.event_json       = workflow.event_json;
            wf.condition_json   = workflow.condition_json;
            wf.update_json      = workflow.update_json;

            string desc = OperLogBLL.CompareValue <sys_workflow>(wfOld, wf);

            if (!string.IsNullOrEmpty(desc))
            {
                dal.Update(wf);
                OperLogBLL.OperLogUpdate(desc, wf.id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORKFLOW_RULE, "编辑工作流规则");
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// 删除工作流规则
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool DeleteWorkflow(long id, long userId)
        {
            sys_workflow wf = dal.FindById(id);

            wf.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
            wf.delete_user_id = userId;
            dal.Update(wf);
            OperLogBLL.OperLogDelete <sys_workflow>(wf, wf.id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORKFLOW_RULE, "删除工作流规则");
            return(true);
        }
Example #3
0
 /// <summary>
 /// 新增工作流规则
 /// </summary>
 /// <param name="workflow"></param>
 /// <param name="userId"></param>
 /// <returns></returns>
 public bool AddWorkflow(sys_workflow workflow, long userId)
 {
     workflow.id             = dal.GetNextIdCom();
     workflow.create_user_id = userId;
     workflow.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
     workflow.update_time    = workflow.create_time;
     workflow.update_user_id = userId;
     dal.Insert(workflow);
     OperLogBLL.OperLogAdd <sys_workflow>(workflow, workflow.id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORKFLOW_RULE, "新增工作流规则");
     return(true);
 }
Example #4
0
        /// <summary>
        /// 停用工作流规则
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool SetWorkflowInactive(long id, long userId)
        {
            sys_workflow wf = dal.FindById(id);

            if (wf.is_active == 0)
            {
                return(true);
            }

            sys_workflow wfOld = dal.FindById(id);

            wf.is_active      = 0;
            wf.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
            wf.update_user_id = userId;
            dal.Update(wf);
            OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sys_workflow>(wfOld, wf), id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORKFLOW_RULE, "停用工作流规则");

            return(true);
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    wfEdit          = bll.GetWorkflowJson(long.Parse(Request.QueryString["id"]));
                    conditionParams = bll.GetWorkflowFormByObject((DicEnum.WORKFLOW_OBJECT)wfEdit.workflow_object_id, LoginUserId);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(Request.Form["workflow_object_id"]))
                {
                    Response.Write("<script>alert('请选择对象!'); </script>");
                    return;
                }
                int workflowObj = int.Parse(Request.Form["workflow_object_id"]);
                var forminfo    = bll.GetWorkflowFormByObject((DicEnum.WORKFLOW_OBJECT)workflowObj, LoginUserId);

                sys_workflow workflow = new sys_workflow();
                workflow.workflow_object_id = workflowObj;
                workflow.name        = Request.Form["name"];
                workflow.description = Request.Form["description"];
                if (string.IsNullOrEmpty(Request.Form["active"]) || (!Request.Form["active"].Equals("on")))
                {
                    workflow.is_active = 0;
                }
                else
                {
                    workflow.is_active = 1;
                }
                if (string.IsNullOrEmpty(Request.Form["useDefTmpl"]) || (!Request.Form["useDefTmpl"].Equals("on")))
                {
                    workflow.use_default_tmpl = 0;
                }
                else
                {
                    workflow.use_default_tmpl = 1;
                }
                if (!string.IsNullOrEmpty(Request.Form["notifyTemp"]))
                {
                    workflow.notify_tmpl_id = int.Parse(Request.Form["notifyTemp"]);
                }
                workflow.notify_subject = Request.Form["notify_subject"];

                workflow.event_json     = GetEventJson((DicEnum.WORKFLOW_OBJECT)workflowObj, forminfo[0]);
                workflow.condition_json = GetConditionJson((DicEnum.WORKFLOW_OBJECT)workflowObj, forminfo[1]);
                workflow.update_json    = GetUpdateJson((DicEnum.WORKFLOW_OBJECT)workflowObj, forminfo[2]);

                if (string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    bll.AddWorkflow(workflow, LoginUserId);
                }
                else
                {
                    workflow.id = long.Parse(Request.QueryString["id"]);
                    bll.EditWorkflow(workflow, LoginUserId);
                }

                if (Request.Form["action"] == "SaveNew")
                {
                    Response.Write("<script>alert('保存工作流规则成功!');self.opener.location.reload();window.location.href='WorkflowRule.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('保存工作流规则成功!');window.close();self.opener.location.reload();</script>");
                }
            }
        }