public void GetJourneyDetails(RootObjectJourneydetail Journey)
        {
            ObjCommon.JourneyListDetails = JsonConvert.SerializeObject(Journey);
            StrCommonObject = JsonConvert.SerializeObject(ObjCommon);
            var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
            ObjCommon.ClearLocationRecord();
            ObjCommon.JourneySave();
            List<JourneyDetails> Journelist = (from a in context.tblJourneyDetails select a).ToList();
            List<Journeydetail> databaseJlist = new List<Journeydetail>();
            Journeydetail _Journey;
            for (int i = 0; i < Journelist.Count; i++)
            {
                _Journey = new Journeydetail();
                _Journey.journey_id = Journelist[i].JourneyId.ToString();
                _Journey.distance = Convert.ToDouble(Journelist[i].Last_distance);
                _Journey.time = Journelist[i].TimeDuration.ToString();
                _Journey.date = Journelist[i].JDate.ToString();
                databaseJlist.Add(_Journey);
                _Journey = null;
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                lstjourneyList.ItemsSource = null;
                lstjourneyList.ItemsSource = databaseJlist;
            });

            if (jlist != null)
            {
                string number = jlist.journey_id;
                ClsJourney objJourney = new ClsJourney();
                objJourney.GetJourneyDetails(ObjCommon.DeviceId, jlist.journey_id, this);
            }
        }
 public Boolean DeleteLocation(IQueryable<LocationTable> QryDelLocation, AgeasDriverDetails context)
 {
     Boolean result = false;
     try
     {
         context.tblLocation.DeleteAllOnSubmit(QryDelLocation);
         context.SubmitChanges();
         //context.Dispose();
         result = true;
     }
     catch (Exception ex)
     {
         result = false;
     }
     return result;
 }
        public List<JourneyDetails> GetJourneyList(IQueryable<JourneyDetails> JourneyQuery)
        {
            List<JourneyDetails> Journeylist = null;

            try
            {
                using (var context = new AgeasDriverDetails(DBConnectionString))
                {
                    if (context.DatabaseExists())
                    {
                        Journeylist = JourneyQuery.ToList();
                    }
                    context.Dispose();
                }
            }
            catch
            {
                Journeylist = null;
            }
            return Journeylist;
        }
 public Boolean CreateDatabase()
 {
     Boolean result = false;
     try
     {
         using (var context = new AgeasDriverDetails(DBConnectionString))
         {
             if (!context.DatabaseExists())
             {
                 context.CreateDatabase();
                 result = true;
             }
             context.Dispose();
         }
     }
     catch
     {
         result = false;
     }
     return result;
 }
        private void CreteXmlBodyForLocPost(String StrDeviceId)
        {
            ClsDBHelper.ClsDBHelper objDBHelper = new ClsDBHelper.ClsDBHelper();
            var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
            var distinctTypeIDs = (from a in context.tblLocation select a.Journeyid).Distinct().ToList();
            try
            {
                envelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                        " <journeydetails> " +
                            "<deviceid>" + StrDeviceId.ToString() + "</deviceid>\n";
                for (int j = 0; j < distinctTypeIDs.Count; j++)
                {
                    List<LocationTable> JourneyLocationlist = (from a in context.tblLocation where a.Journeyid == distinctTypeIDs[j] select a).ToList();

                    if (JourneyLocationlist.Count > 0)
                    {
                        envelope += "<journey id=\"" + distinctTypeIDs[j].ToString() + "\">";

                        for (int i = 0; i < JourneyLocationlist.Count; i++)
                        {
                            envelope += "<latlong> <latitude>" + JourneyLocationlist[i].Lat + "</latitude> <longitude>" + JourneyLocationlist[i].Long + "</longitude> <datetime>" +  JourneyLocationlist[i].DateTime+ "</datetime> </latlong>";
                        }
                        envelope += " </journey>";
                    }

                }

                envelope += " </journeydetails>";
            }
            catch
            { }
        }
Example #6
0
 public void JourneySave()
 {
     RootObjectJourneydetail ObjRootJouneyDtls = JsonConvert.DeserializeObject<RootObjectJourneydetail>(this.JourneyListDetails);
      if (ObjRootJouneyDtls.complete)
      {
          ClsDBHelper.ClsDBHelper objDBHelper;
          decimal Totaldistance = 0;
          var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
          objDBHelper = new ClsDBHelper.ClsDBHelper();
          IQueryable<DataAccessLayer.JourneyDetails> DeleteJourney = from c in context.tblJourneyDetails select c;
          objDBHelper.DeleteJourneyDetails(DeleteJourney, context);
          DataAccessLayer.JourneyDetails ObjJourney;
          for (int i = 0; i < ObjRootJouneyDtls.user_journey.journeydetails.Count; i++)
          {
              ObjJourney = new DataAccessLayer.JourneyDetails();
              Totaldistance = Totaldistance + Convert.ToDecimal(ObjRootJouneyDtls.user_journey.journeydetails[i].distance);
              ObjJourney.Total_distance = Convert.ToDecimal(Totaldistance);
              ObjJourney.JourneyId = Convert.ToInt16(ObjRootJouneyDtls.user_journey.journeydetails[i].journey_id);
              ObjJourney.Last_distance = Convert.ToDecimal(ObjRootJouneyDtls.user_journey.journeydetails[i].distance);
              ObjJourney.TimeDuration = ObjRootJouneyDtls.user_journey.journeydetails[i].time;
              ObjJourney.JDate = ObjRootJouneyDtls.user_journey.journeydetails[i].date.ToString();
              objDBHelper.InsertJourney(ObjJourney);
              ObjJourney = null;
          }
      }
 }
Example #7
0
 public bool IsRecordHaveForUpload()
 {
     ClsDBHelper.ClsDBHelper objDBHelper = new ClsDBHelper.ClsDBHelper();
      var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
      List<LocationTable> JourneyLocationlist = (from a in context.tblLocation select a).ToList();
      context = null;
      objDBHelper = null;
      if (JourneyLocationlist.Count > 0)
      {
          JourneyLocationlist = null;
          return true;
      }
      else
      {
          JourneyLocationlist = null;
          return false;
      }
 }
Example #8
0
        public Double GetFirstLastLatLong(int lastJourneyID)
        {
            double StartLatitude;
             double StartLongitude;
             double EndLatitude;
             double EndLongitude;
             double ActualDistance;
             Double Totaldistance=0.0;
             var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
             List<LocationTable> JourneyLocationlist = (from a in context.tblLocation orderby a.LocationID ascending where a.Journeyid == lastJourneyID select a).ToList();
             if (JourneyLocationlist.Count > 1)
             {
                 for (int i = 0; i < JourneyLocationlist.Count - 1; i++)
                 {
                     StartLatitude = Convert.ToDouble(JourneyLocationlist[i].Lat.ToString());
                     StartLongitude = Convert.ToDouble(JourneyLocationlist[i].Long.ToString());
                     EndLatitude = Convert.ToDouble(JourneyLocationlist[i+1].Lat.ToString());
                     EndLongitude = Convert.ToDouble(JourneyLocationlist[i+1].Long.ToString());
                     ActualDistance = Getdistance(StartLatitude, StartLongitude, EndLatitude, EndLongitude);
                     Totaldistance = Totaldistance + ActualDistance;
                 }
             }

             Totaldistance = Totaldistance / 1609.34;
             return Totaldistance;
        }
Example #9
0
 public void DeleteLocationRecord()
 {
     ClsDBHelper.ClsDBHelper objDBHelper = new ClsDBHelper.ClsDBHelper();
      var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
      Double Totaldistance;
      var distinctTypeIDs = (from a in context.tblLocation select a.Journeyid).Distinct().ToList();
      for (int j = 0; j < distinctTypeIDs.Count; j++)
      {
          Totaldistance = GetFirstLastLatLong(distinctTypeIDs[j]);
          if (Totaldistance <= 0.5)
          {
              IQueryable<DataAccessLayer.LocationTable> DeleteLocation = from c in context.tblLocation where c.Journeyid == distinctTypeIDs[j] select c;
              objDBHelper.DeleteLocation(DeleteLocation, context);
          }
      }
      context = null;
      objDBHelper = null;
 }
Example #10
0
 public void ClearLocationRecord()
 {
     var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
      ClsDBHelper.ClsDBHelper objDBHelper = new ClsDBHelper.ClsDBHelper();
      IQueryable<DataAccessLayer.LocationTable> DeleteLocation = from c in context.tblLocation select c;
      objDBHelper.DeleteLocation(DeleteLocation, context);
      context = null;
      objDBHelper = null;
 }
Example #11
0
 public Double GetFirstLastLatLong(int lastJourneyID)
 {
     double StartLatitude;
      double StartLongitude;
      double EndLatitude;
      double EndLongitude;
      Double Totaldistance;
      var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
      List<LocationTable> JourneyLocationlist = (from a in context.tblLocation orderby a.LocationID ascending where a.Journeyid == lastJourneyID select a).ToList();
      if (JourneyLocationlist.Count > 0)
      {
          StartLatitude = Convert.ToDouble(JourneyLocationlist[0].Lat.ToString());
          StartLongitude = Convert.ToDouble(JourneyLocationlist[0].Long.ToString());
      }
      else
      {
          StartLatitude = Convert.ToDouble("0.00");
          StartLongitude = Convert.ToDouble("0.00");
      }
      JourneyLocationlist = null;
      JourneyLocationlist = (from a in context.tblLocation orderby a.LocationID descending where a.Journeyid == lastJourneyID select a).ToList();
      if (JourneyLocationlist.Count > 0)
      {
          EndLatitude = Convert.ToDouble(JourneyLocationlist[0].Lat.ToString());
          EndLongitude = Convert.ToDouble(JourneyLocationlist[0].Long.ToString());
      }
      else
      {
          EndLatitude = Convert.ToDouble("0.00");
          EndLongitude = Convert.ToDouble("0.00");
      }
      Totaldistance = Getdistance(StartLatitude, StartLongitude, EndLatitude, EndLongitude) / 1609.34;
      return Totaldistance;
 }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            try
            {
                StrCommonObject = NavigationContext.QueryString["common"];
                ObjCommon = JsonConvert.DeserializeObject<ClsCommon>(StrCommonObject);

                base.OnNavigatedTo(e);
                ImgHeader.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/upperStrip"));
                ImgProgressSelect.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/General/progressSelected"));
                ImgRecordDeselect.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/General/record"));
                ImgHelpDeselect.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/General/help"));
                ImgQuoteDeselect.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/General/quote"));
                ImgProgress.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/mainBg_progress1"));
                ImgProgressButtom.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/mainBg_progress2"));
                txtprogressvalue.Text = "0.5";
                //ObjCommon.TotalJourney = 152;
                if (ObjCommon != null)
                {
                    ObjRootJouneyDtls = JsonConvert.DeserializeObject<RootObjectJourneydetail>(ObjCommon.JourneyListDetails);
                    if (ObjCommon.TotalJourney < 51)
                    {
                        ImageBrush _ImageBrush = new ImageBrush();
                        _ImageBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/displayUnselected"));
                        stackprogress.Background = _ImageBrush;
                        _ImageBrush = null;
                    }
                    else if (ObjCommon.TotalJourney < 100)
                    {
                        ImageBrush _ImageBrush = new ImageBrush();
                        _ImageBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/display(50)"));
                        stackprogress.Background = _ImageBrush;
                        _ImageBrush = null;
                    }
                    else if (ObjCommon.TotalJourney < 150)
                    {
                        ImageBrush _ImageBrush = new ImageBrush();
                        _ImageBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/display(100)"));
                        stackprogress.Background = _ImageBrush;
                        _ImageBrush = null;
                    }
                    //else if (ObjCommon.TotalJourney >= 150)
                    //{

                    //    ImageBrush _ImageBrush = new ImageBrush();
                    //    _ImageBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/display(150)"));
                    //    stackprogress.Background = _ImageBrush;
                    //    _ImageBrush = null;
                    //    StrCommonObject = JsonConvert.SerializeObject(ObjCommon);
                    //    NavigationService.Navigate(new Uri("/Pages/FrmScore.xaml?common=" + StrCommonObject, UriKind.Relative));
                    //}

                    else
                    {
                        ImageBrush _ImageBrush = new ImageBrush();
                        _ImageBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/displayUnselected"));
                        stackprogress.Background = _ImageBrush;
                        _ImageBrush = null;
                    }
                }

                TxtBudget.Text = "LATEST BUDGET EARNED!";
                TxtBudgetDetails.Text = "Well done,you handle those \n comer safely";
                TxtShare.Text = "Share with:";
                TxtJourneyCmplt.Text = "JOURNEYS COMPLETED";

                Imgfacebk.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/facebookIcon"));
                Imgtwitter.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/twitterIcon"));

                ImgTblHeader.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Progress/tableHeader"));

                objDBHelper = new ClsDBHelper.ClsDBHelper();
                var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);

                List<JourneyDetails> Journelist = (from a in context.tblJourneyDetails select a).ToList();

                List<Journeydetail> databaseJlist = new List<Journeydetail>();
                Journeydetail _Journey;
                for (int i = 0; i < Journelist.Count; i++)
                {
                    _Journey = new Journeydetail();
                    _Journey.journey_id = Journelist[i].JourneyId.ToString();
                    _Journey.distance = Convert.ToDouble(Journelist[i].Last_distance.ToString("0.00"));
                    _Journey.time = Journelist[i].TimeDuration.ToString();
                    _Journey.date = Journelist[i].JDate.ToString();
                    databaseJlist.Add(_Journey);
                    _Journey = null;
                }
                lstjourneyList.ItemsSource = databaseJlist;

                if (Journelist.Count > 0)
                {
                    TxtlatestdisValue.Text = Journelist[Journelist.Count - 1].Last_distance.ToString("0.00");

                }

            }
            catch (Exception ex)
            {
            }
        }
Example #13
0
        public List<LocationTable> GetlocationList(IQueryable<LocationTable> JourneyQuery)
        {
            List<LocationTable> Locationlist = null;

            try
            {
                using (var context = new AgeasDriverDetails(DBConnectionString))
                {
                    if (context.DatabaseExists())
                    {
                        Locationlist = JourneyQuery.ToList();
                    }
                    context.Dispose();
                }
            }
            catch
            {
                Locationlist = null;
            }
            return Locationlist;
        }
Example #14
0
        public Boolean InsertLocation(LocationTable LocationDtls)
        {
            Boolean result = false;
            try
            {
                using (var context = new AgeasDriverDetails(DBConnectionString))
                {
                    if (context.DatabaseExists())
                    {

                        context.tblLocation.InsertOnSubmit(LocationDtls);
                        context.SubmitChanges();
                        result = true;
                    }
                    context.Dispose();
                }
            }
            catch
            {
                result = false;
            }
            return result;
        }
        private void lstSelectJourney(object sender, SelectionChangedEventArgs e)
        {
            ListBox cmd = (ListBox)sender;
            jlist = new Journeydetail();
            jlist = (Journeydetail)cmd.SelectedItem;
            cnvBackground.Visibility = Visibility.Visible;
            progressBar1.Visibility = Visibility.Visible;
            if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None)
            {
                progressBar1.Visibility = Visibility.Visible;
                if (ObjCommon.IsRecordHaveForUpload())
                {
                    ObjSubmitJourneyLocation = new ClsSubmitJourneyLocation();
                    ObjSubmitJourneyLocation.PostJourneyLocationDetails(ObjCommon.DeviceId, this);
                    var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);
                    objDBHelper = new ClsDBHelper.ClsDBHelper();
                    IQueryable<DataAccessLayer.LocationTable> DeleteLocation = from c in context.tblLocation select c;
                    objDBHelper.DeleteLocation(DeleteLocation, context);
                }
                else
                {
                    if (jlist != null)
                    {
                        string number = jlist.journey_id;
                        ClsJourney objJourney = new ClsJourney();
                        objJourney.GetJourneyDetails(ObjCommon.DeviceId, jlist.journey_id, this);
                        //NavigationService.Navigate(new Uri("/Pages/frmDetailMessage.xaml?ph_num=" + number +"&Contact_Header=" + mlist.ContactName, UriKind.Relative));
                    }
                }

            }
            else
            {
                MessageBox.Show("Internet connection not available. Please try again later!");
            }
        }