protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    Cities      obj      = new Cities();
                    List <City> cityList = obj.GetCities();

                    dpFromCity.Items.Add("None");
                    foreach (City c in cityList)
                    {
                        ListItem item = new ListItem(c.Name, c.CityId.ToString());
                        dpFromCity.Items.Add(item);
                    }
                    dpFromCity.DataBind();

                    dpToCity.Items.Add("None");
                    foreach (City c in cityList)
                    {
                        ListItem item = new ListItem(c.Name, c.CityId.ToString());
                        dpToCity.Items.Add(item);
                    }
                    dpToCity.DataBind();
                }
                catch (CityManagerException ex)
                {
                    lblError.Text = ex.Message;
                }
            }
        }
 public ActionResult Index(IFormCollection collection)
 {
     _options.LoadPostData(collection);
     ViewBag.DemoOptions = _options;
     ViewBag.Countries   = Countries.GetCountries();
     ViewBag.Cities      = Cities.GetCities();
     return(View());
 }
示例#3
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                if (!lastRun.HasValue || (lastRun.HasValue && !lastRun.Value.Equals(DateTime.Now.Date)))
                {
                    lastRun = DateTime.Now.Date;

                    _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);

                    CsvRow newRow = new CsvRow();
                    newRow.Date = DateTime.Now.Date.ToString("dd.MM.yyyy");

                    string path       = _env.ContentRootPath;
                    string olxRentCsv = $"{path}/olxData.csv";

                    List <CsvRow> records = _localCSVHelper.ReadCSVOldData(olxRentCsv);

                    if (!records.Any(x => x.Date == newRow.Date))
                    {
                        foreach (var city in Cities.GetCities())
                        {
                            try
                            {
                                (int rentCount, int sellCount) = ReadDataFromOlx(city);
                                newRow = GetNewRowData(newRow, city, rentCount, sellCount);
                            }
                            catch (Exception ex)
                            {
                                _logger.LogInformation(ex.Message, DateTimeOffset.Now);
                            }
                        }

                        _localCSVHelper.SaveCSVData(records, newRow, olxRentCsv);
                    }
                }

                int delay = 1000 * 60 * 60 * 1; //1h

                await Task.Delay(delay, stoppingToken);
            }
        }
示例#4
0
 private void listCoun_SelectedIndexChanged(object sender, EventArgs e)
 {
     Cit.GetCities();
 }