Exemplo n.º 1
0
        // GET: Home
        public ActionResult Index()
        {
            ForecastViewModel forecastView = new ForecastViewModel()
            {
                cities          = Cities,
                weatherServices = WeatherServices
            };
            Guid requestGuid = Guid.Empty;

            Guid.TryParse(Request.Cookies["EnteredData"], out requestGuid);
            if (requestGuid != Guid.Empty)
            {
                Response.Cookies.Append("EnteredData", requestGuid.ToString(), new CookieOptions()
                {
                    Expires     = DateTimeOffset.Now.AddMinutes(30),
                    IsEssential = true
                });
                if (sessionDictionary.ContainsKey(requestGuid))
                {
                    return(View("\\Pages\\Index.cshtml", sessionDictionary[requestGuid]));
                }
            }
            else
            {
                Response.Cookies.Append("EnteredData", Guid.NewGuid().ToString(), new CookieOptions()
                {
                    Expires     = DateTimeOffset.Now.AddMinutes(30),
                    IsEssential = true
                });
            }


            return(View("\\Pages\\Index.cshtml", forecastView));
        }
Exemplo n.º 2
0
 private void BindForecastCell(UITableViewCell cell, ForecastViewModel forecast, NSIndexPath path)
 {
     cell.TextLabel.Text = forecast.DayTemp;
     //cell.DetailTextLabel.Text = forecast.DayOfWeek;
     //cell.ImageView.SetImage(new NSUrl(forecast.Icon), UIImage.FromBundle("01d.png"));
     cell.ImageView.SetImage(new NSUrl("http://openweathermap.org/img/w/02d.png"), UIImage.FromBundle("01d.png"));
 }
Exemplo n.º 3
0
        private async Task ShowForecast()
        {
            var forecastViewModel = new ForecastViewModel(_repository, _windowService);
            await forecastViewModel.Initialize();

            _windowService.OpenDialogWindow(forecastViewModel);
        }
Exemplo n.º 4
0
 public ForecastPage(ForecastViewModel forecastViewModel)
 {
     InitializeComponent();
     Init();
     ForecastViewModel      = forecastViewModel;
     ForecastViewModel.Page = this;
     this.BindingContext    = ForecastViewModel;
 }
Exemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            // Binding the DataContext to the needed Viewmodel
            // TODO: create VM locator
            DataContext = new ForecastViewModel(_darkSkyService);
        }
Exemplo n.º 6
0
        public void MajdEgyForecastModelDataPointPeldanytTranszformalokForecastViewModelTipusra()
        {
            var forecast = ForecastDataPointFactory();

            forecastViewModel = mapper.Map <ForecastViewModel>(forecast);

            logger.Information("Mapped from {@ForecastDataPoint} to {@ForecastViewModel}", forecast, forecastViewModel);
        }
        public MainView()
        {
            InitializeComponent();

            _forecastViewModel = new ForecastViewModel();

            InitializeDataBindings();
        }
Exemplo n.º 8
0
        public ActionResult Hunter()
        {
            var query = from d in db.Demands
                        join cq in db.CustomerQohs on d.Pn equals cq.Pn
                        join tx in db.TxQohs on d.Pn equals tx.Pn
                        join sc in db.ShipCommits on d.Pn equals sc.Pn
                        join s in db.ShipIns.Where(r => r.ShipInStatusId != 3) on d.Pn equals s.Pn into incgroup
                        join mp in db.MasterPartLists on d.Pn equals mp.CustomerPn
                        where mp.CustomerId == 4 && mp.CustomerDivisionId == 7
                        select new
            {
                CustomerPn = mp.CustomerPn,
                COH        = cq.Qoh,
                TOH        = tx.Qoh,
                Wk1        = (cq.Qoh + tx.Qoh - d.DemandWk30 + sc.ShipCommit30),
                Wk2        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 + sc.ShipCommit30 + sc.ShipCommit31),
                Wk3        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32),
                Wk4        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33),
                Wk5        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34),
                Wk6        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 - d.DemandWk35 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34 + sc.ShipCommit35),
                Wk7        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 - d.DemandWk35 - d.DemandWk36 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34 + sc.ShipCommit35 + sc.ShipCommit36),
                Wk8        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 - d.DemandWk35 - d.DemandWk36 - d.DemandWk37 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34 + sc.ShipCommit35 + sc.ShipCommit36 + sc.ShipCommit37),
                Wk9        = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 - d.DemandWk35 - d.DemandWk36 - d.DemandWk37 - d.DemandWk38 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34 + sc.ShipCommit35 + sc.ShipCommit36 + sc.ShipCommit37 + sc.ShipCommit38),
                Wk10       = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 - d.DemandWk35 - d.DemandWk36 - d.DemandWk37 - d.DemandWk38 - d.DemandWk39 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34 + sc.ShipCommit35 + sc.ShipCommit36 + sc.ShipCommit37 + sc.ShipCommit38 + sc.ShipCommit39),
                Wk11       = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 - d.DemandWk35 - d.DemandWk36 - d.DemandWk37 - d.DemandWk38 - d.DemandWk39 - d.DemandWk40 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34 + sc.ShipCommit35 + sc.ShipCommit36 + sc.ShipCommit37 + sc.ShipCommit38 + sc.ShipCommit39 + sc.ShipCommit40),
                Wk12       = (cq.Qoh + tx.Qoh - d.DemandWk30 - d.DemandWk31 - d.DemandWk32 - d.DemandWk33 - d.DemandWk34 - d.DemandWk35 - d.DemandWk36 - d.DemandWk37 - d.DemandWk38 - d.DemandWk39 - d.DemandWk40 - d.DemandWk41 + sc.ShipCommit30 + sc.ShipCommit31 + sc.ShipCommit32 + sc.ShipCommit33 + sc.ShipCommit34 + sc.ShipCommit35 + sc.ShipCommit36 + sc.ShipCommit37 + sc.ShipCommit38 + sc.ShipCommit39 + sc.ShipCommit40 + sc.ShipCommit41),
            };

            List <ForecastViewModel> quantities = new List <ForecastViewModel>();

            foreach (var f in query.ToList())
            {
                ForecastViewModel mymodel = new ForecastViewModel()
                {
                    CustomerPn = f.CustomerPn,
                    COH        = f.COH,
                    TOH        = f.TOH,
                    Wk1        = f.Wk1,
                    Wk2        = f.Wk2,
                    Wk3        = f.Wk3,
                    Wk4        = f.Wk4,
                    Wk5        = f.Wk5,
                    Wk6        = f.Wk6,
                    Wk7        = f.Wk7,
                    Wk8        = f.Wk8,
                    Wk9        = f.Wk9,
                    Wk10       = f.Wk10,
                    Wk11       = f.Wk11,
                    Wk12       = f.Wk12
                };

                quantities.Add(mymodel);
            }

            return(View("Hunter", quantities));

            //return View(db.Demands.ToList());
        }
Exemplo n.º 9
0
        public async Task <ActionResult> Forecast(ForecastViewModel vm)
        {
            if (ModelState.IsValid)
            {
                //try to parse vm address as an integer for zip code, or text for city and state
                bool isZip = isZipCode(vm.Address) ? true : false;

                //post to openweather for temperature, min/max
                string queryString = "";

                if (isZip)
                {
                    //check to see if there exists a record with same zip code captured in last 30 minutes
                    WeatherResult cacheRes = getFreshCache(vm.Address, DateTime.Now);

                    if (cacheRes != null)
                    {
                        vm.temp     = cacheRes.Temp;
                        vm.temp_max = cacheRes.Max_temp;
                        vm.temp_min = cacheRes.Min_temp;
                        vm.cacheHit = true;
                        return(View("ForecastDetails", vm));
                    }
                    queryString = "?zip=" + vm.Address + ",us&units=imperial&" + appKeyQueryString;
                }
                else
                {
                    queryString = "?q=" + vm.Address + ",us&units=imperial&" + appKeyQueryString;
                }

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(weatherURL);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.GetAsync(queryString).Result;
                if (response.IsSuccessStatusCode)
                {
                    //parse results and set to view model details
                    string jsonRes = await response.Content.ReadAsStringAsync();

                    Forecast forecast = JsonConvert.DeserializeObject <Forecast>(jsonRes);

                    vm.temp     = forecast.main.temp;
                    vm.temp_max = forecast.main.temp_max;
                    vm.temp_min = forecast.main.temp_min;

                    //if request was by zip, cache results for later storage
                    if (isZip)
                    {
                        storeWeatherResults(vm.Address, DateTime.Now, vm.temp, vm.temp_max, vm.temp_min);
                    }

                    return(View("ForecastDetails", vm));
                }

                client.Dispose();
            }
            return(View(vm));
        }
Exemplo n.º 10
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            CityName.Text = "7-Day Forecast for " + DataRepo.SelectedCity.Name;

            FVM = new ForecastViewModel();
            await FVM.LoadForecasts(DataRepo.SelectedCity.Coords.Lat, DataRepo.SelectedCity.Coords.Lon);
        }
Exemplo n.º 11
0
        public ForecastView(City city)
        {
            BindingContext = new ForecastViewModel(city);
            var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(0, 8, 0, 8)
            };

            var activity = new ActivityIndicator
            {
                IsEnabled = true
            };

            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            stack.Children.Add(activity);

            var label = new Label()
            {
                Text = "Loading...",
                HorizontalOptions = LayoutOptions.Center
            };

            label.SetBinding(Label.IsVisibleProperty, "IsBusy");
            label.SetBinding(Label.TextProperty, "LoadingLabel");
            stack.Children.Add(label);

            var listView = new ListView();

            listView.SetBinding(ListView.IsVisibleProperty, "IsNotBusy"); //TODO: change this to templated call

            listView.ItemsSource = ViewModel.Items;

            var cell = new DataTemplate(typeof(ImageCell));

            cell.SetBinding(ImageCell.TextProperty, new Binding(".", converter: new ForecastValueConverter()));
            cell.SetBinding(ImageCell.DetailProperty, "Summary");
            cell.SetBinding(ImageCell.ImageSourceProperty, new Binding("IconCode", stringFormat: "cbc_white_{0:D2}.png"));

            listView.ItemTapped += (sender, args) =>
            {
                if (listView.SelectedItem == null)
                {
                    return;
                }

                //this.Navigation.PushAsync(new BlogDetailsView(listView.SelectedItem as FeedItem));
                listView.SelectedItem = null;
            };

            listView.ItemTemplate = cell;

            stack.Children.Add(listView);

            Content = stack;
        }
Exemplo n.º 12
0
        public ActionResult _Commits(int customer, int div, int mls)
        {
            var query = from d in db.Demands
                        join cq in db.CustomerQohs on d.Pn equals cq.Pn
                        join tx in db.TxQohs on d.Pn equals tx.Pn
                        join sc in db.ShipCommits on d.Pn equals sc.Pn
                        join s in db.ShipIns.Where(r => r.ShipInStatusId != 3) on d.Pn equals s.Pn into incgroup
                        join mp in db.MasterPartLists on d.Pn equals mp.CustomerPn
                        where mp.CustomerId == customer && mp.CustomerDivisionId == div && mp.MlsDivisionId == mls
                        select new
            {
                CustomerPn = mp.CustomerPn,
                COH        = cq.Qoh,
                TOH        = tx.Qoh,
                Wk1        = sc.ShipCommit30,
                Wk2        = sc.ShipCommit31,
                Wk3        = sc.ShipCommit32,
                Wk4        = sc.ShipCommit33,
                Wk5        = sc.ShipCommit34,
                Wk6        = sc.ShipCommit35,
                Wk7        = sc.ShipCommit36,
                Wk8        = sc.ShipCommit37,
                Wk9        = sc.ShipCommit38,
                Wk10       = sc.ShipCommit39,
                Wk11       = sc.ShipCommit40,
                Wk12       = sc.ShipCommit41
            };

            List <ForecastViewModel> quantities = new List <ForecastViewModel>();

            foreach (var f in query.ToList())
            {
                ForecastViewModel mymodel = new ForecastViewModel()
                {
                    CustomerPn = f.CustomerPn,
                    COH        = f.COH,
                    TOH        = f.TOH,
                    Wk1        = f.Wk1,
                    Wk2        = f.Wk2,
                    Wk3        = f.Wk3,
                    Wk4        = f.Wk4,
                    Wk5        = f.Wk5,
                    Wk6        = f.Wk6,
                    Wk7        = f.Wk7,
                    Wk8        = f.Wk8,
                    Wk9        = f.Wk9,
                    Wk10       = f.Wk10,
                    Wk11       = f.Wk11,
                    Wk12       = f.Wk12
                };

                quantities.Add(mymodel);
            }

            return(View("_ShipCommitPartialView", quantities));
            //return View();
        }
Exemplo n.º 13
0
        public ActionResult Forecast()
        {
            var vm = new ForecastViewModel
            {
                AvailablePlayers = getAvailablePlayersSelectListItems()
            };

            return(View(vm));
        }
Exemplo n.º 14
0
        async Task LoadForecastAsync()
        {
            _forecastStackPanel.Opacity = 0;

            var forecast = await _weatherService.GetForecastAsync();

            DataContext = new ForecastViewModel(this, forecast);

            _fadeIn.Begin();
        }
Exemplo n.º 15
0
 public ForecastPage()
 {
     InitializeComponent();
     Init();
     ForecastViewModel = new ForecastViewModel(this)
     {
         Navigation = this.Navigation
     };
     this.BindingContext = ForecastViewModel;
 }
Exemplo n.º 16
0
        public async Task <ActionResult> Index()
        {
            ForecastViewModel forecast = new ForecastViewModel();

            using (HttpClient client = new HttpClient())
            {
                forecast = await client.GetFromJsonAsync <ForecastViewModel>("http://api.weatherstack.com/current?access_key=" + key + "&query=Lviv");
            }

            return(View(forecast));
        }
Exemplo n.º 17
0
 private void AssertForecastViewModel(ForecastViewModel sut)
 {
     Assert.IsNotNull(sut);
     Assert.AreEqual(new DateTimeOffset(2018, 12, 17, 23, 0, 0, TimeSpan.FromSeconds(0)), sut.Time);
     Assert.AreEqual("Ködös idő reggel.", sut.Summary);
     Assert.AreEqual("fog", sut.Icon);
     Assert.AreEqual(double.MaxValue, sut.Temperature);
     Assert.AreEqual(double.MaxValue, sut.ApparentTemperature);
     Assert.AreEqual(double.MaxValue, sut.AtmosphericPressure);
     Assert.AreEqual(double.MaxValue, sut.WindSpeed);
     Assert.AreEqual(double.MaxValue, sut.Humidity);
     Assert.AreEqual(int.MaxValue, sut.UvIndex);
 }
Exemplo n.º 18
0
        public IActionResult Forecast(double lat, double lon)
        {
            var fvm    = new ForecastViewModel();
            var result = Helpers.GetForecastByCoords(lat, lon);
            var code   = Convert.ToInt32(Helpers.Parse(result, "cod"));

            if (code == 200)
            {
                fvm.FiveDay = Helpers.GenerateForecast(result);
            }
            // Need to handle unsuccessful queries

            return(View(fvm));
        }
Exemplo n.º 19
0
        public async void GetForecast()
        {
            // Instantiate the viewModel list
            ForecastViewModel viewModel = new ForecastViewModel {
                Forecasts = new ObservableCollection <Forecast>()
            };

            HttpClient client = new HttpClient()
            {
                BaseAddress =
                    new Uri(
                        "https://api.openweathermap.org/")
            };
            var    apiKey      = ResourceLoader.GetForCurrentView().GetString("ApiKey");
            string requestUri  = "data/2.5/forecast?zip=54915&appid=" + apiKey; // API Key here
            var    result      = client.GetAsync(requestUri).Result;
            var    content     = result.Content.ReadAsStringAsync();
            var    text        = content.Result;
            var    weatherData = JsonConvert.DeserializeObject <ExtendedForecast>(text);

            // Change temperature from Kelvin to Fahrenheit, with 1 decimal place
            foreach (var item in weatherData.list)
            {
                // Convert temperatures from Kelvin to Fahrenheit
                item.main.temp     = convertToFahrenheit(item.main.temp);
                item.main.temp_min = convertToFahrenheit(item.main.temp_min);
                item.main.temp_max = convertToFahrenheit(item.main.temp_max);

                // convert OpenWeatherMap icon from a sprite into a png image from the Images folder
                item.weather[0].icon = GetUsableWeatherIcon(item.weather[0].icon);


                // Get day of week for forecast
                if (item.dt_txt >= DateTime.Now)
                {
                    // Expected input: 2018/01/01 06:00:00
                    // Expected output: Tuesday, January 01 (or January 1)
                    var forecastDate = item.dt_txt.ToString("dddd, MMMM dd");
                    item.dayofweek = forecastDate;
                }
                // Show 1 temperature per day
                var index = weatherData.list.IndexOf(item);
                if (((index + 7) % 8) == 0)
                {
                    viewModel.Forecasts.Add(item);
                }
            }
            //viewModel.Forecasts = weatherData.list;
            DisplayWeather.ItemsSource = viewModel.Forecasts;
        }
Exemplo n.º 20
0
 /// <summary>
 ///报表8:假期交通量统计表
 /// </summary>
 /// <returns></returns>
 public ActionResult HDaySta()
 {
     try
     {
         ForecastViewModel model = ReportFactory.Instance.report8.GetForecastWhere();
         ViewBag.StartTime = model.ForecastDate.Value.ToString("yyyy年M月d日");
         HolidayConfigViewModel pHdayConfig = ReportFactory.Instance.GetHolidayConfigById(8);
         ViewBag.HolidayStartTime = pHdayConfig.HolidayStartTime.Value.ToString("yyyy年M月d日");
         ViewBag.HolidayEndTime   = pHdayConfig.HolidayEndTime.Value.ToString("yyyy年M月d日");
     }
     catch (Exception ex)
     {
         SystemLog.GetInstance().Info(ex.Message);
     }
     return(View());
 }
        async Task LoadForecastAsync()
        {
            try
            {
                _forecastStackPanel.Opacity = 0;

                var forecast = await _weatherService.GetForecastAsync();

                DataContext = new ForecastViewModel(this, forecast);

                _fadeIn.Begin();
            }
            catch (Exception ex) when(DebugHelper.IsHandled <ForecastWeather>(ex))
            {
                // If we're unable to load, this is probably a configuration issue.
            }
        }
Exemplo n.º 22
0
        private void BindViewHolder(CachingViewHolder holder, ForecastViewModel forecast, int position)
        {
            var image = holder.FindCachedViewById <ImageView>(Resource.Id.FCT_IconImageView);

            ImageDownloader.AssignImageAsync(image, forecast.Icon, this);

            var dayOfWeek = holder.FindCachedViewById <TextView>(Resource.Id.FCT_DayOfWeekTextView);

            dayOfWeek.Text = forecast.DayOfWeek;

            var description = holder.FindCachedViewById <TextView>(Resource.Id.FCT_DescriptionTextView);

            description.Text = forecast.Description;

            var dayTemp = holder.FindCachedViewById <TextView>(Resource.Id.FCT_DayTempTextView);

            dayTemp.Text = forecast.DayTemp;
        }
Exemplo n.º 23
0
 /// <summary>
 ///报表9:收费公路运行情况
 /// </summary>
 /// <returns></returns>
 public ActionResult RoadRunSit()
 {
     try
     {
         ConfigTimeViewModel model = ReportFactory.Instance.report9.GetRoadRunSitWhere();
         ViewBag.HolidayStartTime  = model.HolidayStartTime.Value.ToString("yyyy年M月d日");
         ViewBag.HolidayEndTime    = model.HolidayEndTime.Value.ToString("yyyy年M月dd日");
         ViewBag.ComparedStartTime = model.ComparedStartTime.Value.ToString("yyyy年M月d日");
         ViewBag.ComparedEndTime   = model.ComparedEndTime.Value.ToString("yyyy年M月d日");
         ForecastViewModel modelForecast = ReportFactory.Instance.report9.GetForecastWhere();
         ViewBag.ForecastDate  = modelForecast.ForecastDate.Value.ToString("yyyy年M月d日");
         ViewBag.ForecastFloat = modelForecast.ForecastFloat;
     }
     catch (Exception ex)
     {
         SystemLog.GetInstance().Info(ex.Message);
     }
     return(View());
 }
Exemplo n.º 24
0
 /// <summary>
 /// 报表4:重要运输通道主线收费站数据日报表
 /// </summary>
 /// <returns></returns>
 public ActionResult ImpStaDaily()
 {
     try
     {
         ForecastViewModel model = ReportFactory.Instance.report1.GetForecastWhere(new QueryParameters()
         {
             ReportType = 4
         });
         ViewBag.StartTime = model.ForecastDate.Value.ToString("yyyy年M月d日");
         HolidayConfigViewModel pHdayConfig = ReportFactory.Instance.GetHolidayConfigById(4);
         ViewBag.HolidayStartTime = pHdayConfig.HolidayStartTime.Value.ToString("yyyy年M月d日");
         ViewBag.HolidayEndTime   = pHdayConfig.HolidayEndTime.Value.ToString("yyyy年M月d日");
     }
     catch (Exception ex)
     {
         SystemLog.GetInstance().Info(ex.Message);
     }
     return(View());
 }
        private async void ButonSearchLatitudeLongitude_OnClick(object sender, RoutedEventArgs e)
        {
            this.InitVisibility(Visibility.Collapsed);
            try
            {
                var data = await OpenWeatherViewModel.GetWeatherAsync(((ComboBoxItem)ComboBoxCountry.SelectedItem).Tag.ToString(), this.TextBoxPostalCode.Text);

                data.ForecastViewModel = await ForecastViewModel.GetForecastAsync(((ComboBoxItem)ComboBoxCountry.SelectedItem).Tag.ToString(), this.TextBoxPostalCode.Text);

                DataContext = data;

                this.InitVisibility(Visibility.Visible);
            }
            catch (System.Net.Http.HttpRequestException exception)
            {
#if DEBUG
                Console.WriteLine(exception);
#endif
            }
        }
Exemplo n.º 26
0
        private async Task InitializeBetValues(List <ForecastViewModel> model)
        {
            SettingsJson settings = _dataService.GetSettings();

            for (int i = 0; i < settings.ThreadNumbers; i++)
            {
                ForecastViewModel currentForecast = model.LastOrDefault(x =>
                                                                        x.ThreadNumber == i && x.GameResultType == GameResultType.Expectation);

                if (currentForecast == null || currentForecast.BetValue > 0)
                {
                    continue;
                }

                StateJson state = await _algorithmService.CalculateNextStateAsync(currentForecast.Id,
                                                                                  allowIncreaseBet : settings.AllowIncreaseBetValue);

                currentForecast.BetValue = state.Bets[i];
            }
        }
Exemplo n.º 27
0
        public PanoramaPage1()
        {
            InitializeComponent();

            StartPeriodicAgent();

            Loaded += OnLoaded;

            mForecastCityViewModel = new ForecastCityViewModel();

            mWeekDayViewModel             = new WeekDayViewModel();
            WeekDayViewOnPage.DataContext = mWeekDayViewModel;

            mForecastViewModel             = new ForecastViewModel();
            ForecastViewOnPage.DataContext = mForecastViewModel;

            mMainPageViewModel     = new MainPageViewModel();
            FirstPivot.DataContext = mMainPageViewModel;
            DateTime now = DateTime.Now;

            mMainPageViewModel.DateText        = now.ToString("        M/dd dddd", new CultureInfo("zh-TW"));
            mMainPageViewModel.BackgroundImage = mBackgroundImage;
            MainPageLayoutRoot.DataContext     = mMainPageViewModel;

            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings.Contains("lastLaunchTime"))
            {
                TimeSpan difference = DateTime.Now - (DateTime)settings["lastLaunchTime"];
                if (difference.Days >= 13)
                {
                    MessageBox.Show("因為系統會自動關閉不常用的程式背景作業,請至少每兩週開啟一次晴時多雲偶陣雨,讓動態磚能自動更新!");
                }
            }
            settings["lastLaunchTime"] = DateTime.Now;
            settings.Save();

            //WeekDayViewOnPage.DataContext = forecastCityViewModel;
            //WeekDayViewOnPage.DataContext = new WeekDayViewModel();
        }
Exemplo n.º 28
0
        public async Task <IActionResult> UpdateForecast()
        {
            // NOTE: Make dynamic by accepting a location name from the front end.
            var data = await _weatherService.GetWeatherData("Belfast");

            if (!data.IsSuccess)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            var result = new ForecastViewModel
            {
                Today = _mapper.Map <ConsolidatedWeather, DayForecastViewModel>(
                    data.Data.ConsolidatedWeather.First(),
                    opt => opt.AfterMap((src, dst) => dst.WeatherImage = string.Format(_dataProviderSettings.ImageUrlTemplate, dst.WeatherImage))),
                Days = _mapper.Map <IEnumerable <ConsolidatedWeather>, List <DayForecastViewModel> >(
                    data.Data.ConsolidatedWeather.Skip(1),
                    opt => opt.AfterMap((src, dst) => dst.ForEach(d => d.WeatherImage = string.Format(_dataProviderSettings.ImageUrlTemplate, d.WeatherImage))))
            };

            return(Ok(result));
        }
Exemplo n.º 29
0
        /// <summary>
        /// 获取配置预测信息
        /// </summary>
        /// <returns></returns>
        public ForecastViewModel GetForecastWhere()
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                var list = db.OT_HDayConfig.Where(a => a.Id == 8).Select(a => new ForecastViewModel
                {
                    ForecastDate  = a.ForeDate,
                    ForecastFloat = a.ForeFloat
                }).ToList();

                ForecastViewModel model = new ForecastViewModel();
                if (list != null && list.Count > 0)
                {
                    model = list[0];
                }
                else
                {
                    model.ForecastDate  = DateTime.Now.AddDays(-1);
                    model.ForecastFloat = 5;
                }
                return(model);
            }
        }
        public ActionResult Index([Bind(Include = "CityName")] ForecastViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.WeekDays = new List <string>(5);
                    string firstCityName = model.CityName;
                    model.City = _service.GetCity(firstCityName);
                    _service.RefreshWeather(model.City);
                    if (model.City.Name.ToLower() != firstCityName.ToLower())
                    {
                        TempData["error"] = String.Format("Coundnt find {0}, did you mean {1}?", firstCityName, model.City.Name);
                    }

                    int daynr = (int)DateTime.Now.DayOfWeek;
                    while (model.WeekDays.Count() < 5) //antal dagar vi vill blicka framåt med
                    {
                        if (daynr >= 7)                //dagar i veckan
                        {
                            daynr = 0;
                        }
                        model.WeekDays.Add(DateTime.Now.AddDays(model.WeekDays.Count()).DayOfWeek.ToString());
                        daynr++;
                    }
                }
            }
            catch (FileNotFoundException)
            {
                TempData["error"] = String.Format("This city dosent exist.");
            }
            catch (Exception ex)
            {
                return(View("SystemError"));
            }
            return(View(model));
        }