diff --git a/ProcessManageUI/MainWindow.xaml b/ProcessManageUI/MainWindow.xaml
index bf52c66..d006145 100644
--- a/ProcessManageUI/MainWindow.xaml
+++ b/ProcessManageUI/MainWindow.xaml
@@ -5,9 +5,36 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProcessManageUI"
mc:Ignorable="d"
- Title="MainWindow" Height="450" Width="800">
+ ResizeMode="NoResize"
+ Title="ProcessManage" Height="450" Width="800" >
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProcessManageUI/MainWindow.xaml.cs b/ProcessManageUI/MainWindow.xaml.cs
index 59c2bf5..965b09d 100644
--- a/ProcessManageUI/MainWindow.xaml.cs
+++ b/ProcessManageUI/MainWindow.xaml.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
@@ -16,6 +17,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
+using System.Xml.Linq;
using static ProcessManageUI.SqliteHelper;
using static System.Net.WebRequestMethods;
@@ -49,40 +51,48 @@ namespace ProcessManageUI
{
InitializeComponent();
+ IP.Text = SQLIP;
+ MOD.Text = SQMOD;
+ NAME.Text = SQLNAME;
+ USER.Text = SQLUSER;
+ PAW.Text = SQLPASWORD;
+ TIMEMS.Text = _intervalMs.ToString();
+
+ Datalog.Text = "启动";
+ Datalog.AppendText("\n读取配置");
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
Gram = SQLiteHelpers.ExecuteDataSet("select * from Gram", null).Tables[0]; //读取表写入缓存
Product = SQLiteHelpers.ExecuteDataSet("select * from ProcessManage", null).Tables[0];
- SQLiteHelpers.Close();
+ SQLiteHelpers.Close();
+ Datalog.AppendText("\n设定循环时间"+ _intervalMs+"MS");
disTimer.Tick += EXTask;
disTimer.Start();//计时开始
}
-
private void EXTask(object sender, EventArgs e)
{
disTimer.Stop();//停止计时
string Connstr_SC;
string DyelotsBulkedRecipe_sql = "SELECT * FROM [dbo].[DyelotsBulkedRecipe] WHERE Created > '"
+ DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd") + "' AND ProductType = '1' AND Process IS NULL";
+ if (SQMOD == "Windows Authentication")
+ {
+ Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI";
+ }
+ else
+ {
+ Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASWORD;
+ }
+ SqlConnection conn_SC = new SqlConnection(Connstr_SC);
+ conn_SC.OpenAsync(); //连接数据库
+ SqlDataAdapter DyelotsBulkedRecipe_ = new SqlDataAdapter(DyelotsBulkedRecipe_sql, Connstr_SC);
try
{
DyelotsBulkedRecipe.Clear();
Datalog.Text = null;
-
- if (SQMOD == "Windows Authentication")
- {
- Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI";
- }
- else
- {
- Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASWORD;
- }
- SqlConnection conn_SC = new SqlConnection(Connstr_SC);
- conn_SC.OpenAsync(); //连接数据库
- SqlDataAdapter DyelotsBulkedRecipe_ = new SqlDataAdapter(DyelotsBulkedRecipe_sql, Connstr_SC);
- conn_SC.Close();
+ Datalog.AppendText(DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") +" 开始转换");
DyelotsBulkedRecipe_.Fill(DyelotsBulkedRecipe);
for (int i = DyelotsBulkedRecipe.Rows.Count; i > 0; i--)
@@ -90,9 +100,11 @@ namespace ProcessManageUI
if (DyelotsBulkedRecipe.Rows.Count <= 0) { break; }//跳出循环
string Dyelot = DyelotsBulkedRecipe.Rows[0].Field("Dyelot");
+ int ReDye = DyelotsBulkedRecipe.Rows[0].Field("ReDye");
+ int StepNumber = DyelotsBulkedRecipe.Rows[0].Field("StepNumber");
double gram = 0;
int type_id = 0;
- DataRow[] rowdat = DyelotsBulkedRecipe.Select("Dyelot ='" + Dyelot + "'");//行
+ DataRow[] rowdat = DyelotsBulkedRecipe.Select("Dyelot ='" + Dyelot + "' AND ReDye='"+ ReDye+ "' AND StepNumber ='"+ StepNumber+"'");//行
foreach (DataRow row in rowdat)//删除指定信息行
{
@@ -101,22 +113,37 @@ namespace ProcessManageUI
int a = Product.Select("ProductCode = " + row.Field("ProductCode")).First().Field("ProductType");
if (a > type_id) type_id = a;
}
- catch (Exception) { }
+ catch (Exception ex)
+ {
+ LogGing.ERRDATA(ex);
+ Datalog.AppendText(ex.ToString());
+ }
gram += row.Field("Grams");
row.Delete();
row.AcceptChanges();
}
- string NAME = Gram.Select("Type='"+type_id +"' and min<'"+gram+"' and max>'"+gram+"'").First().Field("name");
-
-
-
+ string NAME = "Process";
+ try
+ {
+ NAME = Gram.Select("Type='" + type_id + "' and min<='" + gram + "' and max>'" + gram + "'").First().Field("name");
+ }
+ catch (Exception ex)
+ {
+ LogGing.ERRDATA(ex);
+ Datalog.AppendText(ex.ToString());
+ }
+ string DyelotsBulkedRecipe_updata = "UPDATE [dbo].[DyelotsBulkedRecipe] SET Process ='"+NAME+
+ "'WHERE Dyelot ='" + Dyelot + "' AND ReDye='" + ReDye + "' AND StepNumber ='" + StepNumber + "'";
+ SqlCommand DyelotsBulkedRecipe_UP = new SqlCommand(DyelotsBulkedRecipe_updata, conn_SC);
Count++;
- Datalog.AppendText("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") + " 转换工单:" + Dyelot + "流程:"+ NAME);
- LogGing.LogGingDATA( "转换工单:" + Dyelot + "流程:");
+ Datalog.AppendText("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") +
+ " 转换工单:" + Dyelot + "-重染:"+ReDye+"-步骤:"+StepNumber+"\n影响行数"+
+ DyelotsBulkedRecipe_UP.ExecuteNonQuery() + "-流程:"+ NAME);
+ LogGing.LogGingDATA( "转换工单:" + Dyelot + "重染" + ReDye + "步骤" + StepNumber + "流程:" + NAME);
}
- Datalog.AppendText("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") + $" 转换{Count}条");
+ Datalog.AppendText("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") + $" 转换完成{Count}条");
Count = 0;
}
catch (Exception ex)
@@ -126,8 +153,19 @@ namespace ProcessManageUI
}
finally
{
+ conn_SC.Close();
disTimer.Start();//计时开始
}
}
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ Configini.IniWritevalue("SQL_SERVER", "SQL1", IP.Text);
+ Configini.IniWritevalue("SQL_SERVER", "SQL2", NAME.Text);
+ Configini.IniWritevalue("SQL_SERVER", "SQL3", MOD.Text);
+ Configini.IniWritevalue("SQL_SERVER", "SQL4", USER.Text);
+ Configini.IniWritevalue("SQL_SERVER", "SQL5", PAW.Text);
+ Configini.IniWritevalue("SQL_SERVER", "SQL6", TIMEMS.Text);
+ }
}
}