sc 3 months ago
parent
commit
800cf3004d
  1. 5
      ProcessManage/ProcessManage.csproj
  2. 41
      ProcessManage/Program.cs

5
ProcessManage/ProcessManage.csproj

@ -36,6 +36,7 @@
<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" />
@ -54,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>

41
ProcessManage/Program.cs

@ -3,17 +3,34 @@ 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");
@ -21,7 +38,7 @@ 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();
@ -29,8 +46,28 @@ namespace ProcessManage
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,