|
|
@@ -20,6 +20,10 @@ using System.Management;
|
|
|
using System.Xml;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
+using System.Runtime.Remoting.Channels.Ipc;
|
|
|
+using System.Runtime.Remoting.Channels;
|
|
|
+using System.Runtime.Remoting;
|
|
|
+using OTSMeasureApp.ServiceCenter;
|
|
|
|
|
|
namespace OTSMeasureApp
|
|
|
{
|
|
|
@@ -157,13 +161,7 @@ namespace OTSMeasureApp
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- //判断是否有授权
|
|
|
- if(!RegistrationVerification())
|
|
|
- {
|
|
|
- MessageBox.Show("Error: missing authorization");
|
|
|
- System.Environment.Exit(0);
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
ArrangWorkspaceWindow();
|
|
|
|
|
|
@@ -191,17 +189,29 @@ namespace OTSMeasureApp
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) this.CheckMeasureSysFileExist() = false");
|
|
|
+ log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) InitResultData() failed");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) (m_DataMgrFun.CheckParamFile() && m_DataMgrFun.CheckStageFile()) = false");
|
|
|
+ log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) (LoadParamFile() && LoadStageParamFile()) failed");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!m_MsrThreadWrapper.ConnectSEM())
|
|
|
+ {
|
|
|
+ MessageBox.Show("Connect SEM failed!Please goto the SysMgrApp.exe to setup the proper parameter and check other parameter of the EDS software");
|
|
|
+ System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
|
|
|
+ process.FileName = "OTSSysMgrApp.exe";//打开app的路径
|
|
|
+ //string FilePath = string.Join(" ",m_ProjData.GetPathName());
|
|
|
+ //process.Arguments = FilePath;//多个参数用空格隔开
|
|
|
+ process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
|
|
|
+ System.Diagnostics.Process.Start(process);
|
|
|
}
|
|
|
+ PrepareIpcServer();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) OTSIncAMeasureAppForm_Load:" + ex.ToString());
|
|
|
+ log.Error(" OTSIncAMeasureAppForm_Load:" + ex.ToString());
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1316,117 +1326,18 @@ namespace OTSMeasureApp
|
|
|
return csName;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // 获得CPU的序列号
|
|
|
- static string getCpu()
|
|
|
- {
|
|
|
- string strCpu = null;
|
|
|
- ManagementClass myCpu = new ManagementClass("win32_Processor");
|
|
|
- ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
|
|
|
- foreach (ManagementObject myObject in myCpuConnection)
|
|
|
- {
|
|
|
- strCpu = myObject.Properties["Processorid"].Value.ToString();
|
|
|
- break;
|
|
|
- }
|
|
|
- return strCpu;
|
|
|
- }
|
|
|
-
|
|
|
- // 取得设备硬盘的卷标号
|
|
|
- static string GetDiskVolumeSerialNumber()
|
|
|
- {
|
|
|
- ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
|
|
|
- ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
|
|
|
- disk.Get();
|
|
|
- return disk.GetPropertyValue("VolumeSerialNumber").ToString();
|
|
|
- }
|
|
|
-
|
|
|
- public static IDictionary<String, List<String>> ReadXML(string address)
|
|
|
- {
|
|
|
- IDictionary<String, List<String>> infos = new Dictionary<String, List<String>>();
|
|
|
-
|
|
|
- if (File.Exists(address))
|
|
|
- {
|
|
|
- XmlDocument xmlDoc = new XmlDocument();
|
|
|
-
|
|
|
- xmlDoc.Load(address);
|
|
|
-
|
|
|
- XmlNode xn = xmlDoc.SelectSingleNode("infos");
|
|
|
-
|
|
|
- XmlNodeList xnl = xn.ChildNodes;
|
|
|
-
|
|
|
- foreach (XmlNode xnf in xnl)
|
|
|
- {
|
|
|
- XmlElement xe = (XmlElement)xnf;
|
|
|
-
|
|
|
- XmlNode nameNode = xe.SelectSingleNode("ID");
|
|
|
-
|
|
|
- string name = nameNode.InnerText;
|
|
|
- Console.WriteLine(name);
|
|
|
- XmlNode filelist = xe.SelectSingleNode("filelist");
|
|
|
-
|
|
|
- List<String> list = new List<string>();
|
|
|
-
|
|
|
- foreach (XmlNode item in filelist.ChildNodes)
|
|
|
- {
|
|
|
- list.Add(item.InnerText);
|
|
|
- }
|
|
|
-
|
|
|
- infos.Add(name, list);
|
|
|
- }
|
|
|
- }
|
|
|
- return infos;
|
|
|
- }
|
|
|
- private string ConvertString(string str)
|
|
|
- {
|
|
|
- string str_out;
|
|
|
- string[] arr = str.Split(',');
|
|
|
- byte[] be = new byte[arr.Count()];
|
|
|
-
|
|
|
- for (int i = 0; i < arr.Count(); i++)
|
|
|
- {
|
|
|
- be[i] = Convert.ToByte(arr[i]);
|
|
|
- }
|
|
|
- str_out = Encoding.Unicode.GetString(be);
|
|
|
- return str_out;
|
|
|
- }
|
|
|
- private bool RegistrationVerification()
|
|
|
+ private void PrepareIpcServer()
|
|
|
{
|
|
|
- string CPUID, DiskID;
|
|
|
- try
|
|
|
- {
|
|
|
- SenseShield.DogDecrypting.decrypting(101);//参数为许可号
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- CPUID = getCpu();
|
|
|
- DiskID = GetDiskVolumeSerialNumber();
|
|
|
- var ID = ReadXML("./Config/SysData/RegistrationProofreading.txt");
|
|
|
- List<string> list_str = new List<string>();
|
|
|
- List<string> list_time = new List<string>();
|
|
|
- ID.TryGetValue("ID", out list_str);
|
|
|
- ID.TryGetValue("Time", out list_time);
|
|
|
- string setCPU = ConvertString(list_str[0]);
|
|
|
- string setDisk = ConvertString(list_str[1]);
|
|
|
- string setYear = ConvertString(list_time[0]);
|
|
|
- string setMonth = ConvertString(list_time[1]);
|
|
|
- string setDay = ConvertString(list_time[2]);
|
|
|
- if (CPUID != setCPU || DiskID != setDisk)
|
|
|
- {
|
|
|
- return false;
|
|
|
+ //Instantiate our server channel.
|
|
|
+ IpcServerChannel channel = new IpcServerChannel("ServerChannel");
|
|
|
+ //Register the server channel.
|
|
|
+ ChannelServices.RegisterChannel(channel, false);
|
|
|
+ //Register this service type.
|
|
|
+ RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcSEMController), "RemoteObject", WellKnownObjectMode.Singleton);
|
|
|
+ //RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject2), "RemoteObject2", WellKnownObjectMode.Singleton);
|
|
|
+ //Console.WriteLine("press return to exit");
|
|
|
+ //Console.ReadLine();
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- DateTime dt = DateTime.ParseExact(setYear + setMonth + setDay+ "235959", "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
|
|
|
-
|
|
|
- if (DateTime.Now > dt)
|
|
|
- {
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- return true;
|
|
|
}
|
|
|
}
|
|
|
}
|