Compare commits

...
12 Commits
5 changed files with 51 additions and 19 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());
+1
View File
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProcessManageUI" xmlns:local="clr-namespace:ProcessManageUI"
mc:Ignorable="d" mc:Ignorable="d"
Loaded="Window_Loaded"
ResizeMode="NoResize" ResizeMode="NoResize"
Title="ProcessManage" Height="450" Width="800" > Title="ProcessManage" Height="450" Width="800" >
<Grid> <Grid>
+42 -17
View File
@@ -11,9 +11,9 @@ 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.Forms;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
@@ -23,7 +23,6 @@ using System.Windows.Shapes;
using System.Windows.Threading; using System.Windows.Threading;
using System.Xml.Linq; using System.Xml.Linq;
using static ProcessManageUI.SqliteHelper; using static ProcessManageUI.SqliteHelper;
using static System.Net.WebRequestMethods;
namespace ProcessManageUI namespace ProcessManageUI
{ {
@@ -71,7 +70,7 @@ namespace ProcessManageUI
base.OnClosing(e); base.OnClosing(e);
} }
private static IniFile.IniFiles Configini = new IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "ProcessManageConfigini.ini"); private static IniFile.IniFiles Configini = new IniFile.IniFiles(Environment.CurrentDirectory + "\\ProcessManageConfigini.ini");
private static string SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件 private static string SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
private static string SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2"); private static string SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2");
private static string SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3"); private static string SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3");
@@ -82,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
@@ -94,9 +95,11 @@ namespace ProcessManageUI
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
// 程序默认启动时隐藏窗体 }
Hide(); private void Window_Loaded(object sender, RoutedEventArgs e)
{ // 程序默认启动时隐藏窗体
//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读取配置");
@@ -113,7 +117,7 @@ namespace ProcessManageUI
Product = SQLiteHelpers.ExecuteDataSet("select * from ProcessManage", null).Tables[0]; Product = SQLiteHelpers.ExecuteDataSet("select * from ProcessManage", null).Tables[0];
SQLiteHelpers.Close(); SQLiteHelpers.Close();
Datalog.AppendText("\n设定循环时间"+ _intervalMs+"MS"); Datalog.AppendText("\n设定循环时间" + _intervalMs + "MS");
disTimer.Tick += EXTask; disTimer.Tick += EXTask;
disTimer.Start();//计时开始 disTimer.Start();//计时开始
@@ -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 + "'"; "' 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 + "'";
}
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
@@ -270,7 +293,7 @@ namespace ProcessManageUI
SQLiteHelpers.Open(); //打开数据库 SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("Gram", null, null); SQLiteHelpers.Delete("Gram", null, null);
DataTable data_t = Gram.Clone(); DataTable data_t = Gram.Clone();
Product.AcceptChanges(); Gram.AcceptChanges();
for (int i = 0; i < Gram.Rows.Count; i++) for (int i = 0; i < Gram.Rows.Count; i++)
{ {
data_t.Clear();//清空 data_t.Clear();//清空
@@ -288,5 +311,7 @@ namespace ProcessManageUI
data_Grid.Visibility=Visibility.Collapsed; data_Grid.Visibility=Visibility.Collapsed;
disTimer.Start();//计时 disTimer.Start();//计时
} }
} }
} }
Binary file not shown.
+5 -1
View File
@@ -16,7 +16,7 @@
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
@@ -24,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -37,6 +38,9 @@
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>sunlight_logo.ico</ApplicationIcon> <ApplicationIcon>sunlight_logo.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<StartupObject>ProcessManageUI.App</StartupObject>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />