示例#1
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            FlowMaster flowmaster = new FlowMaster();

            int indexMasterId = dr.GetOrdinal("MasterId");
            flowmaster.MasterId = Convert.ToInt32(dr[indexMasterId]);

            int indexMasterName = dr.GetOrdinal("MasterName");
            flowmaster.MasterName = Convert.ToString(dr[indexMasterName]);

            int indexMasterStatus = dr.GetOrdinal("MasterStatus");
            flowmaster.MasterStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexMasterStatus]);

            int indexViewUrl = dr.GetOrdinal("ViewUrl");
            if (dr["ViewUrl"] != DBNull.Value)
            {
                flowmaster.ViewUrl = Convert.ToString(dr[indexViewUrl]);
            }

            int indexConditionUrl = dr.GetOrdinal("ConditionUrl");
            if (dr["ConditionUrl"] != DBNull.Value)
            {
                flowmaster.ConditionUrl = Convert.ToString(dr[indexConditionUrl]);
            }

            int indexSuccessUrl = dr.GetOrdinal("SuccessUrl");
            if (dr["SuccessUrl"] != DBNull.Value)
            {
                flowmaster.SuccessUrl = Convert.ToString(dr[indexSuccessUrl]);
            }

            int indexRefusalUrl = dr.GetOrdinal("RefusalUrl");
            if (dr["RefusalUrl"] != DBNull.Value)
            {
                flowmaster.RefusalUrl = Convert.ToString(dr[indexRefusalUrl]);
            }

            int indexViewTitle = dr.GetOrdinal("ViewTitle");
            if (dr["ViewTitle"] != DBNull.Value)
            {
                flowmaster.ViewTitle = Convert.ToString(dr[indexViewTitle]);
            }

            int indexCreatorId = dr.GetOrdinal("CreatorId");
            if (dr["CreatorId"] != DBNull.Value)
            {
                flowmaster.CreatorId = Convert.ToInt32(dr[indexCreatorId]);
            }

            int indexCreateTime = dr.GetOrdinal("CreateTime");
            if (dr["CreateTime"] != DBNull.Value)
            {
                flowmaster.CreateTime = Convert.ToDateTime(dr[indexCreateTime]);
            }

            int indexLastModifyId = dr.GetOrdinal("LastModifyId");
            if (dr["LastModifyId"] != DBNull.Value)
            {
                flowmaster.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]);
            }

            int indexLastModifyTime = dr.GetOrdinal("LastModifyTime");
            if (dr["LastModifyTime"] != DBNull.Value)
            {
                flowmaster.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]);
            }

            return flowmaster;
        }
示例#2
0
        /// <summary>
        /// 根据流程模版,创建任务及任务的第一节点,返回任务的id
        /// </summary>
        /// <param name="user">当前用户</param>
        /// <param name="master">流程模版</param>
        /// <param name="source">数据源</param>
        /// <param name="task">任务</param>
        /// <returns></returns>
        private ResultModel CreateTask(UserModel user, FlowMaster master, DataSource source, Task task)
        {
            ResultModel result = new ResultModel();

            try
            {
                //写入DataSource
                DataSourceDAL dataSourceDAL = new DataSourceDAL();
                result = dataSourceDAL.Insert(user, source);
                if (result.ResultStatus != 0)
                    return result;

                int sourceId = Convert.ToInt32(result.ReturnValue);

                //写入task
                TaskDAL taskDAL = new TaskDAL();
                task.DataSourceId = sourceId;
                result = taskDAL.Insert(user, task);
                if (result.ResultStatus != 0)
                    return result;

                int taskId = Convert.ToInt32(result.ReturnValue);
                task.TaskId = taskId;

                //在审核流程中添加提交审核人
                NodeDAL nodeDAL = new NodeDAL();
                result = nodeDAL.Load<Node>(user, CommandType.Text, string.Format("select * from dbo.Wf_Node where MasterId = {0} and NodeStatus = {1}", master.MasterId, (int)StatusEnum.已生效));
                if (result.ResultStatus != 0)
                    return result;

                List<Node> nodes = result.ReturnValue as List<Node>;
                if (nodes != null)
                {
                    Node firstNode = nodes.OrderBy(a => a.NodeLevel).First();
                    //如果存在NodeLevel为0(提交人)
                    if (firstNode.NodeLevel == 0)
                    {
                        TaskNodeDAL taskNodeDAL = new TaskNodeDAL();
                        result = taskNodeDAL.Insert(user, new TaskNode()
                        {
                            NodeId = firstNode.NodeId,
                            TaskId = taskId,
                            NodeLevel = firstNode.NodeLevel,
                            NodeStatus = StatusEnum.已生效,
                            EmpId = source.EmpId,
                            AuditTime = DefaultValue.DefaultTime
                        });

                        int taskNodeId = (int)result.ReturnValue;

                        TaskOperateLogDAL taskOperateLogDAL = new TaskOperateLogDAL();
                        result = taskOperateLogDAL.Insert(user, new TaskOperateLog()
                        {
                            TaskNodeId = taskNodeId,
                            EmpId = source.EmpId,
                            Memo = "",
                            LogTime = DateTime.Now,
                            LogResult = ""
                        });
                    }
                }

                result = CreateTaskNodes(user, task, 1, source);
                if (result.ResultStatus != 0)
                    return result;

                result.ReturnValue = taskId;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.ResultStatus = -1;
            }

            return result;
        }
示例#3
0
        public override IModel CreateModel(DataRow dr)
        {
            FlowMaster flowmaster = new FlowMaster();

            flowmaster.MasterId = Convert.ToInt32(dr["MasterId"]);

            flowmaster.MasterName = Convert.ToString(dr["MasterName"]);

            flowmaster.MasterStatus = (Common.StatusEnum)Convert.ToInt32(dr["MasterStatus"]);

            if (dr["ViewUrl"] != DBNull.Value)
            {
                flowmaster.ViewUrl = Convert.ToString(dr["ViewUrl"]);
            }

            if (dr["ConditionUrl"] != DBNull.Value)
            {
                flowmaster.ConditionUrl = Convert.ToString(dr["ConditionUrl"]);
            }

            if (dr["SuccessUrl"] != DBNull.Value)
            {
                flowmaster.SuccessUrl = Convert.ToString(dr["SuccessUrl"]);
            }

            if (dr["RefusalUrl"] != DBNull.Value)
            {
                flowmaster.RefusalUrl = Convert.ToString(dr["RefusalUrl"]);
            }

            if (dr["ViewTitle"] != DBNull.Value)
            {
                flowmaster.ViewTitle = Convert.ToString(dr["ViewTitle"]);
            }

            if (dr["CreatorId"] != DBNull.Value)
            {
                flowmaster.CreatorId = Convert.ToInt32(dr["CreatorId"]);
            }

            if (dr["CreateTime"] != DBNull.Value)
            {
                flowmaster.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
            }

            if (dr["LastModifyId"] != DBNull.Value)
            {
                flowmaster.LastModifyId = Convert.ToInt32(dr["LastModifyId"]);
            }

            if (dr["LastModifyTime"] != DBNull.Value)
            {
                flowmaster.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]);
            }

            return flowmaster;
        }
示例#4
0
        /// <summary>
        /// 提交审核并创建任务和提醒消息
        /// </summary>
        /// <param name="user">用户</param>
        /// <param name="model">提交审核数据实体</param>
        /// <param name="master">模版</param>
        /// <param name="source">数据源</param>
        /// <param name="task">任务</param>
        /// <returns></returns>
        public ResultModel AuditAndCreateTask(UserModel user, IModel model, FlowMaster master, DataSource source, Task task)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    DataSourceDAL dataSourceDAL = new DataSourceDAL();
                    result = dataSourceDAL.CheckHasSource(new DataSource() { TableCode = model.TableName, RowId = model.Id });
                    if (result.ResultStatus != 0 || result.AffectCount > 0)
                    {
                        result.Message = "不能重复提交审核";
                        result.ResultStatus = -1;
                        return result;
                    }

                    Common.Operate operate = Common.Operate.CreateOperate(model, true);
                    if (operate == null)
                    {
                        result.Message = "模版不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    result = operate.Get(user, model.Id);
                    if (result.ResultStatus != 0)
                        return result;

                    IModel resultModel = result.ReturnValue as IModel;
                    if (resultModel == null || resultModel.Id <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "数据不存在,不能提交审核";
                        return result;
                    }

                    //判断是否可以直接审核通过
                    FlowMasterConfigDAL flowMasterConfigDAL = new FlowMasterConfigDAL();
                    result = flowMasterConfigDAL.GetByMasterId(user, master.MasterId);
                    if (result.ResultStatus == 0)
                    {
                        FlowMasterConfig flowMasterConfig = result.ReturnValue as FlowMasterConfig;
                        if (flowMasterConfig != null && flowMasterConfig.ConfigId > 0 && flowMasterConfig.CanPassAudit)
                        {
                            result = RequestCallBackUrlForPass(user, source, true);

                            if (result.ResultStatus != 0)
                                return result;

                            if (result.ResultStatus == 0)
                                scope.Complete();

                            return result;
                        }
                    }

                    result = operate.Submit(user, resultModel);
                    if (result.ResultStatus != 0)
                        return result;

                    result = this.CreateTask(user, master, source, task);
                    if (result.ResultStatus != 0)
                        return result;

                    int taskId = (int)result.ReturnValue;

                    string aids = string.Empty;

                    AttachBLL attachBLL = new AttachBLL();
                    result = attachBLL.GetAttachIds(user, resultModel);
                    if (result.ResultStatus == 0)
                    {
                        DataTable dt = result.ReturnValue as DataTable;
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            aids = dt.Rows.Cast<DataRow>().Aggregate(aids, (current, dr) => current + (dr["AttachId"].ToString() + ","));

                            if (!string.IsNullOrEmpty(aids))
                                aids = aids.Substring(0, aids.Length - 1);
                        }

                        TaskAttachBLL taskAttachBLL = new TaskAttachBLL();
                        result = taskAttachBLL.InsertAttach(user, taskId, aids);
                        if (result.ResultStatus != 0)
                            return result;
                    }
                    else
                        result.ResultStatus = 0;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.ResultStatus = -1;
            }
            return result;
        }