Ejemplo n.º 1
0
 public DateAndPositionsCollection()
 {   
     var rfM = new ReferenceMeeting(DateTime.Now.Date, null) { City = "Paris" };
     var rfM2 = new ReferenceMeeting(DateTime.Now.AddDays(1).Date, null) { City = "Paris" };
     var rfMbis = new ReferenceMeeting(DateTime.Now.Date.AddDays(1), null) { City = "Rouen" };
     var rfM2bis = new ReferenceMeeting(DateTime.Now.AddDays(2).Date, null) { City = "Quincampoix les Miroufles" };
     this._items.Add(new DateAndPositions(DateTime.Now.Date, rfM, rfM2));
     this._items.Add(new DateAndPositions(DateTime.Now.Date.AddDays(1), rfMbis, rfM2bis));
 }
Ejemplo n.º 2
0
        public void GetAllRoadMapsAsync(DateTime startDate, DateTime endDate, ReferenceMeeting startPosition, ReferenceMeeting endPosition)
        {
            if(startDate > endDate)
            {
                Debug.WriteLine("startDate doit être inférieure à endDate");
                AllRoadMapsReceived(this, new AllRoadMapReceivedEventArgs() { Error = true, MessageError = "La date de départ doit être strictement inférieure à la date d'arrivée" });
                return;
            }
            if (startDate == endDate)
            {
                endDate.Date.AddDays(1);
            }
            string messageError = string.Empty;

            List<DateTime> days = new List<DateTime>();
            List<RoadMap> roadMaps = new List<RoadMap>();
            int countSended = 0;
            int countReceived = 0;
            DateTime i = startDate;
            while (i <= endDate)
            {
                days.Add(i);
                i = i.AddDays(1);
            }

            RoadMapReceived += (o, e) =>
            {
                if (e.Error)
                {
                    messageError = e.MessageError;
                }
                countReceived++;
                if (!e.Error)
                    roadMaps.Add(e.RoadMap);
                if (countReceived >= days.Count)
                {
                    var arg = new AllRoadMapReceivedEventArgs();
                    if (messageError != string.Empty)
                    {
                        arg.MessageError = messageError;
                    }
                    if (roadMaps.Count <= 0)
                        arg.Error = true;

                    arg.RoadMaps.AddRange(roadMaps.OrderBy(obj=>obj.Date));
                    AllRoadMapsReceived(this, arg);
                    RoadMapReceived = null;
                }
            };

            foreach (var item in days)
            {
                GetRoadMapAsync(item, startPosition, endPosition);
                countSended++;
            }
        }
Ejemplo n.º 3
0
        public void GetRoadMapAsync(DateTime date, ReferenceMeeting startPosition, ReferenceMeeting endPosition)
        {
            IMeetingManager meetingManager;
            ITripManager tripManager;
            RoadMap roadMap = new RoadMap();
            meetingManager = new MeetingManager();
            tripManager = new TripManager();
            roadMap.Date = date;

            //Lorsque on reçoit tous les RDV géolocalisés
            meetingManager.AllMeetingsRetreived += (o, eventMeeting) =>
            {
                if (eventMeeting.Error)
                {
                    RoadMapReceived(this, new RoadMapReceivedEventArgs(null) { Error = true, MessageError = eventMeeting.MessageError});
                    meetingManager.AllMeetingsRetreived = null;
                    return;
                }

                startPosition.DateTime = eventMeeting.Meetings.FirstOrDefault().DateTime.Date;
                endPosition.DateTime = eventMeeting.Meetings.FirstOrDefault().DateTime.Date.AddDays(1);
                //Position de départ
                roadMap.Meetings.Add(startPosition);
                //Enregistrement des rendez-vous dans la roadmap
                roadMap.Meetings.AddRange(eventMeeting.Meetings);
                //Position d'arrivée
                roadMap.Meetings.Add(endPosition);

                //Lorsque on reçoit le chemin complet de la journée
                tripManager.TripReceived += (o2, eventTrip) =>
                {
                    if (eventTrip.Error)
                    {
                        RoadMapReceived(this, new RoadMapReceivedEventArgs(null) { Error = true, MessageError = "L'adresse de départ ou d'arrivée décrite dans les paramètres de l'application est incorrecte!" });
                        tripManager.TripReceived = null;
                        return;
                    }
                    roadMap.RouteResult = eventTrip.RouteResult;
                    roadMap.Trips.AddRange(eventTrip.Trips);
                    RoadMapReceived(this, new RoadMapReceivedEventArgs(roadMap)); 
                    tripManager.TripReceived = null;
                };
                if (roadMap.ValidMeetings.Count <= 0)
                {
                    RoadMapReceived(this, new RoadMapReceivedEventArgs(null) { Error = true });
                    return;
                }
                //Calcule du chemin complet de façon asynchrone
                tripManager.GetTripAsync(roadMap.ValidMeetings);
            };
            //Récupération et vérification des rendez-vous
            meetingManager.GetAllMeetingsAsync(date);
        }
        private void btn_selectRoadMaps_Click(object sender, RoutedEventArgs e)
        {
            IRoadMapManager manager = new RoadMapManager();
            ApplicationBarIconButton settings = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
            ApplicationBarIconButton refresh = ApplicationBar.Buttons[1] as ApplicationBarIconButton;
            ApplicationBarIconButton export = ApplicationBar.Buttons[2] as ApplicationBarIconButton;

            manager.AllRoadMapsReceived += (o, eRoadMapReceived) =>
            {
                var l = new List<DateAndPositions>();
                foreach (var roadmap in eRoadMapReceived.RoadMaps)
                {
                    l.Add(new DateAndPositions(roadmap.Date, roadmap.Meetings.FirstOrDefault(), roadmap.Meetings.LastOrDefault()));
                }
                this._roadmaps = eRoadMapReceived.RoadMaps;
                collection.Items = l;
                this.progressBar.IsIndeterminate = false;
                this.lbl_progressBar.Visibility = System.Windows.Visibility.Collapsed;
                dateFrom.IsEnabled = true;
                dateTo.IsEnabled = true;
                settings.IsEnabled = true;
                refresh.IsEnabled = true;
                export.IsEnabled = true;
                btn_selectRoadMaps.IsEnabled = true;
                if (eRoadMapReceived.Error)
                    MessageBox.Show("une erreur est survenue");
            };


            
            /// <summary>
            /// TODO : à remplacer par les meetings des settings
            /// </summary>
            ReferenceMeeting start = new ReferenceMeeting(new DateTime(2013, 1, 2, 8, 30, 0), new Location()
            {
                Latitude = 48.85693,
                Longitude = 2.3412
            }) { City = "Paris", Subject = "Start" };
            ReferenceMeeting end = start;
            end.Subject = "End";

            manager.GetAllRoadMapsAsync(this.dateFrom.Value.Value, this.dateTo.Value.Value, start, end);
            this.progressBar.IsIndeterminate = true;
            dateFrom.IsEnabled = false;
            dateTo.IsEnabled = false;
            btn_selectRoadMaps.IsEnabled = false;

            settings.IsEnabled = false;
            refresh.IsEnabled = false;
            export.IsEnabled = false;
            this.lbl_progressBar.Visibility = System.Windows.Visibility.Visible;
        }
Ejemplo n.º 5
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            //MeetingManagerTest.SearchStringAsyncTEST();
            //MeetingManagerTest.GetAllMeetingsAsyncTEST();
            //TripManagerTest.GetTripAsyncTEST();
            //TripManagerTest.GetAllTripsAsyncTEST();
            //RoadMapManagerTest.GetRoadMapAsyncTEST();
            //RoadMapManagerTest.GetAllRoadMapsAsyncTEST();
            //HtmlTest.HtmlConstructTEST();
            //return;

            ///TRIAL
            //Microsoft.Phone.Tasks.MarketplaceDetailTask market = new Microsoft.Phone.Tasks.MarketplaceDetailTask();
            //LicenseInformation licence = new LicenseInformation();
            //licence.IsTrial();

            IRoadMapManager manager = new RoadMapManager();
            this.DataContext = new Route();
            (DataContext as Route).Credential = BingMapCredential.CREDENTIAL;
            manager.RoadMapReceived += OnRoadMapReceived;

            //Meeting de départ
            ReferenceMeeting start = new ReferenceMeeting(new DateTime(2013, 1, 2, 8, 30, 0), new Location()
            {
                Latitude = 48.85693,
                Longitude = 2.3412
            }) { 
                City = "Paris", 
                Subject = "Départ coucou lol" 
            };
            //Meeting d'arrivé
            ReferenceMeeting end = new ReferenceMeeting(new DateTime(2013, 1, 2, 18, 30, 0), new Location()
            {
                Latitude = 48.85693,
                Longitude = 2.3412
            }) { 
                City = "Paris", 
                Subject = "Arrivée coucou lol" 
            };
            //Appel de la récupération des données
            manager.GetRoadMapAsync(new DateTime(2013, 1, 3), start, end);
            
        }
Ejemplo n.º 6
0
        private void signInButton_SessionChanged_1(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status != LiveConnectSessionStatus.Connected)
                return;


            manager.AllRoadMapsReceived += (o, eventAllRoadMaps) =>
            {
                if (eventAllRoadMaps.RoadMaps.Count  == 0)
                {
                    Debug.WriteLine("Aucun rendez-vous n'existe pour les jours sélectionnés");
                    return;
                }

                try
                {
                    //SaveTableur();
                    SpreadSheetRoadmapGenerator.GenerateXLS("feuilles-de-route.xlsx", eventAllRoadMaps.RoadMaps, 5.5f, 1.6f);
                    if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
                    {
                        myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
                        fileStream = myIsolatedStorage.OpenFile("feuilles-de-route.xlsx", FileMode.Open, FileAccess.Read);
                        reader = new StreamReader(fileStream);
                        App.Session = e.Session;
                        LiveConnectClient client = new LiveConnectClient(e.Session);
                        client.UploadCompleted += client_UploadCompleted;
                        client.UploadAsync("me/skydrive", "feuilles-de-route.xlsx", reader.BaseStream, OverwriteOption.Overwrite);
                    }
                }
                catch (Exception exception)
                {
                    Debug.WriteLine(exception.Message);
                }
            };
            ReferenceMeeting start = new ReferenceMeeting(new DateTime(2013, 1, 2, 8, 30, 0), new Location()
            {
                Latitude = 48.85693,
                Longitude = 2.3412
            }) { City = "Paris", Subject = "Start" };
            ReferenceMeeting end = start;
            end.Subject = "End";

            manager.GetAllRoadMapsAsync(new DateTime(2013, 1, 2), new DateTime(2013, 2, 10), start, end);

        }
        private void initRoadTrip()
        {
            if (settings["latiAdrDepart"] != "" && settings["longiAdrDepart"] != "" && settings["latiAdrArriver"] != "" && settings["longiAdrArriver"] != "")
            {
                rt_ConsoTrajet.tb_Info1.Text = "Consomation";
                rt_CoutTot.tb_Info1.Text = "Coût total";
                rt_DistRdv.tb_Info1.Text = "Distance parcourue";
                rt_nbrRdv.tb_Info1.Text = "Nombres de RDVs";
                rt_TpsTrajetRdv.tb_Info1.Text = "Temps de trajet";
                gr_AnomalieLieu.Children.Clear();
                gr_AnomalieTemps.Children.Clear();
                gr_InfoRD.Children.Clear();
                gr_InfoRDOpti.Children.Clear();
                map_Rdv.Children.Clear();
                myRMM = new RoadMapManager();
                myMM = new MeetingManager();
                tripTimeFail = new List<Trip>();
                meetingLocationFail = new List<Meeting>();

                var myRefMeetDepart = new ReferenceMeeting();
                myRefMeetDepart.Address = (string)settings["AdrDepart"];
                myRefMeetDepart.City = (string)settings["VilleDepart"];
                myRefMeetDepart.Location = new Location() { Latitude = (double)settings["latiAdrDepart"], Longitude = (double)settings["longiAdrDepart"] };

                var myRefMeetArriver = new ReferenceMeeting();
                myRefMeetArriver.Address = (string)settings["AdrArriver"];
                myRefMeetArriver.City = (string)settings["VilleArriver"];
                myRefMeetArriver.Location = new Location() { Latitude = (double)settings["latiAdrArriver"], Longitude = (double)settings["longiAdrArriver"] };

                myRMM.RoadMapReceived += OnRoadMapReceived;
                myRMM.GetRoadMapAsync((DateTime)settings["Date"], myRefMeetDepart, myRefMeetArriver);

                indicator = new ProgressIndicator
                {
                    IsVisible = true,
                    IsIndeterminate = true,
                    Text = "Chargement..."
                };
                SystemTray.SetProgressIndicator(this, indicator);
            }
            else
            {
                MessageBox.Show("Veuillez vérifier vos lieux de départ et d'arriver dans les paramètres");
            }
        }
        public static void GetRoadMapAsyncTEST()
        {
            IRoadMapManager manager = new RoadMapManager();

            manager.RoadMapReceived += (o, e) =>
            {
                if (e.Error)
                {
                    Debug.WriteLine("Aucun rendez-vous n'existe pour le jour sélectionné");
                    return;
                }
                Debug.WriteLine("YopYop Bling on a récupéré la roadmap!!");
            };
            ReferenceMeeting start = new ReferenceMeeting(new DateTime(2013, 1, 2, 8, 30, 0), new Location() { Latitude = 48.85693,
                                                                     Longitude = 2.3412});
            ReferenceMeeting end = new ReferenceMeeting(new DateTime(2013, 1, 2, 18, 30, 0), new Location() { Latitude = 48.85693,
                                                                     Longitude = 2.3412});

            manager.GetRoadMapAsync(new DateTime(2013, 1, 2), start, end);
        }
        public static void GetAllRoadMapsAsyncTEST()
        {
            IRoadMapManager manager = new RoadMapManager();

            manager.AllRoadMapsReceived += (o, e) =>
            {
                if (e.RoadMaps.Count  == 0)
                {
                    Debug.WriteLine("Aucun rendez-vous n'existe pour les jours sélectionnés");
                    return;
                }
                Debug.WriteLine("YopYop Bling on a récupéré les roadmaps!!");
            };
            ReferenceMeeting start = new ReferenceMeeting(new DateTime(2013, 1, 2, 8, 30, 0), new Location()
            {
                Latitude = 48.85693,
                Longitude = 2.3412
            }) { City = "Paris", Subject = "Start" };
            ReferenceMeeting end = start;
            end.Subject = "End";

            manager.GetAllRoadMapsAsync(new DateTime(2013, 1, 2), new DateTime(2013, 1, 4), start, end);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Selectionne les roadmaps en fonction d'un intervalle de temps
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_selectRoadMaps_Click(object sender, RoutedEventArgs e)
        {
            if (!App.IsConnected())
            {
                MessageBox.Show("Vous n'êtes pas connecté à internet");
                return;
            }

            collection.Items.Clear();
            IRoadMapManager manager = new RoadMapManager();
            manager.AllRoadMapsReceived += (o, eRoadMapReceived) =>
            {
                if (eRoadMapReceived.Error)
                {
                    MessageBox.Show(eRoadMapReceived.MessageError);
                    this.enableInterface();
                    return;
                }
                for (int i=0; i < eRoadMapReceived.RoadMaps.Count; i++)
                {
                    var roadmap = eRoadMapReceived.RoadMaps[i];
                    collection.Items.Add(new DateAndPositions(i, roadmap));
                }
                manager.AllRoadMapsReceived = null;
                this.enableInterface();

                ToastPrompt toast = new ToastPrompt();
                toast.Title = "Résultats";
                toast.Message = eRoadMapReceived.RoadMaps.Count + " feuille(s) de route récupérée(s)";
                toast.Show();
            };
            if (!IsolatedStorageSettings.ApplicationSettings.Contains("latiAdrDepart") ||
                !IsolatedStorageSettings.ApplicationSettings.Contains("longiAdrDepart")||
                !IsolatedStorageSettings.ApplicationSettings.Contains("VilleDepart") ||
                !IsolatedStorageSettings.ApplicationSettings.Contains("latiAdrArriver")||
                !IsolatedStorageSettings.ApplicationSettings.Contains("longiAdrArriver")||
                !IsolatedStorageSettings.ApplicationSettings.Contains("VilleArriver") ||
                !IsolatedStorageSettings.ApplicationSettings.Contains("ConsoCarburant")||
                !IsolatedStorageSettings.ApplicationSettings.Contains("PrixCarburant"))
            {
                MessageBox.Show("Veillez à paramètrer correctement l'application avant d'utiliser l'export Excel. Les villes de départ et d'arrivée sont manquantes");
                NavigationService.Navigate(new Uri("/Page/PivotParam.xaml", UriKind.Relative));
                return;
            }

            ReferenceMeeting start = new ReferenceMeeting(this.dateFrom.Value.Value, new Location()
            {
                Latitude = (double)settings["latiAdrDepart"],
                Longitude = (double)settings["longiAdrDepart"]
            }) { City = (string)settings["VilleDepart"], Subject = "Start" };
            ReferenceMeeting end = new ReferenceMeeting(this.dateFrom.Value.Value, new Location()
            {
                Latitude = (double)settings["latiAdrArriver"],
                Longitude = (double)settings["longiAdrArriver"]
            }) { City = (string)settings["VilleArriver"], Subject = "End" };

            this.disableInterface();
            manager.GetAllRoadMapsAsync(this.dateFrom.Value.Value, this.dateTo.Value.Value, start, end);
        }