|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
|
|
|
|
|
using DSWeb.TruckMng.Helper;
|
|
|
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
|
|
|
using DSWeb.Areas.SysMng.Models.SysTask;
|
|
|
|
|
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.SysMng.DAL.SysTask
|
|
|
|
|
{
|
|
|
|
|
public partial class SysTaskDAL
|
|
|
|
|
{
|
|
|
|
|
#region state
|
|
|
|
|
|
|
|
|
|
static public List<TaskStateMC> GetTaskState(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
TaskStateMC t = new TaskStateMC();
|
|
|
|
|
strSql.Append(t.getSQL());
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetData1(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<TaskStateMC> SetData1(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<TaskStateMC>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
TaskStateMC data = new TaskStateMC();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.ID = Convert.ToDecimal(reader["ID"]);
|
|
|
|
|
data.STATEKEY = Convert.ToString(reader["STATEKEY"]);
|
|
|
|
|
data.NAME = Convert.ToString(reader["NAME"]);
|
|
|
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
|
|
data.PROP1 = Convert.ToString(reader["PROP1"]);
|
|
|
|
|
data.PROP2 = Convert.ToString(reader["PROP2"]);
|
|
|
|
|
data.PROP3 = Convert.ToString(reader["PROP3"]);
|
|
|
|
|
data.PROP4 = Convert.ToString(reader["PROP4"]);
|
|
|
|
|
data.PROP5 = Convert.ToString(reader["PROP5"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Execution
|
|
|
|
|
|
|
|
|
|
static public List<TaskExecutionMC> GetTaskExecution(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
TaskExecutionMC t = new TaskExecutionMC();
|
|
|
|
|
strSql.Append(t.getSQL());
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetData2(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<TaskExecutionMC> SetData2(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<TaskExecutionMC>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
TaskExecutionMC data = new TaskExecutionMC();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
//data.INDEXID = Convert.ToDecimal(reader["INDEXID"]);
|
|
|
|
|
data.ID = Convert.ToDecimal(reader["ID"]);
|
|
|
|
|
data.STATEKEY = Convert.ToString(reader["STATEKEY"]);
|
|
|
|
|
data.NAME = Convert.ToString(reader["NAME"]);
|
|
|
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
|
|
data.PROP1 = Convert.ToString(reader["PROP1"]);
|
|
|
|
|
data.PROP2 = Convert.ToString(reader["PROP2"]);
|
|
|
|
|
data.PROP3 = Convert.ToString(reader["PROP3"]);
|
|
|
|
|
data.PROP4 = Convert.ToString(reader["PROP4"]);
|
|
|
|
|
data.PROP5 = Convert.ToString(reader["PROP5"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ProgressIndex
|
|
|
|
|
|
|
|
|
|
static public List<TaskProgressIndexMC> GetTaskProgressIndex(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
TaskProgressIndexMC t = new TaskProgressIndexMC();
|
|
|
|
|
strSql.Append(t.getSQL());
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetData3(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<TaskProgressIndexMC> SetData3(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<TaskProgressIndexMC>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
TaskProgressIndexMC data = new TaskProgressIndexMC();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.ID = Convert.ToDecimal(reader["ID"]);
|
|
|
|
|
data.EXECUTIONID = Convert.ToString(reader["EXECUTIONID"]);
|
|
|
|
|
data.EXECUTIONNAME = Convert.ToString(reader["EXECUTIONNAME"]);
|
|
|
|
|
//data.EXECUTIONREF = Convert.ToString(reader["EXECUTIONREF"]);
|
|
|
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
|
|
data.CURRENTSTATEID = Convert.ToString(reader["CURRENTSTATEID"]);
|
|
|
|
|
data.CURRENTSTATENAME = Convert.ToString(reader["CURRENTSTATENAME"]);
|
|
|
|
|
//data.CURRENTSTATEREF = Convert.ToString(reader["CURRENTSTATEREF"]);
|
|
|
|
|
data.FINISHSTATEID = Convert.ToString(reader["FINISHSTATEID"]);
|
|
|
|
|
data.FINISHSTATENAME = Convert.ToString(reader["FINISHSTATENAME"]);
|
|
|
|
|
//data.FINISHSTATEREF = Convert.ToString(reader["FINISHSTATEREF"]);
|
|
|
|
|
data.PROP1 = Convert.ToString(reader["PROP1"]);
|
|
|
|
|
data.PROP2 = Convert.ToString(reader["PROP2"]);
|
|
|
|
|
data.PROP3 = Convert.ToString(reader["PROP3"]);
|
|
|
|
|
data.PROP4 = Convert.ToString(reader["PROP4"]);
|
|
|
|
|
data.PROP5 = Convert.ToString(reader["PROP5"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 返回每个动作一行的结果,用于表示多个起点的同名动作
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strCondition"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
static public List<TaskProgressIndexMC> GetTaskProgressIndex_single(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
TaskProgressIndexMC t = new TaskProgressIndexMC();
|
|
|
|
|
strSql.Append(t.getSQL());
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetData3_1(strSql);
|
|
|
|
|
}
|
|
|
|
|
private static List<TaskProgressIndexMC> SetData3_1(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<TaskProgressIndexMC>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
TaskProgressIndexMC data = new TaskProgressIndexMC();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.ID = Convert.ToDecimal(reader["ID"]);
|
|
|
|
|
data.EXECUTIONID = Convert.ToString(reader["EXECUTIONID"]);
|
|
|
|
|
data.EXECUTIONNAME = Convert.ToString(reader["EXECUTIONNAME"]);
|
|
|
|
|
//data.EXECUTIONREF = Convert.ToString(reader["EXECUTIONREF"]);
|
|
|
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
|
|
|
data.CURRENTSTATEID = Convert.ToString(reader["CURRENTSTATEID"]);
|
|
|
|
|
data.CURRENTSTATENAME = Convert.ToString(reader["CURRENTSTATENAME"]);
|
|
|
|
|
//data.CURRENTSTATEREF = Convert.ToString(reader["CURRENTSTATEREF"]);
|
|
|
|
|
data.FINISHSTATEID = Convert.ToString(reader["FINISHSTATEID"]);
|
|
|
|
|
data.FINISHSTATENAME = Convert.ToString(reader["FINISHSTATENAME"]);
|
|
|
|
|
//data.FINISHSTATEREF = Convert.ToString(reader["FINISHSTATEREF"]);
|
|
|
|
|
data.PROP1 = Convert.ToString(reader["PROP1"]);
|
|
|
|
|
data.PROP2 = Convert.ToString(reader["PROP2"]);
|
|
|
|
|
data.PROP3 = Convert.ToString(reader["PROP3"]);
|
|
|
|
|
data.PROP4 = Convert.ToString(reader["PROP4"]);
|
|
|
|
|
data.PROP5 = Convert.ToString(reader["PROP5"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
var needinsert = true;
|
|
|
|
|
foreach (var head in headList) {
|
|
|
|
|
if (head.EXECUTIONID == data.EXECUTIONID) {
|
|
|
|
|
needinsert = false;
|
|
|
|
|
head.SetValue("STATEREF", head.GetValue("STATEREF")+";"+ data.CURRENTSTATEREF+ "→" + data.FINISHSTATEREF);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (needinsert) {
|
|
|
|
|
data.SetValue("STATEREF", data.CURRENTSTATEREF + "→" + data.FINISHSTATEREF);
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 参数为当前状态key值。返回值为可以进行的操作步骤列表。
|
|
|
|
|
static public List<TaskExecutionMC> GetExecution(string KEY)
|
|
|
|
|
{
|
|
|
|
|
var rlist = new List<TaskExecutionMC>();
|
|
|
|
|
string condition = " 1=2 ";
|
|
|
|
|
if (!string.IsNullOrEmpty(KEY))
|
|
|
|
|
{
|
|
|
|
|
condition = " STATEKEY IN(select executionid from Sys_Task_Progress_Index where currentstateid = ('" + KEY + "')) ";
|
|
|
|
|
}
|
|
|
|
|
rlist = GetTaskExecution(condition);
|
|
|
|
|
|
|
|
|
|
return rlist;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 参数操作步骤ID和当前状态值,返回值为新的状态值。
|
|
|
|
|
static public TaskStateMC DoExecution(string STATEKEY, string EXECUTIONKEY)
|
|
|
|
|
{
|
|
|
|
|
string condition = " STATEKEY in(select FINISHSTATEID from Sys_Task_Progress_Index where CURRENTSTATEID='" + STATEKEY + "' and EXECUTIONID='" + EXECUTIONKEY + "')";
|
|
|
|
|
|
|
|
|
|
var r = GetTaskState(condition);
|
|
|
|
|
|
|
|
|
|
if (r.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return r[0];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//错误
|
|
|
|
|
var result = new TaskStateMC();
|
|
|
|
|
result.STATEKEY = "0000";
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取‘当前状态是否包含指定值’
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取‘当前状态能否删除’ 看sys_task_state当中的五属性是否包含‘candelete’
|
|
|
|
|
/// TASKHEAD:3000 押箱业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="KEY"></param>KEY值
|
|
|
|
|
/// <param name="word"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
static public bool TaskGetWord(string KEY,string word) {
|
|
|
|
|
var pop1 = BasicDataRefDAL.GetCommaWordExist("Sys_Task_State", "PROP1", word, "STATEKEY = '" + KEY + "'");
|
|
|
|
|
var pop2 = BasicDataRefDAL.GetCommaWordExist("Sys_Task_State", "PROP2", word, "STATEKEY = '" + KEY + "'");
|
|
|
|
|
var pop3 = BasicDataRefDAL.GetCommaWordExist("Sys_Task_State", "PROP3", word, "STATEKEY = '" + KEY + "'");
|
|
|
|
|
var pop4 = BasicDataRefDAL.GetCommaWordExist("Sys_Task_State", "PROP4", word, "STATEKEY = '" + KEY + "'");
|
|
|
|
|
var pop5 = BasicDataRefDAL.GetCommaWordExist("Sys_Task_State", "PROP5", word, "STATEKEY = '" + KEY + "'");
|
|
|
|
|
|
|
|
|
|
return (pop1 || pop2 || pop3 || pop4 || pop5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|