Example #1
0
        /// <summary>
        /// Write one character to its player current data
        /// </summary>
        /// <param name="entity">the char to write</param>
        public void WriteCharacter(ICharacter entity)
        {
            var dirName = BaseDirectory + entity.AccountHandle + "/" + CurrentDirectoryName + entity.ID + "/";

            if (!VerifyDirectory(dirName))
                throw new Exception("Unable to locate or create base player directory.");

            var entityFileName = GetCharacterFilename(entity);

            if (string.IsNullOrWhiteSpace(entityFileName))
                return;

            var fullFileName = dirName + entityFileName;
            var archiveFileDirectory = BaseDirectory + entity.AccountHandle + "/" + ArchiveDirectoryName + entity.ID + "/" + DatedBackupDirectory;

            try
            {
                ArchiveCharacter(entity);
                WriteToFile(fullFileName, entity.ToBytes());
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }
        }