添加项目文件。
This commit is contained in:
82
WPFWCSDemo/Utilities/Table/TaskHistoryManager.cs
Normal file
82
WPFWCSDemo/Utilities/Table/TaskHistoryManager.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WPFWCSDemo.Models.Tables;
|
||||
|
||||
namespace WPFWCSDemo.Utilities.Table
|
||||
{
|
||||
public class TaskHistoryManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取表数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<TaskHistory> ListAll()
|
||||
{
|
||||
|
||||
using (DataTable? dt = SqlHelper.ExecuteTable("SELECT * FROM TASK_HISTORY ORDER BY CREATETIME DESC"))
|
||||
{
|
||||
if (dt == null || dt.Rows.Count == 0) return null;
|
||||
|
||||
List<TaskHistory> scheduleHistoryManagers = new List<TaskHistory>();
|
||||
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
scheduleHistoryManagers.Add(ToModels(dr));
|
||||
}
|
||||
|
||||
#region 反射方法
|
||||
/*
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
tasks.Add(dr.DataRowToModel<ScheduleManager>());
|
||||
}
|
||||
*/
|
||||
#endregion
|
||||
|
||||
return scheduleHistoryManagers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将表行转换成实体数据
|
||||
/// </summary>
|
||||
/// <param name="dr"></param>
|
||||
/// <returns></returns>
|
||||
public static TaskHistory ToModels(DataRow dr)
|
||||
{
|
||||
if (dr == null) return null;
|
||||
|
||||
TaskHistory taskHistory = new TaskHistory();
|
||||
|
||||
taskHistory.JobId = dr["jobId"].ToString();
|
||||
taskHistory.TaskId = dr["TaskId"].ToString();
|
||||
taskHistory.PalletId = dr["PalletId"].ToString();
|
||||
taskHistory.SourceLocation = dr["SourceLocation"].ToString();
|
||||
taskHistory.TargetLocation = dr["TargetLocation"].ToString();
|
||||
taskHistory.TaskType = dr["TaskType"].ToString();
|
||||
taskHistory.TaskState = dr["TaskState"].ToString();
|
||||
//scheduleHistoryManager.ReportState = (int)dr["ReportResult"];
|
||||
taskHistory.ScheduleState = dr["ScheduleState"].ToString();
|
||||
taskHistory.CreateTime = Convert.ToDateTime(dr["ScheduleTime"]);
|
||||
taskHistory.FinishTime = Convert.ToDateTime(dr["FinishTime"]);
|
||||
//try
|
||||
//{
|
||||
// taskHistory.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
|
||||
// taskHistory.FinishTime = Convert.ToDateTime(dr["FinishTime"]);
|
||||
//}
|
||||
//catch (Exception)
|
||||
//{
|
||||
// //MessageBox.Show("查询的时间内容不能为空!(错误代码:3001)");
|
||||
//}
|
||||
|
||||
|
||||
return taskHistory;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user