예제 #1
0
 private void AddButton_Click(object sender, EventArgs e)
 {
     Add ad = new Add(rts);
     ad.ShowDialog();
     if (rts != null)
     {
         RoutesBoxList.Items.Clear();
         rts = ad.getRTS();
         for (int i = 0; i < rts.getRoute().Count; i++)
             RoutesBoxList.Items.Add(ad.getRTS().getRoutebyId(i).getCateg());
     }
     else
     {
         RoutesBoxList.Items.Clear();
         rts = ad.getRTS();
         for (int i = 0; i < ad.getRTS().getRoute().Count; i++)
             RoutesBoxList.Items.Add(ad.getRTS().getRoutebyId(i).getCateg());
     }
 }
예제 #2
0
        private void readJson(string fileToOpen)
        {
            try
            {
                JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();

                byte[] byteArray = System.IO.File.ReadAllBytes(fileToOpen);

                string jsonResponse = System.Text.Encoding.UTF8.GetString(byteArray);
                RoutesVerwaltung singlePerson = jsonSerializer.Deserialize<RoutesVerwaltung>(jsonResponse);
                rts = singlePerson;

                var jss = new JavaScriptSerializer();
                var dict = jss.Deserialize<Dictionary<string, dynamic>>(jsonResponse);
                                ProgressBarStatus();
                var json = jss.Serialize(dict);
                //RoutesBoxList.Items.Add(singlePerson.getRoute().Count);
                //RoutesBoxList.Items.Add(json);
                //RoutesBoxList.Items.Add(singlePerson.children);
                //singlePerson.getRoutebyId(1).getCateg();
                RoutesBoxList.Items.Clear();
                for (int i = 0; i < rts.getRoute().Count; i++)
                {
                    RoutesBoxList.Items.Add(rts.getRoutebyId(i).getCateg());
                }

                //RoutesBoxList.Items.Add(jsonResponse);
                //RoutesBoxList.Items.Add(singlePerson.getCateg());

            }
            catch (Exception e)
            {
                RoutesBoxList.Items.Add("Cannot deserialize json " + fileToOpen);
            }
            /*var json = System.IO.File.ReadAllText(@"D:\App\VertrigoServ\www\dialog\RTSBapp\data\TransportTable.json");

            var objects = JArray.Parse(json); // parse as array
            foreach (JObject root in objects)
            {
                foreach (KeyValuePair<String, JToken> app in root)
                {
                    //var appName = app.Key;
                    var LEVEL = (String)app.Value["LEVEL"];
                    //var value = (String)app.Value["Value"];

                    //Console.WriteLine(appName);
                    //Console.WriteLine(description);
                    //Console.WriteLine(value);
                    //Console.WriteLine("\n");
                    RoutesBoxList.Items.Add(LEVEL);
                }
            }*/
               /* var json = System.IO.File.ReadAllText(@"D:\App\VertrigoServ\www\dialog\RTSBapp\data\TransportTable.json");
            WebClient c = new WebClient();
            var data = c.DownloadString("http://127.0.0.1:25065/dialog/RTSBapp/data/TransportTable.json");
            //Console.WriteLine(data);
            JObject o = JObject.Parse(data);
            RoutesBoxList.Items.Add("Name: " + o["CATEG"]);*/
        }