Пример #1
0
        private void buttonProcess_Click(object sender, EventArgs e)
        {
            using (System.IO.Stream f = new FileStream(this.textBoxFile.Text, FileMode.Open))
            {
                XmlReader reader = new XmlTextReader(f);
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);

                string json = "";

                if ((string)this.comboBoxNetworkType.SelectedItem == "DVB-S")
                {
                    List<ServiceDVBS> servicelist = new System.Collections.Generic.List<ServiceDVBS>();
                    foreach (var service in doc["services"].ChildNodes)
                    {
                        ServiceDVBS s = new ServiceDVBS();
                        ExtractService((XmlNode)service, s);
                        servicelist.Add(s);
                    }
                    json = CreateJSONString(servicelist);
                }
                else if ((string)this.comboBoxNetworkType.SelectedItem == "DVB-T")
                {
                    List<ServiceDVBT> servicelist = new System.Collections.Generic.List<ServiceDVBT>();
                    foreach (var service in doc["services"].ChildNodes)
                    {
                        ServiceDVBT s = new ServiceDVBT();
                        ExtractService((XmlNode)service, s);
                        servicelist.Add(s);
                    }
                    json = CreateJSONString(servicelist);
                }
                else if ((string)this.comboBoxNetworkType.SelectedItem == "DVB-C")
                {
                    List<ServiceDVBC> servicelist = new System.Collections.Generic.List<ServiceDVBC>();
                    foreach (var service in doc["services"].ChildNodes)
                    {
                        ServiceDVBC s = new ServiceDVBC();
                        ExtractService((XmlNode)service, s);
                        servicelist.Add(s);
                    }
                    json = CreateJSONString(servicelist);
                }
                else
                {
                    throw new Exception(string.Format("Unexpected network type '{0}'", (string)this.comboBoxNetworkType.SelectedItem));
                }

                //Trace.WriteLine(json);

                this.textBoxStatusCode.Text = "";
                this.textBoxResponseBody.Text = "";
                SendHTTPRequest(json);
            }
        }
Пример #2
0
 private void ExtractService(XmlNode l, ServiceDVBS s)
 {
     ExtractService(l, (Service)s);
     s.RollOff = Convert.ToInt32(l.Attributes["roll_off"].Value);
     s.ModulationType = Convert.ToInt32(l.Attributes["modulation_type"].Value);
     s.ModulationSystem = Convert.ToInt32(l.Attributes["modulation_system"].Value);
     s.Fec = l.Attributes["fec"].Value;
     s.Symbolrate = Convert.ToInt32(l.Attributes["symbolrate"].Value);
     s.Polarity = l.Attributes["polarity"].Value;
     s.Frequency = Convert.ToInt32(l.Attributes["frequency"].Value);
     s.Position = l.Attributes["position"].Value;
 }