Beispiel #1
0
        /// <summary>
        /// Send changes to DB
        /// </summary>
        /// <param name="LocalModifications"></param>
        /// <param name="deleted"></param>
        internal static async void SendChangesToDB(string LocalModificationsString, string deleted)
        {
            try
            {
                var LocalModifications = Newtonsoft.Json.JsonConvert.DeserializeObject <Rootobject>(LocalModificationsString);
                var ServerModel        = await GetModelFromServer(CollectionName, DocumentName);

                var ServerChildren  = ServerModel._object.children;
                var ServerGeometry  = ServerModel.geometries;
                var ServerMaterials = ServerModel.materials;
                var objectsOnly     = LocalModifications._object.children.Where(x => !x.name.Contains("Camera")).ToList();
                UpdateRootObject(ServerChildren, LocalModifications._object.children);

                //Update geometry
                UpdateRootObject(ServerGeometry, LocalModifications.geometries);

                UpdateRootObject(ServerMaterials, LocalModifications.materials);
                FillEmptyChildren(ServerModel);

                RhinoManagement.SaveCurrentModel(ServerModel);
                var change = new Dictionary <FieldPath, object>();
                change[new FieldPath(new string[] { "object", "children" })] = ServerModel._object.children;
                change[new FieldPath(new string[] { "geometries" })]         = ServerModel.geometries;
                await firestoreDb.Collection(CollectionName).Document(DocumentName).UpdateAsync(change);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error " + ex.Message);
                return;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create a listener to receive changes from Firebase
        /// </summary>
        public static void ReceiveChangesFromDB()
        {
            Rootobject RootObject = new Rootobject();

            try
            {
                DocumentReference       docRef   = firestoreDb.Collection(CollectionName).Document(DocumentName);
                FirestoreChangeListener listener = docRef.Listen(snapshot =>
                {
                    Console.WriteLine("Callback received document snapshot.");

                    if (snapshot.Exists)
                    {
                        Console.WriteLine("Document data for {0} document:", snapshot.Id);

                        var st          = Newtonsoft.Json.JsonConvert.SerializeObject(snapshot.ToDictionary());
                        var _RootObject = Newtonsoft.Json.JsonConvert.DeserializeObject <Rootobject>(st);
                        RhinoManagement.ProcessRemoteChanges(_RootObject);

                        //TODO check this to detect changes
                    }
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error " + ex.Message);
                return;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Send a first model to Firestore
        /// </summary>
        /// <param name="model"></param>
        /// <param name="CollectionName"></param>
        /// <param name="ModelName"></param>
        internal static async void SendModelToDB(string model, string CollectionName, string ModelName)
        {
            var models = firestoreDb.Collection(CollectionName).Document(ModelName);
            var obj    = Newtonsoft.Json.JsonConvert.DeserializeObject <Rootobject>(model);

            RhinoManagement.SaveCurrentModel(obj);
            await models.SetAsync(obj);
        }
Beispiel #4
0
        private void SendModel_Click(object sender, RoutedEventArgs e)
        {
            string ro = RhinoManagement.ConvertModelToString();

            if (ro != null)
            {
                FireBaseConnection.SendModelToDB(ro, "models", projectName);
            }
        }
Beispiel #5
0
        private void Send_Button_Click(object sender, RoutedEventArgs e)
        {
            string ro = RhinoManagement.ConvertChangesToString();

            if (ro != null)
            {
                FireBaseConnection.SendChangesToDB(ro, null);
            }


            MainForm.ClearChangedItems();
        }
Beispiel #6
0
 private void Receive_Button_Click(object sender, RoutedEventArgs e)
 {
     RhinoManagement.ApplyChanges();
     MainForm.ClearReceivedItems();
 }