Exemple #1
0
        private void ResponseMessageToLock()
        {
            int MySendByteCount = 38; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0C30";
            }
            else
            {
                HexSendMessageIDString = "300C";
            }

            //--填充字节信息头-----------------------------------------------
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }



            MySendMessageBytes[2] = 1;

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16); //默认小端格式
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //--填充日期----
            string MyDateTimeString = GetDateTimeWeekIndex();

            byte[] MyDateTimeBytes = Encoding.ASCII.GetBytes(MyDateTimeString);
            for (int i = 0; i < 15; i++)
            {
                MySendMessageBytes[22 + i] = MyDateTimeBytes[i];
            }

            MyAsynchLockServerSocketService.StartAsynchSendMessage(MyReadWriteChannel, MySendMessageBytes);
        }
        private void DriveToSmartLock(string ParaSnapStr)
        {
            //------校验字节------------------------------------------------
            int MySendByteCount = 24; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0B20";
            }
            else
            {
                HexSendMessageIDString = "200B";
            }


            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            MySendMessageBytes[22] = 1;  //抓拍标志



            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);
        }
Exemple #3
0
        private void addkeyDriveToSmartLockExx()
        {
            int MySendByteCount = 23; //加校验字节0x17

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0522";
            }
            else
            {
                HexSendMessageIDString = "2205";
            }


            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }



            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);
        }
Exemple #4
0
        private void ResponseMessageToLock(Byte ProcessResultID)
        {
            int MySendByteCount = 22 + 1 + 1;//加校验字节=24

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                //HexSendMessageIDString = "1810";

                switch (MyMessageTypeID)
                {
                case "1011":
                    HexSendMessageIDString = "1210";
                    break;

                case "1013":
                    HexSendMessageIDString = "1410";
                    break;

                case "1015":
                    HexSendMessageIDString = "1610";
                    break;

                case "1017":
                    HexSendMessageIDString = "1810";
                    break;

                case "2003":
                    HexSendMessageIDString = "0420";
                    break;

                case "2007":
                    HexSendMessageIDString = "0820";
                    break;

                case "2105":
                    HexSendMessageIDString = "0621";
                    break;

                default:
                    HexSendMessageIDString = "1810";
                    break;
                }
            }
            else
            {
                HexSendMessageIDString = "1018"; //暂不执行
            }

            //填充字节信息头2个字节------------------------------------------------------------
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }



            MySendMessageBytes[2] = 1;
            //原样打回所谓流水号-----------------------------------------------------------------
            for (int i = 0; i < 5; i++)
            {
                MySendMessageBytes[i + 3] = this.MyReadBuffers[i + 3];
            }

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //填充命令处理结果
            MySendMessageBytes[22] = ProcessResultID; // 0;

            MyAsynchLockServerSocketService.StartAsynchSendMessage(MyReadWriteChannel, MySendMessageBytes);
            //----Test----------------------------------------------------------------------------------------

            /*
             * string BaseMessageString = null;
             * for (int i = 0; i < 24; i++)
             * {
             *
             *  BaseMessageString = BaseMessageString + string.Format("{0:X2}", MySendMessageBytes[i]);
             *
             * }
             * MyAsynchLockServerSocketService.SamrtLockMessageToSave(MyLockIDStr, "1018", BaseMessageString);
             */
        }
Exemple #5
0
        private void ReplyMessageToLock()
        {
            //如果主动上传发送消息响应到云锁,否则不回应
            //if (HexMessageTypeIDStr != "3007") return;
            if (SnapTypeID == 2)
            {
                return;
            }

            int MySendByteCount = 24; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = SnapTypeID == 0 ? "0830" : "0A30";
            }
            else
            {
                HexSendMessageIDString = SnapTypeID == 0 ? "3008" : "300A";
            }

            //填充字节信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }



            MySendMessageBytes[2] = 1;

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //填充命令处理结果

            MySendMessageBytes[22] = 0; ////ProcessID;// 0;成功;//-1:FF失败

            MyAsynchLockServerSocketService.StartAsynchSendMessage(MyReadWriteChannel, MySendMessageBytes);
        }
        private void ReplyLoginMessageToLock(Byte ProcessID, Byte TimeSynchID, AsynchLockServerSocketService MyAsynchLockServerSocketService, SocketServiceReadWriteChannel MyReadWriteChannel)
        {
            //------校验字节------------------------------------------------
            int MySendByteCount = 40; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0210";
            }
            else
            {
                HexSendMessageIDString = "1002";
            }


            string MyDateTimeString = GetDateTimeWeekIndex();

            byte[] MyDateTimeBytes = Encoding.ASCII.GetBytes(MyDateTimeString);

            //填充字节信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }



            MySendMessageBytes[2] = 1;

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //填充命令处理结果

            MySendMessageBytes[22] = ProcessID;   // 0;//-1:FF失败
            MySendMessageBytes[23] = TimeSynchID; //1;

            //填充日期
            for (int i = 0; i < 15; i++)
            {
                MySendMessageBytes[24 + i] = MyDateTimeBytes[i];
            }

            MyAsynchLockServerSocketService.StartAsynchSendMessage(MyReadWriteChannel, MySendMessageBytes);
        }
        private void ResponseMessageToLock(Byte ProcessID, Byte DataSynchID)
        {
            //----无校验字节--------------------------------------------------
            int MySendByteCount = 25; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0410";
            }
            else
            {
                HexSendMessageIDString = "1004";
            }



            //填充字节信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }



            MySendMessageBytes[2] = 1;

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //填充命令处理结果

            MySendMessageBytes[22] = ProcessID;   // 0;
            MySendMessageBytes[23] = DataSynchID; //1;



            MyAsynchLockServerSocketService.StartAsynchSendMessage(MyReadWriteChannel, MySendMessageBytes);
        }
Exemple #8
0
        private void tempkeyDriveToSmartLockEx(string tempKeyStr)
        {
            //------校验字节------------------------------------------------
            int MySendByteCount = 75; //加校验字节29+45+1=75

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0920";
            }
            else
            {
                HexSendMessageIDString = "2009";
            }

            //---密码生成!----------------------------------------------------
            //byte[] MyKeyStrBytes = Encoding.UTF8.GetBytes(tempKeyStr);
            //byte ntempKeyStr1 = byte.Parse(tempKeyStr.Substring(0, 1));
            //byte ntempKeyStr2 = byte.Parse(tempKeyStr.Substring(1, 1));
            //byte ntempKeyStr3 = byte.Parse(tempKeyStr.Substring(2, 1));
            //byte ntempKeyStr4 = byte.Parse(tempKeyStr.Substring(3, 1));
            //byte ntempKeyStr5 = byte.Parse(tempKeyStr.Substring(5, 1));

            byte[] MyKeyStrBytes = new byte[6];
            for (int i = 0; i < 6; i++)
            {
                MyKeyStrBytes[i] = byte.Parse(tempKeyStr.Substring(i, 1));
            }



            //string MyDateTimeString = GetDateTimeWeekIndex();//生效时间
            GetDateTimeWeekIndex(); //生效时间--创建时间
            byte[] MyDateTimeBytes = Encoding.UTF8.GetBytes(DateTimeStr);

            string MyEndDateTimeString = GetEndDateTimeWeekIndex(); //失效时间

            byte[] MyEndDateTimeBytes = Encoding.UTF8.GetBytes(MyEndDateTimeString);



            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //--填充临时字符密码字节----

            for (int i = 0; i < 6; i++)
            {
                MySendMessageBytes[22 + i] = MyKeyStrBytes[i];
            }

            MyKeyStrBytes.CopyTo(MySendMessageBytes, 22);

            MySendMessageBytes[28] = 1; //一次性密码

            //--填充起始时间点字节----

            /*
             * for (int i = 0; i < 15; i++)
             * {
             *
             * MySendMessageBytes[29 + i] = MyDateTimeBytes[i];
             *
             * }
             * */

            MyDateTimeBytes.CopyTo(MySendMessageBytes, 29);
            //--填充结束时间点字节----

            /*
             * for (int i = 0; i < 15; i++)
             * {
             *
             *  MySendMessageBytes[44 + i] = MyEndDateTimeBytes[i];
             *
             * }
             */

            MyEndDateTimeBytes.CopyTo(MySendMessageBytes, 44);
            //--填充生成时间字节----

            /*
             * for (int i = 0; i < 15; i++)
             * {
             *
             * MySendMessageBytes[59 + i] = MyDateTimeBytes[i];
             *
             * }
             * */

            MyDateTimeBytes.CopyTo(MySendMessageBytes, 59);


            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);

            //----Test------------------------------------------------------------------------------------------

            /*
             * string SendMessageString = null;
             * for (int i = 0; i < MySendMessageBytes.Length; i++)
             * {
             *
             *  SendMessageString = SendMessageString + string.Format("{0:X2}", MySendMessageBytes[i]);
             *
             * }
             *
             * MyAsynchLockServerSocketService.SamrtLockResponseToSave(MyLockIDStr, "2009", SendMessageString);
             * */
        }
Exemple #9
0
        private void tempkeyDriveToSmartLock(string tempKeyStr)
        {
            //------校验字节------------------------------------------------
            int MySendByteCount = 44; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0920";
            }
            else
            {
                HexSendMessageIDString = "2009";
            }


            byte[] MyKeyStrBytes = Encoding.UTF8.GetBytes(tempKeyStr);
            //string MyDateTimeString = GetDateTimeWeekIndex();
            GetDateTimeWeekIndex();
            byte[] MyDateTimeBytes = Encoding.UTF8.GetBytes(DateTimeStr);

            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //--填充字符密码字节----

            for (int i = 0; i < 6; i++)
            {
                MySendMessageBytes[22 + i] = MyKeyStrBytes[i];
            }

            //--填充日期字节----
            for (int i = 0; i < 15; i++)
            {
                MySendMessageBytes[28 + i] = MyDateTimeBytes[i];
            }

            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);
        }
Exemple #10
0
        private void deletekeyDriveToSmartLockEx(int KeyNumberID)
        {
            int MySendByteCount = 41; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0720";
            }
            else
            {
                HexSendMessageIDString = "2007";
            }



            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            MySendMessageBytes[22] = 1; //只删除一个用户

            //--用户序号
            string HexKeyNumberIDString = string.Format("{0:X4}", KeyNumberID);

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[23] = Convert.ToByte(HexKeyNumberIDString.Substring(2, 2), 16);
                MySendMessageBytes[24] = Convert.ToByte(HexKeyNumberIDString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[23] = Convert.ToByte(HexKeyNumberIDString.Substring(0, 2), 16);
                MySendMessageBytes[24] = Convert.ToByte(HexKeyNumberIDString.Substring(2, 2), 16);
            }


            //--填充日期字节----
            byte[] MyDateTimeBytes = Encoding.UTF8.GetBytes(DateTimeStr);
            for (int i = 0; i < 15; i++)
            {
                MySendMessageBytes[25 + i] = MyDateTimeBytes[i];
            }


            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);
        }
Exemple #11
0
        private void addkeyDriveToSmartLockEx(int KeyNumberID)
        {
            //增加密钥加强版
            int MySendByteCount = 41; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0522";
            }
            else
            {
                HexSendMessageIDString = "2205";
            }


            //string MyDateTimeString = GetDateTimeWeekIndex();
            GetDateTimeWeekIndex();
            byte[] MyDateTimeBytes = Encoding.UTF8.GetBytes(DateTimeStr);

            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //--填充字符密码字节----

            /*
             * for (int i = 0; i < 6; i++)
             * {
             *
             *  MySendMessageBytes[22 + i] = MyKeyStrBytes[i];
             *
             * }
             */

            MySendMessageBytes[22] = 1; //只增加一个用户

            //--用户序号
            string HexKeyNumberIDString = string.Format("{0:X4}", KeyNumberID);

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[23] = Convert.ToByte(HexKeyNumberIDString.Substring(2, 2), 16);
                MySendMessageBytes[24] = Convert.ToByte(HexKeyNumberIDString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[23] = Convert.ToByte(HexKeyNumberIDString.Substring(0, 2), 16);
                MySendMessageBytes[24] = Convert.ToByte(HexKeyNumberIDString.Substring(2, 2), 16);
            }

            //--填充日期字节----
            for (int i = 0; i < 15; i++)
            {
                MySendMessageBytes[25 + i] = MyDateTimeBytes[i];
            }

            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);
        }
Exemple #12
0
        private void DriveToSmartLock(string MasterKey)
        {
            //------校验字节------------------------------------------------
            int MySendByteCount = 45; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0320";
            }
            else
            {
                HexSendMessageIDString = "2003";
            }

            //--填充字符密码字节----
            //byte[] MyKeyStrBytes = Encoding.UTF8.GetBytes(KeyStr);
            byte[] MyMasterKeyBytes = new byte[6];
            for (int i = 0; i < 6; i++)
            {
                MyMasterKeyBytes[i] = byte.Parse(MasterKey.Substring(i, 1));
            }
            MyMasterKeyBytes.CopyTo(MySendMessageBytes, 22);

            /*
             * for (int i = 0; i < 6; i++)
             * {
             *
             * MySendMessageBytes[22 + i] = MyKeyStrBytes[i];
             *
             * }
             * */

            string MyDateTimeString = GetDateTimeWeekIndex();

            byte[] MyDateTimeBytes = Encoding.UTF8.GetBytes(MyDateTimeString);

            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }


            //--填充日期字节----
            for (int i = 0; i < 15; i++)
            {
                MySendMessageBytes[28 + i] = MyDateTimeBytes[i];
            }

            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);
        }
        private void ReplyLoginMessageToLock(Byte ProcessID, Byte TimeSynchID, RequestAttachment MyRequestAttachment)
        {
            int MySendByteCount = 40; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyRequestAttachment.MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0210";
            }
            else
            {
                HexSendMessageIDString = "1002";
            }


            string MyDateTimeString = GetDateTimeWeekIndex();

            byte[] MyDateTimeBytes = Encoding.ASCII.GetBytes(MyDateTimeString);

            //填充字节信息头
            if (MyRequestAttachment.MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }



            MySendMessageBytes[2] = 1;

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyRequestAttachment.MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }



            MySendMessageBytes[22] = ProcessID;   // 0;//-1:0xFF失败
            MySendMessageBytes[23] = TimeSynchID; //1;

            //填充日期

            /*
             * for (int i = 0; i < 15; i++)
             * {
             *
             *    MySendMessageBytes[24 + i] = MyDateTimeBytes[i];
             *
             * }
             */

            //MyRequestAttachment.MyAsynchLockServerSocketService.StartAsynchSendMessage(MyRequestAttachment.MyReadWriteChannel, MySendMessageBytes);

            MyRequestAttachment.MyLoginUser.IsCloseSocket = true;//设置关闭标志
            MyRequestAttachment.MyAsynchLockServerSocketService.StartAsynchSendMessageEx(MyRequestAttachment.MyLoginUser, MySendMessageBytes);
        }
Exemple #14
0
        private void DriveToSmartLock()
        {
            //------------------------------------------------------
            int MySendByteCount = 38; //加校验字节

            byte[] MySendMessageBytes = new byte[MySendByteCount];

            string HexSendLenghtString = string.Format("{0:X4}", MySendByteCount);

            string HexSendMessageIDString;

            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                HexSendMessageIDString = "0530";
            }
            else
            {
                HexSendMessageIDString = "3005";
            }


            string MyDateTimeString = GetDateTimeWeekIndex();

            byte[] MyDateTimeBytes = Encoding.ASCII.GetBytes(MyDateTimeString);

            //填充缓冲区信息头
            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
            }
            else
            {
                MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
            }

            MySendMessageBytes[2] = 2;  //移动端请求

            MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
            MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);



            if (MyAsynchLockServerSocketService.DataFormateFlag)
            {
                MySendMessageBytes[10] = 1;
                MySendMessageBytes[12] = 1;
            }
            else
            {
                MySendMessageBytes[11] = 1;
                MySendMessageBytes[13] = 1;
            }

            //--填充日期字节----
            for (int i = 0; i < 15; i++)
            {
                MySendMessageBytes[22 + i] = MyDateTimeBytes[i];
            }

            MyAsynchLockServerSocketService.StartAsynchSendMessage(NewReadWriteChannel, MySendMessageBytes);
        }
        public int AsynchSendSnapVideoFrame(byte[] InSendVideoFrameBuffers)
        {
            ReceiveIDFlag = 1;

            try
            {
                bool   DataFormateFlag = true;
                int    PreHeadLenght   = 40;
                UInt32 SendImageFileLenght;
                string HexSendMessageIDString;
                SendImageFileLenght = (UInt32)InSendVideoFrameBuffers.Length;
                byte[] MySendMessageBytes = new byte[SendImageFileLenght + PreHeadLenght];

                MySendMessageBytes[2]  = 1;    //推送消息标志
                MySendMessageBytes[15] = 0xFF; //虚拟锁标志!
                string HexSendLenghtString;
                if (DataFormateFlag)
                {
                    HexSendMessageIDString = "0930";//消息类别!
                }
                else
                {
                    HexSendMessageIDString = "3009";
                }


                MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
                MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);

                if (DataFormateFlag)
                {
                    MySendMessageBytes[10] = 1;
                    MySendMessageBytes[12] = 1;
                }
                else
                {
                    MySendMessageBytes[11] = 1;
                    MySendMessageBytes[13] = 1;
                }
                //------------------------------------------------------------------------------
                if (SendImageFileLenght <= 65536 - PreHeadLenght)//---短文件状态!
                {
                    //填充22个字节信息头开头两个字节
                    HexSendLenghtString = string.Format("{0:X4}", (UInt16)SendImageFileLenght + 22);
                    if (DataFormateFlag)
                    {
                        MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                        MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                    }
                    else
                    {
                        MySendMessageBytes[0] = Convert.ToByte(HexSendLenghtString.Substring(0, 2), 16);
                        MySendMessageBytes[1] = Convert.ToByte(HexSendLenghtString.Substring(2, 2), 16);
                    }
                }
                //-----文件长度信息!
                MySendMessageBytes[14] = 0xFF;                                                      //文件传输标志!
                string HexSendImageFileLenghtString = string.Format("{0:X8}", SendImageFileLenght); //文件长度:4个字节
                                                                                                    //填充40个字节信息头

                /*
                 *                                                                           MySendMessageBytes[2] = 1;
                 *
                 *
                 *                                                                           if (DataFormateFlag)
                 *                                                                           {
                 *                                                                               HexSendMessageIDString = "0730";
                 *                                                                           }
                 *                                                                           else
                 *                                                                           {
                 *                                                                               HexSendMessageIDString = "3007";
                 *                                                                           }
                 *
                 *                                                                          MySendMessageBytes[8] = Convert.ToByte(HexSendMessageIDString.Substring(0, 2), 16);
                 *                                                                           MySendMessageBytes[9] = Convert.ToByte(HexSendMessageIDString.Substring(2, 2), 16);
                 *
                 *                                                                           if (DataFormateFlag)
                 *                                                                           {
                 *                                                                               MySendMessageBytes[10] = 1;
                 *                                                                               MySendMessageBytes[12] = 1;
                 *
                 *                                                                           }
                 *                                                                           else
                 *                                                                           {
                 *                                                                               MySendMessageBytes[11] = 1;
                 *                                                                               MySendMessageBytes[13] = 1;
                 *                                                                           }
                 */

                if (DataFormateFlag)//小端模式
                {
                    MySendMessageBytes[18] = Convert.ToByte(HexSendImageFileLenghtString.Substring(6, 2), 16);
                    MySendMessageBytes[19] = Convert.ToByte(HexSendImageFileLenghtString.Substring(4, 2), 16);

                    MySendMessageBytes[20] = Convert.ToByte(HexSendImageFileLenghtString.Substring(2, 2), 16);
                    MySendMessageBytes[21] = Convert.ToByte(HexSendImageFileLenghtString.Substring(0, 2), 16);
                }
                else
                {
                    MySendMessageBytes[18] = Convert.ToByte(HexSendImageFileLenghtString.Substring(0, 2), 16);
                    MySendMessageBytes[19] = Convert.ToByte(HexSendImageFileLenghtString.Substring(2, 2), 16);

                    MySendMessageBytes[20] = Convert.ToByte(HexSendImageFileLenghtString.Substring(4, 2), 16);
                    MySendMessageBytes[21] = Convert.ToByte(HexSendImageFileLenghtString.Substring(6, 2), 16);
                }

                //-----------------------------------------------------------------------------------
                //byte[] MySendImageBytes = MyMemoryStream.GetBuffer();
                InSendVideoFrameBuffers.CopyTo(MySendMessageBytes, PreHeadLenght);//腾充图像数据


                if (SynchSendCommand(MySendMessageBytes) == 0)
                {
                    SendIDFlag = 0;
                }
            }
            catch (Exception ExceptionInfor)
            {
                SendIDFlag = 2;
            }
            finally
            {
                ;
            }
            return(SendIDFlag);

            return(SendIDFlag);
        }