2023-11-27 14:07:44 +08:00
|
|
|
|
|
|
|
|
|
using MECF.Framework.Common.DataCenter;
|
|
|
|
|
using MECF.Framework.Common.MECF.Framework.Common.Utilities;
|
2023-11-15 09:59:10 +08:00
|
|
|
|
using MECF.Framework.Common.Utilities;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
|
|
|
|
|
{
|
|
|
|
|
public class RecipeHistory
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// GUID编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string StrGuid { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 登录的用户名
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RoleName { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Recipe类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ProcessType { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 快照时Recipe名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RecipeName { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 从XML转成string类型的Recipe内容
|
|
|
|
|
/// </summary>
|
2023-11-27 14:07:44 +08:00
|
|
|
|
public string RecipeFromXML { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Recipe使用GZip压缩
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string RecipeGZip;
|
2023-11-15 09:59:10 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Recipe内容压缩后转成哈希值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string HashCode { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存Receip时记录时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CreateTime { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预留空白1,默认为null
|
|
|
|
|
/// </summary>
|
2023-11-21 15:56:50 +08:00
|
|
|
|
public string Spare1 { get; set; }
|
2023-11-15 09:59:10 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预留空白2,默认为null
|
|
|
|
|
/// </summary>
|
2023-11-21 15:56:50 +08:00
|
|
|
|
public string Spare2 { get; set; }
|
2023-11-15 09:59:10 +08:00
|
|
|
|
|
2023-11-20 10:02:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 数据库操作
|
2023-11-15 09:59:10 +08:00
|
|
|
|
public bool SaveDB()
|
|
|
|
|
{
|
|
|
|
|
//只有存储时,才自动给这些属性赋值
|
|
|
|
|
CreateTime = DateTime.Now.ToString("G");
|
|
|
|
|
StrGuid = Guid.NewGuid().ToString();
|
2023-11-27 14:07:44 +08:00
|
|
|
|
HashCode = Sha256.EncodeString(RecipeFromXML);
|
|
|
|
|
RecipeGZip = StringGZip.CompressString(RecipeFromXML);
|
|
|
|
|
|
2023-11-15 09:59:10 +08:00
|
|
|
|
|
|
|
|
|
return QueryDataClient.Instance.Service.ExcuteTransAction(new List<string> { SaveCmd() });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据Recipe名称,返回此名称产生的所有历史记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="recipeName"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<RecipeHistory> QueryDB(string recipeName)
|
|
|
|
|
{
|
|
|
|
|
string cmd = $"select * from recipe_history_data where recipe_name = '{recipeName}'";
|
|
|
|
|
var dt = QueryDataClient.Instance.Service.QueryData(cmd);
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<RecipeHistory> recipeMemories = new List<RecipeHistory>();
|
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
recipeMemories.Add(new RecipeHistory()
|
|
|
|
|
{
|
2023-11-21 15:56:50 +08:00
|
|
|
|
StrGuid = dt.Rows[i]["str_guid"].ToString(),
|
|
|
|
|
RoleName = dt.Rows[i]["role_name"].ToString(),
|
|
|
|
|
ProcessType = dt.Rows[i]["process_type"].ToString(),
|
|
|
|
|
RecipeName = dt.Rows[i]["recipe_name"].ToString(),
|
|
|
|
|
HashCode = dt.Rows[i]["hash_code"].ToString(),
|
2023-11-27 14:07:44 +08:00
|
|
|
|
//RecipeFromXML = StringGZip.DecompressString( dt.Rows[0]["recipe_gzip"].ToString()), //一般情况下这个内容都很大,返回集合中不对该属性赋值。
|
2023-11-21 15:56:50 +08:00
|
|
|
|
CreateTime = dt.Rows[i]["create_time"].ToString(),
|
|
|
|
|
Spare1 = dt.Rows[i]["spare1"].ToString(),
|
|
|
|
|
Spare2 = dt.Rows[i]["spare2"].ToString()
|
2023-11-15 09:59:10 +08:00
|
|
|
|
});
|
2023-11-21 15:56:50 +08:00
|
|
|
|
if (i >= 25)
|
|
|
|
|
break;
|
2023-11-15 09:59:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return recipeMemories;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据Recipe名称+createTime,返回特定记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="recipeName"></param>
|
|
|
|
|
/// <param name="createTime"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public RecipeHistory QueryDB(string recipeName, string createTime)
|
|
|
|
|
{
|
2023-11-20 10:02:29 +08:00
|
|
|
|
string cmd = $"select * from recipe_history_data where recipe_name = '{recipeName}' and create_time = '{createTime}'";
|
2023-11-15 09:59:10 +08:00
|
|
|
|
var dt = QueryDataClient.Instance.Service.QueryData(cmd);
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return new RecipeHistory()
|
|
|
|
|
{
|
|
|
|
|
StrGuid = dt.Rows[0]["str_guid"].ToString(),
|
|
|
|
|
RoleName = dt.Rows[0]["role_name"].ToString(),
|
|
|
|
|
ProcessType = dt.Rows[0]["process_type"].ToString(),
|
|
|
|
|
RecipeName = dt.Rows[0]["recipe_name"].ToString(),
|
|
|
|
|
HashCode = dt.Rows[0]["hash_code"].ToString(),
|
2023-11-27 14:07:44 +08:00
|
|
|
|
RecipeFromXML = StringGZip.DecompressString( dt.Rows[0]["recipe_gzip"].ToString()),//数据库查询时返回解压后的正确数据
|
2023-11-15 09:59:10 +08:00
|
|
|
|
CreateTime = dt.Rows[0]["create_time"].ToString(),
|
2023-11-21 15:56:50 +08:00
|
|
|
|
Spare1 = dt.Rows[0]["spare1"].ToString(),
|
|
|
|
|
Spare2 = dt.Rows[0]["spare2"].ToString()
|
2023-11-15 09:59:10 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string SaveCmd()
|
|
|
|
|
{
|
|
|
|
|
string cmd_data_insert =
|
|
|
|
|
"insert into recipe_history_data" +
|
2023-11-27 14:07:44 +08:00
|
|
|
|
"(str_guid,role_name,process_type,recipe_name,hash_code,recipe_gzip, create_time,spare1,spare2)" +
|
2023-11-15 09:59:10 +08:00
|
|
|
|
$"values ('{StrGuid}'," +
|
|
|
|
|
$"'{RoleName}'," +
|
|
|
|
|
$"'{ProcessType}'," +
|
|
|
|
|
$"'{RecipeName}'," +
|
|
|
|
|
$"'{HashCode}'," +
|
2023-11-27 14:07:44 +08:00
|
|
|
|
$"'{RecipeGZip}'," +
|
2023-11-15 09:59:10 +08:00
|
|
|
|
$"'{CreateTime}'," +
|
2023-11-21 15:56:50 +08:00
|
|
|
|
$"'{Spare1}'," +
|
|
|
|
|
$"'{Spare2}')";
|
2023-11-15 09:59:10 +08:00
|
|
|
|
|
|
|
|
|
return cmd_data_insert;
|
|
|
|
|
}
|
2023-11-27 14:07:44 +08:00
|
|
|
|
|
|
|
|
|
|
2023-11-20 10:02:29 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
2023-11-15 09:59:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|