Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
d13edd4070
9 files changed
+315
-5
No files matched your search
@@ -0,0 +1,123 @@
|
||||
using LiveChartsCore.Kernel;
|
||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
|
||||
|
||||
namespace SunlightCentralizedControlManagement_SCCM_.EX.Exchange
|
||||
{
|
||||
public class BDC_SQL
|
||||
{
|
||||
public class BDCSqlHelper
|
||||
{
|
||||
// SqlConnection conn_SC = new SqlConnection();//数据库
|
||||
string db;
|
||||
public void Config(string IP, string DATABASE, string USER, string PAWSSD, bool MODE)//连接dbc数据库
|
||||
{
|
||||
if (MODE) //连接数据库测试
|
||||
{
|
||||
db="server=" + IP + ";database=" + DATABASE + ";Trusted_Connection=SSPI";
|
||||
}
|
||||
else
|
||||
{
|
||||
db="server=" + IP + ";database=" + DATABASE + ";User ID=" + USER + ";Password=" + PAWSSD;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> UPDATA(string name,string where,DataRow entity)//dbc数据库
|
||||
{
|
||||
string DAT = null;
|
||||
int rowsAffected = 0;
|
||||
int type = 0;
|
||||
try { type = entity.Field<int>("Type"); } catch { }
|
||||
try
|
||||
{
|
||||
|
||||
DAT = "DispenseDyelot='" + entity.Field<string>("Dyelot") + "',DispenseReDye='" + entity.Field<int>("Redye")+"',";
|
||||
if (type == 2)
|
||||
{
|
||||
DAT = DAT+"DyeCallOff=" + entity.Field<int>("Step") + ",DyeState = 201,DyeTank=" +
|
||||
entity.Field<int>("Tank");
|
||||
}
|
||||
else if (type == 3)
|
||||
{
|
||||
DAT = DAT+"PowderCallOff=" + entity.Field<int>("Step") +",PowderState=201,PowderTank=" +
|
||||
entity.Field<int>("Tank");
|
||||
}
|
||||
else
|
||||
{
|
||||
DAT = DAT+"ChemicalCallOff=" + entity.Field<int>("Step") +",ChemicalState=201,ChemicalTank=" +
|
||||
entity.Field<int>("Tank");
|
||||
}
|
||||
|
||||
using (var connection = new SqlConnection(db))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = "UPDATE "+ name + " SET "+ DAT + " WHERE "+ where;
|
||||
// command.Parameters.AddWithValue("@table", name);
|
||||
// command.Parameters.AddWithValue("@Id", where);
|
||||
// command.Parameters.AddWithValue("@data", DAT);
|
||||
rowsAffected = await command.ExecuteNonQueryAsync();
|
||||
|
||||
LogGing.ExchangeDATA( command.CommandText.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
}
|
||||
return rowsAffected;
|
||||
}
|
||||
|
||||
public async Task<DataTable> SELECT(string name, string where)//dbc数据库
|
||||
{
|
||||
DataTable rowsAffected = new DataTable();
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(db))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = "SELECT * FROM " + name + " WHERE " + where;
|
||||
var dat = await command.ExecuteReaderAsync();
|
||||
rowsAffected.Load(dat);
|
||||
|
||||
LogGing.ExchangeDATA(command.CommandText.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
}
|
||||
return rowsAffected;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+9
@@ -699,6 +699,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 DispenseException 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string DispenseException {
|
||||
get {
|
||||
return ResourceManager.GetString("DispenseException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 DispenseGrams 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -1074,4 +1074,7 @@
|
||||
<data name="Subroutine" xml:space="preserve">
|
||||
<value>Subroutine</value>
|
||||
</data>
|
||||
<data name="DispenseException" xml:space="preserve">
|
||||
<value>Dispense Exception</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1074,4 +1074,7 @@
|
||||
<data name="Subroutine" xml:space="preserve">
|
||||
<value>Subroutine</value>
|
||||
</data>
|
||||
<data name="DispenseException" xml:space="preserve">
|
||||
<value>DispenseException</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1074,4 +1074,7 @@
|
||||
<data name="Subroutine" xml:space="preserve">
|
||||
<value>副功能</value>
|
||||
</data>
|
||||
<data name="DispenseException" xml:space="preserve">
|
||||
<value>输送异常</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1074,4 +1074,7 @@
|
||||
<data name="Subroutine" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="DispenseException" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
</root>
|
||||
@@ -109,6 +109,7 @@
|
||||
<Compile Include="EX\DispenseState.xaml.cs">
|
||||
<DependentUpon>DispenseState.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EX\Exchange\BDC_SQL.cs" />
|
||||
<Compile Include="EX\ManualDyelot.xaml.cs">
|
||||
<DependentUpon>ManualDyelot.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -114,7 +114,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
MainWindowViewModel.SQMOD = TEXT_SQMOD.Text;
|
||||
MainWindowViewModel.SQLUSER = TEXT_SQLUSER.Text;
|
||||
MainWindowViewModel.SQLPASWORD = TEXT_SQLPASWORD.Text;
|
||||
MainWindowViewModel.SQL_LINK();//更新设定
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ using LiveChartsCore.Geo;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenTK.Graphics.ES11;
|
||||
using ScottPlot.Palettes;
|
||||
using SunlightCentralizedControlManagement_SCCM_.EX.Exchange;
|
||||
using SunlightCentralizedControlManagement_SCCM_.Properties;
|
||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||
@@ -11,10 +13,12 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Speech.Synthesis;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -26,10 +30,11 @@ using System.Windows.Threading;
|
||||
using System.Xml.Linq;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using System.Speech.Synthesis;
|
||||
using static MaterialDesignThemes.Wpf.Theme;
|
||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using static System.Windows.Forms.AxHost;
|
||||
|
||||
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
@@ -69,6 +74,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
public static bool DyelotsDispenser;
|
||||
public static SqlConnection conn_SC =new SqlConnection();//数据库
|
||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
private BDC_SQL.BDCSqlHelper bDCSqlHelper = new BDC_SQL.BDCSqlHelper();
|
||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||
public static DataTable Machines = new DataTable(); //设备表缓存
|
||||
// public static DataRow MachinesROW;
|
||||
@@ -99,7 +105,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
USER_data = SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0];
|
||||
Dyelot_CALL = SQLiteHelpers.ExecuteDataSet("select * from Dyelot", null).Tables[0].Clone();
|
||||
SQLiteHelpers.Close();
|
||||
|
||||
|
||||
USERCapacity(App.USER_Purview);//App.USER_Purview);
|
||||
CountDown();
|
||||
TcpClientNEW();
|
||||
@@ -131,7 +137,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public static async void SQL_LINK()//连接dbc数据库
|
||||
public async void SQL_LINK()//连接dbc数据库
|
||||
{
|
||||
if (conn_SC.State == ConnectionState.Open) conn_SC.Close();
|
||||
try
|
||||
@@ -152,6 +158,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
LogGing.LogGingDATA("[Database='" + ex + "']=SQLSERVER");
|
||||
ERR_c++;
|
||||
}
|
||||
|
||||
if (SQMOD == "Windows Authentication") //连接数据库测试
|
||||
{
|
||||
bDCSqlHelper.Config(SQLIP, SQLNAME, SQLUSER, SQLPASWORD, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
bDCSqlHelper.Config(SQLIP, SQLNAME, SQLUSER, SQLPASWORD, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void CountDown()
|
||||
@@ -304,7 +319,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
else { Time60++; }
|
||||
}
|
||||
void Tick_Event_5S()//Tick_Event周期执行事件5S
|
||||
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
||||
{
|
||||
for (int i = 0; i < Machinesdata_Count; i++)
|
||||
{/**发送800指令**/
|
||||
@@ -348,7 +363,158 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
try
|
||||
{//处理呼叫请求列表
|
||||
if (Dyelot_CALL.Select("State='202'").Count() > 0)
|
||||
{
|
||||
DataRow row = Dyelot_CALL.Select("State='202'").First();
|
||||
var r = await bDCSqlHelper.UPDATA("Machines", "Name = '" + row.Field<string>("Machine") + "'", row);
|
||||
if (r > 0)
|
||||
{
|
||||
DataRow[] dataRows = Dyelot_CALL.Select("Dyelot='" + row.Field<string>("Dyelot") +
|
||||
"' and Redye='" + row.Field<int>("Redye") +
|
||||
"' and Step='" + row.Field<int>("Step") + "'");
|
||||
foreach (DataRow dataRow in dataRows)
|
||||
{
|
||||
dataRow.BeginEdit();
|
||||
dataRow["State"] = 203;
|
||||
dataRow.EndEdit();
|
||||
}
|
||||
Dictionary<string, object> dat_ = new Dictionary<string, object>();//缓存函数
|
||||
dat_.Add("State", 203);
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Update("DyelotHistory", dat_,
|
||||
"Dyelot='" + row.Field<string>("Dyelot") +
|
||||
"' and Redye='" + row.Field<int>("Redye") +
|
||||
"' and Step='" + row.Field<int>("Step") + "'", null);// 执行插入
|
||||
SQLiteHelpers.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
try
|
||||
{//检查呼叫回复列表
|
||||
if (Dyelot_CALL.Select("State='203'").Count() > 0)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
int ri = 0;
|
||||
// DataRow[] dataRows = Dyelot_CALL.Select("State='203'");
|
||||
foreach (DataRow dataRow in Dyelot_CALL.Select("State='203'"))
|
||||
{
|
||||
ri++;
|
||||
if ((dataRow["State"].ToString() != "301") && (dataRow["State"].ToString() != "309"))
|
||||
{
|
||||
if (dataRow.Field<int>("Type") == 2)
|
||||
{
|
||||
dt = await bDCSqlHelper.SELECT("Machines", "Name = '" + dataRow.Field<string>("Machine") +
|
||||
"' AND (DyeState = 301 OR DyeState = 309)");
|
||||
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
if (dt.Select("DyeState = 301").Count() > 0)
|
||||
{
|
||||
Dyelot_CALL.Rows.Remove(dataRow);
|
||||
|
||||
DataTable dr = await bDCSqlHelper.SELECT("DyelotsBulkedRecipe",
|
||||
"Dyelot = '" + dataRow.Field<string>("Dyelot") +
|
||||
"' AND ReDye = " + dataRow.Field<int>("ReDye") +
|
||||
" AND StepNumber = " + dataRow.Field<int>("StepNumber"));
|
||||
|
||||
foreach (DataRow Row in dr.Rows)
|
||||
{
|
||||
DataRow data = Dyelot_CALL.Select("ProductCode='" + Row.Field<string>("ProductCode") + "'").First();
|
||||
data.BeginEdit();
|
||||
data["Amount"] = Row.Field<float>("Amount");
|
||||
data["DispenseEndTime"] = Row.Field<DateTime>("DispenseEndTime").ToString("yyyy/MM/dd HH:mm:ss");
|
||||
data.EndEdit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.InfData.Rows.Add(new object[] { dataRow["Machine"],
|
||||
Resources.Dyelot + dataRow["Dyelot"] + Resources.Step + dataRow["Step"]+
|
||||
Resources.DispenseException,
|
||||
Selet_Machines(Machines, "SYSKEY", "Name='" + dataRow["Machine"] + "'"),
|
||||
Selet_Machines(Machines, "ID", "Name='" + dataRow["Machine"] + "'")});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dataRow.Field<int>("Type") == 3)
|
||||
{
|
||||
dt = await bDCSqlHelper.SELECT("Machines", "Name = '" + dataRow.Field<string>("Machine") +
|
||||
"' AND (PowderState = 301 OR PowderState = 309)");
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
if (dt.Select("PowderState = 301").Count() > 0)
|
||||
{
|
||||
Dyelot_CALL.Rows.Remove(dataRow);
|
||||
DataTable dr = await bDCSqlHelper.SELECT("DyelotsBulkedRecipe",
|
||||
"Dyelot = '" + dataRow.Field<string>("Dyelot") +
|
||||
"' AND ReDye = " + dataRow.Field<int>("ReDye") +
|
||||
" AND StepNumber = " + dataRow.Field<int>("StepNumber"));
|
||||
|
||||
foreach (DataRow Row in dr.Rows)
|
||||
{
|
||||
DataRow data = Dyelot_CALL.Select("ProductCode='" + Row.Field<string>("ProductCode") + "'").First();
|
||||
data.BeginEdit();
|
||||
data["Amount"] = Row.Field<float>("Amount");
|
||||
data["DispenseEndTime"] = Row.Field<DateTime>("DispenseEndTime").ToString("yyyy/MM/dd HH:mm:ss");
|
||||
data.EndEdit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.InfData.Rows.Add(new object[] { dataRow["Machine"],
|
||||
Resources.Dyelot + dataRow["Dyelot"] + Resources.Step + dataRow["Step"]+
|
||||
Resources.DispenseException,
|
||||
Selet_Machines(Machines, "SYSKEY", "Name='" + dataRow["Machine"] + "'"),
|
||||
Selet_Machines(Machines, "ID", "Name='" + dataRow["Machine"] + "'")});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = await bDCSqlHelper.SELECT("Machines", "Name = '" + dataRow.Field<string>("Machine") +
|
||||
"' AND (ChemicalState = 301 OR ChemicalState = 309)");
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
if (dt.Select("PowderState = 301").Count() > 0)
|
||||
{
|
||||
Dyelot_CALL.Rows.Remove(dataRow);
|
||||
DataTable dr = await bDCSqlHelper.SELECT("DyelotsBulkedRecipe",
|
||||
"Dyelot = '" + dataRow.Field<string>("Dyelot") +
|
||||
"' AND ReDye = " + dataRow.Field<int>("ReDye") +
|
||||
" AND StepNumber = " + dataRow.Field<int>("StepNumber"));
|
||||
|
||||
foreach (DataRow Row in dr.Rows)
|
||||
{
|
||||
DataRow data = Dyelot_CALL.Select("ProductCode='" + Row.Field<string>("ProductCode") + "'").First();
|
||||
data.BeginEdit();
|
||||
data["Amount"] = Row.Field<float>("Amount");
|
||||
data["DispenseEndTime"] = Row.Field<DateTime>("DispenseEndTime").ToString("yyyy/MM/dd HH:mm:ss");
|
||||
data.EndEdit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.InfData.Rows.Add(new object[] { dataRow["Machine"],
|
||||
Resources.Dyelot + dataRow["Dyelot"] + Resources.Step + dataRow["Step"]+
|
||||
Resources.DispenseException,
|
||||
Selet_Machines(Machines, "SYSKEY", "Name='" + dataRow["Machine"] + "'"),
|
||||
Selet_Machines(Machines, "ID", "Name='" + dataRow["Machine"] + "'")});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user