public void MainActivity()
        {
            try
            {
                Place objPlace = new Place();
                List <RecordsModel> objRecordsModel = new List <RecordsModel>();
                List <RecordsModel> objCityList     = new List <RecordsModel>();

                //fetching country, state, city name from govt api
                objRecordsModel = objPlace.FetchPlace();



                //adding country, state, city name from govt api to database
                objPlace.AddPlace(objRecordsModel);

                //fetching city details from database(above list may keep changing so we are taking city details from database)
                objCityList = objPlace.FetchCity();

                //fetching station records from pvt api based on the city
                foreach (var cityRecord in objCityList)
                {
                    Place objPlace1 = new Place();
                    List <StationModel> objStationList = new List <StationModel>();
                    string cityId = cityRecord.id;
                    string city   = cityRecord.city;

                    ////for debugger point
                    //string str = "";

                    //on the basis of city we call below function and get the station list with aqi,name & lat long from pvt api
                    objStationList = objPlace1.FetchStation(city);

                    //add station name,aqi, lat long into the database
                    objPlace1.addStation(objStationList, cityId);

                    if (objStationList != null)
                    {
                        //fetch and add pollutants of stations of every city.
                        Pollutant objPollutant = new Pollutant();
                        objPollutant.FetchAddPollutants(objStationList);
                    }
                }
            }

            catch (Exception ex)
            {
                string message = ex.ToString();
            }
        }
Beispiel #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string name = Pname.Text;
            string desc = PDesc.Text;
            string loca = PLocation.Text;
            int    cat  = int.Parse(category.SelectedItem.Value);
            string reg  = region.SelectedItem.Value;

            var    folder   = Server.MapPath("~/uploads");
            string fileName = Path.GetFileName(FileUpload.PostedFile.FileName);
            string filePath = "~/uploads/" + fileName;

            imgName.Text = fileName.ToString();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            FileUpload.PostedFile.SaveAs(Server.MapPath(filePath));

            Place pl = new Place(name, desc, loca, cat, filePath, reg);

            int result = pl.AddPlace();

            if (result == 1)
            {
                lblMsg.Text      = "Place successfully added!";
                lblMsg.ForeColor = System.Drawing.Color.Green;
                Pname.Text       = "";
                PDesc.Text       = "";
                PLocation.Text   = "";
                category.ClearSelection();
                imgName.Text = "";
                region.ClearSelection();
                Response.Redirect("~/Views/Places/ViewAllPlaces.aspx");
            }
            else
            {
                lblMsg.Text      = "An error occured while adding, try again.";
                lblMsg.ForeColor = System.Drawing.Color.Red;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Добавление новой площадки
 /// </summary>
 private void InsAddPlaceExecute()
 {
     try
     {
         var selPlace = new SelectPlace();
         var placeId  = selPlace.Select();
         if (!placeId.IsValidEx())
         {
             return;
         }
         var place = Place.AddPlace(placeId);
         if (place != null)
         {
             place.IsVisualPlaceOn = true;
         }
         // Запись статистики
         PluginStatisticsHelper.AddStatistic();
     }
     catch (Exception ex)
     {
         InsService.ShowMessage(ex, "Ошибка");
     }
 }