Exemplo n.º 1
0
        public bool Execute()
        {
            int    length    = 29;
            int    count     = _content.Length / length;
            string commandId = "";

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                commandId = _content[i * length].ToString();
                content   = new byte[27];
                Array.Copy(_content, 2 + (length * i), content, 0, 27);
                ICommand cmd;
                switch (commandId)
                {
                case "1":
                    cmd = new MJ2_61444_1(content, StationId, PlatformTime);
                    break;

                case "2":
                    cmd = new MJ2_61444_2(content, StationId, PlatformTime);
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
        public bool Execute()
        {
            try
            {
                int    length = 19;
                int    count  = _content.Length / length;
                byte[] DeviceType;
                byte[] content;
                for (int i = 0; i < count; i++)
                {
                    DeviceType = new byte[2];
                    Array.Copy(_content, 7 + length * i, DeviceType, 0, 2);
                    content = new byte[19];
                    Array.Copy(_content, length * i, content, 0, length);
                    ICommand cmd;
                    switch (ConverUtil.ByteToStr_A(DeviceType))
                    {
                    case "0444":
                        cmd = new CeXie_61443_0444(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    cmd.Execute();
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error("处理协议格式命令错误:" + ex.Message);
            }

            return(true);
        }
Exemplo n.º 3
0
        private void Single(byte[] content)
        {
            try
            {
                string CmdId = content[0].ToString();
                byte[] Data  = new byte[20];
                Array.Copy(content, 1, Data, 0, 20);
                ICommand i;
                switch (CmdId)
                {
                case "0":
                    i = new YKGC_64_00(Data, StationId, PlatformTime);
                    break;

                default:
                    i = new IgnoreCommand();
                    break;
                }
                i.Execute();
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(Name + "错误:" + ex.Message + " 原始代码:" + OriginalCode);
            }
        }
        public bool Execute()
        {
            int length = 19;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string commandid;

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + (length * i), DeviceType, 0, 2);
                commandid = _content[13 + (i * length)].ToString();
                content   = new byte[19];
                Array.Copy(_content, length * i, content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "8040":
                    cmd = new QZGK_61443_8040_01(content, StationId, PlatformTime);
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
Exemplo n.º 5
0
        public bool Execute()
        {
            int length = 19;

            if (Content.Length % length == 0)
            {
                int    Count = Content.Length / length;
                string DeviceType;
                string CommandId;
                byte[] SubContent;
                for (int i = 0; i < Count; i++)
                {
                    DeviceType = ConverUtil.ByteToStr_Q(Content, 7 + (length * i), 2);
                    CommandId  = Content[13 + (i * length)].ToString();
                    SubContent = ConverUtil.Byte_Q(Content, length * i, length);
                    ICommand cmd;
                    switch (DeviceType)
                    {
                    case "8016":
                        switch (CommandId)
                        {
                        case "1":
                            cmd = new DJJ_61443_8016_01(SubContent, StationId, PlatformTime);
                            break;

                        default:
                            cmd = new IgnoreCommand();
                            break;
                        }
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    cmd.Execute();
                }
            }
            else
            {
                MyLibrary.Log.Fatal(NAME + "长度出错;原始代码:" + MyLibrary.ConverUtil.ByteToHStr(Content));
            }

            return(true);
        }
        public ActionResult PostBlabbers(string blabberUsername, string command)
        {
            if (IsUserLoggedIn() == false)
            {
                return(RedirectToLogin(HttpContext.Request.RawUrl));
            }

            var username = GetLoggedInUsername();

            try
            {
                using (var dbContext = new BlabberDB())
                {
                    dbContext.Database.Connection.Open();

                    IBlabberCommand cmd;
                    switch (command)
                    {
                    case "listen":
                        cmd = new ListenCommand(dbContext.Database.Connection, username);
                        break;

                    case "ignore":
                        cmd = new IgnoreCommand(dbContext.Database.Connection, username);
                        break;

                    default:
                        throw new InvalidOperationException($"The command '{command}' was not recognized.");
                    }

                    cmd.Execute(blabberUsername);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            var viewModel = PopulateBlabbersViewModel("blab_name ASC", username);

            return(View(viewModel));
        }
Exemplo n.º 7
0
        public bool Execute()
        {
            string SubCmd = _content[0].ToString();
            int    Length = Convert.ToInt32(ConverUtil.ByteToStr_2(_content, 1));

            byte[] Content = new byte[Length];
            Array.Copy(_content, 3, Content, 0, Length);
            ICommand cmd;

            switch (SubCmd)
            {
            case "1":
                cmd = new HU_3_1(Content, StationId, PlatformTime);
                break;

            default:
                cmd = new IgnoreCommand();
                break;
            }
            cmd.Execute();
            return(true);
        }
Exemplo n.º 8
0
        public bool Execute()
        {
            try
            {
                int    length = 16;
                int    count  = _content.Length / length;
                byte[] DeviceType;
                byte[] content;
                for (int i = 0; i < count; i++)
                {
                    string ddd = _content[i * 16].ToString();
                    if (ddd == "170")
                    {
                        DeviceType = new byte[2];
                        Array.Copy(_content, 2 + (length * i), DeviceType, 0, 2);
                        content = new byte[length - 3];
                        Array.Copy(_content, (length * i) + 1, content, 0, length - 3);
                        ICommand cmd;
                        switch (ConverUtil.ByteToStr_A(DeviceType))
                        {
                        case "0444":
                            cmd = new CeXie_66_0444(content, StationId, PlatformTime);
                            break;

                        default:
                            cmd = new IgnoreCommand();
                            break;
                        }
                        cmd.Execute();
                    }
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error("处理协议格式命令错误:" + ex.Message);
            }

            return(true);
        }
        public bool Execute()
        {
            int length = 19;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string commandid;

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + (length * i), DeviceType, 0, 2);
                commandid = _content[13 + (i * length)].ToString();
                content   = new byte[19];
                Array.Copy(_content, length * i, content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "0410":
                    cmd = new CZW_61444_0410(content, StationId, PlatformTime);
                    break;

                case "0406":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0406_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0406_02(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_0406_04(content, StationId, PlatformTime);
                        break;

                    case "10":
                        cmd = new CZW_61444_0406_10(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0407":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0407_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0407_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0408":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0408_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0408_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0409":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0409_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0409_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0480":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0480_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0480_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040A":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040A_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040A_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040C":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040C_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040C_02(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_040C_04(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040D":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040D_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040D_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040B":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040B_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040B_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0440":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0440_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0440_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61444_0440_03(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_0440_04(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0441":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0441_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0441_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61444_0441_03(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0442":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0442_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0442_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61444_0442_03(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_0442_04(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0417":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0417_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0417_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
Exemplo n.º 10
0
        public bool Execute()
        {
            int    length    = 42;
            int    count     = _content.Length / length;
            string commandId = "";

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                commandId = _content[i * length].ToString();
                content   = new byte[40];
                Array.Copy(_content, 2 + (length * i), content, 0, 40);
                ICommand cmd;
                switch (commandId)
                {
                case "1":
                    cmd = new MJ2_61443_1(content, StationId, PlatformTime);
                    break;

                case "2":
                    cmd = new MJ2_61443_2(content, StationId, PlatformTime);
                    break;

                case "3":
                    cmd = new MJ2_61443_3(content, StationId, PlatformTime);
                    break;

                case "4":
                    cmd = new MJ2_61443_4(content, StationId, PlatformTime);
                    break;

                case "5":
                    cmd = new MJ2_61443_5(content, StationId, PlatformTime);
                    break;

                case "6":
                    cmd = new MJ2_61443_6(content, StationId, PlatformTime);
                    break;

                case "7":
                    cmd = new MJ2_61443_7(content, StationId, PlatformTime);
                    break;

                case "8":
                    cmd = new MJ2_61443_8(content, StationId, PlatformTime);
                    break;

                case "9":
                    cmd = new MJ2_61443_9(content, StationId, PlatformTime);
                    break;

                case "10":
                    cmd = new MJ2_61443_10(content, StationId, PlatformTime);
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
        public bool Execute()
        {
            int length = 27;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string CommandId;

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + (length * i), DeviceType, 0, 2);
                CommandId = _content[13 + (i * length)].ToString();
                content   = new byte[27];
                Array.Copy(_content, length * i, content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "0430":
                    switch (CommandId)
                    {
                    case "1":
                        cmd = new CZW_61504_0430_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61504_0430_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61504_0430_03(content, StationId, PlatformTime);
                        break;

                    //case "4":
                    //    cmd = new CZW_61504_0430_04(content, StationId, PlatformTime);  //振川说暂时不用。
                    //    break;
                    //case "5":
                    //    cmd = new CZW_61504_0430_05(content, StationId, PlatformTime);  //振川说暂时不用。
                    //    break;
                    //case "7":
                    //    cmd = new CZW_61504_0430_07(content, StationId, PlatformTime);
                    //    break;
                    //case "8":
                    //    cmd = new CZW_61504_0430_08(content, StationId, PlatformTime);
                    //    break;
                    //case "10":
                    //    cmd = new CZW_61504_0430_10(content, StationId, PlatformTime);
                    //    break;
                    //case "12":
                    //    cmd = new CZW_61504_0430_12(content, StationId, PlatformTime);
                    //    break;
                    //case "14":
                    //    cmd = new CZW_61504_0430_14(content, StationId, PlatformTime);
                    //    break;
                    case "16":
                        cmd = new CZW_61504_0430_16(content, StationId, PlatformTime);
                        break;

                    case "48":
                        cmd = new CZW_61504_0430_48(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
Exemplo n.º 12
0
        public bool Execute()
        {
            try
            {
                int    CycleNum = 0;
                string CommandIdStr;
                UInt16 lengthInt;
                byte[] CommandId = new byte[2];
                byte[] length    = new byte[2];
                byte[] SubContent;
                for (int i = 0; i < _content.Length; i += CycleNum)
                {
                    Array.Copy(_content, i, CommandId, 0, 2);
                    Array.Copy(_content, 2 + i, length, 0, 2);
                    CommandIdStr = ConverUtil.ByteToStr_A(CommandId);
                    lengthInt    = Convert.ToUInt16(ConverUtil.ByteToStr_A(length), 16);
                    SubContent   = new byte[lengthInt];
                    Array.Copy(_content, 4 + i, SubContent, 0, lengthInt);
                    ICommand cmd;
                    switch (CommandIdStr)
                    {
                    case "0001":
                        cmd = new MJ_33_0001(SubContent, StationId, PlatformTime);     //小写的b到f转成大写的B到F。
                        break;

                    case "0002":
                        cmd = new MJ_33_0002(SubContent, StationId, PlatformTime);
                        break;

                    case "0003":
                        cmd = new MJ_33_0003(SubContent, StationId, PlatformTime);
                        break;

                    case "0012":
                        cmd = new MJ_33_0012(SubContent, StationId, PlatformTime);     //12
                        break;

                    case "0046":
                        cmd = new MJ_33_0046(SubContent, StationId, PlatformTime);
                        break;

                    case "0291":
                        cmd = new MJ_33_0291(SubContent, StationId, PlatformTime);
                        break;

                    case "0292":
                        cmd = new MJ_33_0292(SubContent, StationId, PlatformTime);
                        break;

                    case "0293":
                        cmd = new MJ_33_0293(SubContent, StationId, PlatformTime);
                        break;

                    case "0294":
                        cmd = new MJ_33_0294(SubContent, StationId, PlatformTime);
                        break;

                    case "0295":
                        cmd = new MJ_33_0295(SubContent, StationId, PlatformTime);
                        break;

                    case "0296":
                        cmd = new MJ_33_0296(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    cmd.Execute();
                    CycleNum = 4 + lengthInt;
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error("解析命令:" + ex.Message + " 原始代码:" + ConverUtil.ByteToStr_A(_content));
            }
            return(true);
        }
        public bool Execute()
        {
            int length = 19;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string commandid;

            byte[] SubContent;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + length * i, DeviceType, 0, 2);
                commandid  = _content[13 + i * length].ToString();
                SubContent = new byte[19];
                Array.Copy(_content, length * i, _content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "0406":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0406_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0600":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0600_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0601":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0601_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0602":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0602_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
        public bool Execute()
        {
            int length = 35;

            if (Content.Length % length == 0)
            {
                int    Count = Content.Length / length;
                string DeviceType;
                string CommandId;
                byte[] SubContent;
                for (int i = 0; i < Count; i++)
                {
                    DeviceType = ConverUtil.ByteToStr_Q(Content, 7 + (length * i), 2);
                    CommandId  = Content[13 + (i * length)].ToString();
                    SubContent = ConverUtil.Byte_Q(Content, length * i, length);
                    ICommand cmd;
                    switch (DeviceType)
                    {
                    case "0411":
                        switch (CommandId)
                        {
                        case "1":
                            cmd = new CZW_61506_0411_01(SubContent, StationId, PlatformTime);
                            break;

                        case "2":
                            cmd = new CZW_61506_0411_02(SubContent, StationId, PlatformTime);
                            break;

                        case "3":
                            cmd = new CZW_61506_0411_03(SubContent, StationId, PlatformTime);
                            break;

                        case "17":
                            cmd = new CZW_61506_0411_17(SubContent, StationId, PlatformTime);
                            break;

                        case "19":
                            cmd = new CZW_61506_0411_19(SubContent, StationId, PlatformTime);
                            break;

                        case "21":
                            cmd = new CZW_61506_0411_21(SubContent, StationId, PlatformTime);
                            break;

                        //case "33":
                        //    cmd = new CZW_61506_0411_33(SubContent, StationId, PlatformTime);
                        //    break;
                        case "35":
                            cmd = new CZW_61506_0411_35(SubContent, StationId, PlatformTime);
                            break;

                        case "37":
                            cmd = new CZW_61506_0411_37(SubContent, StationId, PlatformTime);
                            break;

                        case "51":
                            cmd = new CZW_61506_0411_51(SubContent, StationId, PlatformTime);
                            break;

                        case "53":
                            cmd = new CZW_61506_0411_53(SubContent, StationId, PlatformTime);
                            break;

                        case "67":
                            cmd = new CZW_61506_0411_67(SubContent, StationId, PlatformTime);
                            break;

                        case "69":
                            cmd = new CZW_61506_0411_69(SubContent, StationId, PlatformTime);
                            break;

                        case "177":
                            cmd = new CZW_61506_0411_177(SubContent, StationId, PlatformTime);
                            break;

                        case "195":
                            cmd = new CZW_61506_0411_195(SubContent, StationId, PlatformTime);
                            break;

                        case "197":
                            cmd = new CZW_61506_0411_197(SubContent, StationId, PlatformTime);
                            break;

                        case "199":
                            cmd = new CZW_61506_0411_199(SubContent, StationId, PlatformTime);
                            break;

                        case "201":
                            cmd = new CZW_61506_0411_201(SubContent, StationId, PlatformTime);
                            break;

                        default:
                            cmd = new IgnoreCommand();
                            break;
                        }
                        break;

                    case "0426":
                        switch (CommandId)
                        {
                        case "1":
                            cmd = new CZW_61506_0426_01(SubContent, StationId, PlatformTime);
                            break;

                        case "2":
                            cmd = new CZW_61506_0426_02(SubContent, StationId, PlatformTime);
                            break;

                        case "3":
                            cmd = new CZW_61506_0426_03(SubContent, StationId, PlatformTime);
                            break;

                        case "4":
                            cmd = new CZW_61506_0426_04(SubContent, StationId, PlatformTime);
                            break;

                        default:
                            cmd = new IgnoreCommand();
                            break;
                        }
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    cmd.Execute();
                }
            }
            else
            {
                MyLibrary.Log.Fatal(Name + "长度出错;原始代码:" + MyLibrary.ConverUtil.ByteToHStr(Content));
            }

            return(true);
        }