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(); }
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 { } }
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; } } }
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; } }
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; }
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; }
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) { } }
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(); } }
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!"); } }