コード例 #1
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 override IKeyedData Create(IAccount creator, StaffRank rank)
        {
            DataAccess.FileSystem.PlayerData accessor = new DataAccess.FileSystem.PlayerData();

            try
            {
                //reset this guy's Id to the next one in the list
                GetNextId();
                Created     = DateTime.Now;
                Creator     = creator;
                CreatorRank = rank;

                //Default godsight to all false on creation unless you're making a new administrator
                if (rank == StaffRank.Admin)
                {
                    SuperSenses = new HashSet <MessagingType>()
                    {
                        MessagingType.Audible,
                        MessagingType.Olefactory,
                        MessagingType.Psychic,
                        MessagingType.Tactile,
                        MessagingType.Taste,
                        MessagingType.Visible
                    };
                }

                //No approval stuff necessary here
                ApproveMe(creator, rank);

                PersistToCache();
                accessor.WriteCharacter(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(null);
            }

            return(this);
        }
コード例 #2
0
        /// <summary>
        /// Update the field data for this object to the db
        /// </summary>
        /// <returns>success status</returns>
        public override bool Save(IAccount editor, StaffRank rank)
        {
            DataAccess.FileSystem.PlayerData accessor = new DataAccess.FileSystem.PlayerData();

            try
            {
                //No approval stuff necessary here
                ApproveMe(editor, rank);

                LastRevised = DateTime.Now;

                PersistToCache();
                accessor.WriteCharacter(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Update the field data for this object to the db
        /// </summary>
        /// <returns>success status</returns>
        public override bool SystemSave()
        {
            DataAccess.FileSystem.PlayerData accessor = new DataAccess.FileSystem.PlayerData();

            try
            {
                if (Created == DateTime.MinValue)
                {
                    SystemCreate();
                }
                else
                {
                    //only able to edit its own crap
                    if (CreatorHandle != DataHelpers.SystemUserHandle)
                    {
                        return(false);
                    }

                    State          = ApprovalState.Approved;
                    ApproverHandle = DataHelpers.SystemUserHandle;
                    ApprovedOn     = DateTime.Now;
                    ApproverRank   = StaffRank.Builder;
                    LastRevised    = DateTime.Now;

                    PersistToCache();
                    accessor.WriteCharacter(this);
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Add it to the cache and save it to the file system made by SYSTEM
        /// </summary>
        /// <returns>the object with Id and other db fields set</returns>
        public override IKeyedData SystemCreate()
        {
            DataAccess.FileSystem.PlayerData accessor = new DataAccess.FileSystem.PlayerData();

            try
            {
                if (Created != DateTime.MinValue)
                {
                    SystemSave();
                }
                else
                {
                    //reset this guy's Id to the next one in the list
                    GetNextId();
                    Created       = DateTime.Now;
                    CreatorHandle = DataHelpers.SystemUserHandle;
                    CreatorRank   = StaffRank.Builder;

                    PersistToCache();
                    accessor.WriteCharacter(this);
                }


                State          = ApprovalState.Approved;
                ApproverHandle = DataHelpers.SystemUserHandle;
                ApprovedOn     = DateTime.Now;
                ApproverRank   = StaffRank.Builder;
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(null);
            }

            return(this);
        }