Beispiel #1
0
    public void SetEachPlantDataInDbAfterCreatingContract()
    {
        plant                   = new SinglePlantFive();
        plant.ContractID        = ContractID;
        plant.isPlantInContract = true;
        plant.isPlantPlanted    = true;
        plant.isDroneAssigned   = false;
        plant.FieldID           = id;

        string ToJson = JsonUtility.ToJson(plant);

        reference.Child("USERS").Child(LogInAndRegister.Instance.UserName).Child("GAMESPACE").Child("CONTRACT" + plant.ContractID).Child("PLANTS").Child("PLANT" + plant.FieldID).SetRawJsonValueAsync(ToJson);
    }
Beispiel #2
0
 public void GetDBDataForPlant()
 {
     FirebaseDatabase.DefaultInstance
     .GetReference("USERS").Child(LogInAndRegister.Instance.UserName).Child("GAMESPACE").Child("CONTRACT" + ContractID).Child("PLANTS").Child("PLANT" + id)
     .GetValueAsync().ContinueWith(task =>
     {
         if (task.IsFaulted)
         {
             // Handle the error...
         }
         else if (task.IsCompleted)
         {
             DataSnapshot snapshot = task.Result;
             Debug.Log("data for plant " + snapshot.GetRawJsonValue());
             plant = JsonUtility.FromJson <SinglePlantFive>(snapshot.GetRawJsonValue());
         }
     });
 }