Exemplo n.º 1
0
        public bool IsLastApprover(string uid, Model.FlowInfo flow)
        {
            string cmdText = @"select 1 from Task 
                                where flowId=@flowId 
                                and uid!=@uid 
                                and logtime is null";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@uid", uid),
                new SqlParameter("@flowId", flow.FlowId)
            };
            return(SqlHelper.ExecuteScalar(cmdText, parameters) == null);
        }
Exemplo n.º 2
0
        public void CancelAllOtherTasks(UserInfo currentUser, Model.FlowInfo flow, Model.ActionType action)
        {
            string cmdText = @"update Task set [Act]=@act,Comment=@comment,logTime=getdate() 
                               where flowId=@flowId 
                               and uid!=@uid 
                               and logTime is null";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@act", (int)action),
                new SqlParameter("@comment", Enum.GetName(typeof(Model.ActionType), action) + " by " + currentUser.DisplayName),     //base on act for reject/approval/return,
                new SqlParameter("@flowId", flow.FlowId),
                new SqlParameter("@uid", currentUser.UID)
            };
            SqlHelper.ExecuteNonQuery(cmdText, parameters);
        }
Exemplo n.º 3
0
        public int CreateFlow(Model.FlowInfo flow)
        {
            string cmdText = @"insert into flow (parentId,Status,ReqId) 
                            values (@parentId,@Status,@ReqId); select @@identity;";

            SqlParameter[] parameters =
            {
                new SqlParameter("@parentId", flow.ParentId),
                new SqlParameter("@Status",   (int)flow.Status),
                new SqlParameter("@ReqId",    flow.ReqId)
            };
            object obj = SqlHelper.ExecuteScalar(cmdText, parameters);

            return(obj == null ? -1 : Convert.ToInt32(obj));
        }
Exemplo n.º 4
0
        public Model.FlowInfo GetFlow(int flowId)
        {
            Model.FlowInfo flow      = null;
            string         cmdText   = "select * from flow where flowId=@flowId";
            SqlParameter   parameter = new SqlParameter("@flowId", flowId);

            using (SqlDataReader reader = SqlHelper.ExecuteReader(cmdText, parameter))
            {
                if (reader.Read())
                {
                    flow          = new Model.FlowInfo();
                    flow.FlowId   = (int)reader["flowId"];
                    flow.ParentId = (int)reader["parentId"];
                    flow.Status   = (Model.FlowStatus)reader["Status"];
                    flow.ReqId    = (int)reader["ReqId"];
                }
            }
            return(flow);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 取消代理者或被代理者的task
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="flow"></param>
        /// <param name="action"></param>
        public void CancelDelegateTasks(string uid, Model.FlowInfo flow, Model.ActionType action)
        {
            string cmdText = @"update Task set Act=@act,comment=@comment,logTime=GETDATE()
                               where flowId=@flowId 
                               and uid!=@uid
                               and logTime is null 
                               and Role in (
		                            select Role from task 
		                            where flowId=@flowId and uid=@uid 
		                            and logTime is null)"        ;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@act", (int)action),
                new SqlParameter("@comment", Enum.GetName(typeof(Model.ActionType), action) + " by " + uid),     //base on act for reject/approval/return,
                new SqlParameter("@flowId", flow.FlowId),
                new SqlParameter("@uid", uid)
            };
            SqlHelper.ExecuteNonQuery(cmdText, parameters);
        }
Exemplo n.º 6
0
        public Model.FlowInfo GetParentFlow(int reqId)
        {
            Model.FlowInfo flow    = null;
            string         cmdText = @"select flowId,parentId,Status,ReqId from flow where ReqId=@reqId and parentId=0";
            SqlParameter   param   = new SqlParameter("@reqId", reqId);

            using (SqlDataReader reader = SqlHelper.ExecuteReader(cmdText, param))
            {
                if (reader.Read())
                {
                    flow = new Model.FlowInfo
                    {
                        FlowId   = Convert.ToInt32(reader["flowId"]),
                        ParentId = Convert.ToInt32(reader["parentId"]),
                        Status   = (Model.FlowStatus) int.Parse(reader["Status"].ToString()),
                        ReqId    = Convert.ToInt32(reader["ReqId"])
                    };
                }
            }
            return(flow);
        }