コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: dongdong-2009/LiChunYu
        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();
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: dongdong-2009/LiChunYu
        private void Form1_Load(object sender, EventArgs e)
        {
            WFNetLib.ADO.SQLServerOP.ConnectionString = "Data Source=.\\SQL2008;Initial Catalog=LCY_Server;Persist Security Info=True;User ID=sa;Password=1001001";
            KeyDataQueueDataDBOption.deleteAll();
            Thread t = new Thread(KeyDataWork.KeyDataWorkThread);

            t.Start();
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string queueID;
            string ret = webAPIFunc.GetRetString(ErrType.UnkownErr);

            try
            {
                queueID = Request.QueryString["queueID"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(queueID))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                KeyDataWorkLogData kdl = KeyDataWorkLogDataDBOption.Get(int.Parse(queueID));
                if (kdl != null)//已完成
                {
                    if (kdl.bOK)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.retOK);
                        Response.Write(ret);
                        return;
                    }
                    else
                    {
                        ret = "4,";
                        Response.Write(ret);
                        return;
                    }
                }
                int index = KeyDataQueueDataDBOption.GetIndex(queueID);
                if (index == -1)//申请的数据无效
                {
                    ret = "3,";
                    Response.Write(ret);
                    return;
                }
                else
                {
                    ret = "2," + index.ToString();
                    Response.Write(ret);
                    return;
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Status_Unkown:" + ex.Message, Global.txtLogFolder + "KeyData.txt", true);
            }
            Response.Write(ret);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            //txtLogFolder = WFNetLib.aspNetFunc.GetRootPath();
            WFNetLib.ADO.SQLServerOP.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString();
            ESLQueueDataDBOption.deleteAll();
            bRun = true;
            Thread t = new Thread(ESLWork.ESLPass);

            t.Start();
            KeyDataQueueDataDBOption.deleteAll();
            Thread t1 = new Thread(KeyDataWork.KeyDataWorkThread);

            t1.Start();
            Thread t2 = new Thread(ClearHPassLog.ClearHPassLogThread);

            t2.Start();
            WFNetLib.Log.TextLog.AddTextLog("web Start", Global.txtLogFolder + "workLog.txt", true);
        }
コード例 #7
0
ファイル: KeyDataWork.cs プロジェクト: dongdong-2009/LiChunYu
        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);
                    }
                }
            }
        }