Archived
Compare commits
4
Commits
4c7c353074
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5f558fae5 | ||
|
|
800cf3004d | ||
|
|
7bac465084 | ||
|
|
d530b35e35 |
No files matched your search
@@ -33,8 +33,11 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -52,11 +55,15 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="ProcessManage.db" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Data.SQLite">
|
||||
<Version>1.0.119</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="sunlight_logo.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Binary file not shown.
+96
-10
@@ -1,17 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProcessManage
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ShowWindow(IntPtr hWnd, int cmdShow);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern IntPtr GetConsoleWindow();
|
||||
|
||||
const int SW_HIDE = 0;
|
||||
const int SW_SHOW = 5;
|
||||
const int SW_MINIMIZE = 6;
|
||||
|
||||
|
||||
|
||||
|
||||
private static IniFile.IniFiles Configini = new IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "ProcessManageConfigini.ini");
|
||||
private static string SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
||||
private static string SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2");
|
||||
@@ -19,13 +38,36 @@ namespace ProcessManage
|
||||
private static string SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
||||
private static string SQLPASWORD = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
||||
private static DataTable DyelotsBulkedRecipe = new DataTable();
|
||||
private static Timer _timer;
|
||||
private static System.Threading.Timer _timer;
|
||||
private static int Count = 0;
|
||||
private static readonly int _intervalMs = int.Parse( Configini.IniReadvalue("SQL_SERVER", "SQL6"));
|
||||
private static DataTable Product = new DataTable();
|
||||
private static DataTable Gram = new DataTable();
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var handle = GetConsoleWindow();
|
||||
// ShowWindow(handle, SW_MINIMIZE);
|
||||
ShowWindow(handle, SW_HIDE);
|
||||
|
||||
// 托盘图标部分
|
||||
var notifyIcon = new NotifyIcon();
|
||||
notifyIcon.Icon = new System.Drawing.Icon("./sunlight_logo.ico");
|
||||
notifyIcon.Visible = true;
|
||||
notifyIcon.Text = "Process选择";
|
||||
notifyIcon.MouseClick += (s, e) =>
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
ShowWindow(handle, SW_SHOW);
|
||||
//Process.GetCurrentProcess().MainWindowHandle; // 强制刷新焦点
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("Process选择功能启动");
|
||||
_timer = new Timer(
|
||||
_timer = new System.Threading.Timer(
|
||||
callback: EXTask,
|
||||
state: null,
|
||||
dueTime: 100,
|
||||
@@ -40,12 +82,9 @@ namespace ProcessManage
|
||||
private static void EXTask(object state)
|
||||
{
|
||||
string Connstr_SC;
|
||||
string DyelotsBulkedRecipe_sql = "SELECT * FROM [dbo].[DyelotsBulkedRecipe] WHERE Created > '"
|
||||
+ DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd") + "' AND Process IS NULL";
|
||||
try
|
||||
{
|
||||
DyelotsBulkedRecipe.Clear();
|
||||
|
||||
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";
|
||||
if (SQMOD == "Windows Authentication")
|
||||
{
|
||||
Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI";
|
||||
@@ -57,14 +96,60 @@ namespace ProcessManage
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC);
|
||||
conn_SC.OpenAsync(); //连接数据库
|
||||
SqlDataAdapter DyelotsBulkedRecipe_ = new SqlDataAdapter(DyelotsBulkedRecipe_sql, Connstr_SC);
|
||||
conn_SC.Close();
|
||||
try
|
||||
{
|
||||
DyelotsBulkedRecipe.Clear();
|
||||
DyelotsBulkedRecipe_.Fill(DyelotsBulkedRecipe);
|
||||
|
||||
for (int i = DyelotsBulkedRecipe.Rows.Count; i > 0; i--)
|
||||
{
|
||||
if (DyelotsBulkedRecipe.Rows.Count <= 0) { break; }//跳出循环
|
||||
|
||||
string Dyelot = DyelotsBulkedRecipe.Rows[0].Field<string>("Dyelot");
|
||||
int ReDye = DyelotsBulkedRecipe.Rows[0].Field<int>("ReDye");
|
||||
int StepNumber = DyelotsBulkedRecipe.Rows[0].Field<int>("StepNumber");
|
||||
double gram = 0;
|
||||
int type_id = 0;
|
||||
DataRow[] rowdat = DyelotsBulkedRecipe.Select("Dyelot ='" + Dyelot + "' AND ReDye='" + ReDye + "' AND StepNumber ='" + StepNumber + "'");//行
|
||||
|
||||
foreach (DataRow row in rowdat)//删除指定信息行
|
||||
{
|
||||
try
|
||||
{
|
||||
int a = Product.Select("ProductCode = " + row.Field<string>("ProductCode")).First().Field<int>("ProductType");
|
||||
if (a > type_id) type_id = a;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
Console.Write(ex.ToString());
|
||||
}
|
||||
|
||||
gram += row.Field<double>("Grams");
|
||||
row.Delete();
|
||||
row.AcceptChanges();
|
||||
}
|
||||
string NAME = "Process";
|
||||
try
|
||||
{
|
||||
NAME = Gram.Select("Type='" + type_id + "' and min<=" + (int)gram + " and max>" + (int)gram + "").First().Field<string>("name");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
Console.Write(ex.ToString());
|
||||
}
|
||||
|
||||
Console.Write("\n"+DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss")+$"转换{Count}条");
|
||||
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++;
|
||||
Console.Write("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") +
|
||||
" 转换工单:" + Dyelot + "-重染:" + ReDye + "-步骤:" + StepNumber + "\n影响行数" +
|
||||
DyelotsBulkedRecipe_UP.ExecuteNonQuery() + "-流程:" + NAME);
|
||||
LogGing.LogGingDATA("转换工单:" + Dyelot + "重染" + ReDye + "步骤" + StepNumber + "流程:" + NAME);
|
||||
}
|
||||
// Console.Write("\n" + DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss") + $" 转换完成{Count}条");
|
||||
Count = 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -74,6 +159,7 @@ namespace ProcessManage
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn_SC.Close();
|
||||
_timer.Change(
|
||||
dueTime: _intervalMs,
|
||||
period: Timeout.Infinite);//设定下次触发
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Reference in new issue
Block a user