public void GetJourneyDetails(RootObjectJourneydetail Journey) { ObjCommon.JourneyListDetails = JsonConvert.SerializeObject(Journey); StrCommonObject = JsonConvert.SerializeObject(ObjCommon); var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString); 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); ObjCommon.JourneySave(); }
public void gotoProgress() { var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString); int NoOfRecord = (from a in context.tblJourneyDetails select a.Last_distance).Count(); if (NoOfRecord > 0) { ObjCommon.TotalJourney = Convert.ToDouble((from a in context.tblJourneyDetails select a.Last_distance).Sum()); // Double DTotalJourney = Convert.ToDouble(LastDistIDQuery.Sum()); //ObjCommon.TotalJourney = Convert.ToDouble(LastDistIDQuery); } else { if (ObjCommon != null) ObjCommon.TotalJourney = 0; } StrCommonObject = JsonConvert.SerializeObject(ObjCommon); Deployment.Current.Dispatcher.BeginInvoke(() => { StrCommonObject = JsonConvert.SerializeObject(ObjCommon); NavigationService.Navigate(new Uri("/Pages/FrmProgress.xaml?common=" + StrCommonObject, UriKind.Relative)); }); }
private void WaitTrick(object sender, EventArgs e) { try { LoadIntervalCount +=1; if (LoadIntervalCount > 10) { timerLoading.Stop(); var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString); decimal LastDistIDQuery = (from a in context.tblJourneyDetails select a.Last_distance).Sum(); // Double DTotalJourney = Convert.ToDouble(LastDistIDQuery.Sum()); ObjCommon.TotalJourney = Convert.ToDouble(LastDistIDQuery); Deployment.Current.Dispatcher.BeginInvoke(() => { StrCommonObject = JsonConvert.SerializeObject(ObjCommon); NavigationService.Navigate(new Uri("/Pages/FrmProgress.xaml?common=" + StrCommonObject, UriKind.Relative)); }); } } catch { } }
private void OfflineJourneySave() { string TotalRun = runTime.ToString(@"hh\:mm\:ss"); Double Totaldistance = Getdistance(StartLatitude, StartLongitude, EndLatitude, EndLongitude); if (Totaldistance > 0.5) { var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString); int JourneyIDQuery = (from a in context.tblJourneyDetails select a.JourneyId).Count(); DataAccessLayer.JourneyDetails ObjJourney = new DataAccessLayer.JourneyDetails(); if (JourneyIDQuery > 0) { decimal LastDistIDQuery = (from a in context.tblJourneyDetails select a.Total_distance).Sum(); double DLastDistIDQuery = Convert.ToDouble(LastDistIDQuery); Totaldistance = Totaldistance + DLastDistIDQuery; ObjJourney.Total_distance = Convert.ToDecimal(Totaldistance); } else { ObjJourney.Total_distance = Convert.ToDecimal(Totaldistance); } lastJourneyID = JourneyIDQuery + 1; ObjJourney.JourneyId = lastJourneyID; ObjJourney.Last_distance = Convert.ToDecimal(Totaldistance); ObjJourney.TimeDuration = TotalRun; ObjJourney.JDate = System.DateTime.Now.ToString(); objDBHelper.InsertJourney(ObjJourney); ObjJourney = null; } else { IntervalForwait(); ImgLoader.Visibility = Visibility.Visible; LoaderMsg.Visibility = Visibility.Visible; progressBar1.Visibility = Visibility.Visible; var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString); objDBHelper = new ClsDBHelper.ClsDBHelper(); IQueryable<DataAccessLayer.LocationTable> DeleteLocation = from c in context.tblLocation where c.Journeyid == lastJourneyID select c; objDBHelper.DeleteLocation(DeleteLocation, context); } }
private void ImgButton_Tab(object sender, System.Windows.Input.GestureEventArgs e) { if(!IsImageChange) { objDBHelper = new ClsDBHelper.ClsDBHelper(); var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString); int JourneyIDQuery = (from a in context.tblLocation select a.Journeyid).Count(); lastJourneyID = JourneyIDQuery + 1; IsFirst = true; IsImageChange = true; ImgButton.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Record/stopButton")); ImgGreen.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Record/greenlightActive")); ImgRed.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Record/redlight")); cnvBackground.Visibility = Visibility.Visible; ImageAnimation(); //IntervalForGpsTrack(); App.RunningInBackground = true; App.Geolocator = new Geolocator(); App.Geolocator.DesiredAccuracy = PositionAccuracy.High; App.Geolocator.ReportInterval = (uint)TimeSpan.FromSeconds(22).TotalMilliseconds; //App.Geolocator.MovementThreshold = 1; // The units are meters. App.Geolocator.PositionChanged += geolocator_PositionChanged; } else { IsImageChange = false; ImgButton.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Record/startButton")); ImgGreen.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Record/greenlight")); ImgRed.Source = new System.Windows.Media.Imaging.BitmapImage(ClsCommon.GetScaledImageUri("/Images/Record/RedlightActive")); timer.Stop(); //timerGPS.Stop(); App.RunningInBackground = false; cnvBackground.Visibility = Visibility.Collapsed; OfflineJourneySave(); } }
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { ObjLocationTbl = new DataAccessLayer.LocationTable(); try { ObjLocationTbl.Journeyid = lastJourneyID; ObjLocationTbl.Lat = args.Position.Coordinate.Latitude.ToString(); ObjLocationTbl.Long = args.Position.Coordinate.Longitude.ToString(); ObjLocationTbl.DateTime = String.Format("{0:yyyy-MM-dd H:mm:ss}", System.DateTime.Now.ToLocalTime()); var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString); if (IsFirst) { StartLatitude = args.Position.Coordinate.Latitude; StartLongitude = args.Position.Coordinate.Longitude; EndLatitude = args.Position.Coordinate.Latitude; EndLongitude = args.Position.Coordinate.Longitude; IsFirst = false; } else { EndLatitude = args.Position.Coordinate.Latitude; EndLongitude = args.Position.Coordinate.Longitude; } objDBHelper.InsertLocation(ObjLocationTbl); } catch { } ObjLocationTbl = null; if (!App.RunningInBackground) { Dispatcher.BeginInvoke(() => { ; }); } else { Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast(); toast.Content = args.Position.Coordinate.Latitude.ToString("0.00") + "," + args.Position.Coordinate.Longitude.ToString("0.00"); toast.Title = "Location: "; toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative); toast.Show(); } }