public static async Task AddNewRoadSurvey(RoadSurvey survey, Road road = null) { await App.LocalRoadSurveyTable.InsertAsync(survey); if (road == null) road = await App.LocalRoadTable.LookupAsync(survey.RoadId); await road.AddNewSurvey(survey); }
public SingleSegmentNewSurveyVm(Segment segment, RoadSurvey roadSurvey) { Survey = new SegmentSurvey(roadSurvey, segment); if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.ContainsKey("DefaultRater")) Survey.Rater = Windows.Storage.ApplicationData.Current.LocalSettings.Values["DefaultRater"] as String; Segment = segment; EnableSaveButton = true; SurveyPhotoWrappers = new ObservableCollection<SurveyPhotoWrapper>(); }
// Default values public SegmentSurvey(RoadSurvey roadSurvey, Segment segment) { IsWindshieldSurvey = false; SegSurveyDate = DateTime.Now; RoadSurveyId = roadSurvey.Id; RoadSurveyDate = roadSurvey.Date; RoadId = roadSurvey.RoadId; InventId = segment.InventId; PlaceId = segment.PlaceId; SequenceId = segment.SequenceId; IsSynced = false; Id = ((DateTime) SegSurveyDate).ToFileTime() + "-" + InventId; CopacesRating = 100; }
private async Task editRoadSurvyToTrashRoad(RoadSurvey sr) { sr.PlaceId = "10086"; sr.RoadId = "100869999999"; try { await App.LocalRoadSurveyTable.UpdateAsync(sr); } catch (Exception updateEx) { updateEx.ToString(); throw; } }
public async Task AddNewSurvey(RoadSurvey roadSurvey) { LastSurveyDate = roadSurvey.Date; HasUnfinishedSurvey = true; await App.LocalRoadTable.UpdateAsync(this); }
public static async Task<List<SegmentSurvey>> GetSegmentSurveysByRoadSurvey(RoadSurvey roadSurvey) { return await App.LocalSegmentSurveyTable .Where(ss => ss.RoadSurveyId == roadSurvey.Id) .ToListAsync(); }
private async Task<List<Segment>> GetUnSurveyedSegments(List<Segment> allSegments, RoadSurvey roadSurvey) { var surveyedSegmentIds = await roadSurvey.GetSurveyedSegmentInventIds(); var unSurveyedSegments = allSegments .Where(s => !surveyedSegmentIds.Contains(s.InventId)) .ToList(); return unSurveyedSegments; }
/// <summary> /// "Start New Survey" Callback /// </summary> private async void ButtonStartSurvey_OnClick(object sender, RoutedEventArgs e) { var road = ViewModel.CurRoad; //var confirmDialog = // new MessageDialog("This will create a new road survey for road: " + road.Name + ", are you sure?"); //confirmDialog.Commands.Add(new UICommand("Confirm")); //confirmDialog.Commands.Add(new UICommand("Cancel")); //var confirmRes = await confirmDialog.ShowAsync(); //if (confirmRes.Label == "Confirm") //{ // Create a new road survey var newRoadSurvey = new RoadSurvey(road); await SyncHelper.AddNewRoadSurvey(newRoadSurvey, road); try { Frame.Navigate(typeof(NewSurveyPage), new NewSurveyPageNavParameter { Segments = ViewModel.Segments, RoadSurvey = newRoadSurvey }); } catch (Exception ex) { NotificationHelper.ShowErrorMessage(ex.ToString()); } //} }
private async Task<bool> checkHasUnfinishedSurvey(Road road, RoadSurvey roadSurvey) { if (roadSurvey == null) { road.HasUnfinishedSurvey = false; await App.LocalRoadTable.UpdateAsync(road); return false; } var unSurveyedSegments = await GetUnSurveyedSegments(ViewModel.Segments, roadSurvey); if (unSurveyedSegments==null || unSurveyedSegments.Count == 0) return false; return true; }