Esempio n. 1
0
 public static IQueryable <CitiesDataContext> GetCities()
 {
     SQLworker.SetConnect();
     rsl = SQLworker.GetCitiesList();
     SQLworker.CloseConnect();
     return(rsl.citiesList.AsQueryable());
 }
Esempio n. 2
0
        //Возвращает регионы
        public RegionCitiesLists GetRegionCitiesList()
        {
            RegionCitiesLists reglist = new RegionCitiesLists();

            List <RegionsDataContext> regionsList  = new List <RegionsDataContext>();
            List <CitiesDataContext>  citiesList   = new List <CitiesDataContext>();
            List <Cities1>            ListOfCities = new List <Cities1>();
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load("https://pogoda.yandex.ru/static/cities.xml");

            foreach (XmlNode node in xDoc.DocumentElement)
            {
                foreach (XmlNode node2 in node.ChildNodes)
                {
                    if (ParseXMLString(node2.OuterXml, "country=\"") == "Россия")
                    {
                        ListOfCities.Add(new Cities1
                        {
                            citName = node2.InnerText,
                            id      = ParseXMLString(node2.OuterXml, "id=\""),
                            part    = ParseXMLString(node2.OuterXml, "part=\""),
                            region  = ParseXMLString(node2.OuterXml, "region=\"")
                        });
                    }
                }
            }
            var custs = (from customer in ListOfCities
                         select new { customer.part }).Distinct();


            int k = 1;

            foreach (var item in custs)
            {
                regionsList.Add(new RegionsDataContext
                {
                    name     = item.part,
                    regionID = k
                });
                var custs2 = (from customer in ListOfCities
                              select new { customer.citName, customer.part, customer.id }).Where(t => t.part.ToString() == item.part.ToString());
                foreach (var item2 in custs2)
                {
                    citiesList.Add(new CitiesDataContext
                    {
                        name     = item2.citName,
                        regionID = k,
                        yandexID = int.Parse(item2.id)
                    });
                }
                k++;
            }
            reglist.citiesList  = citiesList;
            reglist.regionsList = regionsList;
            return(reglist);
        }
Esempio n. 3
0
        public Settings()
        {
            InitializeComponent();
            SQLiteDatabaseWorker SQLworker = new SQLiteDatabaseWorker();

            SQLworker.SetConnect(Program.DBName);
            rsl = SQLworker.GetCitiesList();
            SQLworker.CloseConnect();
            //rsl = ym.GetRegionCitiesList();
        }