partial void AddUser_TouchUpInside(NSObject sender) { double fare = 0; if (lblPassword.ToString() == null || lblPassword.ToString().Length <= 0) { CallAlert("Error adding the user", "Do not leave the password in blank."); } else if (lblEmail.ToString() == null || lblEmail.ToString().Length <= 0) { CallAlert("Error adding the user", "Do not leave the email in blank."); } if (Double.TryParse(lblAmount.Text, out fare)) { fare = Double.Parse(lblAmount.Text); } string position = lblPosition.Text; string name = lblName.Text; string rfid = lblRfid.Text; string role = "user"; if (switchAdmin.On) { role = "administrator"; } if (fare <= 0 || fare.ToString() == null || fare.ToString().Length <= 0) { CallAlert("Error adding the user", "The amount can't be lower than one."); } else if (rfid == null || rfid.Length <= 0) { CallAlert("Error adding the user", "The rfid can't be in blank."); } else if (position.Length <= 0 || position == null || name == null || name.Length <= 0) { CallAlert("Error adding the user", "Do not leave empty fields."); } else { Auth.DefaultInstance.CreateUser(lblEmail.Text, lblPassword.Text, HandleAuthResult); } void HandleAuthResult(User user, NSError error) { if (error != null) { AuthErrorCode errorCode; if (IntPtr.Size == 8) // 64 bits devices { errorCode = (AuthErrorCode)((long)error.Code); } else // 32 bits devices { errorCode = (AuthErrorCode)((int)error.Code); } // Posible error codes that CreateUser method could throw switch (errorCode) { case AuthErrorCode.InvalidEmail: CallAlert("Error", "Please insert a valid email"); break; case AuthErrorCode.EmailAlreadyInUse: CallAlert("Error", "Email is already in use"); break; case AuthErrorCode.OperationNotAllowed: CallAlert("Error", "Operation not allowed"); break; case AuthErrorCode.WeakPassword: CallAlert("Error", "Insecure password, please try again"); break; default: // Print error break; } } else { //Generates a auto id for the team members node. DatabaseReference adduserNode = userNode.GetChildByAutoId(); //Generates an auto id for the rfid node. DatabaseReference addrfidNode = rfidNode.GetChildByAutoId(); //Sets the keys and values for the node. object[] rfid_keys = { "id", "status", "tag" }; object[] rfid_val = { addrfidNode.Key, 0, lblRfid.Text }; //Join the key with the nodes. var rfid_data = NSDictionary.FromObjectsAndKeys(rfid_val, rfid_keys, rfid_keys.Length); addrfidNode.SetValue(rfid_data); //Sets the keys and values for the node. object[] keys = { "authid", "fare", "id", "name", "position", "rfid", "roles" }; object[] values = { user.Uid, fare, adduserNode.Key, name, position, addrfidNode.Key, role }; var data = NSDictionary.FromObjectsAndKeys(values, keys, keys.Length); adduserNode.SetValue(data); //Return to the main view. this.NavigationController.PopViewController(true); } } }
void Start() { FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://hero-firebase-access.firebaseio.com/"); reactions_reference = FirebaseDatabase.DefaultInstance.GetReference("live reactions"); }
private void Awake() { userReference = FirebaseManager.Instance.Reference.Child("FaustRank2"); }
public void UpdateBase() { panelLoading.SetActive(true); // Set up the Editor before calling into the realtime database. FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://tomaelcontrol-830dd.firebaseio.com/");//Here you should change for you base data link!!!! // Get the root reference location of the database. DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference; string json = JsonUtility.ToJson(workShopsSubcriptions); reference.Child("WorkShopsSubcriptions").Child(Session.auth.CurrentUser.UserId).SetRawJsonValueAsync(json).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SetRawJsonValueAsync was canceled."); AggregateException exception = task.Exception as AggregateException; if (exception != null) { FirebaseException fireBaseException = null; foreach (Exception e in exception.InnerExceptions) { fireBaseException = e as FirebaseException; if (fireBaseException != null) { break; } } if (fireBaseException != null) { Debug.LogError("SetRawJsonValueAsync encountered an error: " + fireBaseException.Message); textLogError.text = fireBaseException.Message; } } return; } if (task.IsFaulted) { Debug.LogError("SetRawJsonValueAsync was faulted."); AggregateException exception = task.Exception as System.AggregateException; if (exception != null) { FirebaseException fireBaseException = null; foreach (System.Exception e in exception.InnerExceptions) { fireBaseException = e as FirebaseException; if (fireBaseException != null) { break; } } if (fireBaseException != null) { Debug.LogError("SetRawJsonValueAsync encountered an error: " + fireBaseException.Message); textLogError.text = fireBaseException.Message; } } return; } if (task.IsCompleted) { buttonRegister.SetActive(false); buttonDoQuestion.SetActive(true); textLogError.text = "Done!"; panelLoading.SetActive(false); } }); }
/// <summary> /// Called once per frame. /// LeaderboardController's initialization and events are queued in its Database callback /// methods and then triggered in Update, because Firebase Database uses asynchronous /// threads in "ContinueWith" when results are retrieved, but many Unity functions such /// as modifying UI elements can only be called from the main thread. /// </summary> private void Update() { if (!initialized) { if (readyToInitialize) { FirebaseApp app = FirebaseApp.DefaultInstance; if (EditorAuth) { app.SetEditorP12FileName(EditorP12FileName); app.SetEditorServiceAccountEmail(EditorServiceAccountEmail); app.SetEditorP12Password(EditorP12Password); } if (app.Options.DatabaseUrl != null) { app.SetEditorDatabaseUrl(app.Options.DatabaseUrl); } dbref = FirebaseDatabase.DefaultInstance.RootReference; initialized = true; RefreshScores(); readyToInitialize = false; if (FirebaseInitialized != null) { FirebaseInitialized(this, null); } } return; } if (refreshScores) { RefreshScores(); return; } if (sendScoreAddedEvent) { sendScoreAddedEvent = false; if (ScoreAdded != null) { ScoreAdded(this, userScoreArgs); } return; } if (sendUserScoreEvent) { sendUserScoreEvent = false; if (UserScoreUpdated != null) { UserScoreUpdated(this, userScoreArgs); } return; } if (sendUpdateTopScoresEvent) { sendUpdateTopScoresEvent = false; if (TopScoresUpdated != null) { TopScoresUpdated(this, new TopScoreArgs { TopScores = TopScores, StartDate = StartDate, EndDate = EndDate }); } return; } }
private void Start() { rockStatus = false; reference = FirebaseDatabase.DefaultInstance.RootReference; }
public void RemoveListener() { availabilityRef.RemoveValue(); availabilityRef.RemoveEventListener(this); availabilityRef = null; }
public Task EditDbProperties(DatabaseReference databaseReference) { _applicationInteraction.OpenDatabaseProperties(databaseReference); return(Task.CompletedTask); }
public bool CanEditDbProperties(DatabaseReference databaseReference) { return(databaseReference != null); }
public bool CanSaveDatabaseCopyAs(DatabaseReference databaseReference) { return(databaseReference != null); }
public bool CanCloseDatabase(DatabaseReference databaseReference) { return(databaseReference != null); }
public DatabaseClosed(DatabaseReference databaseReference) { DatabaseReference = databaseReference; }
public void SignInWithEmailAndPasswordAsync() { loading.SetActive(true); Debug.Log("At the start of sign in"); FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; reference = FirebaseDatabase.DefaultInstance.RootReference; FirebaseAuth.DefaultInstance.SignInWithEmailAndPasswordAsync(Email.text.Replace(" ", "").ToLower(), Password.text).ContinueWith(task => { if (task.IsCanceled) { Debug.Log("SignInWithEmailAndPasswordAsync was canceled."); valid = false; return; } if (task.IsFaulted) { Debug.Log("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); valid = false; return; } //if no error means successfully login newUser = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); //even though login successfully we still need to check if the acc login on other devices FirebaseDatabase.DefaultInstance .GetReference("Groups/" + newUser.UserId + "/isLoggedIn").GetValueAsync().ContinueWith(signIntask => { if (signIntask.IsFaulted) { //Handle the error... Debug.LogError("Get the value of isLoggedIn encounter an error(task.IsFaulted) :" + signIntask.Exception); } else if (signIntask.IsCompleted) { LoggedInDataSnapshot = signIntask.Result; isLoggedIn = Convert.ToBoolean(LoggedInDataSnapshot.GetValue(true).ToString()); if (isLoggedIn) { //if there is another device logging into other device changeScene = false; Debug.Log("Someone log in your account..."); } else { //reference.Child("Groups").Child(newUser.UserId).Child("isLoggedIn").SetValueAsync(true); //continue with loading scene changeScene = true; Debug.Log("No one logged in into your account, logging in...Enjoy!"); //ChangeScene(); } //Do something with snapshot... } else if (signIntask.IsCanceled) { Debug.Log("Get the value of isLoggedIn encounter an error(task.IsCanceled) :" + task.Exception); } else { Debug.Log("Enter else..."); } }); }); }
public void AddChildUser() { reference = FirebaseDatabase.DefaultInstance.GetReference("Child").Child(Constants.ParentUDID); Pushid = reference.Push().Key; writeNewUser(schoolName.text, Pushid); }
public async Task <Result <CollectionDocumentChangeEventArgs> > AddFileToDatabase(DatabaseReference database) { var maybeFileName = await _applicationInteraction.ShowOpenFileDialog("Add file to database"); if (maybeFileName.HasNoValue) { return(Result.Fail <CollectionDocumentChangeEventArgs>("FILE_OPEN_CANCELED")); } try { var maybeId = await _applicationInteraction.ShowInputDialog("New file id:", "Enter new file id", Path.GetFileName(maybeFileName.Value)); if (maybeId.HasValue) { var file = database.AddFile(maybeId.Value, maybeFileName.Value); var documentsCreated = new CollectionDocumentChangeEventArgs(ReferenceNodeChangeAction.Add, new [] { file }, file.Collection); return(Result.Ok(documentsCreated)); } } catch (Exception exc) { _applicationInteraction.ShowError(exc, "Failed to upload file:" + Environment.NewLine + exc.Message, "Database error"); } return(Result.Fail <CollectionDocumentChangeEventArgs>("FILE_OPEN_FAIL")); }
public bool CanAddFile(DatabaseReference databaseReference) { return(databaseReference != null); }
public override void ViewDidLoad() { base.ViewDidLoad(); referenceBD = Database.DefaultInstance.GetRootReference(); //Eventos(); }
public bool CanAddCollection(DatabaseReference databaseReference) { return(databaseReference != null); }
public void InitializeFirebase() { auth = FirebaseAuth.DefaultInstance; DBreference = FirebaseDatabase.DefaultInstance.RootReference; }
public Task RefreshDatabase(DatabaseReference databaseReference) { databaseReference?.Refresh(); return(Task.CompletedTask); }
public void EndTrip() { newTripRef.RemoveEventListener(this); newTripRef = null; }
public bool CanRefreshDatabase(DatabaseReference databaseReference) { return(databaseReference != null); }
private void Awake() { FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://virtualtour-c8888.firebaseio.com/"); reference = FirebaseDatabase.DefaultInstance.RootReference; }
public bool CanRevealInExplorer(DatabaseReference databaseReference) { return(databaseReference != null); }
public void Start() { FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://pipebasefire.firebaseio.com/"); dbref = FirebaseDatabase.DefaultInstance.RootReference; }
public async Task OpenDatabase(string path, string password = "") { if (Store.Current.IsDatabaseOpen(path)) { return; } if (!File.Exists(path)) { _applicationInteraction.ShowError("Cannot open database, file not found.", "File not found"); return; } if (ArchiveExtensions.GetDriveType(path) == DriveType.Network) { _applicationInteraction.ShowAlert("Maintaining connection to network files is not guaranteed!", "Network file", UINotificationType.Info); } try { var rememberMe = false; if (DatabaseReference.IsDbPasswordProtected(path)) { if (string.IsNullOrWhiteSpace(password) && _recentFilesProvider.TryGetPassword(path, out var storedPassword)) { password = storedPassword; rememberMe = true; } var maybePasswordInput = await _applicationInteraction.ShowPasswordInputDialog("Database is password protected, enter password:"******"Database password.", password, rememberMe); if (maybePasswordInput.HasNoValue) { return; } password = maybePasswordInput.Value.Password; rememberMe = maybePasswordInput.Value.RememberMe; } Store.Current.AddDatabase(new DatabaseReference(path, password)); if (!string.IsNullOrEmpty(password) && rememberMe) { _recentFilesProvider.InsertRecentFile(path, password); } else { _recentFilesProvider.InsertRecentFile(path); } } catch (LiteException liteException) { await OpenDatabaseExceptionHandler(liteException, path, password); } catch (NotSupportedException notSupportedException) { _applicationInteraction.ShowError(notSupportedException, "Failed to open database [NotSupportedException]:" + Environment.NewLine + notSupportedException.Message); } catch (Exception e) { Logger.Error(e, "Failed to open database: "); _applicationInteraction.ShowError(e, "Failed to open database [Exception]:" + Environment.NewLine + e.Message); } }
void Start() { remplazo01.SetActive(false); remplazo02.SetActive(false); Instruccion = true; //PanelG1N1.SetActive(false); General.SetActive(false); BtnLink.SetActive(false); Btn_aceptar.SetActive(false); Text_text_Nivel.SetActive(false); //iden = gameObject.GetComponent<AuthManager>().userIdd.id; //iden = authManager.iden; //iden = gameObject.GetComponent<AuthManager>().ide; FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://engame-test.firebaseio.com/"); // Get the root reference location of the database. reference = FirebaseDatabase.DefaultInstance.RootReference; authUI = GetComponent <AuthUI>(); //auth = Firebase.Auth.FirebaseAuth.DefaultInstance; InitializeFirebase(); /**************/ start_time_h = DateTime.Now.Hour; start_time_m = DateTime.Now.Minute; start_time_s = DateTime.Now.Second; //puente.transform.positio //player.transform.position.x corx = 24; cory = 8; cor2x = 20; cor2y = -8; punt = 0; mesaje.text = "SCORE: " + punt; input = true; bander = true; coordenadaX = 0; coordenadaZ = 0; pushh = true; pushh2 = true; flagg = true; Screen.orientation = ScreenOrientation.Landscape; /*********************************************/ cubesPivotDistance = cubeSize * cubesInRow / 2; cubesPivot = new Vector3(cubesPivotDistance, cubesPivotDistance, cubesPivotDistance); /*********************************************/ speed = (float)0.015; timeStep = (float)1.0; flag_borde = false; bordes = new List <List <Vector2> >(); n_escenario = 0; /**************** ESCENARIO 0 *************************/ lista_aux = new List <Vector2>(); margen = new Vector2(-4, -12); lista_aux.Add(margen); margen = new Vector2(0, -12); lista_aux.Add(margen); margen = new Vector2(4, -12); lista_aux.Add(margen); margen = new Vector2(8, -12); lista_aux.Add(margen); margen = new Vector2(12, -12); lista_aux.Add(margen); margen = new Vector2(16, -12); lista_aux.Add(margen); margen = new Vector2(20, -12); lista_aux.Add(margen); margen = new Vector2(24, -12); lista_aux.Add(margen); margen = new Vector2(28, -12); lista_aux.Add(margen); margen = new Vector2(28, -8); lista_aux.Add(margen); margen = new Vector2(28, -4); lista_aux.Add(margen); margen = new Vector2(28, 0); lista_aux.Add(margen); margen = new Vector2(28, 4); lista_aux.Add(margen); margen = new Vector2(28, 8); lista_aux.Add(margen); margen = new Vector2(28, 12); lista_aux.Add(margen); margen = new Vector2(28, 16); lista_aux.Add(margen); margen = new Vector2(24, 16); lista_aux.Add(margen); margen = new Vector2(20, 16); lista_aux.Add(margen); margen = new Vector2(16, 16); lista_aux.Add(margen); margen = new Vector2(12, 16); lista_aux.Add(margen); margen = new Vector2(8, 16); lista_aux.Add(margen); margen = new Vector2(4, 16); lista_aux.Add(margen); margen = new Vector2(0, 16); lista_aux.Add(margen); margen = new Vector2(-4, 16); lista_aux.Add(margen); margen = new Vector2(-8, 16); lista_aux.Add(margen); margen = new Vector2(-8, 12); lista_aux.Add(margen); margen = new Vector2(-8, 8); lista_aux.Add(margen); margen = new Vector2(-8, 4); lista_aux.Add(margen); margen = new Vector2(-8, 0); lista_aux.Add(margen); margen = new Vector2(-8, -4); lista_aux.Add(margen); margen = new Vector2(-8, -8); lista_aux.Add(margen); complete = false; complete2 = false; bordes.Add(lista_aux); /***************** ESCENARIO II ************************/ escenario1 = new Vector2(20, 8); metas.Add(escenario1); /***************** ESCENARIO III ************************/ escenario1 = new Vector2(40, -12); metas.Add(escenario1); /***************** ESCENARIO IV ************************/ escenario1 = new Vector2(-12, -8); metas.Add(escenario1); IniciarBordes(); //margen = new Vector2(28, -8); lista_aux.Add(margen); Print_e(); }
public Task CloseDatabase(DatabaseReference database) { Store.Current.CloseDatabase(database); return(Task.CompletedTask); }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //do stuff if (scene.name == "lobby") { Debug.Log("SetUpLobby :: PLAYER_ID = " + PLAYER_ID + ", NAME = " + PLAYER_NAME); GAME_ID = null; PLAYER_TEAM = 0; // TODO: Wire this shit up in the interface... // Find ui items GameObject canvasObject = GameObject.Find("Canvas"); baseMenu = canvasObject.transform.Find("BaseMenu").gameObject; hostJoinButtons = baseMenu.transform.Find("HostJoinButtons").gameObject; GameObject hostButton = hostJoinButtons.transform.Find("HostButton").gameObject; GameObject joinButton = hostJoinButtons.transform.Find("JoinButton").gameObject; connectDialog = baseMenu.transform.Find("ConnectDialog").gameObject; GameObject backButton = connectDialog.transform.Find("BackButton").gameObject; availableGamesContainer = connectDialog.transform.Find("Games").transform.Find("AvailableGamesContainer"); // Set button onClick functions hostButton.GetComponent <Button>().onClick.AddListener(delegate { HostGame(); }); joinButton.GetComponent <Button>().onClick.AddListener(delegate { ShowAvailableGames(); }); backButton.GetComponent <Button>().onClick.AddListener(delegate { CancelHostGame(); }); // Set userinfo panel GameObject.Find("UsernameText").GetComponent <Text>().text = PLAYER_NAME; DatabaseReference winsReference = firebaseDatabaseReference.Child("users").Child(PLAYER_ID).Child("wins"); winsReference.GetValueAsync() .ContinueWith(task => { if (task.IsFaulted) { // Handle the error... } else if (task.IsCompleted) { // Get availableGames from snapshot DataSnapshot snapshot = task.Result; string snapshotString = "" + snapshot.Value; int winsInt; if (snapshotString == "") { winsInt = 0; } else { winsInt = Convert.ToInt32(snapshotString); } GameObject.Find("WinsText").GetComponent <Text>().text = "" + winsInt; } }); DatabaseReference lossesReference = firebaseDatabaseReference.Child("users").Child(PLAYER_ID).Child("losses"); lossesReference.GetValueAsync() .ContinueWith(task => { if (task.IsFaulted) { // Handle the error... } else if (task.IsCompleted) { // Get availableGames from snapshot DataSnapshot snapshot = task.Result; string snapshotString = "" + snapshot.Value; int lossesInt; if (snapshotString == "") { lossesInt = 0; } else { lossesInt = Convert.ToInt32(snapshotString); } GameObject.Find("LossesText").GetComponent <Text>().text = "" + lossesInt; } }); connectDialog.SetActive(false); hostJoinButtons.SetActive(true); baseMenu.SetActive(true); } }
public static void Compare_protein_properties() { DatabaseReference d = new DatabaseReference("asdf", "asdfg", new List <Tuple <string, string> > { new Tuple <string, string>("bbb", "ccc") }); DatabaseReference dd = new DatabaseReference("asdf", "asdfg", new List <Tuple <string, string> > { new Tuple <string, string>("bbb", "ccc") }); DatabaseReference de = new DatabaseReference("asdf", "asdefg", new List <Tuple <string, string> > { new Tuple <string, string>("bbb", "ccc") }); DatabaseReference df = new DatabaseReference("asddf", "asdfg", new List <Tuple <string, string> > { new Tuple <string, string>("bbb", "ccc") }); DatabaseReference dg = new DatabaseReference("asdf", "asdfg", new List <Tuple <string, string> > { new Tuple <string, string>("babb", "ccc") }); DatabaseReference dh = new DatabaseReference("asdf", "asdfg", new List <Tuple <string, string> > { new Tuple <string, string>("bbb", "cccf") }); Assert.True(dd.Equals(d)); Assert.False(de.Equals(d)); Assert.False(df.Equals(d)); Assert.False(dg.Equals(d)); Assert.False(dh.Equals(d)); Assert.AreEqual(5, new HashSet <DatabaseReference> { d, dd, de, df, dg, dh }.Count); SequenceVariation s = new SequenceVariation(1, "hello", "hey", "hi"); SequenceVariation sv = new SequenceVariation(1, "hello", "hey", "hi"); SequenceVariation sss = new SequenceVariation(2, "hallo", "hey", "hi"); SequenceVariation ssss = new SequenceVariation(1, "hello", "heyy", "hi"); SequenceVariation sssss = new SequenceVariation(1, "hello", "hey", "hii"); Assert.True(s.Equals(sv)); Assert.False(s.Equals(sss)); Assert.False(s.Equals(ssss)); Assert.False(s.Equals(sssss)); Assert.AreEqual(4, new HashSet <SequenceVariation> { s, sv, sss, ssss, sssss }.Count); DisulfideBond b = new DisulfideBond(1, "hello"); DisulfideBond bb = new DisulfideBond(1, "hello"); DisulfideBond bbb = new DisulfideBond(1, 2, "hello"); DisulfideBond bbbb = new DisulfideBond(1, 2, "hello"); DisulfideBond ba = new DisulfideBond(1, 3, "hello"); DisulfideBond baa = new DisulfideBond(2, 2, "hello"); DisulfideBond baaa = new DisulfideBond(1, 2, "hallo"); Assert.AreEqual(b, bb); Assert.AreEqual(bbb, bbbb); Assert.AreNotEqual(b, bbb); Assert.AreNotEqual(ba, bbb); Assert.AreNotEqual(baa, bbb); Assert.AreNotEqual(baaa, bbb); Assert.AreEqual(5, new HashSet <DisulfideBond> { b, bb, bbb, bbbb, ba, baa, baaa }.Count); ProteolysisProduct pp = new ProteolysisProduct(1, 1, "hello"); ProteolysisProduct paaa = new ProteolysisProduct(1, 1, "hello"); ProteolysisProduct p = new ProteolysisProduct(null, null, "hello"); ProteolysisProduct ppp = new ProteolysisProduct(1, 2, "hello"); ProteolysisProduct pa = new ProteolysisProduct(2, 1, "hello"); ProteolysisProduct paa = new ProteolysisProduct(1, 1, "hallo"); Assert.AreEqual(pp, paaa); Assert.AreNotEqual(p, pp); Assert.AreNotEqual(pp, ppp); Assert.AreNotEqual(pp, pa); Assert.AreNotEqual(pp, paa); Assert.AreEqual(5, new HashSet <ProteolysisProduct> { p, pp, ppp, pa, paa, paaa }.Count); }