private void button1_Click(object sender, EventArgs e) { FileInfo f; if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } f = new FileInfo(openFileDialog1.FileName); Stream stream = File.OpenRead(f.FullName); byte[] pBuf = new byte[stream.Length]; stream.Read(pBuf, 0, (int)stream.Length); stream.Close(); KeyDataQueueData kdq = new KeyDataQueueData(); //kdq.IP = WFGlobal.getIp(); kdq.DeviceID = DeviceID; kdq.format = 7; kdq.KeyOption = 0x01ff; kdq.SSID = StringsFunction.byteToHexStr(pBuf, 0, 4, ""); kdq.BIN = StringsFunction.byteToHexStr(pBuf, 0, 1024, ""); int id = KeyDataQueueDataDBOption.Insert(kdq); if (KeyDataWork.bCalc == false) { KeyDataWork.autoResetEvent.Set(); } }
protected void Page_Load(object sender, EventArgs e) { string ret = webAPIFunc.GetRetString(ErrType.UnkownErr); try { string post = WFHttpWebResponse.PostInput(Request.InputStream); if (string.IsNullOrEmpty(post))//没有这两个变量 { ret = webAPIFunc.GetRetString(ErrType.MissParam); Response.Write(ret); return; } post = post.Substring(0, post.Length - 1); byte[] rx = StringsFunction.strToHexByte(post, ""); KeyDataQueueData kd = new KeyDataQueueData(); kd.DeviceID = StringsFunction.byteToHexStr(rx, 0, 4, ""); kd.KeyOption = BytesOP.MakeShort(rx[4], rx[5]); kd.format = rx[6]; kd.IP = aspNetFunc.getIp(); kd.SSID = StringsFunction.byteToHexStr(rx, 7, 4, ""); kd.BIN = StringsFunction.byteToHexStr(rx, 7, 1024, ""); if (DeviceInfoDataDBOption.Get(kd.DeviceID) == null) { ret = webAPIFunc.GetRetString(ErrType.NoRegDevice); Response.Write(ret); return; } int queueID = KeyDataQueueDataDBOption.Insert(kd); if (KeyDataWork.bCalc == false) { KeyDataWork.autoResetEvent.Set(); } ret = webAPIFunc.GetRetString(ErrType.retOK, queueID.ToString()); Response.Write(ret); return; } catch (System.Exception ex) { ret = webAPIFunc.GetRetString(ErrType.UnkownErr); TextLog.AddTextLog("Add_Unkown:" + ex.Message, Global.txtLogFolder + "KayData.txt", true); } Response.Write(ret); }