|
|
|
|
|
|
|
|
|
using ConvertHelper;
|
|
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace VOL.Entity.DomainModels
|
|
|
|
|
{
|
|
|
|
|
public class SaveModel
|
|
|
|
|
{
|
|
|
|
|
public Dictionary<string, object> MainData { get; set; }
|
|
|
|
|
public List<Dictionary<string, object>> DetailData { get; set; }
|
|
|
|
|
public List<object> DelKeys { get; set; }
|
|
|
|
|
public List<object> WorkKeys { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 从前台传入的其他参数(自定义扩展可以使用)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public object Extra { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fieldname"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string getMainDataValueStr(string fieldname) {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (MainData.ContainsKey(fieldname))
|
|
|
|
|
{
|
|
|
|
|
return MainData[fieldname].ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
public string getValue(string fieldname)
|
|
|
|
|
{
|
|
|
|
|
return getMainDataValueStr(fieldname);
|
|
|
|
|
}
|
|
|
|
|
public string GetjoinWorkKeys()
|
|
|
|
|
{
|
|
|
|
|
if (WorkKeys == null || WorkKeys.Count == 0) return "";
|
|
|
|
|
return $"'{string.Join("','", WorkKeys)}'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得带单引号,用逗号连接的一个字符串,可以用于sql的in子句
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetjoinDelKeys()
|
|
|
|
|
{
|
|
|
|
|
if (DelKeys == null || DelKeys.Count == 0) return "";
|
|
|
|
|
return $"'{string.Join("','", DelKeys)}'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Guid> GetWorkKeysList()
|
|
|
|
|
{
|
|
|
|
|
var result = new List<Guid>();
|
|
|
|
|
|
|
|
|
|
foreach (var item in WorkKeys) {
|
|
|
|
|
result.Add(new Guid(item.ToString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> GetWorkKeysList_Str()
|
|
|
|
|
{
|
|
|
|
|
var result = new List<String>();
|
|
|
|
|
|
|
|
|
|
foreach (var item in WorkKeys)
|
|
|
|
|
{
|
|
|
|
|
if(!string.IsNullOrWhiteSpace( item.ToString()))
|
|
|
|
|
result.Add( item.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MakeSureHaveField(string fieldname) {
|
|
|
|
|
if (MainData == null)
|
|
|
|
|
MainData = new Dictionary<string, object>();
|
|
|
|
|
|
|
|
|
|
if (!MainData.ContainsKey(fieldname))
|
|
|
|
|
{
|
|
|
|
|
MainData.Add(fieldname, "");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (MainData[fieldname] == null) {
|
|
|
|
|
MainData[fieldname] = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fieldname"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
public void AddField(string fieldname, string value = "") {
|
|
|
|
|
if(MainData==null)
|
|
|
|
|
MainData = new Dictionary<string, object>();
|
|
|
|
|
|
|
|
|
|
if (!MainData.ContainsKey(fieldname))
|
|
|
|
|
{
|
|
|
|
|
MainData.Add(fieldname, value);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
MainData[fieldname] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetValue(string fieldname, string value = "") {
|
|
|
|
|
AddField(fieldname, value);
|
|
|
|
|
}
|
|
|
|
|
public bool HaveField(string fieldname)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (MainData.ContainsKey(fieldname))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var _s = MainData[fieldname].ToString();
|
|
|
|
|
|
|
|
|
|
var result = !string.IsNullOrWhiteSpace(_s);
|
|
|
|
|
return result;
|
|
|
|
|
}return false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void FieldAddValue(string fieldname, string value = "")
|
|
|
|
|
{
|
|
|
|
|
if (MainData == null)
|
|
|
|
|
MainData = new Dictionary<string, object>();
|
|
|
|
|
|
|
|
|
|
if (!MainData.ContainsKey(fieldname))
|
|
|
|
|
{
|
|
|
|
|
MainData.Add(fieldname, value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(MainData[fieldname].ToString()))
|
|
|
|
|
MainData[fieldname] = value;
|
|
|
|
|
else {
|
|
|
|
|
MainData[fieldname] += "," + value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void removefield(string fieldname) {
|
|
|
|
|
BasicDALRef.DicRemovekeys(MainData, fieldname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在SaveAndPushstatus时,
|
|
|
|
|
/// execution值位于workkeys中第一条 必须有
|
|
|
|
|
/// reason值位于workkeys第二条 可以没有
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetExection()
|
|
|
|
|
{
|
|
|
|
|
if (WorkKeys.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return WorkKeys[0].ToString();
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
public string GetReason()
|
|
|
|
|
{
|
|
|
|
|
if (WorkKeys.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
return WorkKeys[1].ToString();
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|