コード例 #1
0
        public void TestFunc()
        {
            string       packetype = "AddDailyBroadcast";
            OperatorData op        = new OperatorData();

            op.OperatorType = packetype;
            op.ModuleType   = "1";
            JavaScriptSerializer Serializer = new JavaScriptSerializer();

            switch (packetype)
            {
            case "AddDailyBroadcast":
            case "ModifyDailyBroadcast":
                string data = "[{\"ItemID\":72076,\"B_Daily_cmd_tag\":1,\"Program\":{\"NetID\":1,\"TSID\":1,\"ServiceID\":1,\"PCR_PID\":1,\"Program_PID\":4013,\"Priority\":4,\"Volume\":1,\"EndTime\":\"2019/5/27 17:35:09\",\"B_Address_type\":1,\"list_Terminal_Address\":[\"634152310000\"]}}]";
                switch (op.ModuleType)
                {
                case "1":        //节目切播
                    // JsonstructureDeal(ref data);
                    ////因为有ValueType缘故 不能反序列化
                    string[]       dataArray = data.Split(',');
                    ChangeProgram_ pp        = new ChangeProgram_();

                    pp.Program = new DailyCmdChangeProgram();


                    foreach (var item in dataArray)
                    {
                        if (item.Contains("ItemID"))
                        {
                            pp.ItemID = item.Split(':')[1];
                        }

                        if (item.Contains("B_Daily_cmd_tag"))
                        {
                            // pp.B_Daily_cmd_tag = Convert.ToByte(item.Split(':')[1]);
                        }
                        if (item.Contains("Program") && !item.Contains("Program_PID"))
                        {
                            pp.Program.NetID = (short)Convert.ToInt32(item.Split(':')[2]);
                        }
                        if (item.Contains("TSID"))
                        {
                            pp.Program.TSID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("ServiceID"))
                        {
                            pp.Program.ServiceID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("PCR_PID"))
                        {
                            pp.Program.PCR_PID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("Program_PID"))
                        {
                            pp.Program.Program_PID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("Priority"))
                        {
                            pp.Program.Priority = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("Volume"))
                        {
                            pp.Program.Volume = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("EndTime"))
                        {
                            string tmp = item.Substring(10);

                            string   tmp1 = tmp.Substring(1);
                            string   tmp2 = tmp1.Substring(0, tmp1.Length - 1);
                            DateTime dd   = Convert.ToDateTime(tmp2);
                            pp.Program.EndTime = dd;
                        }
                        if (item.Contains("B_Address_type"))
                        {
                            pp.Program.B_Address_type = (byte)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("list_Terminal_Address"))
                        {
                            string tmp  = item.Split(':')[1].Substring(1);
                            string tmp2 = tmp.Substring(0, tmp.Length - 4);

                            string tmp3 = tmp2.Substring(1);

                            string   tmp4  = tmp3.Substring(0, tmp3.Length - 1);
                            string[] array = tmp4.Split(',');

                            int arraylength = array.Length;

                            if (SingletonInfo.GetInstance().IsGXProtocol)
                            {
                                for (int i = 0; i < arraylength; i++)
                                {
                                    array[i] = array[i] + "000000";
                                }
                            }


                            pp.Program.list_Terminal_Address = new List <string>(array);
                        }
                    }
                    List <ChangeProgram_> listCP = new List <ChangeProgram_>();
                    listCP.Add(pp);

                    op.Data = listCP;
                    break;

                case "3":        //播放控制
                    JsonstructureDeal(ref data);
                    List <PlayCtrl_> listPC = Serializer.Deserialize <List <PlayCtrl_> >(data);
                    op.Data = listPC;
                    break;

                case "4":        //输出控制
                    JsonstructureDeal(ref data);
                    List <OutSwitch_> listOS = Serializer.Deserialize <List <OutSwitch_> >(data);
                    op.Data = listOS;
                    break;

                case "5":        //RDS编码数据透传
                    JsonstructureDeal(ref data);
                    List <RdsTransfer_> listRT = Serializer.Deserialize <List <RdsTransfer_> >(data);
                    op.Data = listRT;
                    break;
                }

                break;

            case "DelDailyBroadcast":
                string ItemList = "72080";
                op.Data = ItemList;
                break;
            }
            DataDealHelper.MyEvent(op);
        }
コード例 #2
0
        private void AnalysisDailyBroadcastData(IPrimitiveMap map)
        {
            string       packetype = map["PACKETTYPE"].ToString();
            OperatorData op        = new OperatorData();

            op.OperatorType = packetype;
            op.ModuleType   = map["Cmdtag"].ToString();
            JavaScriptSerializer Serializer = new JavaScriptSerializer();

            switch (packetype)
            {
            case "AddDailyBroadcast":
            case "ModifyDailyBroadcast":
                string data = map["data"].ToString();
                switch (op.ModuleType)
                {
                case "1":        //节目切播
                    JsonstructureDeal(ref data);
                    ////因为有ValueType缘故 不能反序列化
                    string[]       dataArray = data.Split(',');
                    ChangeProgram_ pp        = new ChangeProgram_();

                    pp.Program = new DailyCmdChangeProgram();


                    foreach (var item in dataArray)
                    {
                        if (item.Contains("ItemID"))
                        {
                            pp.ItemID = item.Split(':')[1];
                        }

                        if (item.Contains("B_Daily_cmd_tag"))
                        {
                            // pp.B_Daily_cmd_tag = Convert.ToByte(item.Split(':')[1]);
                        }
                        if (item.Contains("Program"))
                        {
                            pp.Program.NetID = (short)Convert.ToInt32(item.Split(':')[2]);
                        }
                        if (item.Contains("TSID"))
                        {
                            pp.Program.TSID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("ServiceID"))
                        {
                            pp.Program.ServiceID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("PCR_PID"))
                        {
                            pp.Program.ServiceID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("Program_PID"))
                        {
                            pp.Program.Program_PID = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("Priority"))
                        {
                            pp.Program.Priority = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("Volume"))
                        {
                            pp.Program.Volume = (short)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("EndTime"))
                        {
                            DateTime dd = Convert.ToDateTime(item.Split(':')[1]);
                            pp.Program.EndTime = dd;
                        }
                        if (item.Contains("B_Address_type"))
                        {
                            pp.Program.B_Address_type = (byte)Convert.ToInt32(item.Split(':')[1]);
                        }

                        if (item.Contains("list_Terminal_Address"))
                        {
                            string   tmp   = item.Split(':')[1].Substring(1);
                            string   tmp2  = tmp.Substring(0, tmp.Length - 4);
                            string[] array = tmp2.Split(',');

                            pp.Program.list_Terminal_Address = new List <string>(array);
                        }
                    }



                    List <ChangeProgram_> listCP = new List <ChangeProgram_>();
                    listCP.Add(pp);

                    op.Data = listCP;
                    break;

                case "3":        //播放控制
                    JsonstructureDeal(ref data);
                    List <PlayCtrl_> listPC = Serializer.Deserialize <List <PlayCtrl_> >(data);
                    op.Data = listPC;
                    break;

                case "4":        //输出控制
                    JsonstructureDeal(ref data);
                    List <OutSwitch_> listOS = Serializer.Deserialize <List <OutSwitch_> >(data);
                    op.Data = listOS;
                    break;

                case "5":        //RDS编码数据透传
                    JsonstructureDeal(ref data);
                    List <RdsTransfer_> listRT = Serializer.Deserialize <List <RdsTransfer_> >(data);
                    op.Data = listRT;
                    break;
                }

                break;

            case "DelDailyBroadcast":
                string ItemList = map["ItemIDList"].ToString();
                op.Data = ItemList;
                break;
            }
            DataDealHelper.MyEvent(op);
        }