2018-06-07 00:45:47 +08:00
|
|
|
|
using Longbow.Cache;
|
|
|
|
|
using Longbow.Logging;
|
2016-11-18 15:37:48 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.Common;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.DataAccess
|
|
|
|
|
{
|
|
|
|
|
public static class TaskHelper
|
|
|
|
|
{
|
2017-03-30 16:15:45 +08:00
|
|
|
|
private const string RetrieveTasksDataKey = "TaskHelper-RetrieveTasks";
|
2016-11-18 15:37:48 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询所有任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static IEnumerable<Task> RetrieveTasks()
|
|
|
|
|
{
|
2017-04-05 11:54:21 +08:00
|
|
|
|
return CacheManager.GetOrAdd(RetrieveTasksDataKey, key =>
|
2016-11-18 15:37:48 +08:00
|
|
|
|
{
|
2016-12-16 10:52:13 +08:00
|
|
|
|
string sql = "select top 1000 t.*, u.DisplayName from Tasks t inner join Users u on t.UserName = u.UserName order by AssignTime desc";
|
2016-11-18 15:37:48 +08:00
|
|
|
|
List<Task> tasks = new List<Task>();
|
|
|
|
|
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
tasks.Add(new Task()
|
|
|
|
|
{
|
2017-03-30 16:15:45 +08:00
|
|
|
|
Id = (int)reader[0],
|
2016-11-18 15:37:48 +08:00
|
|
|
|
TaskName = (string)reader[1],
|
|
|
|
|
AssignName = (string)reader[2],
|
|
|
|
|
UserName = (string)reader[3],
|
|
|
|
|
TaskTime = (int)reader[4],
|
|
|
|
|
TaskProgress = (double)reader[5],
|
|
|
|
|
AssignTime = (DateTime)reader[6],
|
|
|
|
|
AssignDisplayName = (string)reader[7]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { ExceptionManager.Publish(ex); }
|
|
|
|
|
return tasks;
|
2017-04-05 11:54:21 +08:00
|
|
|
|
});
|
2016-11-18 15:37:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|