Exemplo n.º 1
0
        /// <summary>
        /// Update the field data for this object to the db
        /// </summary>
        /// <returns>success status</returns>
        public virtual bool Save()
        {
            var accessor = new NetMud.DataAccess.FileSystem.BackingData();

            try
            {
                accessor.WriteEntity(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return false;
            }

            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes everything in the cache back to the file system
        /// </summary>
        /// <returns>full or partial success</returns>
        public static bool WriteFullBackup()
        {
            var fileAccessor = new NetMud.DataAccess.FileSystem.BackingData();

            try
            {
                LoggingUtility.Log("World BackingData backup to current INITIATED.", LogChannels.Backup, true);

                fileAccessor.ArchiveFull();

                //Get all the entities (which should be a ton of stuff)
                var entities = BackingDataCache.GetAll();

                foreach (var entity in entities)
                    fileAccessor.WriteEntity(entity as IData);

                LoggingUtility.Log("Entire backing data set written to current.", LogChannels.Backup, true);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return false;
            }

            return true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add it to the cache and save it to the file system
        /// </summary>
        /// <returns>the object with ID and other db fields set</returns>
        public virtual IData Create()
        {
            var accessor = new NetMud.DataAccess.FileSystem.BackingData();

            try
            {
                //reset this guy's ID to the next one in the list
                GetNextId();

                BackingDataCache.Add(this);
                accessor.WriteEntity(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return null;
            }

            return this;
        }