예제 #1
0
        public LibBusinessTask GetCacheItem(string taskId)
        {
            LibBusinessTask task = this.Get <LibBusinessTask>(taskId);

            if (task == null)
            {
                task = GetBusinessTask(taskId);
                Default.Set(taskId, task);
            }
            return(task);
        }
예제 #2
0
        private LibBusinessTask GetBusinessTask(string taskId)
        {
            SqlBuilder sqlBuilder = new SqlBuilder("axp.ScheduleTask");
            string     sql        = sqlBuilder.GetQuerySql(0, "A.TASKID,A.PROGID,A.BUSINESSTASKID,A.CALENDARID,A.ISJUSTWORKDAY,A.INTERVALTIME,A.EXECDATE,A.REPEATDATEMARK,A.EXECCONDITION,A.TITLE,A.MAINCONTENT,B.EXECTIME",
                                                           string.Format("A.TASKID={0}", LibStringBuilder.GetQuotString(taskId)), "B.EXECTIME");
            LibDataAccess   dataAccess = new LibDataAccess();
            LibBusinessTask task       = null;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    if (task == null)
                    {
                        task = new LibBusinessTask();
                        task.BusinessTaskId = LibSysUtils.ToString(reader["BUSINESSTASKID"]);
                        task.CalendarId     = LibSysUtils.ToString(reader["CALENDARID"]);
                        task.ExecCondition  = LibSysUtils.ToString(reader["ExecCondition"]);
                        task.ExecDate       = LibSysUtils.ToInt32(reader["EXECDATE"]);
                        task.IntervalTime   = LibSysUtils.ToInt32(reader["INTERVALTIME"]);
                        task.IsJustWorkDay  = LibSysUtils.ToBoolean(reader["ISJUSTWORKDAY"]);
                        task.ProgId         = LibSysUtils.ToString(reader["PROGID"]);
                        task.Title          = LibSysUtils.ToString(reader["TITLE"]);
                        task.MainContent    = LibSysUtils.ToString(reader["MAINCONTENT"]);
                        task.RepeatDateMark = LibSysUtils.ToInt32(reader["REPEATDATEMARK"]);
                        task.TaskId         = taskId;
                    }
                    task.ExecTime.Add(LibSysUtils.ToInt32(reader["EXECTIME"]));
                }
            }
            sql = string.Format("select distinct A.TASKID,A.PERSONID,D.DEPTID,C.USERID from AXPSCHEDULETASKPERSON A " +
                                "inner join AXPSCHEDULETASK B on B.TASKID=A.TASKID left join COMPERSON D on D.PERSONID=A.PERSONID inner join AXPUSER C on C.PERSONID=A.PERSONID " +
                                "where B.TASKID={0}", LibStringBuilder.GetQuotString(taskId));
            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    task.Liaison.Add(new LibBusinessTaskLiaison()
                    {
                        PersonId = LibSysUtils.ToString(reader["PERSONID"]),
                        DeptId   = LibSysUtils.ToString(reader["DEPTID"]),
                        UserId   = LibSysUtils.ToString(reader["USERID"])
                    });
                }
            }
            return(task);
        }
예제 #3
0
 public void AddCacheItem(LibBusinessTask task)
 {
     Default.Set(task.TaskId, task); //时间是永久
 }
예제 #4
0
        private static void InitBusinessTask()
        {
            Dictionary <string, LibBusinessTask> taskList = new Dictionary <string, LibBusinessTask>();
            int        currentDate = LibDateUtils.GetCurrentDate();
            SqlBuilder sqlBuilder  = new SqlBuilder("axp.ScheduleTask");
            string     sql         = sqlBuilder.GetQuerySql(0, "A.TASKID,A.PROGID,A.BUSINESSTASKID,A.CALENDARID,A.ISJUSTWORKDAY,A.INTERVALTIME,A.EXECDATE,A.REPEATDATEMARK,A.EXECCONDITION,A.TITLE,A.MAINCONTENT,B.EXECTIME",
                                                            string.Format("A.CURRENTSTATE=2 and (A.VALIDITYSTARTDATE <= {0} and (A.VALIDITYENDDATE>{0} or A.VALIDITYENDDATE = 0))", currentDate), "A.TASKID,B.EXECTIME");
            LibDataAccess dataAccess = new LibDataAccess();

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    string taskId   = LibSysUtils.ToString(reader["TASKID"]);
                    int    execTime = LibSysUtils.ToInt32(reader["EXECTIME"]);
                    if (taskList.ContainsKey(taskId))
                    {
                        if (execTime > 0)
                        {
                            taskList[taskId].ExecTime.Add(execTime);
                        }
                    }
                    else
                    {
                        LibBusinessTask task = new LibBusinessTask();
                        task.BusinessTaskId = LibSysUtils.ToString(reader["BUSINESSTASKID"]);
                        task.CalendarId     = LibSysUtils.ToString(reader["CALENDARID"]);
                        task.ExecCondition  = LibSysUtils.ToString(reader["ExecCondition"]);
                        task.ExecDate       = LibSysUtils.ToInt32(reader["EXECDATE"]);
                        task.IntervalTime   = LibSysUtils.ToInt32(reader["INTERVALTIME"]);
                        task.IsJustWorkDay  = LibSysUtils.ToBoolean(reader["ISJUSTWORKDAY"]);
                        task.ProgId         = LibSysUtils.ToString(reader["PROGID"]);
                        task.Title          = LibSysUtils.ToString(reader["TITLE"]);
                        task.MainContent    = LibSysUtils.ToString(reader["MAINCONTENT"]);
                        task.RepeatDateMark = LibSysUtils.ToInt32(reader["REPEATDATEMARK"]);
                        task.TaskId         = taskId;
                        if (execTime > 0)
                        {
                            task.ExecTime.Add(execTime);
                        }
                        taskList.Add(taskId, task);
                    }
                }
            }
            sql = string.Format("select distinct A.TASKID,A.PERSONID,D.DEPTID,C.USERID from AXPSCHEDULETASKPERSON A " +
                                "inner join AXPSCHEDULETASK B on B.TASKID=A.TASKID left join COMPERSON D on D.PERSONID=A.PERSONID inner join AXPUSER C on C.PERSONID=A.PERSONID " +
                                "where B.CURRENTSTATE=2 and (B.VALIDITYSTARTDATE <= {0} and (B.VALIDITYENDDATE>{0} or B.VALIDITYENDDATE = 0))", currentDate);
            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    string taskId = LibSysUtils.ToString(reader["TASKID"]);
                    if (taskList.ContainsKey(taskId))
                    {
                        taskList[taskId].Liaison.Add(new LibBusinessTaskLiaison()
                        {
                            PersonId = LibSysUtils.ToString(reader["PERSONID"]),
                            DeptId   = LibSysUtils.ToString(reader["DEPTID"]),
                            UserId   = LibSysUtils.ToString(reader["USERID"])
                        });
                    }
                }
            }
            foreach (var item in taskList)
            {
                _Default.Set(item.Key, item.Value);
            }
        }