예제 #1
0
        private void UpdatePlayer(bool create)
        {
            Debug.Log("<color=yellow>Updating cloud data: player called Mithrandir will be level 100.</color>");

            // Get the json string of the object.
            string jsonPlayer = JsonUtility.ToJson(_playerData);

            // Look in the 'PlayerInfo' table, for an object of name as specified, and overwrite with the current obj data.
            Drive.UpdateObjects(_tableName, "name", _playerData.name, jsonPlayer, create, true);
        }
        public void UpdatePhotoInfo(int currentPhotoTemp, string columnName, string updatedValue)
        {
            // We will update an entire row for this photo.  Might someday update just the specific cell if faster.
            // First, construct a row item with current photo data...
            //int i = photoReview.currentPhoto;
            int    i                = currentPhotoTemp;
            string rowUID           = allPhotos[i].filename; // TODO: see if match on filename is much faster than dropbox_path
            string columnToMatchUID = "filename";
            // handle blank date field
            var dateTempString = "";

            if (allPhotos[i].date != "")
            {
                //dateTempString = System.DateTime.Parse(allPhotos[i].date).ToString("d"); // de-serialize JSON formatting of date (not needed?)
            }

            PhotoInfo _photoData = new PhotoInfo
            {
                filename         = allPhotos[i].filename,
                photo_uid        = allPhotos[i].photo_uid,
                dropbox_path     = allPhotos[i].dropbox_path,
                folder           = allPhotos[i].folder,
                date             = dateTempString,
                location         = allPhotos[i].location,
                comments         = allPhotos[i].comments,
                favorite         = allPhotos[i].favorite,
                forget_photo     = allPhotos[i].forget_photo,
                file_type        = allPhotos[i].file_type,
                audio_file_path  = allPhotos[i].audio_file_path,
                last_edited_date = allPhotos[i].last_edited_date,
                last_editor_name = allPhotos[i].last_editor_name
            };

            // Now substitute in the updatedValue wherever it belongs...
            if (columnName == "date")
            {
                _photoData.date = updatedValue;
            }
            if (columnName == "location")
            {
                _photoData.location = updatedValue;
            }
            if (columnName == "comments")
            {
                _photoData.comments = updatedValue;
            }
            if (columnName == "favorite")
            {
                _photoData.favorite = updatedValue;
            }
            if (columnName == "forget_photo")
            {
                _photoData.forget_photo = updatedValue;
            }
            if (columnName == "audio_file_path")
            {
                _photoData.audio_file_path = updatedValue;
            }

            // Add last_edited_date and last_editor_name
            //dateTempString = System.DateTime.Now.ToLongTimeString();
            string dateTimeNowString = System.DateTime.Now.ToString("yyyy-MM-dd\\THH:mm:ss\\Z");

            _photoData.last_edited_date = dateTimeNowString;
            _photoData.last_editor_name = photoReview.editorName;

            string jsonPhotoInfo = JsonUtility.ToJson(_photoData);

            // Look in the current sheet for a photo with same "dropbox_path", and overwrite with the updated photo data.
            Debug.Log("*** Started UpdatePhotoInfo() loading at " + System.DateTime.Now.ToLongTimeString());

            Debug.Log("AllPhotosSheet = " + AllPhotosSheet);
            Drive.UpdateObjects(AllPhotosSheet, columnToMatchUID, rowUID, jsonPhotoInfo, false, true);
            Debug.Log("Updating row " + _photoData.filename);
            Debug.Log("With this data:\n" + jsonPhotoInfo);
        }