using DataEntity.Device;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.ComponentModel;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using XImagingXhandler.XDAL;
|
using Newtonsoft.Json;
|
using System.IO;
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
namespace XImagingXhandler.XDAL
|
{
|
/// <summary>
|
/// 绑定到实验方法流程节点的实体基类
|
/// </summary>
|
public class MethodEx : Method, ICloneable
|
{
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public MethodEx()
|
{
|
Children = new ObservableCollection<MethodEx>();
|
Parent = null;
|
Level = 0;
|
}
|
|
/// <summary>
|
/// 带参构造函数,初始化参数属性值
|
/// </summary>
|
/// <param name="method">命令方法实体对象</param>
|
public MethodEx(Method method)
|
{
|
this.method_id = method.method_id;
|
this.method_name = method.method_name;
|
this.method_status = method.method_status;
|
this.method_content = method.method_content;
|
this.method_Tipcontent = method.method_Tipcontent;
|
this.method_ico = method.method_ico;
|
this.method_group_id = method.method_group_id;
|
this.method_support = method.method_support;
|
this.method_type = method.method_type;
|
Children = new ObservableCollection<MethodEx>();
|
Parent = null;
|
Level = 0;
|
Moveable = true;
|
canDrop = true;
|
control = null;
|
tag = null;
|
isEnabled = true;
|
}
|
|
/// <summary>
|
/// 带参构造函数,初始化参数属性值
|
/// </summary>
|
/// <param name="method">命令方法实体对象</param>
|
/// <param name="parentItem">父节点命令对象</param>
|
public MethodEx(Method method, MethodEx parentItem)
|
{
|
this.method_id = method.method_id;
|
this.method_name = method.method_name;
|
this.method_status = method.method_status;
|
this.method_content = method.method_content;
|
this.method_Tipcontent = method.method_Tipcontent;
|
this.method_ico = method.method_ico;
|
this.method_group_id = method.method_group_id;
|
this.method_support = method.method_support;
|
this.method_type = method.method_type;
|
Children = new ObservableCollection<MethodEx>();
|
Parent = parentItem;
|
Level = parentItem.Level + 1;
|
Moveable = true;
|
canDrop = true;
|
control = null;
|
tag = null;
|
isEnabled = true;
|
}
|
/// <summary>
|
/// 带参构造函数,初始化参数属性值
|
/// </summary>
|
/// <param name="method">命令方法实体对象</param>
|
/// <param name="parentItem">父节点命令对象</param>
|
/// <param name="isDeepCopy">是否深拷贝,true:false</param>
|
public MethodEx(MethodEx method, MethodEx parentItem,bool isDeepCopy)
|
{
|
this.method_id = method.method_id;
|
this.method_name = method.method_name;
|
this.method_status = method.method_status;
|
this.method_content = method.method_content;
|
this.method_Tipcontent = method.method_Tipcontent;
|
this.method_ico = method.method_ico;
|
this.method_group_id = method.method_group_id;
|
this.method_support = method.method_support;
|
this.method_type = method.method_type;
|
Children = new ObservableCollection<MethodEx>();
|
Parent = parentItem;
|
Level = parentItem.Level + 1;
|
Moveable = true;
|
canDrop = true;
|
control = method.control;
|
tag = method.tag;
|
isEnabled = true;
|
}
|
|
/// <summary>
|
/// 运行起点
|
/// </summary>
|
private string _method_isrun = "";
|
public string method_isrun
|
{
|
get { return _method_isrun; }
|
set
|
{
|
_method_isrun = value;
|
OnPropertyChanged(nameof(method_isrun));
|
}
|
}
|
|
/// <summary>
|
/// 索引值
|
/// </summary>
|
private int _index;
|
public int Index
|
{
|
get { return _index; }
|
set
|
{
|
_index = value;
|
OnPropertyChanged("Index");
|
}
|
}
|
|
private string _strIndex;
|
/// <summary>
|
/// 实验流程中节点位置编号
|
/// </summary>
|
public string strIndex
|
{
|
get { return _strIndex; }
|
set
|
{
|
_strIndex = value;
|
OnPropertyChanged("strIndex");
|
}
|
}
|
|
/// <summary>
|
/// 方法的层级
|
/// </summary>
|
private int _level;
|
public int Level
|
{
|
get { return _level; }
|
set
|
{
|
_level = value;
|
OnPropertyChanged("Level");
|
}
|
}
|
|
/// <summary>
|
/// 该方法是否可以移动
|
/// </summary>
|
public bool Moveable { get; set; }
|
|
/// <summary>
|
/// 父节点对象
|
/// </summary>
|
public MethodEx Parent
|
{
|
get;
|
set;
|
}
|
|
/// <summary>
|
/// 该方法是否能drop
|
/// </summary>
|
public bool canDrop { get; set; }
|
|
/// <summary>
|
/// 孩子节点对象集合
|
/// </summary>
|
public ObservableCollection<MethodEx> Children
|
{
|
get;
|
set;
|
}
|
|
/// <summary>
|
/// 加载Shared.AllNodeMethod所有子方法时,子方法存储位置。不能存在Children里,不然页面加载会有异常!!!
|
/// </summary>
|
public MethodEx SubMethod
|
{
|
get;
|
set;
|
}
|
|
/// <summary>
|
/// 设置节点的父节点
|
/// </summary>
|
/// <param name="parent"></param>
|
public void SetParent(MethodEx parent)
|
{
|
this.Parent = parent;
|
this.Level = parent.Level + 1;
|
}
|
|
private bool _isSelected = false;
|
/// <summary>
|
/// 节点是否被选中
|
/// </summary>
|
public bool isSelected
|
{
|
get { return _isSelected; }
|
set
|
{
|
_isSelected = value;
|
OnPropertyChanged("isSelected");
|
}
|
}
|
|
private bool _isEnabled;
|
/// <summary>
|
/// 是否被禁用
|
/// </summary>
|
public bool isEnabled
|
{
|
get { return _isEnabled; }
|
set
|
{
|
_isEnabled = value;
|
OnPropertyChanged("isEnabled");
|
}
|
}
|
|
private string _groupID;
|
/// <summary>
|
/// 用以标注这个方法的开始和结束2个节点是同一组节点
|
/// </summary>
|
public string groupID
|
{
|
get { return _groupID; }
|
set
|
{
|
_groupID = value;
|
OnPropertyChanged("groupID");
|
}
|
}
|
|
private int _isError;
|
/// <summary>
|
/// 产生错误节点
|
/// </summary>
|
public int IsError
|
{
|
get { return _isError; }
|
set
|
{
|
_isError = value;
|
OnPropertyChanged("IsError");
|
}
|
}
|
|
/// <summary>
|
/// UI对象
|
/// </summary>
|
public object control { get; set; }
|
|
/// <summary>
|
/// 保存属性实体
|
/// </summary>
|
public object tag { get; set; }
|
|
/// <summary>
|
/// 设备信息
|
/// </summary>
|
public DeviceConfigModel device { get; set; }
|
|
public object Clone()
|
{
|
return (object)this.MemberwiseClone();
|
}
|
|
public object CloneDeep()
|
{
|
// 将对象转换为JSON字符串
|
string json = JsonConvert.SerializeObject(this);
|
|
// 将JSON字符串转换回对象
|
return JsonConvert.DeserializeObject(json, this.GetType());
|
}
|
|
public static T DeepCopy<T>(T obj)
|
{
|
object retval;
|
using (MemoryStream ms = new MemoryStream())
|
{
|
BinaryFormatter bf = new BinaryFormatter();
|
//序列化成流
|
bf.Serialize(ms, obj);
|
ms.Seek(0, SeekOrigin.Begin);
|
//反序列化成对象
|
retval = bf.Deserialize(ms);
|
ms.Close();
|
}
|
return (T)retval;
|
}
|
}
|
}
|