public MaintenanceCollection GeographyNeedsUpdated() { //Repositories.LocationRepo.SetMaintenanceFlags(); var maintColl = new MaintenanceCollection(); maintColl.Title = "Database 'Geography' Data Needs Updated"; maintColl.Locations = Repositories.LocationRepo.GetAllMissingDbGeo(); maintColl.ConvertToJsonLocationsOnly(); return(maintColl); }
private async void KegsCommandRecieverAsync() { try { await _navigationService.GoBackAsync(animated : false); KegHasAlert = false; Alerts = null; MaintenanceCollection.Clear(); RemoveMaintenanceCollection.Clear(); } catch (Exception ex) { Crashes.TrackError(ex); } }
private async void AddAlertCommandRecieverAsync() { if (SelectedMaintenance != null) { List <long> neededTypes = MaintenanceCollection.Where(x => x.Id == SelectedMaintenance.Id).Select(x => x.Id).ToList(); var model = new AddMaintenanceAlertRequestModel { AlertCc = "", DueDate = SelectedMaintenance.DueDate, KegId = KegId, Message = SelectedMaintenance.Message, NeededTypes = neededTypes, ReminderDays = 5 }; try { Loader.StartLoading(); var result = await _dashboardService.PostMaintenanceAlertAsync(model, AppSettings.SessionId, Configuration.PostedMaintenanceAlert); if (result.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString()) { await _dialogService.DisplayAlertAsync("Alert", "Alert adedd successfuly", "Ok"); foreach (var item in result.AddMaintenanceAlertResponseModel) { var removal = MaintenanceCollection.Where(x => x.Id == item.MaintenanceType.Id).FirstOrDefault(); if (removal != null) { MaintenanceCollection.Remove(removal); RemoveMaintenanceCollection.Add(removal); } } } } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); SelectedMaintenance = null; } } }
private async void RemoveAlertCommandRecieverAsync() { if (RemoveSelecetedMaintenance != null) { var neededTypes = RemoveMaintenanceCollection.Where(x => x.Id == RemoveSelecetedMaintenance.Id).Select(x => x.Id).FirstOrDefault(); Loader.StartLoading(); var model = new DeleteMaintenanceAlertRequestModel { KegId = KegId, TypeId = neededTypes, }; try { var result = await _dashboardService.PostMaintenanceDeleteAlertUrlAsync(model, AppSettings.SessionId, Configuration.DeleteTypeMaintenanceAlert); if (result.Response.StatusCode == System.Net.HttpStatusCode.OK.ToString()) { Loader.StopLoading(); await _dialogService.DisplayAlertAsync("Alert", "Alert removed successfuly", "Ok"); foreach (var item in result.AddMaintenanceAlertResponseModel) { var removedItem = RemoveMaintenanceCollection.Where(x => x.Id != item.MaintenanceType.Id).First(); if (removedItem != null) { RemoveMaintenanceCollection.Remove(removedItem); MaintenanceCollection.Add(removedItem); } break; } } } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); RemoveSelecetedMaintenance = null; } } }
public MaintenanceCollection GetLocsWithMissingCoordinates() { //Repositories.LocationRepo.SetMaintenanceFlags(); var maintColl = new MaintenanceCollection(); maintColl.Title = "Addresses missing coordinates"; var locMissing = new List <Location>(); var locMissingLat = locService.GetLocationsByPropertyValue("Latitude", 0); var locMissingLong = locService.GetLocationsByPropertyValue("Longitude", 0); locMissing.AddRange(locMissingLat); locMissing.AddRange(locMissingLong); maintColl.Locations = locMissing; maintColl.ConvertToJsonLocationsOnly(); return(maintColl); }
public async Task LoadMaintenanceHistoryAsync(string _kegId, string _contents, long _heldDays, string _possessorName, string _barcode, string _typeName, string _sizeName) { try { Loader.StartLoading(); KegId = _kegId; Contents = _contents == string.Empty ? "--" : _contents; HeldDays = _heldDays; PossessorName = _possessorName; Barcode = _barcode; TypeName = _typeName; SizeName = _sizeName; var kegStatus = await _dashboardService.GetKegStatusAsync(KegId, AppSettings.SessionId); var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); var addMaintenanceCollection = RealmDb.All <MaintainTypeReponseModel>().ToList(); KegHasAlert = kegStatus.MaintenanceAlerts.Count > 0 ? true : false; Alerts = kegStatus.MaintenanceAlerts; try { foreach (var item in addMaintenanceCollection) { var flag = kegStatus.MaintenanceAlerts.Where(x => x.Id == item.Id).FirstOrDefault(); if (flag == null) { MaintenanceCollection.Add(new MaintenanceAlert { Id = (int)item.Id, ActivationMethod = item.ActivationMethod, AssetSize = "", AssetType = "", Barcode = Barcode, DefectType = item.DefectType.ToString(), DueDate = DateTimeOffset.Now, IsActivated = false, KegId = _kegId, LocationId = kegStatus.Location.PartnerId, LocationName = kegStatus.Owner.FullName, Message = "", Name = item.Name, OwnerId = kegStatus.Pallet?.OwnerId, OwnerName = kegStatus.Pallet?.OwnerName, PalletBarcode = kegStatus.Pallet?.Barcode, PalletId = kegStatus.Pallet?.PalletId, TypeId = kegStatus.TypeId, TypeName = kegStatus.TypeName }); } } } catch (Exception ex) { Crashes.TrackError(ex); } RemoveMaintenanceCollection = new ObservableCollection <MaintenanceAlert>(kegStatus.MaintenanceAlerts); Owner = kegStatus.Owner.FullName; Batch = kegStatus.Batch == string.Empty ? "--" : kegStatus.Batch; Posision = new LocationInfo { Address = kegStatus.Location.Address, Label = kegStatus.Location.City, Lat = kegStatus.Location.Lat, Lon = kegStatus.Location.Lon }; var value = await _dashboardService.GetKegMaintenanceHistoryAsync(KegId, AppSettings.SessionId); MaintenancePerformedCollection = value.KegMaintenanceHistoryResponseModel; if (value.KegMaintenanceHistoryResponseModel.Count > 0) { IsVisibleListView = true; } else { IsVisibleListView = false; } } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); } }