public IQuery EndBefore(IDocumentSnapshot document) { var wrapper = (DocumentSnapshotWrapper)document; var query = Query.EndingBefore(wrapper.DocumentSnapshot); return(new QueryWrapper(query)); }
public LocationInfo(GeoPoint location, bool inGeoQuery, IDocumentSnapshot snapshot) { Location = location; InGeoQuery = inGeoQuery; GeoHash = new GeoHash(location); Snapshot = snapshot; }
public IQuery StartAfter(IDocumentSnapshot document) { var wrapper = (DocumentSnapshotWrapper)document; var query = Query.StartingAfter(wrapper.DocumentSnapshot); return(new QueryWrapper(query)); }
public async Task <User> GetUserByPresenceIdAsync(string presenceId) { User result = null; if (!string.IsNullOrEmpty(presenceId)) { try { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(User)).WhereEqualsTo(nameof(User.PresenceId), presenceId).GetDocumentsAsync(); IDocumentSnapshot documentSnapshot = querySnapshot.Documents.FirstOrDefault(); if (documentSnapshot.Exists) { result = documentSnapshot.ToObject <User>(); } } catch (Exception e) { result = null; App.LogException(e); } } return(result); }
public async Task <ObservableCollection <Event> > GetNextEventListByParticipantUsername(string username, Event evento) { ObservableCollection <Event> result = new ObservableCollection <Event>(); try { IDocumentSnapshot documentSnapshotLast = await _firestore.GetCollection(nameof(Event)).GetDocument(evento.Id).GetDocumentAsync(); if (documentSnapshotLast != null) { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(Event)) .WhereArrayContains(nameof(Event.UsersList), username) .OrderBy(nameof(Event.StartDateTime), true) .StartAfter(documentSnapshotLast) .LimitTo(20) .GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { Event newEvent = documentSnapshot.ToObject <Event>(); result.Add(newEvent); } } } } catch (Exception e) { result = null; App.LogException(e); } return(result); }
private void ChildRemoved(IDocumentSnapshot document) { var key = document.Id; var info = _locationInfos[key]; if (info == null) { return; } lock (_lock) { var location = GeoFire.GetLocationValue(document); var hash = (location != null) ? new GeoHash(location) : null; if (hash != null && GeoHashQueriesContainGeoHash(hash)) { return; } _locationInfos.Remove(key); if (!info.InGeoQuery) { return; } OnDocumentExited?.Invoke(this, new DocumentEventArgs <T>(info.Snapshot.ToObject <T>())); } }
public IQuery StartAt(IDocumentSnapshot document) { var wrapper = (DocumentSnapshotWrapper)document; var query = CollectionReference.StartingAt(wrapper.DocumentSnapshot); return(new QueryWrapper(query)); }
public IQuery EndAt(IDocumentSnapshot document) { var wrapper = (DocumentSnapshotWrapper)document; var query = _query.EndingAt((DocumentSnapshot)wrapper); return(new QueryWrapper(query)); }
public IQuery EndBefore(IDocumentSnapshot document) { var wrapper = (DocumentSnapshotWrapper)document; var query = _collectionReference.EndBefore((DocumentSnapshot)wrapper); return(new QueryWrapper(query)); }
public IQuery StartAfter(IDocumentSnapshot document) { var wrapper = (DocumentSnapshotWrapper)document; var query = _collectionReference.StartAfter((DocumentSnapshot)wrapper); return(new QueryWrapper(query)); }
private void UpdateLocationInfo(IDocumentSnapshot document, GeoPoint location) { var key = document.Id; _locationInfos.TryGetValue(key, out var oldInfo); var isNew = oldInfo == null; var changedLocation = oldInfo != null && !Equals(oldInfo.Location, location); var wasInQuery = oldInfo != null && oldInfo.InGeoQuery; var isInQuery = LocationIsInQuery(location); if ((isNew || !wasInQuery) && isInQuery) { OnDocumentEntered?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>(), location)); } else if (!isNew && isInQuery) { if (changedLocation) { OnDocumentMoved?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>(), location)); } OnDocumentChanged?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>(), location)); } else if (wasInQuery && !isInQuery) { OnDocumentExited?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>())); } var newInfo = new LocationInfo(location, LocationIsInQuery(location), document); _locationInfos.Add(key, newInfo); }
public static DocumentSnapshot ToNative(this IDocumentSnapshot @this) { if (@this is DocumentSnapshotWrapper wrapper) { return(wrapper.Wrapped); } throw new FirebaseException($"This implementation of {nameof(IDocumentSnapshot)} is not supported for this method"); }
public DocumentChange( IDocumentSnapshot documentSnapshot, DocumentChangeType changeType, int newIndex, int oldIndex) { DocumentSnapshot = documentSnapshot; ChangeType = changeType; NewIndex = newIndex; OldIndex = oldIndex; }
public static GeoPoint GetLocationValue(IDocumentSnapshot documentSnapshot) { var data = documentSnapshot.Data; var geoPoint = (GeoPoint)data["l"]; if (!GeoUtils.CoordinatesValid(geoPoint.Latitude, geoPoint.Longitude)) { throw new ArgumentException($"Check {documentSnapshot.Id}. " + $"GeoPoint [lat: {geoPoint.Latitude}, long: {geoPoint.Longitude}] is invalid"); } return(geoPoint); }
public async Task <Int64> CreateOrderIdAsync() { IDocumentSnapshot document = await fireStoreInstance.GetDocument("/OrderIds/unCmzg3mr1W9U9pAQQSk").GetDocumentAsync(); OrderId orderId = document.ToObject <OrderId>(); Int64 currentOrderId = orderId.Id; orderId.Id = currentOrderId + 1; await fireStoreInstance.GetDocument("/OrderIds/unCmzg3mr1W9U9pAQQSk").UpdateDataAsync(orderId); return(await Task.FromResult(orderId.Id)); }
private void ChildChanged(IDocumentSnapshot document) { var location = GeoFire.GetLocationValue(document); if (location != null) { UpdateLocationInfo(document, location); } else { Debug.Assert(false, "Got Datasnapshot without location with key " + document.Id); } }
public async Task <ObservableCollection <Event> > GetNextFutureEventListPageAsync(Event evento) { ObservableCollection <Event> result = new ObservableCollection <Event>(); if (evento != null) { try { IDocumentSnapshot documentSnapshotLast = await _firestore.GetCollection(nameof(Event)).GetDocument(evento.Id).GetDocumentAsync(); if (documentSnapshotLast != null) { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(Event)) .WhereGreaterThanOrEqualsTo(nameof(Event.StartDateTime), DateTime.Now) .OrderBy(nameof(Event.StartDateTime)) .StartAfter(documentSnapshotLast) .LimitTo(20) .GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { Event newEvent = documentSnapshot.ToObject <Event>(); result.Add(newEvent); } } } } catch (Exception e) { result = null; App.LogException(e); } } return(result); }
public async Task <User> GetUserAsync(string email) { User result = null; if (!string.IsNullOrEmpty(email)) { try { IDocumentSnapshot documentSnapshot = await _firestore.GetCollection(nameof(User)).GetDocument(email).GetDocumentAsync(); if (documentSnapshot.Exists) { result = documentSnapshot.ToObject <User>(); } } catch (Exception e) { result = null; App.LogException(e); } } return(result); }
public async Task <Event> GetEventAsync(string id) { Event result = null; if (!string.IsNullOrEmpty(id)) { try { IDocumentSnapshot documentSnapshot = await _firestore.GetCollection(nameof(Event)).GetDocument(id).GetDocumentAsync(); if (documentSnapshot.Exists) { result = documentSnapshot.ToObject <Event>(); } } catch (Exception e) { result = null; App.LogException(e); } } return(result); }
public MyHttpServer(IDocumentSnapshot document, int port) : base(port) { _document = document; }
public MyHttpServer(IDocumentSnapshot document, int port) : base(port) { _document = document; }
public IQuery EndBefore(IDocumentSnapshot document) { var query = _collectionReference.EndingBefore(document.ToNative()); return(new QueryWrapper(query)); }
public IQuery StartAfter(IDocumentSnapshot document) { var query = _query.StartingAfter(document.ToNative()); return(new QueryWrapper(query)); }
public IQuery EndBefore(IDocumentSnapshot document) { var query = _query.EndingBefore(document.ToNative()); return(new QueryWrapper(query)); }
public IQuery StartAfter(IDocumentSnapshot document) { var query = _collectionReference.StartingAfter(document.ToNative()); return(new QueryWrapper(query)); }
public IQuery StartingAfter(IDocumentSnapshot snapshot) { return(_wrapped.StartAfter(snapshot.ToNative()).ToAbstract()); }
public IQuery EndingBefore(IDocumentSnapshot snapshot) { return(_wrapped.EndBefore(snapshot.ToNative()).ToAbstract()); }