Compare commits

...
8 Commits
2 changed files with 37 additions and 12 deletions

No files matched your search

+3 -1
View File
@@ -40,7 +40,7 @@ namespace ProcessManageUI
directoryInfo.Create();//创建日志路径 directoryInfo.Create();//创建日志路径
} }
} }
public static void ERRDATA(System.Exception dat) public static void ERRDATA(System.Exception dat,string d)
{ {
string Log_time = DateTime.Now.ToString("yyyy-MM-dd"); string Log_time = DateTime.Now.ToString("yyyy-MM-dd");
string logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录 string logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录
@@ -57,6 +57,7 @@ namespace ProcessManageUI
// wr.Close(); // wr.Close();
FileStream fil = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建写入文件 FileStream fil = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建写入文件
StreamWriter wfil = new StreamWriter(fil);//创建文件 StreamWriter wfil = new StreamWriter(fil);//创建文件
wfil.WriteLine("[" + Log_timehms + "];[DYELOT] ||" + d);
wfil.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString()); wfil.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString());
wfil.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.Source.ToString() + Environment.NewLine.ToString()); wfil.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.Source.ToString() + Environment.NewLine.ToString());
wfil.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString()); wfil.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString());
@@ -67,6 +68,7 @@ namespace ProcessManageUI
{ {
FileStream fs = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件 FileStream fs = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件
StreamWriter wr = new StreamWriter(fs);//创建文件 StreamWriter wr = new StreamWriter(fs);//创建文件
wr.WriteLine("[" + Log_timehms + "];[DYELOT] ||" + d);
wr.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString()); wr.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString());
wr.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.ToString() + Environment.NewLine.ToString()); wr.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.ToString() + Environment.NewLine.ToString());
wr.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString()); wr.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString());
+34 -11
View File
@@ -11,6 +11,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
@@ -80,9 +81,11 @@ namespace ProcessManageUI
private static DataTable Gram = new DataTable(); private static DataTable Gram = new DataTable();
private static int Count = 0; private static int Count = 0;
private static readonly int _intervalMs = int.Parse(Configini.IniReadvalue("SQL_SERVER", "SQL6")); private static readonly int _intervalMs = int.Parse(Configini.IniReadvalue("SQL_SERVER", "SQL6"));
private static readonly int _type = int.Parse(Configini.IniReadvalue("SQL_SERVER", "SQL7"));
private static SQLiteHelper SQLiteHelpers = null; //定义数据库 private static SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly static string DBAddress = Environment.CurrentDirectory + "\\ProcessManage.db"; //数据库路径 private readonly static string DBAddress = Environment.CurrentDirectory + "\\ProcessManage.db"; //数据库路径
private int DATAGRID_TABLE; private int DATAGRID_TABLE;
private int dbr_machine=0;
//设置定时器 //设置定时器
DispatcherTimer disTimer = new DispatcherTimer DispatcherTimer disTimer = new DispatcherTimer
@@ -96,7 +99,7 @@ namespace ProcessManageUI
} }
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
{ // 程序默认启动时隐藏窗体 { // 程序默认启动时隐藏窗体
Hide(); //Hide();
IP.Text = SQLIP; IP.Text = SQLIP;
MOD.Text = SQMOD; MOD.Text = SQMOD;
@@ -104,6 +107,7 @@ namespace ProcessManageUI
USER.Text = SQLUSER; USER.Text = SQLUSER;
PAW.Text = SQLPASWORD; PAW.Text = SQLPASWORD;
TIMEMS.Text = _intervalMs.ToString(); TIMEMS.Text = _intervalMs.ToString();
dbr_machine = int.Parse(Configini.IniReadvalue("SQL_SERVER", "SQLM"));
Datalog.Text = "启动"; Datalog.Text = "启动";
Datalog.AppendText("\n读取配置"); Datalog.AppendText("\n读取配置");
@@ -126,7 +130,8 @@ namespace ProcessManageUI
string Connstr_SC; string Connstr_SC;
string DyelotsBulkedRecipe_sql = string DyelotsBulkedRecipe_sql =
"SELECT * FROM [dbo].[DyelotsBulkedRecipe] WHERE Created > '" + DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd") + "SELECT * FROM [dbo].[DyelotsBulkedRecipe] WHERE Created > '" + DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd") +
"' AND ProductType = '1' AND Process IS NULL AND StepNumber IS NOT NULL AND ProductCode IS NOT NULL AND ReDye IS NOT NULL"; " ' and Created <'" + DateTime.Now.AddMinutes(-1).ToString("yyyy/MM/dd") +
"' AND ProductType = '" + _type + "' AND Process IS NULL AND StepNumber IS NOT NULL AND ProductCode IS NOT NULL AND ReDye IS NOT NULL";
if (SQMOD == "Windows Authentication") if (SQMOD == "Windows Authentication")
{ {
Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI"; Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI";
@@ -154,6 +159,7 @@ namespace ProcessManageUI
int StepNumber = DyelotsBulkedRecipe.Rows[0].Field<int>("StepNumber"); int StepNumber = DyelotsBulkedRecipe.Rows[0].Field<int>("StepNumber");
double gram = 0; double gram = 0;
int type_id = 0; int type_id = 0;
string machine_T = "";
DataRow[] rowdat = DyelotsBulkedRecipe.Select("Dyelot ='" + Dyelot + "' AND ReDye='"+ ReDye+ "' AND StepNumber ='"+ StepNumber+"'");//行 DataRow[] rowdat = DyelotsBulkedRecipe.Select("Dyelot ='" + Dyelot + "' AND ReDye='"+ ReDye+ "' AND StepNumber ='"+ StepNumber+"'");//行
foreach (DataRow row in rowdat)//删除指定信息行 foreach (DataRow row in rowdat)//删除指定信息行
@@ -165,17 +171,19 @@ namespace ProcessManageUI
} }
catch (Exception ex) catch (Exception ex)
{ {
LogGing.ERRDATA(ex); LogGing.ERRDATA(ex, Dyelot);
Datalog.AppendText(ex.ToString()); Datalog.AppendText("Dyelot="+Dyelot+"=="+ex.ToString());
} }
gram += row.Field<double>("Grams"); gram += row.Field<double>("Grams");
row.Delete(); row.Delete();
row.AcceptChanges(); row.AcceptChanges();
} }
string NAME = "Process"; string NAME = "Process";
int Class = 0; int Class = 0;
int TANK = 0; int TANK = 0;
try try
{ {
NAME = Gram.Select("Type='" + type_id + "' and min<=" + (int)gram + " and max>" + (int)gram + "").First().Field<string>("name"); NAME = Gram.Select("Type='" + type_id + "' and min<=" + (int)gram + " and max>" + (int)gram + "").First().Field<string>("name");
@@ -184,26 +192,41 @@ namespace ProcessManageUI
} }
catch (Exception ex) catch (Exception ex)
{ {
LogGing.ERRDATA(ex); LogGing.ERRDATA(ex, Dyelot);
Datalog.AppendText(ex.ToString()); Datalog.AppendText(ex.ToString());
} }
string DyelotsBulkedRecipe_updata = "UPDATE [dbo].[DyelotsBulkedRecipe] SET Process ='"+NAME+ string DyelotsBulkedRecipe_updata = "UPDATE [dbo].[DyelotsBulkedRecipe] SET Process ='" + NAME +
"' ,ProductClass='" +Class+ "',MixTankNo='"+ TANK + "' ,ProductClass='" + Class + "',MixTankNo='" + TANK +
"' WHERE Dyelot ='" + Dyelot + "' AND ReDye='" + ReDye + "' AND StepNumber ='" + StepNumber + "'";
if (dbr_machine == 1)//添加机台
{
string DyelotsBulkedRecipe_machine = "SELECT * FROM[dbo].[Dyelots] " +
" WHERE Dyelot ='" + Dyelot + "' AND ReDye='" + ReDye + "'";
SqlDataAdapter DyelotsBulkedRecipe_m = new SqlDataAdapter(DyelotsBulkedRecipe_machine, conn_SC);
DataTable dataTableM = new DataTable();
DyelotsBulkedRecipe_m.Fill(dataTableM);
machine_T = dataTableM.Rows[0].Field<string>("Machine");
DyelotsBulkedRecipe_updata = "UPDATE [dbo].[DyelotsBulkedRecipe] SET Process ='" + NAME +
"' ,ProductClass='" + Class + "',MixTankNo='" + TANK + "',Machine='" + machine_T +
"' WHERE Dyelot ='" + Dyelot + "' AND ReDye='" + ReDye + "' AND StepNumber ='" + StepNumber + "'"; "' WHERE Dyelot ='" + Dyelot + "' AND ReDye='" + ReDye + "' AND StepNumber ='" + StepNumber + "'";
SqlCommand DyelotsBulkedRecipe_UP = new SqlCommand(DyelotsBulkedRecipe_updata, conn_SC); }
SqlCommand DyelotsBulkedRecipe_UP = new SqlCommand(DyelotsBulkedRecipe_updata, conn_SC);
Count++; Count++;
Datalog.AppendText("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") + Datalog.AppendText("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") +
" 转换工单:" + Dyelot + "-重染:"+ReDye+"-步骤:"+StepNumber+"\n影响行数"+ " 转换工单:" + Dyelot + "-重染:"+ReDye+"-步骤:"+StepNumber+"\n影响行数"+
DyelotsBulkedRecipe_UP.ExecuteNonQuery() + "-流程:"+ NAME); DyelotsBulkedRecipe_UP.ExecuteNonQuery() + "-流程:"+ NAME+ "-机台:" + machine_T);
LogGing.LogGingDATA( "转换工单:" + Dyelot + "重染" + ReDye + "步骤" + StepNumber + "流程:" + NAME); LogGing.LogGingDATA( "转换工单:" + Dyelot + "重染" + ReDye + "质量" + gram + "步骤" + StepNumber + "流程:" + NAME+"机台:" + machine_T);
} }
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; Count = 0;
} }
catch (Exception ex) catch (Exception ex)
{//错误处理 {//错误处理
LogGing.ERRDATA(ex); LogGing.ERRDATA(ex,"NULL");
Datalog.AppendText(ex.ToString()); Datalog.AppendText(ex.ToString());
} }
finally finally