Beispiel #1
0
        private void ImportManufacturers()
        {
            JArray jManufacturers = ReadJSON.ReadArray(directory + "/manufacturers.json");

            foreach (JObject jManufacturer in jManufacturers)
            {
                int      id          = jManufacturer.GetValue("id").ToObject <int>();
                String   name        = jManufacturer.GetValue("name").ToObject <String>();
                String   url         = jManufacturer.GetValue("url").ToObject <String>();
                String   imgurl      = jManufacturer.GetValue("imgUrl").ToObject <String>();
                String[] array_years = jManufacturer.GetValue("years").ToObject <String[]>();
                String   years       = "[" + String.Join(",", array_years) + "]";
                Console.WriteLine(id + " : " + name);
                manufacturers.Add(id, name);

                db.InsertManufacturer(id, name, url, imgurl, years);
            }
        }
Beispiel #2
0
        private void ImportManufacturerBikes(int pId, String pName)
        {
            DateTime date          = DateTime.Now;
            JObject  jManufacturer = ReadJSON.ReadObject(directory + "/" + pName + ".json");
            JArray   jBikes        = jManufacturer.GetValue("bikes").ToObject <JArray>();

            foreach (JObject jBike in jBikes)
            {
                int    id            = jBike.GetValue("id").ToObject <int>();
                String name          = jBike.GetValue("name").ToObject <String>();
                String url           = jBike.GetValue("urlMotoplanete").ToObject <String>();
                String imgurl        = jBike.GetValue("urlImgMotoplanete").ToObject <String>();
                int?   year          = jBike.GetValue("year").ToObject <int?>();
                int?   maxSpeed      = jBike.GetValue("maxSpeed").ToObject <int?>();
                int?   zeroToHundred = jBike.GetValue("zeroToHundred").ToObject <int?>();
                int?   price         = jBike.GetValue("price").ToObject <int?>();

                String category   = jBike.GetValue("category").ToObject <String>();
                int    idCategory = ImportCategory(category);

                int idRearAxle     = ImportRearAxle(jBike.GetValue("rearAxle").ToObject <JObject>());
                int idFrontAxle    = ImportFrontAxle(jBike.GetValue("frontAxle").ToObject <JObject>());;
                int idEngine       = ImportEngine(jBike.GetValue("engine").ToObject <JObject>());;
                int idTransmission = ImportTransmission(jBike.GetValue("transmission").ToObject <JObject>());;
                int idFrame        = ImportFrame(jBike.GetValue("frame").ToObject <JObject>());

                int?idModele = null;
                if (name != null)
                {
                    year = Int32.Parse(name.Substring(name.Length - 5));
                }

                db.InsertBike(id, name, url, imgurl, year, maxSpeed, zeroToHundred, price, idCategory, idRearAxle, idFrontAxle, idEngine, idTransmission, idFrame, pId, date, idModele);
                date = date.AddHours(-1);
            }
        }