Compare commits

...
12 Commits
5 changed files with 55 additions and 23 deletions

No files matched your search

+3 -1
View File
@@ -40,7 +40,7 @@ namespace ProcessManageUI
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 logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录
@@ -57,6 +57,7 @@ namespace ProcessManageUI
// wr.Close();
FileStream fil = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建写入文件
StreamWriter wfil = new StreamWriter(fil);//创建文件
wfil.WriteLine("[" + Log_timehms + "];[DYELOT] ||" + d);
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 message] ||" + dat.Message.ToString() + Environment.NewLine.ToString());
@@ -67,6 +68,7 @@ namespace ProcessManageUI
{
FileStream fs = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件
StreamWriter wr = new StreamWriter(fs);//创建文件
wr.WriteLine("[" + Log_timehms + "];[DYELOT] ||" + d);
wr.WriteLine("[" + Log_timehms + "];[Error] ||" + 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());
+1
View File
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProcessManageUI"
mc:Ignorable="d"
Loaded="Window_Loaded"
ResizeMode="NoResize"
Title="ProcessManage" Height="450" Width="800" >
<Grid>
+46 -21
View File
@@ -11,9 +11,9 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
@@ -23,7 +23,6 @@ using System.Windows.Shapes;
using System.Windows.Threading;
using System.Xml.Linq;
using static ProcessManageUI.SqliteHelper;
using static System.Net.WebRequestMethods;
namespace ProcessManageUI
{
@@ -70,8 +69,8 @@ namespace ProcessManageUI
Hide();
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 SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2");
private static string SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3");
@@ -82,9 +81,11 @@ namespace ProcessManageUI
private static DataTable Gram = new DataTable();
private static int Count = 0;
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 readonly static string DBAddress = Environment.CurrentDirectory + "\\ProcessManage.db"; //数据库路径
private int DATAGRID_TABLE;
private int dbr_machine=0;
//设置定时器
DispatcherTimer disTimer = new DispatcherTimer
@@ -94,26 +95,29 @@ namespace ProcessManageUI
public MainWindow()
{
InitializeComponent();
// 程序默认启动时隐藏窗体
Hide();
DataContext = this;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{ // 程序默认启动时隐藏窗体
//Hide();
IP.Text = SQLIP;
MOD.Text = SQMOD;
NAME.Text = SQLNAME;
USER.Text = SQLUSER;
USER.Text = SQLUSER;
PAW.Text = SQLPASWORD;
TIMEMS.Text = _intervalMs.ToString();
dbr_machine = int.Parse(Configini.IniReadvalue("SQL_SERVER", "SQLM"));
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];
Product = SQLiteHelpers.ExecuteDataSet("select * from ProcessManage", null).Tables[0];
SQLiteHelpers.Close();
Datalog.AppendText("\n设定循环时间"+ _intervalMs+"MS");
Datalog.AppendText("\n设定循环时间" + _intervalMs + "MS");
disTimer.Tick += EXTask;
disTimer.Start();//计时开始
@@ -126,7 +130,8 @@ namespace ProcessManageUI
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 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")
{
Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI";
@@ -154,6 +159,7 @@ namespace ProcessManageUI
int StepNumber = DyelotsBulkedRecipe.Rows[0].Field<int>("StepNumber");
double gram = 0;
int type_id = 0;
string machine_T = "";
DataRow[] rowdat = DyelotsBulkedRecipe.Select("Dyelot ='" + Dyelot + "' AND ReDye='"+ ReDye+ "' AND StepNumber ='"+ StepNumber+"'");//行
foreach (DataRow row in rowdat)//删除指定信息行
@@ -165,17 +171,19 @@ namespace ProcessManageUI
}
catch (Exception ex)
{
LogGing.ERRDATA(ex);
Datalog.AppendText(ex.ToString());
LogGing.ERRDATA(ex, Dyelot);
Datalog.AppendText("Dyelot="+Dyelot+"=="+ex.ToString());
}
gram += row.Field<double>("Grams");
row.Delete();
row.AcceptChanges();
}
string NAME = "Process";
int Class = 0;
int TANK = 0;
try
{
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)
{
LogGing.ERRDATA(ex);
LogGing.ERRDATA(ex, Dyelot);
Datalog.AppendText(ex.ToString());
}
string DyelotsBulkedRecipe_updata = "UPDATE [dbo].[DyelotsBulkedRecipe] SET Process ='"+NAME+
"' ,ProductClass='" +Class+ "',MixTankNo='"+ TANK +
string DyelotsBulkedRecipe_updata = "UPDATE [dbo].[DyelotsBulkedRecipe] SET Process ='" + NAME +
"' ,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 + "'";
SqlCommand DyelotsBulkedRecipe_UP = new SqlCommand(DyelotsBulkedRecipe_updata, conn_SC);
}
SqlCommand DyelotsBulkedRecipe_UP = new SqlCommand(DyelotsBulkedRecipe_updata, conn_SC);
Count++;
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);
DyelotsBulkedRecipe_UP.ExecuteNonQuery() + "-流程:"+ NAME+ "-机台:" + machine_T);
LogGing.LogGingDATA( "转换工单:" + Dyelot + "重染" + ReDye + "质量" + gram + "步骤" + StepNumber + "流程:" + NAME+"机台:" + machine_T);
}
Datalog.AppendText("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") + $" 转换完成{Count}条");
Count = 0;
}
catch (Exception ex)
{//错误处理
LogGing.ERRDATA(ex);
LogGing.ERRDATA(ex,"NULL");
Datalog.AppendText(ex.ToString());
}
finally
@@ -270,7 +293,7 @@ namespace ProcessManageUI
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("Gram", null, null);
DataTable data_t = Gram.Clone();
Product.AcceptChanges();
Gram.AcceptChanges();
for (int i = 0; i < Gram.Rows.Count; i++)
{
data_t.Clear();//清空
@@ -288,5 +311,7 @@ namespace ProcessManageUI
data_Grid.Visibility=Visibility.Collapsed;
disTimer.Start();//计时
}
}
}
Binary file not shown.
+5 -1
View File
@@ -16,7 +16,7 @@
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@@ -24,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -37,6 +38,9 @@
<PropertyGroup>
<ApplicationIcon>sunlight_logo.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>ProcessManageUI.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />