Ejemplo n.º 1
0
        protected override void OnRestoreInstanceState(Bundle savedInstanceState)
        {
            try
            {
                base.OnRestoreInstanceState(savedInstanceState);
                m_bIsRestoring = true;

                m_itrajetLocalID = savedInstanceState.GetInt("itrajetLocalID");
                if (m_itrajetLocalID == 0)
                {
                    Finish();
                }

                m_bIsModeConduite = savedInstanceState.GetBoolean("IsModeConduite");

                m_bIsSimulatorActivated = savedInstanceState.GetBoolean("IsSimulatorActivated");

                int iCurrentArret_localID = savedInstanceState.GetInt("CurrentArret_localID", -1);
                m_currentArret = LocalDatabase.Get().GetArretFromLocalID(new FileAccessManager(), iCurrentArret_localID);

                int iNextArret_localID = savedInstanceState.GetInt("NextArret_localID", -1);
                m_nextArret = LocalDatabase.Get().GetArretFromLocalID(new FileAccessManager(), iNextArret_localID);

                m_bHasShownSecurityMessage = savedInstanceState.GetBoolean("bHasShownSecurityMessage");
            }
            catch (Exception e)
            {
                MobileCenter_Helper.ReportError(new FileAccessManager(), e, GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Arret arret = db.Arrets.Find(id);

            db.Arrets.Remove(arret);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Horaire,EtatArret")] Arret arret)
 {
     if (ModelState.IsValid)
     {
         db.Entry(arret).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(arret));
 }
        public ActionResult Create([Bind(Include = "Id,Horaire,EtatArret")] Arret arret)
        {
            if (ModelState.IsValid)
            {
                db.Arrets.Add(arret);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(arret));
        }
Ejemplo n.º 5
0
        public Arret AddArret(IFileAccessManager logFileManager, Arret Arret)
        {
            int iLocalIDCreated = InsertItem <Arret>(logFileManager, Arret);

            if (iLocalIDCreated > 0)
            {
                return(Arret);
            }
            else
            {
                return(null);//not inserted
            }
        }
Ejemplo n.º 6
0
        private void GoToLatestStopPassedIfNeeded()
        {
            //Verify latest arret passed with that tablet (even if the app has been closed after the arret has been passed)
            Arret latestArret = string.IsNullOrWhiteSpace(Settings.LatestArret) ? null : JSON.DeserializeObject <Arret>(new FileAccessManager(), Settings.LatestArret, "GoToNextStopIfNeeded()");

            //If latest arret passed is of that trajet, go to this arret.
            if (latestArret != null && latestArret.m_iLocalIDtrajet == m_trajet.m_iLocalID)
            {
                m_trajet.GetArretFromLatLon(latestArret.m_lat, latestArret.m_lon, out m_currentArret, out m_nextArret);

                GoToNextStop();
            }
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Arret arret = db.Arrets.Find(id);

            if (arret == null)
            {
                return(HttpNotFound());
            }
            return(View(arret));
        }
Ejemplo n.º 8
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ActionBar.Hide();

            SetContentView(Resource.Layout.horraires_activity);
            this.DonneesRecues = Intent.GetStringArrayListExtra("donnees");

            TextView txtNomArret = (TextView)FindViewById(Resource.Id.txtNomArret);

            txtNomArret.Text = DonneesRecues[0];

            //recupérartions des horraires pour l'arret spécifié
            Arret ar = new Arret(DonneesRecues[0], DonneesRecues[1]);

            this.listeHoraires = await MockTotemAPI.GetInstance().GetListeHoraires(ar);

            ListView listBoxHoraire = (ListView)FindViewById(Resource.Id.listHoraires);

            listBoxHoraire.Adapter = new CustumListView(this, null, null, this.listeHoraires);
        }
Ejemplo n.º 9
0
        private async Task InitUI()
        {
            m_refresher.Refreshing = true;
            AndHUD.Shared.Show(this, Resources.GetString(Resource.String.loading_in_progress), -1, MaskType.Black);
            m_handler_DismissHandHUDIfNeeded.RemoveCallbacks(m_workRunnable_DismissHandHUDIfNeeded);

            //Get trajet from local database
            try
            {
                m_trajet = await Trajet.GettrajetDetailsToShowOnScreen(new FileAccessManager(), m_itrajetLocalID);

                //To never get empty listview
                while (m_trajet.m_lsarret.Count < 22)
                {
                    m_trajet.m_lsarret.Add(new Arret());
                }

                m_trajet.m_lsarret.Reverse();
            }
            catch (Exception)
            {
                DynamicUIBuild_Utils.ShowSnackBar_WithOKButtonToClose(this, m_layoutRoot, Resource.String.snackbar_errorHappened);

                if (m_trajet == null || m_trajet.m_lsarret == null)
                {
                    m_refresher.Refreshing = false;
                    return;
                }
            }

            try
            {
                string stextviewLocationStartText = m_trajet.m_sLocationStart;
                string stextviewTimeStartText     = m_trajet.m_sTimeStart;
                string stextviewLocationEndText   = m_trajet.m_sLocationEnd;
                string stextviewTimeEndText       = m_trajet.m_sTimeEnd;

                //update ui (add empty items if mode conduite to avoid showing white screen when there is not enouth Arret)
                List <Arret> tmp = new List <Arret>();
                if (m_bIsModeConduite)
                {
                    for (int i = 0; i < 20; i++)
                    {
                        tmp.Add(new Arret());
                    }
                }
                tmp.AddRange(m_trajet.m_lsarret);
                m_adapter.RefreshListArret(tmp);
                UpdateGpsLayout();
                UpdateAltimeter();

                //Start
                m_textviewLocationStart.Text = stextviewLocationStartText;
                m_textviewTimeStart.Text     = stextviewTimeStartText;

                //End
                m_textviewLocationEnd.Text = stextviewLocationEndText;
                m_textviewTimeEnd.Text     = stextviewTimeEndText;

                //Time before start
                UpdateTimeBeforeStart();

                //Canal radio.... always hiden for the moment (reunion début Mars 2018
                m_textviewRadio.Text = string.Format(Resources.GetString(Resource.String.activitytrajetDetails_textview_radio), m_trajet.m_lsarret[0]?.m_sRadioCanal);

                //Next stop and Current stop
                if (m_bIsModeConduite && m_nextArret == null)
                {
                    m_nextArret = m_adapter[m_adapter.Count - 1];
                }
                UpdateLayoutNextStop();
                UpdateLayoutCurrentStop();

                //Btn valid preparation
                if (m_bIsModeConduite)
                {
                    m_btnValidPreparation.Visibility = ViewStates.Gone;
                }
                else
                {
                    m_btnValidPreparation.Visibility = ViewStates.Visible;
                }

                //Disable listview scrolling
                if (m_bIsModeConduite)
                {
                    m_listview.Enabled = false;
                }
                else
                {
                    m_listview.Enabled = true;
                }

                //If activity has been reloading, remove all old Arret
                if (m_currentArret != null)
                {
                    m_adapter.RemoveLastItemsUntilCurrentStop(m_currentArret);
                }

                //In every case, scroll the list view to the very bottom
                m_listview.SmoothScrollToPosition(m_adapter.Count);

                //Verify if a arret has already been passed in that trajet. If yes, go to it directly
                GoToLatestStopPassedIfNeeded();
            }
            catch (Exception e)
            {
                DynamicUIBuild_Utils.ShowSnackBar_WithOKButtonToClose(this, m_layoutRoot, Resource.String.snackbar_errorHappened);
                MobileCenter_Helper.ReportError(new FileAccessManager(), e, GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            finally
            {
                m_refresher.Refreshing = false;
                m_handler_DismissHandHUDIfNeeded.PostDelayed(m_workRunnable_DismissHandHUDIfNeeded, 15000);
            }
        }
Ejemplo n.º 10
0
        protected void HistoriqueArret(object sender, EventArgs e)
        {
            string userDate1 = this.DateField1.Value.ToString();

            string[] du = userDate1.Split(' ');
            userDate1 = du[0] + " " + this.TimeField1.Value.ToString();

            string userDate2 = this.DateField2.Value.ToString();

            string[] du2 = userDate2.Split(' ');
            userDate2 = du2[0] + " " + this.TimeField2.Value.ToString();
            string vehiculeid = "";

            vehiculeid = this.MultiCombo1.SelectedItem.Value;
            if (vehiculeid == "" || userDate1 == "" || userDate2 == "")
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Title   = Resources.Resource.Information,
                    Message = "Veuillez choisir un véhicule, une date début et une date fin pour consulter les trajets",
                    Buttons = MessageBox.Button.OK,
                    Icon    = MessageBox.Icon.INFO
                });
            }
            else
            {
                TimeSpan k = DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) - DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                if (k.TotalDays <= 0)
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Title   = Resources.Resource.Information,
                        Message = "La date  début doit être inferieure à la date fin",
                        Buttons = MessageBox.Button.OK,
                        Icon    = MessageBox.Icon.INFO
                    });
                }
                else
                {
                    string        _reqTime = "select * from(select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid desc) a union select * from (select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid )b ";
                    SqlDataReader drT      = Select(_reqTime);

                    int m = 0;
                    while (drT.Read())
                    {
                        du[m] = drT[0].ToString();
                        m++;
                    }
                    drT.Close();
                    DateTime dsup = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    DateTime dinf = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    if (dsup < dinf)
                    {
                        dinf = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                        dsup = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    }


                    if (DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf ||
                        DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup ||
                        DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf ||
                        DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup)
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title   = Resources.Resource.Information,
                            Message = "Les dates début et fin doivent être comprises entre " + dinf + " et " + dsup,
                            Buttons = MessageBox.Button.OK,
                            Icon    = MessageBox.Icon.INFO
                        });
                    }
                    else
                    {
                        int           Compt    = 0;
                        int           vites    = 0;
                        string        c        = "";
                        string        _reqlist = "select d.GPSDateTime,d.latitude,d.longitude ,p.nom+' '+p.prenom as conducteur,d.speed ,d.contact,d.adress from Datatracker d inner join boitier b on b.imei=d.imei inner join affectation_vehicule_boitier abv on abv.boitierid=b.boitierid inner join vehicules  v on v.vehiculeid = abv.vehiculeid inner join vehicule_personnel vp on vp.vehiculeid=v.vehiculeid inner join personnel p on p.personnelid=vp.personnelid where  cast(d.GPSDateTime AS datetime) >= '" + userDate1 + "' AND cast(d.GPSDateTime AS datetime) < '" + userDate2 + "' and v.vehiculeid='" + vehiculeid + "' order by cast(d.GPSDateTime AS datetime)";
                        SqlDataReader drlist   = Select(_reqlist);
                        int           ve       = 0;
                        int           tr       = 0;

                        //    while (drlist.Read())
                        //    {
                        //        Datatracker t = new Datatracker();

                        //        t.contact = Convert.ToInt32(drlist[5]);
                        //        t.GPSDateTime = drlist[0].ToString();
                        //        t.latitude = (double)drlist[1];
                        //        t.longitude = (double)drlist[2];



                        //        if (t.contact == 0)
                        //        {
                        //            tr++;
                        //            if (tr == 1)
                        //            {
                        //                arret = new Arret();
                        //                arret.SetDateD(DateTime.ParseExact(t.GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture));
                        //                arret.setlatitude(t.latitude.ToString());
                        //                arret.setlongitude(t.longitude.ToString());
                        //            }



                        //        }

                        //        if (t.contact == 1 )
                        //        {
                        //            if (tr != 0)
                        //            {
                        //                arret.SetDateF(DateTime.ParseExact(t.GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture));
                        //                ListArret.Add(arret);
                        //                tr = 0;
                        //            }

                        //        }



                        //    }


                        //drlist.Close();
                        while (drlist.Read())
                        {
                            Datatracker t = new Datatracker();

                            t.contact     = Convert.ToInt32(drlist[5]);
                            t.GPSDateTime = drlist[0].ToString();
                            t.latitude    = (double)drlist[1];
                            t.longitude   = (double)drlist[2];
                            t.adress      = drlist[6].ToString();;
                            List.Add(t);
                        }


                        drlist.Close();
                        for (int s = 0; s < List.Count; s++)
                        {
                            if (List[s].contact == 0)
                            {
                                tr++;
                                if (tr == 1)
                                {
                                    arret = new Arret();
                                    arret.SetDateD(DateTime.ParseExact(List[s].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture));
                                    arret.setlatitude(List[s].latitude.ToString());
                                    arret.setlongitude(List[s].longitude.ToString());
                                    arret.setadr(List[s].adress.ToString());
                                }
                            }

                            if (List[s].contact == 1)
                            {
                                if (tr != 0)
                                {
                                    arret.SetDateF(DateTime.ParseExact(List[s].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture));
                                    ListArret.Add(arret);
                                    tr = 0;
                                }
                            }
                            if (s == List.Count - 1 && List[s].contact == 0)
                            {
                                if (tr != 0)
                                {
                                    arret.SetDateF(DateTime.ParseExact(List[s].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture));
                                    ListArret.Add(arret);
                                    tr = 0;
                                }
                            }
                        }


                        List <object> lo = new List <object>();
                        if (ListArret.Count == 0)
                        {
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title   = Resources.Resource.Information,
                                Message = "Aucun arrêt n'a été fait",
                                Buttons = MessageBox.Button.OK,
                                Icon    = MessageBox.Icon.INFO
                            });
                        }
                        else
                        {
                            Store1.RemoveAll();
                            //Store Store1 = this.GridPanelVoyage.GetStore();
                            for (int i = 0; i < ListArret.Count; i++)
                            {
                                //string lat = ListArret[i].latitude;
                                //string lng = ListArret[i].longitude;
                                //string lat1 = ListArret[i].latitude.Replace(",",".");
                                //string lng1 = ListArret[i].longitude.Replace(",", ".");
                                //string adr1 = RetrieveFormatedAddress(lat1, lng1);
                                //adr1 = adr1.Replace("<formatted_address>", "*");
                                //adr1 = adr1.Replace("</formatted_address>", "*");
                                //string[] s = adr1.Split('*');
                                //string adr = s[1];
                                DateTime d  = DateTime.ParseExact(ListArret[i].GetDateD().ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                                DateTime dd = DateTime.ParseExact(ListArret[i].GetDateF().ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture);



                                //  Address[] addresses = geoCoder.ReverseGeoCode(38.8976777, -77.036517);
                                TimeSpan duree = dd - d;
                                object[] test  = new object[6];
                                test[0] = ListArret[i].adr.ToString();
                                test[1] = ListArret[i].dateD.ToShortDateString() + " " + ListArret[i].dateD.ToLongTimeString();
                                test[2] = duree.ToString();
                                test[3] = ListArret[i].dateF.ToShortDateString() + " " + ListArret[i].dateF.ToLongTimeString();

                                test[4] = ListArret[i].latitude;
                                test[5] = ListArret[i].longitude;

                                //{ c, "adrD", Listtrajet[i].position[0].GPSDateTime, "adrF", Listtrajet[i].position[Listtrajet[i].position.Count - 1].GPSDateTime, duree.ToString(), Listtrajet[i].vitesse + " Km/H", polyline, color[col], Listtrajet[i].km + " Km" };
                                lo.Add(test);
                                //            lo.Add(new object[] { adr, ListArret[i].dateD.ToShortDateString() + " " + ListArret[i].dateD.ToLongTimeString(), duree.ToString(), ListArret[i].latitude, ListArret[i].longitude }
                                //);
                            }


                            Store1.Add(lo);
                            Store1.CommitChanges();
                        }
                    }
                }
            }
        }