总览信息发布
This commit is contained in:
commit
0c6bc3105f
5 files changed
+163
-49
No files matched your search
+30
-12
@@ -105,8 +105,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("INSTRUCTION", "CONTINUE");
|
dat_821.Add("INSTRUCTION", "CONTINUE");
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString { ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString() });
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Insert.IsEnabled = false;
|
Insert.IsEnabled = false;
|
||||||
@@ -126,8 +129,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("INSTRUCTION", "PAUSE");
|
dat_821.Add("INSTRUCTION", "PAUSE");
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString { ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString() });
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Insert.IsEnabled = true;
|
Insert.IsEnabled = true;
|
||||||
edit.IsEnabled = true;
|
edit.IsEnabled = true;
|
||||||
@@ -145,8 +151,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("INSTRUCTION", "STOP");
|
dat_821.Add("INSTRUCTION", "STOP");
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString { ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString() });
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}//停止
|
}//停止
|
||||||
private void ListViewItem_edit(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_edit(object sender, MouseButtonEventArgs e)
|
||||||
@@ -178,8 +187,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString { ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString() });
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
|
||||||
MainWindowViewModel.TechnologicalProcess_bool = true;
|
MainWindowViewModel.TechnologicalProcess_bool = true;
|
||||||
}
|
}
|
||||||
@@ -232,8 +244,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString { ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString() });
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -245,8 +260,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("ID", ID);
|
dat_821.Add("ID", ID);
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString { ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString() });
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
|
||||||
MainWindowViewModel.TechnologicalProcess_bool = true;
|
MainWindowViewModel.TechnologicalProcess_bool = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
|
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
|
||||||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d" Loaded="UserControl_Loaded"
|
||||||
d:DesignHeight="900" d:DesignWidth="550">
|
d:DesignHeight="900" d:DesignWidth="550">
|
||||||
<Grid Background="White" Cursor="">
|
<Grid Background="White" Cursor="">
|
||||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,30,0,0" x:Name="comboBoxMachine" VerticalAlignment="Top" Width="270"
|
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,30,0,0" x:Name="comboBoxMachine" VerticalAlignment="Top" Width="270"
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
|
|
||||||
<Button Content="{x:Static lang:Resources.Save}" HorizontalAlignment="Left" Height="35" Margin="450,0,0,10" VerticalAlignment="Bottom" Width="80" Click="Button_Click"/>
|
<Button x:Name="Save" Content="{x:Static lang:Resources.Save}" HorizontalAlignment="Left" Height="35" Margin="450,0,0,10" VerticalAlignment="Bottom" Width="80" Click="Button_Click"/>
|
||||||
<Button HorizontalAlignment="Left" Height="35" Margin="0,0,50,10" VerticalAlignment="Bottom" Width="60" Click="Button_Quit" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}">
|
<Button HorizontalAlignment="Left" Height="35" Margin="0,0,50,10" VerticalAlignment="Bottom" Width="60" Click="Button_Quit" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}">
|
||||||
<materialDesign:PackIcon Kind="ArrowRight" Foreground="#FF00204E" HorizontalAlignment="Center" VerticalAlignment="Center" Width="50" Height="35" />
|
<materialDesign:PackIcon Kind="ArrowRight" Foreground="#FF00204E" HorizontalAlignment="Center" VerticalAlignment="Center" Width="50" Height="35" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -35,18 +35,45 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||||
DataTable ProgramName = new DataTable();
|
DataTable ProgramName = new DataTable();
|
||||||
|
DataTable WorkOrder =new DataTable();
|
||||||
DataTable dat = new DataTable();
|
DataTable dat = new DataTable();
|
||||||
public ProductionPlanningEdit()
|
public ProductionPlanningEdit(string workOrder, bool save)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
ProgramName = SQLiteHelpers.ExecuteDataSet("select * from ProgramName order by ProgramID desc", null).Tables[0]; //读取计划表写入缓存
|
ProgramName = SQLiteHelpers.ExecuteDataSet("select * from ProgramName order by ProgramID desc", null).Tables[0]; //读取计划表写入缓存
|
||||||
|
if (!string.IsNullOrEmpty(workOrder))
|
||||||
|
{
|
||||||
|
WorkOrder = SQLiteHelpers.ExecuteDataSet("select * from Workorder order by EndTime desc", null).Tables[0];
|
||||||
|
// dat = SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps order by Step asc", null).Tables[0];
|
||||||
|
}
|
||||||
SQLiteHelpers.Close(); //关闭连接
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
|
|
||||||
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
|
if (!string.IsNullOrEmpty(workOrder))
|
||||||
comboBoxProgram.ItemsSource = ProgramName.AsEnumerable().Select(rowdata => rowdata.Field<string>("ProgramName")).ToList();//转换工艺代码
|
{
|
||||||
|
//WorkOrder.Select().First().Field<object>("WorkOrder").ToString();
|
||||||
|
comboBoxMachine.Text = WorkOrder.Select().First().Field<object>("Machines").ToString();
|
||||||
|
comboBoxProgram.Text = WorkOrder.Select().First().Field<object>("ProgramName").ToString();
|
||||||
|
comboBoxDyelot.Text = WorkOrder.Select().First().Field<object>("Dyelot").ToString();
|
||||||
|
}
|
||||||
|
if (save)//允许编辑
|
||||||
|
{
|
||||||
|
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
|
||||||
|
comboBoxProgram.ItemsSource = ProgramName.AsEnumerable().Select(rowdata => rowdata.Field<string>("ProgramName")).ToList();//转换工艺代码
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Save.IsEnabled = false;
|
||||||
|
comboBoxMachine.IsEnabled = false;
|
||||||
|
comboBoxProgram.IsEnabled = false;
|
||||||
|
comboBoxDyelot.IsEnabled = false;
|
||||||
|
Grid_data.IsEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
private void comboBoxMachine_DropDownClosed(object sender, EventArgs e)//机台选择
|
private void comboBoxMachine_DropDownClosed(object sender, EventArgs e)//机台选择
|
||||||
{
|
{
|
||||||
@@ -163,8 +190,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
//SQLiteHelpers.Open(); //打开数据库
|
//SQLiteHelpers.Open(); //打开数据库
|
||||||
SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);// 执行插入
|
SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);// 执行插入
|
||||||
DataTable data_t = dat.Clone();
|
DataTable data_t = dat.Clone();
|
||||||
data_t.Columns.Add(new DataColumn() { ColumnName = "WorkOrder", DataType = typeof(String), DefaultValue = WorkOrder_ });
|
try
|
||||||
data_t.Columns.Add(new DataColumn() { ColumnName = "Dyelot", DataType = typeof(String), DefaultValue = Dyelot_ });
|
{
|
||||||
|
data_t.Columns.Add(new DataColumn() { ColumnName = "WorkOrder", DataType = typeof(String), DefaultValue = WorkOrder_ });
|
||||||
|
data_t.Columns.Add(new DataColumn() { ColumnName = "Dyelot", DataType = typeof(String), DefaultValue = Dyelot_ });
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
int a = dat.Rows.Count;
|
int a = dat.Rows.Count;
|
||||||
for (int x = 0; x < a; x++)
|
for (int x = 0; x < a; x++)
|
||||||
{
|
{
|
||||||
@@ -251,8 +282,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
//SQLiteHelpers.Open(); //打开数据库
|
//SQLiteHelpers.Open(); //打开数据库
|
||||||
SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);// 执行插入
|
SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);// 执行插入
|
||||||
DataTable data_t = dat.Clone();
|
DataTable data_t = dat.Clone();
|
||||||
data_t.Columns.Add(new DataColumn() { ColumnName = "WorkOrder", DataType = typeof(String), DefaultValue = WorkOrder_ });
|
try
|
||||||
data_t.Columns.Add(new DataColumn() { ColumnName = "Dyelot", DataType = typeof(String), DefaultValue = Dyelot_ });
|
{
|
||||||
|
data_t.Columns.Add(new DataColumn() { ColumnName = "WorkOrder", DataType = typeof(String), DefaultValue = WorkOrder_ });
|
||||||
|
data_t.Columns.Add(new DataColumn() { ColumnName = "Dyelot", DataType = typeof(String), DefaultValue = Dyelot_ });
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
int a = dat.Rows.Count;
|
int a = dat.Rows.Count;
|
||||||
for (int x = 0; x < a ; x++)
|
for (int x = 0; x < a ; x++)
|
||||||
{
|
{
|
||||||
@@ -316,9 +351,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
DataTable temp = SQLiteHelpers.ExecuteDataSet(
|
DataTable temp = SQLiteHelpers.ExecuteDataSet(
|
||||||
"select * from ProgramSteps where Program='" + sArray[i] + "' order by Step asc", null).Tables[0]; //读取计划表写入缓存
|
"select * from ProgramSteps where Program='" + sArray[i] + "' order by Step asc", null).Tables[0]; //读取计划表写入缓存
|
||||||
if (dat.Columns.Count == 0) dat = temp.Clone();
|
if (dat.Columns.Count == 0) dat = temp.Clone();
|
||||||
foreach (DataRow dr in temp.Rows)
|
foreach (DataRow drT in temp.Rows)
|
||||||
{
|
{
|
||||||
dat.Rows.Add(dr.ItemArray);
|
dat.Rows.Add(drT.ItemArray);
|
||||||
}
|
}
|
||||||
//dat = temp.Copy();
|
//dat = temp.Copy();
|
||||||
}
|
}
|
||||||
@@ -352,7 +387,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
string ProgramNAME;
|
string ProgramNAME;
|
||||||
string Numder = null;
|
string Numder = null;
|
||||||
string ID = null;
|
string ID = null;
|
||||||
string P1, P2, P3, P4, P5;
|
string P1, P2, P3, P4, P5;
|
||||||
|
|
||||||
private void Grid_data_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void Grid_data_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
int rownum = Grid_data.SelectedIndex;//获取鼠标选中行并定义变量
|
int rownum = Grid_data.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
|
|||||||
@@ -133,11 +133,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}//创建日程图
|
}//创建日程图
|
||||||
private void ViewClicked(GanttTask ganttTask)
|
private void ViewClicked(GanttTask ganttTask)
|
||||||
{
|
{
|
||||||
MessageBox.Show("New clicked for task " + ganttTask.Name);
|
Picture.Content = null;
|
||||||
|
Picture.Width = 600;
|
||||||
|
Picture.Content = new ProductionPlanningEdit(ganttTask.ID,false);
|
||||||
}
|
}
|
||||||
private void EditClicked(GanttTask ganttTask)
|
private void EditClicked(GanttTask ganttTask)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Edit clicked for task " + ganttTask.Name);
|
Picture.Content = null;
|
||||||
|
Picture.Width = 600;
|
||||||
|
Picture.Content = new ProductionPlanningEdit(ganttTask.ID, true);
|
||||||
}
|
}
|
||||||
private void DeleteClicked(GanttTask ganttTask)//删除
|
private void DeleteClicked(GanttTask ganttTask)//删除
|
||||||
{
|
{
|
||||||
@@ -181,8 +185,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}
|
}
|
||||||
private void ListViewItem_New(object sender, System.Windows.Input.MouseButtonEventArgs e)//新建事件
|
private void ListViewItem_New(object sender, System.Windows.Input.MouseButtonEventArgs e)//新建事件
|
||||||
{
|
{
|
||||||
|
Picture.Content = null;
|
||||||
Picture.Width = 600;
|
Picture.Width = 600;
|
||||||
Picture.Content = new ProductionPlanningEdit();
|
Picture.Content = new ProductionPlanningEdit(null, true);
|
||||||
}
|
}
|
||||||
private void WorkOrderNumder_Click(object sender, RoutedEventArgs e)
|
private void WorkOrderNumder_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using LiveChartsCore.Geo;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OpenTK.Graphics.ES11;
|
using OpenTK.Graphics.ES11;
|
||||||
using SunlightCentralizedControlManagement_SCCM_.Properties;
|
using SunlightCentralizedControlManagement_SCCM_.Properties;
|
||||||
@@ -17,8 +18,10 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using System.Xml.Linq;
|
||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
|
using static MaterialDesignThemes.Wpf.Theme;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
using static System.Net.WebRequestMethods;
|
using static System.Net.WebRequestMethods;
|
||||||
|
|
||||||
@@ -56,7 +59,21 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
public static string SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
public static string SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
||||||
public static string SQLPASWORD = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
public static string SQLPASWORD = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
||||||
public static SqlConnection conn_SC =new SqlConnection();//数据库
|
public static SqlConnection conn_SC =new SqlConnection();//数据库
|
||||||
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||||
|
public static DataTable Machines = new DataTable(); //设备表缓存
|
||||||
|
public static UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡
|
||||||
|
public MainWindowViewModel()
|
||||||
|
{
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
|
||||||
|
SQLiteHelpers.Close();
|
||||||
|
|
||||||
|
CountDown();
|
||||||
|
TcpClientNEW();
|
||||||
|
SQL_LINK();
|
||||||
|
}
|
||||||
public static async void SQL_LINK()//连接dbc数据库
|
public static async void SQL_LINK()//连接dbc数据库
|
||||||
{
|
{
|
||||||
if (conn_SC.State == ConnectionState.Open) conn_SC.Close();
|
if (conn_SC.State == ConnectionState.Open) conn_SC.Close();
|
||||||
@@ -97,7 +114,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
|
|
||||||
DispatcherTimer dis50ms = new DispatcherTimer
|
DispatcherTimer dis50ms = new DispatcherTimer
|
||||||
{
|
{
|
||||||
Interval = TimeSpan.FromMilliseconds(100) //毫秒
|
Interval = TimeSpan.FromMilliseconds(50) //毫秒
|
||||||
};
|
};
|
||||||
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每一秒执行的方法
|
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每一秒执行的方法
|
||||||
dis50ms.Start();//计时开始
|
dis50ms.Start();//计时开始
|
||||||
@@ -116,6 +133,36 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||||
{
|
{
|
||||||
|
SQLiteHelper WorkOrderSQL = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
WorkOrderSQL.Open(); //打开数据库
|
||||||
|
DataTable WorkOrderdata = WorkOrderSQL.ExecuteDataSet("select * from WorkOrder where State='100'", null).Tables[0]; //读取表写入缓存
|
||||||
|
for(int k=0;k<WorkOrderdata.Rows.Count;k++)
|
||||||
|
{
|
||||||
|
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||||
|
string State = Machines.Select("Name='" + WorkOrderdata_m + "'").
|
||||||
|
First().Field<object>("State").ToString();
|
||||||
|
if ((State == "101") || (State == "201") || (State == "202") || (State == "309"))
|
||||||
|
{
|
||||||
|
DataTable dataTable = WorkOrderdata.Clone();
|
||||||
|
// WorkOrderdata.Columns.Remove("Machines");
|
||||||
|
DataRow dt_temp = WorkOrderdata.Select()[k];
|
||||||
|
dt_temp.BeginEdit();
|
||||||
|
dt_temp["State"] = "101";
|
||||||
|
dt_temp.EndEdit();
|
||||||
|
dataTable.Rows.Add(dt_temp.ItemArray);
|
||||||
|
|
||||||
|
int index = Convert.ToInt16(Machines.Select("NAME='" + WorkOrderdata_m + "'").First().Field<object>("ID"));
|
||||||
|
stringQueue.Enqueue(new QueueString
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", index) + DataTableToDictionary(dataTable).ToJsonString()
|
||||||
|
});
|
||||||
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object>{{ "State", 110 }},
|
||||||
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WorkOrderSQL.Close();
|
||||||
|
|
||||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
|
|
||||||
for (int i = 0; i < Machinesdata_Count; i++)
|
for (int i = 0; i < Machinesdata_Count; i++)
|
||||||
@@ -157,7 +204,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
{
|
{
|
||||||
MachiensTcpClient[i].SendAsync("SC800:SCCM[" + MachiensTcpClient[i].IP + ";" + MachiensTcpClient[i].Port + "]");
|
MachiensTcpClient[i].SendAsync("SC800:SCCM[" + MachiensTcpClient[i].IP + ";" + MachiensTcpClient[i].Port + "]");
|
||||||
}
|
}
|
||||||
}
|
}//发送800指令
|
||||||
}
|
}
|
||||||
void Tick_Event_60S()
|
void Tick_Event_60S()
|
||||||
{
|
{
|
||||||
@@ -171,25 +218,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
, Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString()
|
, Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString()
|
||||||
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString());
|
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString());
|
||||||
}
|
}
|
||||||
}
|
}//重连
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
||||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
|
||||||
public static DataTable Machines = new DataTable(); //设备表缓存
|
|
||||||
public static UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡
|
|
||||||
public MainWindowViewModel()
|
|
||||||
{
|
|
||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
|
||||||
Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
|
|
||||||
SQLiteHelpers.Close();
|
|
||||||
|
|
||||||
CountDown();
|
|
||||||
TcpClientNEW();
|
|
||||||
SQL_LINK();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TcpClient[] MachiensTcpClient = new TcpClient[999];
|
public static TcpClient[] MachiensTcpClient = new TcpClient[999];
|
||||||
public static DataRow[] machinesdata = new DataRow[999];
|
public static DataRow[] machinesdata = new DataRow[999];
|
||||||
public int Machinesdata_Count;
|
public int Machinesdata_Count;
|
||||||
@@ -540,5 +571,29 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
// 创建一个字符串类型的队列
|
// 创建一个字符串类型的队列
|
||||||
public static Queue<QueueString> stringQueue = new Queue<QueueString>();
|
public static Queue<QueueString> stringQueue = new Queue<QueueString>();
|
||||||
|
/// <summary>
|
||||||
|
/// 将 DataTable 转换为 Dictionary 类型数据
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, object> DataTableToDictionary(DataTable dataTable)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
if (dataTable != null)
|
||||||
|
{
|
||||||
|
foreach (DataRow dataRow in dataTable.Rows)
|
||||||
|
{
|
||||||
|
foreach (DataColumn dataColumn in dataTable.Columns)
|
||||||
|
{
|
||||||
|
result.Add(dataColumn.ColumnName, dataRow[dataColumn].ToString());
|
||||||
|
//result = Console.WriteLine(dataRow[dataColumn].ToString());
|
||||||
|
//result.Add(dataColumn.ColumnName, dataRow[dataColumn].ToString())(new RepeatDictionaryComparer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user