protected void Page_Load(object sender, EventArgs e) { string queueID; string ret = "-2000"; try { queueID = Request.QueryString["queueID"]; //信息|用户id|实验id,实验名,实验室; if (string.IsNullOrEmpty(queueID))//没有这两个变量 { ret = "-1"; Response.Write(ret); return; } KeyDataQueueData kd = new KeyDataQueueData(); kd.ID = int.Parse(queueID); KeyDataQueueDataDBOption.delete(kd); ret = "1"; Response.Write(ret); return; } catch (System.Exception ex) { ret = "-100," + ex.Message; TextLog.AddTextLog("Cancel_Unkown:" + ex.Message, Global.txtLogFolder + "KeyData.txt", true); } Response.Write(ret); }
public static void KeyDataWorkThread() { int retryMax = 10; int retry = retryMax; iniFileOP.iniFilePath = "c:\\LCY.ini"; while (true) { bCalc = false; autoResetEvent.WaitOne(); bCalc = true; while (true) { bool bOK = false; KeyDataQueueData eq = KeyDataQueueDataDBOption.GetFirst(); if (eq == null) { break; } KeyDataWorkLogData kl = new KeyDataWorkLogData(); kl.IP = eq.IP; kl.DeviceID = eq.DeviceID; kl.sTime = eq.sTime; kl.SSID = eq.SSID; try { byte[] data = WFNetLib.StringFunc.StringsFunction.strToHexByte(eq.BIN, ""); string folder = "e:\\mb2\\" + eq.SSID; if (WFNetLib.FileOP.IsExist(folder, FileOPMethod.Folder)) { WFNetLib.FileOP.Delete(folder, FileOPMethod.Folder); } GetST12(data); uint keyoption = (uint)eq.KeyOption; for (int i = 0; i < 8; i++) { if (BytesOP.GetBit(keyoption, i)) { iniFileOP.Write("DuoXuan", i.ToString(), "1"); } else { iniFileOP.Write("DuoXuan", i.ToString(), "0"); } } if (BytesOP.GetBit(keyoption, 8)) { iniFileOP.Write("DuoXuan", "all", "1"); } else { iniFileOP.Write("DuoXuan", "all".ToString(), "0"); } iniFileOP.Write("KaiGuan", "KG", "1"); retry = 60; bool bStart = false; while (retry != 0) { Thread.Sleep(1000); retry--; try { int kg = int.Parse(iniFileOP.Read("KaiGuan", "KG")); if (kg == 2) { bStart = true; break; } } catch { } } if (bStart) { retry = 5 * 60; bool bFinish = false; while (retry != 0) { Thread.Sleep(1000); retry--; try { int kg = int.Parse(iniFileOP.Read("KaiGuan", "KG")); if (kg == 3) { bFinish = true; break; } } catch { } } if (bFinish) { if (WFNetLib.FileOP.IsExist(folder, FileOPMethod.Folder)) { byte format = (byte)eq.format; string filename; if (BytesOP.GetBit(format, 0))//11格式 { if (BytesOP.GetBit(keyoption, 0)) { FileInfo f; filename = folder + "\\key_0_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key0_11 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 1)) { FileInfo f; filename = folder + "\\key_1_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key1_11 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 2)) { FileInfo f; filename = folder + "\\key_2_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key2_11 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 3)) { FileInfo f; filename = folder + "\\key_3_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key3_11 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 4)) { FileInfo f; filename = folder + "\\key_4_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key4_11 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 5)) { FileInfo f; filename = folder + "\\key_5_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key5_11 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 6)) { FileInfo f; filename = folder + "\\key_6_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key6_11 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 7)) { FileInfo f; filename = folder + "\\key_7_" + eq.SSID + "_11.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key7_11 = StringsFunction.byteToHexStr(bin, ""); } } if (BytesOP.GetBit(format, 1))//41格式 { if (BytesOP.GetBit(keyoption, 0)) { FileInfo f; filename = folder + "\\key_0_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key0_41 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 1)) { FileInfo f; filename = folder + "\\key_1_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key1_41 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 2)) { FileInfo f; filename = folder + "\\key_2_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key2_41 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 3)) { FileInfo f; filename = folder + "\\key_3_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key3_41 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 4)) { FileInfo f; filename = folder + "\\key_4_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key4_41 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 5)) { FileInfo f; filename = folder + "\\key_5_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key5_41 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 6)) { FileInfo f; filename = folder + "\\key_6_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key6_41 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 7)) { FileInfo f; filename = folder + "\\key_7_" + eq.SSID + "_41.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key7_41 = StringsFunction.byteToHexStr(bin, ""); } } if (BytesOP.GetBit(format, 2))//51格式 { if (BytesOP.GetBit(keyoption, 0)) { FileInfo f; filename = folder + "\\key_0_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key0_51 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 1)) { FileInfo f; filename = folder + "\\key_1_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key1_51 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 2)) { FileInfo f; filename = folder + "\\key_2_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key2_51 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 3)) { FileInfo f; filename = folder + "\\key_3_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key3_51 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 4)) { FileInfo f; filename = folder + "\\key_4_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key4_51 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 5)) { FileInfo f; filename = folder + "\\key_5_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key5_51 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 6)) { FileInfo f; filename = folder + "\\key_6_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key6_51 = StringsFunction.byteToHexStr(bin, ""); } if (BytesOP.GetBit(keyoption, 7)) { FileInfo f; filename = folder + "\\key_7_" + eq.SSID + "_51.bin"; f = new FileInfo(filename); Stream stream = File.OpenRead(f.FullName); byte[] bin = new byte[stream.Length]; stream.Read(bin, 0, (int)stream.Length); stream.Close(); kl.Key7_51 = StringsFunction.byteToHexStr(bin, ""); } } kl.bOK = true; KeyDataWorkLogDataDBOption.Insert(kl); //WFNetLib.FileOP.Delete(folder, FileOPMethod.Folder); } else { kl.bOK = false; KeyDataWorkLogDataDBOption.Insert(kl); } } else { kl.bOK = false; KeyDataWorkLogDataDBOption.Insert(kl); } } else { kl.bOK = false; KeyDataWorkLogDataDBOption.Insert(kl); } KeyDataQueueDataDBOption.delete(eq); } catch// (System.Exception ex) { kl.bOK = false; KeyDataWorkLogDataDBOption.Insert(kl); KeyDataQueueDataDBOption.delete(eq); } } } }