コード例 #1
0
        public static async ETTask SaveLog(this DBProxyComponent self, long uid, DBLog.LogType logType, BsonDocument record)
        {
            DBLog dBLog = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId());

            dBLog.uid      = uid;
            dBLog.logType  = (int)logType;
            dBLog.document = record;
            dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
            await self.SaveLog(dBLog);
        }
コード例 #2
0
        public static async ETTask SaveLog(this DBProxyComponent self, long uid, DBLog.LogType logType, ComponentWithId record)
        {
            Session session = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress);
            DBLog   dBLog   = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId());

            dBLog.uid     = uid;
            dBLog.logType = (int)logType;
            BsonDocument doc = null;

            BsonDocument.TryParse(record.ToJson(), out doc);
            dBLog.document = doc;
            dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
            await self.SaveLog(dBLog);
        }
コード例 #3
0
        /// <summary>
        /// 更新或插入一位使用者
        /// </summary>
        /// <param name="user"></param>
        /// <param name="logType"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public static async ETTask UpsertUser(User user, DBLog.LogType logType, BsonDocument log)
        {
            BsonDocument charSettingLog = new BsonDocument();

            InvalidatePlayerCharSetting(ref user, charSettingLog);
            var needLog1 = log.Count() != 0;
            var needLog2 = charSettingLog.Count() != 0;

            if (needLog1 || needLog2)
            {
                await dbProxy.Save(user);

                if (needLog1)
                {
                    await dbProxy.SaveLog(user.Id, logType, log);
                }
                if (needLog2)
                {
                    await dbProxy.SaveLog(user.Id, DBLog.LogType.UpdateUserCharacterSetting, charSettingLog);
                }
            }
        }
コード例 #4
0
        public static async ETTask SaveLogBatch(this DBProxyComponent self, long uid, DBLog.LogType logType, List <ComponentWithId> components)
        {
            Session session             = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress);
            List <ComponentWithId> list = new List <ComponentWithId>();

            for (int i = 0; i < components.Count; i++)
            {
                ComponentWithId record = null;
                DBLog           dBLog  = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId());
                dBLog.uid     = uid;
                dBLog.logType = (int)logType;
                BsonDocument doc = null;
                BsonDocument.TryParse(record.ToJson(), out doc);
                dBLog.document = doc;
                dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                list.Add(dBLog);
            }

            await self.SaveBatch(list);
        }
コード例 #5
0
        /// <summary>
        /// 得到"新增|異動"一筆道具紀錄的Log物件
        /// </summary>
        /// <param name="uid">異動到哪位使用者的資料</param>
        /// <param name="equipment">要寫入的道具</param>
        /// <param name="equipmentLog">需要詳細記錄的Log</param>
        /// <returns></returns>
        private static DBLog _GetSaveEquipmentDBLog(long uid, Equipment equipment, EquipmentLog equipmentLog, DBLog.LogType logType)
        {
            DBLog dBLog = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId());

            dBLog.uid      = uid;
            dBLog.logType  = (int)logType;
            dBLog.document = new BsonDocument
            {
                { "id", equipment.Id }, // 對應的道具紀錄id
                { "configType", equipment.configType },
                { "configId", equipment.configId },
                { "count", equipmentLog.count },            // 交易數量
                { "fromType", (int)equipmentLog.fromType }, // 從哪邊獲得|移除的
                { "from", equipmentLog.from } // 從哪邊獲得|移除的(玩家=uid, 系統=SystemUid)
            };
            dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
            return(dBLog);
        }