|
|
@@ -7,6 +7,7 @@ using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
+using System.Linq;
|
|
|
using System.Net;
|
|
|
using System.Net.Sockets;
|
|
|
using System.Reflection;
|
|
|
@@ -965,31 +966,14 @@ namespace UAS_MES.PublicMethod
|
|
|
public static void WriteLbl(ApplicationClass lbl)
|
|
|
{
|
|
|
Process[] processes = System.Diagnostics.Process.GetProcessesByName("lppa");
|
|
|
- List<int> PidList = new List<int>();
|
|
|
- List<System.DateTime> Pstarttime = new List<System.DateTime>();
|
|
|
+ Dictionary<string, int> ProInf = new Dictionary<string, int>();
|
|
|
int PID = 0;
|
|
|
for (int i = 0; i < processes.Length; i++)
|
|
|
{
|
|
|
- PidList.Add(processes[i].Id);
|
|
|
- Pstarttime.Add(processes[i].StartTime);
|
|
|
+ ProInf.Add(processes[i].StartTime.ToString(), processes[i].Id);
|
|
|
}
|
|
|
- System.DateTime Temp = Pstarttime[0];
|
|
|
- if (Pstarttime.ToArray().Length > 0)
|
|
|
- {
|
|
|
- PID = PidList[0];
|
|
|
- }
|
|
|
- for (int i = 0; i < PidList.ToArray().Length; i++)
|
|
|
- {
|
|
|
- if (Temp < Pstarttime[i])
|
|
|
- {
|
|
|
- PID = PidList[i];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Temp = Pstarttime[i];
|
|
|
- }
|
|
|
- }
|
|
|
- String str = SystemInf.ProcessesID + "|" + PID;
|
|
|
+ var temp = ProInf.Keys.Max();
|
|
|
+ String str = SystemInf.ProcessesID + "|" + ProInf[temp];
|
|
|
string lblpath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\Log\cacheInfo";
|
|
|
FileStream fs = new FileStream(lblpath + @"\" + "lblprocess" + ".txt", FileMode.Append, FileAccess.Write);
|
|
|
StreamWriter sw = new StreamWriter(fs);
|