Beispiel #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);
            }
        }
Beispiel #2
0
 private void ExtractService(XmlNode l, ServiceDVBC s)
 {
     ExtractService(l, (Service)s);
     s.Frequency = Convert.ToInt32(l.Attributes["frequency"].Value);
 }