public void RemoveChild(Kindergarden kindergarden, int childId) { var child = new ChildQuery().Get(childId); kindergarden.Children.Remove(child); SessionFactoryHelper.CurrentSession.Update(kindergarden); }
public async Task <object> GetData(string Event, string Team, string Match, string Data) { string Path = "events/" + Event + "/teams/" + Team + "/matches/" + Match + "/" + Data; ChildQuery Query = Client.Child(Path); return(await Query.OnceSingleAsync <object>()); }
public FirebaseDataStore(IFirebaseAuthService authService, string path) { var token = authService.AuthLink.FirebaseToken; this.uid = authService.AuthLink.User.LocalId; _query = new FirebaseClient(Config.ApiKeys.FirebaseUrl, () => Task.FromResult(token)) .Child(path); }
public FirebaseDataStore(FirebaseAuthService authService, string path) { FirebaseOptions options = new FirebaseOptions() { AuthTokenAsyncFactory = async() => await authService.GetFirebaseAuthToken() }; _query = new FirebaseClient(BaseUrl, options).Child(path); }
static async Task Firebase() { FirebaseClient client = new FirebaseClient("https://xxxxxxxxxxxxxxx.firebaseio.com"); ChildQuery child = client.Child("xxxxxx"); Shopee data = await child.OnceSingleAsync <Shopee>(); Console.WriteLine(JsonConvert.SerializeObject(data)); }
public ReplayRepo(bool test = false) { fb = Connect().ConfigureAwait(false).GetAwaiter().GetResult(); var rootName = test ? "test" : "v2"; rootQuery = fb.Child(rootName); metas = rootQuery.Child("replays").Child("metas"); datas = rootQuery.Child("replays").Child("datas"); maps = rootQuery.Child("maps"); }
protected void AddChildClick(object sender, EventArgs e) { var child = new ChildQuery().Get(int.Parse(ChildrenList.SelectedValue)); CurrentKindergarden.Children.Add(child); KindergardenEdit.Instance.Update(CurrentKindergarden); ChildrenGrid.DataSource = CurrentKindergarden.Children; ChildrenGrid.DataBind(); }
/// <summary> /// Initializes a new instance of the <see cref="RealtimeDatabase{T}"/> class. /// </summary> /// <param name="childQuery"> The child query. </param> /// <param name="elementRoot"> The element Root. </param> /// <param name="offlineDatabaseFactory"> The offline database factory. </param> /// <param name="filenameModifier"> Custom string which will get appended to the file name. </param> /// <param name="streamChanges"> Specifies whether changes should be streamed from the server. </param> public RealtimeDatabase(ChildQuery childQuery, string elementRoot, Func <Type, string, IDictionary <string, OfflineEntry> > offlineDatabaseFactory, string filenameModifier, bool streamChanges) { this.childQuery = childQuery; this.elementRoot = elementRoot; this.streamChanges = streamChanges; this.database = offlineDatabaseFactory(typeof(T), filenameModifier); this.subject = new Subject <FirebaseEvent <T> >(); Task.Factory.StartNew(this.SynchronizeThread, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
public virtual Task SetAsync(ChildQuery query, string key, OfflineEntry entry) { if (entry.SyncOptions == SyncOptions.Put) { return(query.Child(key).PutAsync(entry.Data)); } else { return(query.Child(key).PatchAsync(entry.Data)); } }
public FirebaseDataStore(/*FirebaseAuthService authService, */ string path) { /* try to tailor out the options * FirebaseOptions options = new FirebaseOptions() * { * AuthTokenAsyncFactory = async () => await authService.GetFirebaseAuthToken() * }; */ _query = new FirebaseClient(BaseUrl /*, options*/).Child(path); }
public async Task Init(string email, string password) { await Log($"Authenticating..."); var ap = new FirebaseAuthProvider(new FirebaseConfig(apiKey)); var auth = await ap.SignInWithEmailAndPasswordAsync(email, password); var options = new FirebaseOptions { } _client = new FirebaseClient(basePath, new FirebaseOptions { AuthTokenAsyncFactory = () => Task.FromResult(auth.FirebaseToken), JsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } }); await Log($"Getting MAC Address..."); var MAC = GetMACAddress(); await Log($"Getting IP Address..."); var ip = await GetIpAddress(); await Log($"Connecting to DB..."); _rig = _client.Child($"{auth.User.LocalId}/rigs/{MAC}"); _user = _client.Child($"{auth.User.LocalId}"); _log = _client.Child($"{auth.User.LocalId}/rigs/{MAC}/console"); _logQueue.ForEach(async l => await LogQueued(l)); await Log($"MAC: {MAC}"); await Log($"IPAddress: {ip}"); await Log($"Email: {email}"); var rig = new Rig { IsActive = true }; var user = new User { IpAddress = ip }; await _user.PatchAsync(user); await _rig.PatchAsync(rig); }
protected void AddChildClick(object sender, EventArgs e) { var child = new ChildQuery().Get(int.Parse(ChildrenList.SelectedValue)); CurrentKindergarden.Children.Add(child); KindergardenEdit.Instance.Update(CurrentKindergarden); ChildrenGrid.DataSource = CurrentKindergarden.Children; ChildrenGrid.DataBind(); }
public WriteTask( RestfulFirebaseApp app, string uri, string blob, Action <RetryExceptionEventArgs> error) { App = app; Uri = uri; Blob = blob; Query = new ChildQuery(app, () => uri); cancellationSource = new CancellationTokenSource(); this.error = error; }
public virtual async Task SetAsync(ChildQuery query, string key, OfflineEntry entry) { using (var child = query.Child(key)) { if (entry.SyncOptions == SyncOptions.Put) { await child.PutAsync(entry.Data); } else { await child.PatchAsync(entry.Data); } } }
public static async void SaveOrders(List <TableOrder> orders) { string[] ConnectionStringArray = connectionString.Split(' '); string restaurantKey = ConnectionStringArray[0]; int tableId = Int32.Parse(ConnectionStringArray[1]) - 1; ChildQuery childQuery = firebaseClient.Child("Restaurants").Child(restaurantKey).Child("Tables").Child(tableId.ToString()); Table table = restaurant.Tables.FirstOrDefault(x => x.Number == (tableId + 1)); table.Orders = orders; await childQuery.PutAsync(table); }
/// <summary> /// Initializes a new instance of the <see cref="RealtimeDatabase{T}"/> class. /// </summary> /// <param name="childQuery"> The child query. </param> /// <param name="elementRoot"> The element Root. </param> /// <param name="offlineDatabaseFactory"> The offline database factory. </param> /// <param name="filenameModifier"> Custom string which will get appended to the file name. </param> /// <param name="streamChanges"> Specifies whether changes should be streamed from the server. </param> /// <param name="pullEverythingOnStart"> Specifies if everything should be pull from the online storage on start. It only makes sense when <see cref="streamChanges"/> is set to true. </param> /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. It this is false, then Put / Post / Delete will not affect server data. </param> public RealtimeDatabase(ChildQuery childQuery, string elementRoot, Func <Type, string, IDictionary <string, OfflineEntry> > offlineDatabaseFactory, string filenameModifier, bool streamChanges, InitialPullStrategy initialPullStrategy, bool pushChanges) { this.childQuery = childQuery; this.elementRoot = elementRoot; this.streamChanges = streamChanges; this.initialPullStrategy = initialPullStrategy; this.pushChanges = pushChanges; this.Database = offlineDatabaseFactory(typeof(T), filenameModifier); this.firebaseCache = new FirebaseCache <T>(new OfflineCacheAdapter <string, T>(this.Database)); this.subject = new Subject <FirebaseEvent <T> >(); this.PutHandler = new SetHandler <T>(); Task.Factory.StartNew(this.SynchronizeThread, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
private async Task Init() { var apiKey = "AIzaSyAf3zX8rG4hGfjLQK4Er61bTW7cQjTptgE"; // your app secret var firebaseAuthProvider = new FirebaseAuthProvider(new FirebaseConfig(apiKey)); var auth = await firebaseAuthProvider.SignInAnonymouslyAsync(); firebaseClient = new FirebaseClient( "https://barontest-152eb.firebaseio.com/", new FirebaseOptions { AuthTokenAsyncFactory = () => Task.FromResult(auth.FirebaseToken.ToString()) }); notifications = firebaseClient.Child("notifications"); await notifications.DeleteAsync(); }
public FirebaseOfflineCacheRepo( FirebaseClient client, string path, string key = "", StreamingOptions streaming = StreamingOptions.None, InitialPullStrategy initialPull = InitialPullStrategy.Everything) { // The offline database filename is named after type T. // So, if you have more than one list of type T objects, you need to differentiate it // by adding a filename modifier; which is what we're using the "key" parameter for. _baseQuery = client.Child(path); _realtimeDb = _baseQuery .AsRealtimeDatabase <T>(key, string.Empty, streaming, initialPull, true); SyncExceptionThrown = Observable .FromEventPattern <ExceptionEventArgs>( h => _realtimeDb.SyncExceptionThrown += h, h => _realtimeDb.SyncExceptionThrown -= h); }
//constructor for card public CardPage(string player, string cardType, string cardLoc, string cardPos, string cardSource) { InitializeComponent(); this.player = player; this.cardType = cardType; this.cardLoc = cardLoc; this.cardPos = cardPos; this.cardSource = cardSource; //init firebase firebase = new FirebaseClient("https://holoyugioh.firebaseio.com"); if (!string.IsNullOrEmpty(player)) { child = firebase.Child(string.Format("Game/Players/{0}/Field/{1}/{2}", player, cardType, cardLoc)); } //init NFC device = DependencyService.Get <INfcForms>(); device.NewTag += HandleNewTag; //init source if (!string.IsNullOrWhiteSpace(cardSource)) { card.Source = cardSource; } //remove specific buttons if (cardType.Equals(GameInfo.SpellTrap)) { defense.IsVisible = false; down.IsVisible = false; } else if (cardType.Equals(GameInfo.Monster)) { set.IsVisible = false; } }
public static async Task Disconnect() { string[] ConnectionStringArray = connectionString.Split(' '); string restaurantKey = ConnectionStringArray[0]; int tableId = Int32.Parse(ConnectionStringArray[1]) - 1; ChildQuery childQuery = firebaseClient.Child("Restaurants").Child(restaurantKey).Child("Tables").Child(tableId.ToString()); Table table = restaurant.Tables.FirstOrDefault(x => x.Number == (tableId + 1)); table.OccupiedStatus = false; table.Orders = null; await childQuery.PutAsync(table); restaurant.Menu.Clear(); restaurant = null; ConnectionStatus = false; }
//initializer private AppData(Context thisContext) { currentLists = new List <GroceryListClass>(); var options = new Firebase.FirebaseOptions.Builder() .SetApplicationId("1:269645497682:android:41aae10df759a3e12da68b") .SetApiKey("AIzaSyDrsPpcJX-o6wnrhbfY5PbOW5frpoNE2MA") .Build(); if (fireApp == null) { fireApp = FirebaseApp.InitializeApp(thisContext, options); } auth = FirebaseAuth.GetInstance(fireApp); string FirebaseURL = "https://groceries-project.firebaseio.com"; FirebaseClient rootNode = new FirebaseClient(FirebaseURL); dataNode = rootNode.Child("data"); usersNode = rootNode.Child("users"); }
public static async Task Read() { AppData.onlineLists = new List <GroceryListClass>(); if (AppData.auth.CurrentUser == null) { return; } ChildQuery listsNode = AppData.dataNode.Child(AppData.currentUser.Uid); var allListsData = await listsNode.OnceAsync <TempGroceryListClass>(); foreach (FirebaseObject <TempGroceryListClass> any in allListsData) { List <ItemClass> itemsOfList = new List <ItemClass>(); ChildQuery thisListNode = listsNode.Child(any.Object.Name); var readItems = await thisListNode.Child("Items").OnceAsync <ItemClass>(); foreach (FirebaseObject <ItemClass> anyItem in readItems) { itemsOfList.Add(anyItem.Object); } GroceryListClass thisList = new GroceryListClass { Name = any.Object.Name, Items = itemsOfList, Owner = any.Object.Owner }; AppData.onlineLists.Add(thisList); } }
public static async Task Connect(string restaurantConnectionString) { string[] restaurantConnectionStringArray = restaurantConnectionString.Split(' '); string restaurantKey = restaurantConnectionStringArray[0]; int tableId = Int32.Parse(restaurantConnectionStringArray[1]) - 1; firebaseClient = new FirebaseClient(Constants.FirebaseUrl); connectionString = restaurantConnectionString; ChildQuery childQuery = firebaseClient.Child("Restaurants").Child(restaurantKey); restaurant = await childQuery.OnceSingleAsync <Restaurant>(); childQuery = firebaseClient.Child("Restaurants").Child(restaurantKey).Child("Tables").Child(tableId.ToString()); Table table = restaurant.Tables.FirstOrDefault(x => x.Number == (tableId + 1)); table.OccupiedStatus = true; await childQuery.PutAsync(table); ConnectionStatus = true; }
/// <summary> /// Create new instances of the <see cref="RealtimeDatabase{T}"/>. /// </summary> /// <typeparam name="T"> Type of elements. </typeparam> /// <typeparam name="TSetHandler"> Type of the custom <see cref="ISetHandler{T}"/> to use. </typeparam> /// <param name="filenameModifier"> Custom string which will get appended to the file name. </param> /// <param name="elementRoot"> Optional custom root element of received json items. </param> /// <param name="streamingOptions"> Realtime streaming options. </param> /// <param name="initialPullStrategy"> Specifies what strategy should be used for initial pulling of server data. </param> /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. It this is false, then Put / Post / Delete will not affect server data. </param> /// <returns> The <see cref="RealtimeDatabase{T}"/>. </returns> public static RealtimeDatabase <T> AsRealtimeDatabase <T, TSetHandler>(this ChildQuery query, string filenameModifier = "", string elementRoot = "", StreamingOptions streamingOptions = StreamingOptions.LatestOnly, InitialPullStrategy initialPullStrategy = InitialPullStrategy.MissingOnly, bool pushChanges = true) where T : class where TSetHandler : ISetHandler <T>, new() { return(new RealtimeDatabase <T>(query, elementRoot, query.Client.Options.OfflineDatabaseFactory, filenameModifier, streamingOptions, initialPullStrategy, pushChanges, Activator.CreateInstance <TSetHandler>())); }
/// <summary> /// Order data by given <see cref="propertyName"/>. Note that this is used mainly for following filtering queries and due to firebase implementation /// the data may actually not be ordered. /// </summary> /// <param name="child"> The child. </param> /// <param name="propertyName"> The property name. </param> /// <returns> The <see cref="OrderQuery"/>. </returns> public static OrderQuery OrderBy(this ChildQuery child, string propertyName) { return(child.OrderBy(() => propertyName)); }
/// <summary> /// References a sub child of the existing node. /// </summary> /// <param name="node"> The child. </param> /// <param name="path"> The path of sub child. </param> /// <returns> The <see cref="ChildQuery"/>. </returns> public static ChildQuery Child(this ChildQuery node, string path) { return(node.Child(() => path)); }
public FirebaseChildQuery(ChildQuery query) : base(query) { Query = query; }
public void Delete(int id) { var entity = new ChildQuery().Get(id); SessionFactoryHelper.CurrentSession.Delete(entity); }
public FirebaseRepo(FirebaseClient client, string path) { _childQuery = client.Child(path); }
public virtual Task PutAsync(ChildQuery query, string key, OfflineEntry entry) { return(query.Child(key).PutAsync(entry.Deserialize <T>())); }
public Task SetAsync(ChildQuery query, string key, OfflineEntry entry) { var user = entry.Deserialize <User>(); return(query.Child(key).Child("currentTabId").PutAsync <string>(user.ActiveGroupId)); }