private async Task UpdateBanenInfoAsync() { try { if (_vereniging == null) { _vereniging = await _verenigingRepository.GetVerenigingAsync(); } if (_afhang == null) { _afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); } List <Baan> banen = await _baanRepository.GetBanenByDateAsync(_vereniging.Id, _vereniging.AccommodatieId, DateTime.Now); ResourceType banenResource = new ResourceType { TypeName = "Banen" }; foreach (Baan baan in banen) { banenResource.ResourceCollection.Add(new Resource { DisplayName = baan.Naam, ResourceName = baan.Naam, TypeName = "Banen" }); } Banen.Add(banenResource); } catch (Exception ex) { string message = ex.Message; throw; } }
public async Task CalCulateDuration(TimeSpan duur) { Afhang afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); int count = _cachedReservering.Spelers.Where(s => s.Id != Guid.Empty).Count(); switch (count) { case 0: _cachedReservering.Duur = TimeSpan.FromMinutes(0); break; case 1: _cachedReservering.Duur = TimeSpan.FromMinutes(afhang.Duur_Een); break; case 2: _cachedReservering.Duur = TimeSpan.FromMinutes(afhang.Duur_Twee); break; case 3: _cachedReservering.Duur = TimeSpan.FromMinutes(afhang.Duur_Drie); break; case 4: _cachedReservering.Duur = TimeSpan.FromMinutes(afhang.Duur_Vier); break; default: _cachedReservering.Duur = TimeSpan.FromMinutes(0); break; } if (duur != TimeSpan.Zero) { if (_cachedReservering.Duur > duur) { _cachedReservering.Duur = duur; } } _cachedReservering.EindTijd = _cachedReservering.BeginTijd.Add(_cachedReservering.Duur); }
private async Task UpdateBaanInfoAsync(Baan baan) { try { if (baan != null) { _baan = baan; _reserveringen = new ObservableCollection <Reservering>(); Afhang afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); _reserveringen = await _reserveringRepository.GetReserveringenByBaanAsync(_baan.Id); BeginTijd = DateTime.Now.TimeOfDay.Add(new TimeSpan(0, afhang.Duur_Precisie, 0)); foreach (Reservering reservering in _reserveringen) { if (reservering.BeginTijd < BeginTijd && BeginTijd < reservering.EindTijd) { BeginTijd = reservering.EindTijd.Add(new TimeSpan(0, afhang.Duur_Precisie, 0)); } } Duur = TimeSpan.FromMinutes(afhang.Duur_Vier); foreach (Reservering reservering in _reserveringen) { if (reservering.BeginTijd > BeginTijd) { Duur = reservering.BeginTijd - BeginTijd; break; } } } } catch { _baan = new Baan { Id = Guid.Empty, Naam = "", Nummer = 0 }; //, Baansoort = "", Nummer = 0 }; } try { _reserveringCurrent = await _reserveringRepository.GetReserveringAsync(); } catch { } }
private async Task UpdateWeatherInfoAsync(bool update) { if (_afhang == null) { _afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); } if (_geoposition == null) { _geoposition = await _locationRepository.GetLocationAsync(); } if (_locationModels == null) { _locationModels = await _locationRepository.GetLocationsByLatLon(_geoposition.Coordinate.Point.Position.Latitude, _geoposition.Coordinate.Point.Position.Longitude); } foreach (LocationModel location in _locationModels) { CurrentConditions = await _weatherRepository.GetCurrentConditionsAsync(location.LocationId, update, true); HourlyModels = await _weatherRepository.GetHourlyAsync(location.LocationId, update); } if (CurrentConditions != null) { //await UpdateWeerIcoonAsync(CurrentConditions); /* * _weerIcoon = new Foto(); * Uri WeatherIcon = new Uri(string.Format("ms-appx:///Assets/Weather/{0}.png", CurrentConditions.WeatherCode)); * StorageFile _storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(WeatherIcon); * * try * { * IBuffer readbuffer = await FileIO.ReadBufferAsync(_storageFile); * _weerIcoon.ContentData = readbuffer.ToArray(); * } * catch (Exception ex) * { * string message = ex.Message; * } */ } }
private async Task RetrieveSpeler() { if (!string.IsNullOrWhiteSpace(_verenigingsnummer) && !string.IsNullOrWhiteSpace(_bondsnummer)) { Vereniging vereniging = await _verenigingRepository.GetVerenigingAsync(); Afhang afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); int uitgavemaand = 4; int uitgavejaar = DateTime.Today.Year - _jaar; if (uitgavejaar > 3 || (uitgavejaar >= 3 && DateTime.Today.Month > uitgavemaand)) { _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = "Deze pas is verlopen. Gebruik uw nieuwe pas"; looking = false; return; } if (vereniging != null && vereniging.Nummer == _verenigingsnummer) { if (!string.IsNullOrWhiteSpace(_bondsnummer)) { _speler = await _spelerRepository.GetSpelerByNummerAsync(vereniging.Id, _bondsnummer); bool already = false; if (_speler != null) { Reservering reservering = await _reserveringRepository.GetReserveringAsync(); already = reservering.Spelers.Count(s => s.Id == _speler.Id) > 0; Reserveringen = new ObservableCollection <Reservering>(); Reserveringen = await _reserveringRepository.GetReserveringenBySpelerAsync(_speler.Id); } #region Nieuwe of bestaande reservering wijzigen if (Index != -1) { //Speler zit al in de huidige reservering if (already) { _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = "Deze speler is al geselecteerd."; looking = false; return; } //Speler heeft al andere reserveringen voor vandaag if (_reserveringen.Count > 0) { //Huidig = true; _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = "Deze speler heeft al reservering(en) voor vandaag."; looking = false; return; } //Niet reeds toegevoegd en geen reservingen if (Index >= 0) { await _reserveringRepository.AddSpelerToReserveringAsync(Index, _speler.Id); _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; Action navigateAction = null; var navigationServiceReference = _navigationService; navigateAction = () => navigationServiceReference.Navigate("Spelers", null); navigateAction = async() => { //await reserveringRepositoryReference.SetReserveringAsync(reserveringReference); navigationServiceReference.Navigate("Spelers", null); }; navigateAction(); /* * Action navigateAction = null; * var navigationServiceReference = _navigationService; * * navigateAction = () => navigationServiceReference.Navigate("Spelers", null); * navigationServiceReference.Navigate("Spelers", null); * navigateAction(); */ } _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = "Er zijn geen gegevens gevonden."; looking = false; return; } #endregion #region Reservering raadplegen if (Index == -1) { if (_reserveringen.Count > 0) { //Bestaand = true; _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = "Er zijn " + _reserveringen.Count + " reserveringen gevonden."; if (_reserveringen.Count == 1) { CardOutput = "Er is " + _reserveringen.Count + " reservering gevonden."; } looking = false; return; } else { _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = "Er zijn geen reserveringen gevonden."; looking = false; return; } } #endregion _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = string.Empty; looking = false; return; } } else { _verenigingsnummer = string.Empty; _bondsnummer = string.Empty; _jaar = DateTime.Today.AddYears(-1).Year; CardInput = string.Empty; if (inactivityTimer != null) { inactivityTimer.Stop(); } inactivityTimer = null; CardOutput = "Deze speler is geen lid van de vereniging"; looking = false; return; } /* * _verenigingsnummer = string.Empty; * _bondsnummer = string.Empty; * _jaar = DateTime.Today.AddYears(-1).Year; * CardInput = string.Empty; * if (inactivityTimer != null) inactivityTimer.Stop(); * inactivityTimer = null; * * CardOutput = string.Empty; * return; */ } }
private async Task UpdateWeatherInfoAsync(bool update) { if (_afhang == null) { _afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); } if (_geoposition == null) { _geoposition = await _locationRepository.GetLocationAsync(); } if (_locationModels == null) { _locationModels = await _locationRepository.GetLocationsByLatLon(_geoposition.Coordinate.Point.Position.Latitude, _geoposition.Coordinate.Point.Position.Longitude); } foreach (LocationModel location in _locationModels) { CurrentConditions = await _weatherRepository.GetCurrentConditionsAsync(location.LocationId, update, true); ObservableCollection <HourlyModel> hourly = await _weatherRepository.GetHourlyAsync(location.LocationId, update); foreach (HourlyModel model in hourly) { if (model.Date.Date == DateTime.Now.Date) { //if (_afhang.BaanBegin.Hours <= (int.Parse(model.ShortTime)) && (int.Parse(model.ShortTime) <= _afhang.BaanEinde.Hours)) //{ /* * if (TemperatureRange.Maximum.Value < double.Parse(model.PredictedTemperature)) * TemperatureRange.Maximum.Value = double.Parse(model.PredictedTemperature); * * if (TemperatureRange.Minimum.Value > double.Parse(model.PredictedTemperature)) * TemperatureRange.Minimum.Value = double.Parse(model.PredictedTemperature); */ HourlyModels.Add(model); //} } //string time = model.ShortTime; } TemperatureRange.Maximum.Value++; TemperatureRange.Minimum.Value--; } /* * var width = 750; * var height = 750; */ var south = 50.00; // AngleToRadians(50.00); var north = 55.00; // AngleToRadians(55.00); var west = 1.50; // AngleToRadians(1.50); var east = 9.00; // AngleToRadians(9.00); var ymin = LatitudeToMercator(south); var ymax = LatitudeToMercator(north); var xmin = LatitudeToMercator(west); var xmax = LatitudeToMercator(east); var htotkmy = HaversineDistance(north, west, north, east); var htotkmx = HaversineDistance(north, west, south, west); var hpxperkmy = 750 / htotkmy; var hpxperkmx = 730 / htotkmx; var ftotkmy = FlatEarth(north, west, north, east); var ftotkmx = FlatEarth(north, west, south, west); var fpxperkmy = 750 / ftotkmy; var fpxperkmx = 730 / ftotkmx; //var hkmx = HaversineDistance(north, west, north, 6.597290 /*_geoposition.Coordinate.Point.Position.Longitude*/); //var hkmy = HaversineDistance(north, west, 53.173119 /*_geoposition.Coordinate.Point.Position.Latitude*/, west); //var fkmx = FlatEarth(north, west, north, 6.597290 /*_geoposition.Coordinate.Point.Position.Longitude*/); //var fkmy = FlatEarth(north, west, 53.173119 /*_geoposition.Coordinate.Point.Position.Latitude*/, west); var hkmx = HaversineDistance(north, west, north, _geoposition.Coordinate.Point.Position.Longitude); var hkmy = HaversineDistance(north, west, _geoposition.Coordinate.Point.Position.Latitude, west); var fkmx = FlatEarth(north, west, north, _geoposition.Coordinate.Point.Position.Longitude); var fkmy = FlatEarth(north, west, _geoposition.Coordinate.Point.Position.Latitude, west); /* * AltitudeReferenceSystem system = _geoposition.Coordinate.Point.AltitudeReferenceSystem; * * var lat = AngleToRadians(_geoposition.Coordinate.Point.Position.Latitude); * var lon = AngleToRadians(_geoposition.Coordinate.Point.Position.Longitude); * * var diflat = AngleToRadians(_geoposition.Coordinate.Point.Position.Latitude - 55.974); * var diflon = AngleToRadians(_geoposition.Coordinate.Point.Position.Longitude - 0.0); * * var h1 = Math.Sin(diflat / 2) * Math.Sin(diflat / 2) + Math.Cos(north) * Math.Cos(lat) * Math.Sin(diflon / 2) * Math.Sin(diflon / 2); * var h2 = 2 * Math.Asin(Math.Min(1, Math.Sqrt(h1))); * var meters = 6371 * h2; */ /* * var xFactor = width/(east - west); * var yFactor = height/(ymax - ymin); * * //var resolution = GetResolution(_geoposition.Coordinate.Point.Position.Latitude); * * var lat = AngleToRadians(_geoposition.Coordinate.Point.Position.Latitude / 60); * var lon = AngleToRadians(_geoposition.Coordinate.Point.Position.Longitude / 60); * * var x = lon; * var y = LatitudeToMercator(lat); * * Position.X = ((x - west) * xFactor);///width;// *(xFactor / resolution); * Position.Y = ((ymax - y) * yFactor);///height;// *(yFactor / resolution); */ //double y = 180 / Math.PI * Math.Log10((Math.Tan(Math.PI / 4 + _geoposition.Coordinate.Point.Position.Latitude * (Math.PI / 180) / 2))); //double x = _geoposition.Coordinate.Point.Position.Latitude; HaversinePosition.Y = (hkmy * hpxperkmy); HaversinePosition.X = (hkmx * hpxperkmx); FlatPosition.Y = (fkmy * fpxperkmy); FlatPosition.X = (fkmx * fpxperkmx); //var boundaries = new GLatLngBounds(new GLatLng(48.895, 0), new GLatLng(55.974, 10.856)); //if (_locationModels == null) _locationModels = await _locationRepository.GetLocationsByLatLon(52.160114, 4.49701); //double Latitude = 52.160114; //double Longitude = 4.49701; //var sinx = Math.Sin((Math.PI * (Longitude - 48.895) /*_geoposition.Coordinate.Point.Position.Longitude*/ / 180.0)); //var x = 365 - (Math.Log((1 + sinx) / (1 - sinx)) / 2) * RadsPerDegre; ////var x = PixelPerLatitude * (Longitude - 48.895); ////var y = PixelPerLongintude * (10.856 - Longitude); ////var x = PixelLongintudeOrigin + (PixelsPerLongintudeDegre * Longitude);// _geoposition.Coordinate.Point.Position.Longitude; //var siny = Math.Sin((Math.PI * (10.856 - Longitude) /*_geoposition.Coordinate.Point.Position.Latitude*/ / 180.0)); //var y = 365 - (Math.Log((1 + siny) / (1 - siny)) / 2) * RadsPerDegre; //Position.X = 365; //Position.Y = 365; //using (ClientContext clientCtx = new ClientContext("https://mijn.clubcloud.nl")) //{ // clientCtx.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication; // FormsAuthenticationLoginInfo fba = new FormsAuthenticationLoginInfo("12073385","rjm557308453!"); // clientCtx.FormsAuthenticationLoginInfo = fba; // clientCtx.FormDigestHandlingEnabled = true; // FormDigestInfo info = clientCtx.GetFormDigestDirect(); // string digest = info.DigestValue; //} }