You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
617 lines
24 KiB
617 lines
24 KiB
using SkiaSharp;
|
|
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.NetworkInformation;
|
|
using System.Net.Sockets;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
using TouchSocket.Core;
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
|
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
|
{
|
|
/// <summary>
|
|
/// MachinesSet.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MachinesView : UserControl, INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
{
|
|
if (PropertyChanged != null)
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
public void RaisePropertyChanged(string propertyName)
|
|
{
|
|
if (PropertyChanged != null)
|
|
{
|
|
if (propertyName != null)
|
|
{
|
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
}
|
|
public MachinesView()
|
|
{
|
|
DataContext = this;
|
|
InitializeComponent();
|
|
CountDown();
|
|
}
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
string machine;
|
|
int LOG_ = 0;
|
|
public static DataTable LOG_dataTable = new DataTable();
|
|
private void Griddata_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
machine = (Griddata.Columns[1].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第1列,
|
|
MAC_name.Text= machine;
|
|
|
|
MainWindowViewModel.dt_d.Clear();
|
|
MainWindowViewModel.dt_a.Clear();
|
|
MainWindowViewModel.dt_m.Clear();
|
|
MainWindowViewModel.dt_ParameterSet.Clear();
|
|
MainWindowViewModel.dt_SysSet.Clear();
|
|
}
|
|
}
|
|
|
|
private void ListViewItem_ArrowLeftRight(object sender, MouseButtonEventArgs e)
|
|
{
|
|
LOG_GRID.Visibility = Visibility.Collapsed;
|
|
IO_GRID.Visibility = Visibility.Visible;
|
|
SYS_GRID.Visibility = Visibility.Collapsed;
|
|
SET_GRID.Visibility = Visibility.Collapsed;
|
|
view = 0;
|
|
}
|
|
private void ListViewItem_VideoHomeSystem(object sender, MouseButtonEventArgs e)
|
|
{
|
|
LOG_GRID.Visibility = Visibility.Collapsed;
|
|
IO_GRID.Visibility = Visibility.Collapsed;
|
|
SYS_GRID.Visibility = Visibility.Visible;
|
|
SET_GRID.Visibility = Visibility.Collapsed;
|
|
view = 2;
|
|
}
|
|
private void ListViewItem_LOG(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (LOG_ >= 3) { LOG_ = 0; }
|
|
else
|
|
{ LOG_++; }
|
|
|
|
LOG_GRID.Visibility = Visibility.Visible;
|
|
IO_GRID.Visibility = Visibility.Collapsed;
|
|
SYS_GRID.Visibility = Visibility.Collapsed;
|
|
SET_GRID.Visibility = Visibility.Collapsed;
|
|
view = 3;
|
|
LOG_dataTable.Clear();
|
|
Dictionary<string, object> dat_859 =new Dictionary<string, object>();
|
|
|
|
if (LOG_ == 0)
|
|
{
|
|
MAC_name.Text = machine+ "(SERVER)";
|
|
dat_859.Add("INSTRUCTION", "SERVER");
|
|
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
|
|
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
}
|
|
else if (LOG_ == 1)
|
|
{
|
|
MAC_name.Text = machine + "(OperationLog)";
|
|
dat_859.Add("INSTRUCTION", "OperationLog");
|
|
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
|
|
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
}
|
|
else if (LOG_ == 2)
|
|
{
|
|
MAC_name.Text = machine + "(IOLog)";
|
|
dat_859.Add("INSTRUCTION", "IOLog");
|
|
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
|
|
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
}
|
|
else
|
|
{
|
|
MAC_name.Text = machine + "(ERRLog)";
|
|
dat_859.Add("INSTRUCTION", "ERRLog");
|
|
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
|
|
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(machine))
|
|
{
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
|
int State_ = Convert.ToInt16(drEmployee.Field<object>("State"));
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
|
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息
|
|
{
|
|
if (drEmployee.Field<bool>("Type"))//
|
|
{//网络
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC859" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
|
+ dat_859.ToJsonString()
|
|
});
|
|
}
|
|
else
|
|
{//串口
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private void ListViewItem_Dharmachakra(object sender, MouseButtonEventArgs e)
|
|
{
|
|
LOG_GRID.Visibility = Visibility.Collapsed;
|
|
IO_GRID.Visibility = Visibility.Collapsed;
|
|
SYS_GRID.Visibility = Visibility.Collapsed;
|
|
SET_GRID.Visibility = Visibility.Visible;
|
|
view = 1;
|
|
}
|
|
private void Grid_D_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Grid_A_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Grid_M_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Grid_D_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
{
|
|
string ID;
|
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
|
|
|
int rownum = Grid_D.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
ID = (Grid_D.Columns[0].GetCellContent(Grid_D.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
|
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
|
datagrid_v.Add("PLC", newValue);
|
|
MainWindowViewModel.SQLiteHelpers.Update("IOName", datagrid_v, "ID ='" + ID + "'", null);//更新
|
|
}
|
|
IO_data();//重新获得io表
|
|
D_view = true;
|
|
}
|
|
|
|
private void Grid_D_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
|
{
|
|
D_view = false;
|
|
}
|
|
|
|
private void Grid_A_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
{
|
|
string ID;
|
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
|
|
|
int rownum = Grid_A.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
ID = (Grid_A.Columns[0].GetCellContent(Grid_A.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
|
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
|
datagrid_v.Add("PLC", newValue);
|
|
MainWindowViewModel.SQLiteHelpers.Update("IOName", datagrid_v, "ID ='" + ID + "'", null);//更新
|
|
}
|
|
A_view = true;
|
|
}
|
|
|
|
private void Grid_A_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
|
{
|
|
A_view = false;
|
|
}
|
|
|
|
private void SYS_Grid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
{
|
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
|
int rownum = SYS_Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
string ID = (SYS_Grid.Columns[1].GetCellContent(SYS_Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
|
|
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
|
datagrid_v.Add("Value", newValue);
|
|
datagrid_v.Add("ID", ID);
|
|
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
|
if (drEmployee.Field<bool>("Type"))//
|
|
{//网络
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC862" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + datagrid_v.ToJsonString()
|
|
});//发送862指令修改系统设置
|
|
}
|
|
else
|
|
{//串口
|
|
|
|
}
|
|
}
|
|
SysSet_view = true;
|
|
}
|
|
|
|
private void SET_Grid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
{
|
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
|
int rownum = SET_Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
string ID = (SET_Grid.Columns[1].GetCellContent(SET_Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
|
|
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
|
datagrid_v.Add("Value", newValue);
|
|
datagrid_v.Add("ID", ID);
|
|
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
|
if (drEmployee.Field<bool>("Type"))//
|
|
{//网络
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC861" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + datagrid_v.ToJsonString()
|
|
});//发送861指令修改程序设置
|
|
}
|
|
else
|
|
{//串口
|
|
|
|
}
|
|
}
|
|
ParameterSet_view = true;
|
|
}
|
|
|
|
private void SYS_Grid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
|
{
|
|
SysSet_view = false;
|
|
}
|
|
|
|
private void SET_Grid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
|
{
|
|
ParameterSet_view = false;
|
|
}
|
|
|
|
private int view = 0;
|
|
private void IO_data()
|
|
{
|
|
if (!string.IsNullOrEmpty(machine))
|
|
{
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
|
|
|
if (drEmployee.Field<bool>("Type"))//
|
|
{//网络
|
|
int State_ = Convert.ToInt16(drEmployee.Field<object>("State"));
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
|
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息
|
|
{
|
|
if (view == 0)
|
|
{
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC851" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
|
});
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC852" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
|
});
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC853" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
|
});
|
|
}
|
|
else if (view == 1)
|
|
{
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC854" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
|
});
|
|
}
|
|
else if (view == 2)
|
|
{
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = "SC855" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{//串口
|
|
int State_ = Convert.ToInt16(drEmployee.Field<object>("State"));
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
|
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息
|
|
{
|
|
if (view == 0)
|
|
{
|
|
|
|
}
|
|
else if (view == 1)
|
|
{
|
|
|
|
}
|
|
else if (view == 2)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void CountDown()
|
|
{
|
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
|
{
|
|
Interval = TimeSpan.FromSeconds(1.5)//秒
|
|
};
|
|
timer1s.Tick += Tick_Event_1S;
|
|
timer1s.Start();
|
|
}//时间周期初始化
|
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
|
{
|
|
IO_data();
|
|
DATA_view();
|
|
if (LOG_dataTable.Rows.Count > 0) {
|
|
LOG_Grid.ItemsSource = LOG_dataTable.DefaultView;
|
|
// LOG_dataTable.Clear();
|
|
}
|
|
}
|
|
private async void DATA_view()//IO显示
|
|
{
|
|
await Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
if (dt_m.Rows.Count >= 0)
|
|
{
|
|
SYSData_M = ToObservableCollection<DATA_M>(dt_m);
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
try
|
|
{
|
|
if (dt_a.Rows.Count >= 0)
|
|
{
|
|
if ((bool)A_view) SYSData_A = ToObservableCollection<DATA_A>(dt_a);
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
try
|
|
{
|
|
if (dt_d.Rows.Count >= 0)
|
|
{
|
|
if ((bool)D_view) SYSData_D = ToObservableCollection<DATA_D>(dt_d);
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
try
|
|
{
|
|
TechnologicalMachine_View = ToObservableCollection<TechnologicalM>(Machines);
|
|
}
|
|
catch (Exception) { }
|
|
try
|
|
{
|
|
if (dt_ParameterSet.Rows.Count >= 0)
|
|
{
|
|
if (ParameterSet_view) Paramete_Set = ToObservableCollection<ParameterSet>(dt_ParameterSet);
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
try
|
|
{
|
|
if (dt_SysSet.Rows.Count >= 0)
|
|
{
|
|
if (SysSet_view) Sys_Set = ToObservableCollection<SysSet>(dt_SysSet);
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
});
|
|
}
|
|
|
|
bool A_view =true;
|
|
bool D_view =true;
|
|
bool ParameterSet_view = true;
|
|
bool SysSet_view = true;
|
|
ObservableCollection<DATA_A> sysData_A = new ObservableCollection<DATA_A>();
|
|
ObservableCollection<DATA_D> sysData_D = new ObservableCollection<DATA_D>();
|
|
ObservableCollection<DATA_M> sysData_M = new ObservableCollection<DATA_M>();
|
|
ObservableCollection<ParameterSet> paramete_Set = new ObservableCollection<ParameterSet>();
|
|
ObservableCollection<SysSet> sys_Set = new ObservableCollection<SysSet>();
|
|
ObservableCollection<TechnologicalM> technologicalMachine_View = new ObservableCollection<TechnologicalM>();
|
|
public ObservableCollection<DATA_A> SYSData_A
|
|
{
|
|
|
|
get { return sysData_A; }
|
|
set
|
|
{
|
|
sysData_A = value;
|
|
RaisePropertyChanged("SYSData_A");
|
|
}
|
|
}
|
|
public ObservableCollection<DATA_D> SYSData_D
|
|
{
|
|
|
|
get { return sysData_D; }
|
|
set
|
|
{
|
|
sysData_D = value;
|
|
RaisePropertyChanged("SYSData_D");
|
|
}
|
|
}
|
|
public ObservableCollection<DATA_M> SYSData_M
|
|
{
|
|
get { return sysData_M; }
|
|
set
|
|
{
|
|
sysData_M = value;
|
|
RaisePropertyChanged("SYSData_M");
|
|
}
|
|
}
|
|
public ObservableCollection<TechnologicalM> TechnologicalMachine_View
|
|
{
|
|
get { return technologicalMachine_View; }
|
|
set
|
|
{
|
|
technologicalMachine_View = value;
|
|
RaisePropertyChanged("TechnologicalMachine_View");
|
|
}
|
|
}
|
|
public ObservableCollection<ParameterSet> Paramete_Set
|
|
{
|
|
get { return paramete_Set; }
|
|
set
|
|
{
|
|
paramete_Set = value;
|
|
RaisePropertyChanged("Paramete_Set");
|
|
}
|
|
}
|
|
public ObservableCollection<SysSet> Sys_Set
|
|
{
|
|
get { return sys_Set; }
|
|
set
|
|
{
|
|
sys_Set = value;
|
|
RaisePropertyChanged("Sys_Set");
|
|
}
|
|
}
|
|
public class DATA_A
|
|
{
|
|
public string IOName { get; set; }
|
|
public int AIO { get; set; }
|
|
public string ID { get; set; }
|
|
public string PLC { get; set; }
|
|
public string type { get; set; }
|
|
}
|
|
public class DATA_D
|
|
{
|
|
public string IOName { get; set; }
|
|
public bool DIO { get; set; }
|
|
public string ID { get; set; }
|
|
public string PLC { get; set; }
|
|
public string type { get; set; }
|
|
}
|
|
public class DATA_M
|
|
{
|
|
public string IOName { get; set; }
|
|
public double Value { get; set; }
|
|
public string ID { get; set; }
|
|
public string PLC { get; set; }
|
|
public string type { get; set; }
|
|
}
|
|
public class TechnologicalM
|
|
{
|
|
public string Name { get; set; }
|
|
public string WorkOrder { get; set; }
|
|
public string Dyelot { get; set; }
|
|
public string Temperature { get; set; }
|
|
public string WaterLevel { get; set; }
|
|
public string Process { get; set; }
|
|
public string Step { get; set; }
|
|
public string Message { get; set; }
|
|
public string State { get; set; }
|
|
public string LOCK { get; set; }
|
|
|
|
}
|
|
public class ParameterSet
|
|
{
|
|
public string Category { get; set; }
|
|
public string ParameterID { get; set; }
|
|
public string ParameterName { get; set; }
|
|
public string Value { get; set; }
|
|
|
|
}
|
|
public class SysSet
|
|
{
|
|
public string Category { get; set; }
|
|
public string ParameterID { get; set; }
|
|
public string ParameterName { get; set; }
|
|
public string Value { get; set; }
|
|
}
|
|
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
|
|
{
|
|
try
|
|
{
|
|
Type t = typeof(T);
|
|
PropertyInfo[] propertys = t.GetProperties();
|
|
ObservableCollection<T> lst = new ObservableCollection<T>();
|
|
string typeName = string.Empty;
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
T entity = new T();
|
|
foreach (PropertyInfo pi in propertys)
|
|
{
|
|
typeName = pi.Name;
|
|
if (dt.Columns.Contains(typeName))
|
|
{
|
|
if (!pi.CanWrite) continue;
|
|
object value = dr[typeName];
|
|
if (value == DBNull.Value) continue;
|
|
if (pi.PropertyType == typeof(string))
|
|
{
|
|
pi.SetValue(entity, value.ToString(), null);
|
|
}
|
|
else if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(int?))
|
|
{
|
|
pi.SetValue(entity, int.Parse(value.ToString()), null);
|
|
}
|
|
else if (pi.PropertyType == typeof(DateTime?) || pi.PropertyType == typeof(DateTime))
|
|
{
|
|
pi.SetValue(entity, DateTime.Parse(value.ToString()), null);
|
|
}
|
|
else if (pi.PropertyType == typeof(float))
|
|
{
|
|
pi.SetValue(entity, float.Parse(value.ToString()), null);
|
|
}
|
|
else if (pi.PropertyType == typeof(double))
|
|
{
|
|
pi.SetValue(entity, double.Parse(value.ToString()), null);
|
|
}
|
|
else
|
|
{
|
|
pi.SetValue(entity, value, null);
|
|
}
|
|
}
|
|
}
|
|
lst.Add(entity);
|
|
}
|
|
return lst;
|
|
}
|
|
catch (Exception) { return null; }
|
|
}
|
|
}
|
|
}
|
|
|