/// <summary> /// Constructeur de base /// </summary> public Parametrage() { ListPhotographe = new List<Photographe>(); ListPeriode = new List<Periode>(); MailSettings = new MailSettings(); MailContents = new MailContents(); AdresseLabo = new Adress(); PrivateKey = String.Empty; GoogleAccount = String.Empty; IsGoogleActivate = false; PrixTicketMoyen = String.Empty; PrixPochetteCompl = String.Empty; PrixPochetteGroupSeul = String.Empty; PrixPochetteSansGroupe = String.Empty; MailFrom = String.Empty; }
/// <summary> /// Calcul le Trajet entre deux points /// </summary> /// <param name="_adress1"></param> /// <param name="_adress2"></param> /// <returns></returns> public static MapsInfo calculTrajet(Adress _adress1, Adress _adress2) { try { // Driving directions DistanceMatrixRequest drivingDirectionRequest = new DistanceMatrixRequest { Origins = new string[] { String.Format("{0}, {1}, {2} FR", _adress1.Voie, _adress1.CodePostal, _adress1.Ville) }, Destinations = new string[] { String.Format("{0}, {1}, {2} FR", _adress2.Voie, _adress2.CodePostal, _adress2.Ville) }, ApiKey = "AIzaSyCFMHHP5HpnqBQ8DT9yTc03U3QNqdQkVtE", Alternatives = true }; DistanceMatrixResponse distanceResponse; distanceResponse = GoogleMapsApi.GoogleMaps.DistanceMatrix.Query(drivingDirectionRequest); Distance _distance = distanceResponse.Rows.First().Elements.First().Distance; Duration _duration = distanceResponse.Rows.First().Elements.First().Duration; return new MapsInfo() { Distance = _distance.Text, Duration = _duration.Text, TempsTrajet = _duration.Value }; } catch (Exception _exc) { Log.Error("Erreur lors du calcul du trajet : ", _exc); return new MapsInfo() { Distance = "---- km", Duration = "--:--:--", TempsTrajet = TimeSpan.MinValue }; } }