Exemplo n.º 1
0
        public TaskStage GetTaskStage(int id)
        {
            string    sql = "select * from TaskStage where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                TaskStageTemplate template   = TaskStageTemplateLogic.GetInstance().GetTaskStageTemplate(Convert.ToInt32(dt.Rows[0]["TemplateID"]));
                string            ActualAppr = "";
                if (dt.Rows[0]["ActualAppr"] != null && dt.Rows[0]["ActualAppr"] != DBNull.Value)
                {
                    ActualAppr = dt.Rows[0]["ActualAppr"].ToString();
                }
                string ActualExec = "";
                if (dt.Rows[0]["ActualExec"] != null && dt.Rows[0]["ActualExec"] != DBNull.Value)
                {
                    ActualExec = dt.Rows[0]["ActualExec"].ToString();
                }
                DateTime ApprTime = DateTime.MinValue;
                if (dt.Rows[0]["ApprTime"] != null && dt.Rows[0]["ApprTime"] != DBNull.Value)
                {
                    ApprTime = Convert.ToDateTime(dt.Rows[0]["ApprTime"]);
                }
                DateTime ExecTime = DateTime.MinValue;
                if (dt.Rows[0]["ExecTime"] != null && dt.Rows[0]["ExecTime"] != DBNull.Value)
                {
                    ExecTime = Convert.ToDateTime(dt.Rows[0]["ExecTime"]);
                }
                TaskStage element = new TaskStage(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Name"].ToString(), template, TaskStage.GetTaskStatus(Convert.ToInt32(dt.Rows[0]["TaskStatus"])), ActualExec, ActualAppr, ExecTime, ApprTime, dt.Rows[0]["Remark"].ToString());
                return(element);
            }
            return(null);
        }
Exemplo n.º 2
0
        public List <int> GetTepmIdsByExecOrAppr(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return(null);
            }
            List <int> ids           = new List <int>();
            List <int> stageTempIds  = new List <int>();
            List <int> stageTempIds1 = TaskStageTemplateLogic.GetInstance().GetTaskStageTemplatesByExecutor(userId);
            List <int> stageTempIds2 = TaskStageTemplateLogic.GetInstance().GetTaskStageTemplatesByApprover(userId);

            if (stageTempIds1.Count > 0)
            {
                stageTempIds.AddRange(stageTempIds1);
            }
            if (stageTempIds2.Count > 0)
            {
                stageTempIds.AddRange(stageTempIds2);
            }
            foreach (int id in stageTempIds)
            {
                string    sql = "select ID from FlowTemplate where ','+Stages+',' like '%," + id + ",%'";
                DataTable dt  = sqlHelper.Query(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ids.Add(Convert.ToInt32(dt.Rows[i]["ID"]));
                    }
                }
            }
            return(ids);
        }
Exemplo n.º 3
0
        public List <FlowTemplate> GetAllFlowTemplates()
        {
            List <FlowTemplate> elements = new List <FlowTemplate>();
            string    sql = "select * from FlowTemplate";
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                TaskStageTemplateLogic tsl = TaskStageTemplateLogic.GetInstance();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    List <TaskStageTemplate> stages = new List <TaskStageTemplate>();
                    string        stageIds          = dt.Rows[i]["Stages"].ToString();
                    List <string> idList            = Flow.GetSatges(stageIds);
                    foreach (string id in idList)
                    {
                        TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(id));
                        if (stage != null)
                        {
                            stages.Add(stage);
                        }
                    }
                    FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), stages);
                    elements.Add(element);
                }
            }
            return(elements);
        }
Exemplo n.º 4
0
        public List <TaskStage> GetAllTaskStages()
        {
            List <TaskStage> elements = new List <TaskStage>();
            string           sql      = "select * from TaskStage";
            DataTable        dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                TaskStageTemplateLogic tstl = TaskStageTemplateLogic.GetInstance();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TaskStageTemplate template   = tstl.GetTaskStageTemplate(Convert.ToInt32(dt.Rows[i]["TemplateID"]));
                    string            ActualAppr = "";
                    if (dt.Rows[i]["ActualAppr"] != null && dt.Rows[i]["ActualAppr"] != DBNull.Value)
                    {
                        ActualAppr = dt.Rows[0]["ActualAppr"].ToString();
                    }
                    string ActualExec = "";
                    if (dt.Rows[i]["ActualExec"] != null && dt.Rows[i]["ActualExec"] != DBNull.Value)
                    {
                        ActualExec = dt.Rows[0]["ActualExec"].ToString();
                    }
                    DateTime ApprTime = DateTime.MinValue;
                    if (dt.Rows[i]["ApprTime"] != null && dt.Rows[i]["ApprTime"] != DBNull.Value)
                    {
                        ApprTime = Convert.ToDateTime(dt.Rows[i]["ApprTime"]);
                    }
                    DateTime ExecTime = DateTime.MinValue;
                    if (dt.Rows[i]["ExecTime"] != null && dt.Rows[i]["ExecTime"] != DBNull.Value)
                    {
                        ExecTime = Convert.ToDateTime(dt.Rows[i]["ExecTime"]);
                    }
                    TaskStage element = new TaskStage(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), template, TaskStage.GetTaskStatus(Convert.ToInt32(dt.Rows[i]["TaskStatus"])), ActualExec, ActualAppr, ExecTime, ApprTime, dt.Rows[i]["Remark"].ToString());
                    elements.Add(element);
                }
            }
            return(elements);
        }
Exemplo n.º 5
0
        public List <FlowTemplate> GetFlowTemplates(string name, int stageCount)
        {
            List <FlowTemplate> elements = new List <FlowTemplate>();

            string where = "where (1=1)";
            if (!string.IsNullOrEmpty(name))
            {
                where += " and Name like '%" + name + "%'";
            }
            string    sql = "select * from FlowTemplate " + where + " order by ID desc";
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                TaskStageTemplateLogic tsl = TaskStageTemplateLogic.GetInstance();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    List <TaskStageTemplate> stages = new List <TaskStageTemplate>();
                    string        stageIds          = dt.Rows[i]["Stages"].ToString();
                    List <string> idList            = Flow.GetSatges(stageIds);
                    if (idList.Count == stageCount)
                    {
                        foreach (string id in idList)
                        {
                            TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(id));
                            if (stage != null)
                            {
                                stages.Add(stage);
                            }
                        }
                        FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), stages);
                        elements.Add(element);
                    }
                }
            }
            return(elements);
        }
Exemplo n.º 6
0
        public FlowTemplate GetFlowTemplate(int id)
        {
            string    sql = "select * from FlowTemplate where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                TaskStageTemplateLogic   tsl    = TaskStageTemplateLogic.GetInstance();
                List <TaskStageTemplate> stages = new List <TaskStageTemplate>();
                string        stageIds          = dt.Rows[0]["Stages"].ToString();
                List <string> idList            = Flow.GetSatges(stageIds);
                foreach (string idStr in idList)
                {
                    TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(idStr));
                    if (stage != null)
                    {
                        stages.Add(stage);
                    }
                }
                FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Name"].ToString(), stages);
                return(element);
            }
            return(null);
        }
Exemplo n.º 7
0
        public List <FlowTemplate> GetFlowTemplates(string where)
        {
            List <FlowTemplate> elements = new List <FlowTemplate>();

            if (!string.IsNullOrEmpty(where))
            {
                string w = where.Trim().ToLower();
                if (!w.StartsWith("where "))
                {
                    w = "where " + w;
                }
                string    sql = "select * from FlowTemplate " + w + " order by ID desc";
                DataTable dt  = sqlHelper.Query(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    TaskStageTemplateLogic tsl = TaskStageTemplateLogic.GetInstance();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        List <TaskStageTemplate> stages = new List <TaskStageTemplate>();
                        string        stageIds          = dt.Rows[i]["Stages"].ToString();
                        List <string> idList            = Flow.GetSatges(stageIds);
                        foreach (string id in idList)
                        {
                            TaskStageTemplate stage = tsl.GetTaskStageTemplate(Convert.ToInt32(id));
                            if (stage != null)
                            {
                                stages.Add(stage);
                            }
                        }
                        FlowTemplate element = new FlowTemplate(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), stages);
                        elements.Add(element);
                    }
                }
            }
            return(elements);
        }