| #!/usr/bin/python   | 
| # -*- coding: GBK -*-   | 
| #-------------------------------------------------------------------------------   | 
| # @copyright: Copyright (c) 2004, 2010 Xiamen Wangyou Network Technology Co.,Ltd., All rights reserved.   | 
| #-------------------------------------------------------------------------------   | 
| #   | 
| import pymongo   | 
| import binascii   | 
| import CommFunc   | 
| import ctypes   | 
| import logging   | 
| import CollectionVesionNO   | 
| from ctypes import (c_ushort, c_int, c_ubyte, c_char, c_ulong, Structure, memset,memmove, sizeof, addressof, create_string_buffer, string_at)   | 
| from MangoDBCommon import( fix_outgoingText, fix_incomingText, fix_incoming, fix_outgoing,addSIDErrorCnt, getSIDErrorCnt, makeSID, checkSID, addADOExceptionCount )   | 
| #MangoDBStruct.py%  | 
| #------------------------------------------------------  | 
| #------------------------------------------------------  | 
| #Íæ¼ÒÏêϸÐÅÏ¢#tagDBPlayer  | 
| class tagDBPlayer(Structure):  | 
|     _pack_ = 1  | 
|     _fields_ = [  | 
|         ('PlayerID', ctypes.c_ulong),  | 
|         ('AccID', ctypes.c_char * 65),  | 
|         ('PlayerName', ctypes.c_char * 33),  | 
|         ('AccState', ctypes.c_ubyte),  | 
|         ('IsDeleted', ctypes.c_ubyte),  | 
|         ('GMLevel', ctypes.c_ubyte),  | 
|         ('Sex', ctypes.c_int),  | 
|         ('Hair', ctypes.c_int),  | 
|         ('HairColor', ctypes.c_int),  | 
|         ('Face', ctypes.c_int),  | 
|         ('FacePic', ctypes.c_int),  | 
|         ('Job', ctypes.c_int),  | 
|         ('ReincarnationLv', ctypes.c_ushort),  | 
|         ('LV', ctypes.c_int),  | 
|         ('TotalExp', ctypes.c_ulong),  | 
|         ('FamilyID', ctypes.c_ulong),  | 
|         ('FamilyName', ctypes.c_char * 33),  | 
|         ('Country', ctypes.c_int),  | 
|         ('TeamHornor', ctypes.c_ulong),  | 
|         ('FamilyHornor', ctypes.c_ulong),  | 
|         ('FamilyActiveValue', ctypes.c_ulong),  | 
|         ('LastWeekFamilyActiveValue', ctypes.c_ulong),  | 
|         ('CountryHornor', ctypes.c_ulong),  | 
|         ('CountryLastWeekHornor', ctypes.c_ulong),  | 
|         ('Mate', ctypes.c_ulong),  | 
|         ('Gold', ctypes.c_ulong),  | 
|         ('GoldPaper', ctypes.c_ulong),  | 
|         ('Silver', ctypes.c_ulong),  | 
|         ('SilverPaper', ctypes.c_ulong),  | 
|         ('FightPoint', ctypes.c_ulong),  | 
|         ('HappyPoint', ctypes.c_ulong),  | 
|         ('MapID', ctypes.c_ulong),  | 
|         ('DataMapID', ctypes.c_ulong),  | 
|         ('CopyMapID', ctypes.c_ulong),  | 
|         ('PosX', ctypes.c_ushort),  | 
|         ('PosY', ctypes.c_ushort),  | 
|         ('FromMapID', ctypes.c_ulong),  | 
|         ('FromCopyMapID', ctypes.c_ulong),  | 
|         ('FromPosX', ctypes.c_ushort),  | 
|         ('FromPosY', ctypes.c_ushort),  | 
|         ('State', ctypes.c_int),  | 
|         ('HP', ctypes.c_ulong),  | 
|         ('MP', ctypes.c_ulong),  | 
|         ('XP', ctypes.c_ulong),  | 
|         ('HPRestoreSetting', ctypes.c_ushort),  | 
|         ('MPRestoreSetting', ctypes.c_ushort),  | 
|         ('FreePoint', ctypes.c_ulong),  | 
|         ('FreeSkillPoint', ctypes.c_ulong),  | 
|         ('STR', ctypes.c_int),  | 
|         ('PNE', ctypes.c_int),  | 
|         ('PHY', ctypes.c_int),  | 
|         ('CON', ctypes.c_int),  | 
|         ('TotalSTR', ctypes.c_int),  | 
|         ('TotalPNE', ctypes.c_int),  | 
|         ('TotalPHY', ctypes.c_int),  | 
|         ('TotalCON', ctypes.c_int),  | 
|         ('Setting', ctypes.c_char * 1000),  | 
|         ('PKValue', ctypes.c_ushort),  | 
|         ('FightPower', ctypes.c_ulong),  | 
|         ('ActiveValue', ctypes.c_ushort),  | 
|         ('PlayerType', ctypes.c_ubyte),  | 
|         ('BackpackLV', ctypes.c_ubyte),  | 
|         ('WarehouseLV', ctypes.c_ubyte),  | 
|         ('HaveWarehousePsw', ctypes.c_ubyte),  | 
|         ('WarehousePsw', ctypes.c_char * 15),  | 
|         ('WarehouseLocked', ctypes.c_ubyte),  | 
|         ('WarehouseGold', ctypes.c_ulong),  | 
|         ('WarehouseSilver', ctypes.c_ulong),  | 
|         ('TeamID', ctypes.c_ulong),  | 
|         ('UseGoldType', ctypes.c_ubyte),  | 
|         ('UseSilverType', ctypes.c_ubyte),  | 
|         ('AttackMode', ctypes.c_ubyte),  | 
|         ('RebornMapID', ctypes.c_ushort),  | 
|         ('RebornPosX', ctypes.c_ushort),  | 
|         ('RebornPosY', ctypes.c_ushort),  | 
|         ('WeekOnlineTime', ctypes.c_ulong),  | 
|         ('LastWeekOnlineTime', ctypes.c_ulong),  | 
|         ('LogoffTime', ctypes.c_char * 30),  | 
|         ('IsHideMask', ctypes.c_ubyte),  | 
|         ('DayProcessGameEventCount', ctypes.c_ulong),  | 
|         ('LoginIP', ctypes.c_char * 20),  | 
|         ('LoginTime', ctypes.c_char * 30),  | 
|         ('OnlineTime', ctypes.c_ulong),  | 
|         ('FriendFavor', ctypes.c_ulong),  | 
|         ('TeamPrivity', ctypes.c_ulong),  | 
|         ('OfflineMinutes', ctypes.c_ulong),  | 
|         ('Energy', ctypes.c_ulong),  | 
|         ('ReceivedSalary', ctypes.c_ulong),  | 
|         ('EquipShowSwitch', ctypes.c_ulong),  | 
|         ('LuckValue', ctypes.c_ushort),  | 
|         ('ExAttr1', ctypes.c_ulong),  | 
|         ('ExAttr2', ctypes.c_ulong),  | 
|         ('ExAttr3', ctypes.c_ulong),  | 
|         ('ExAttr4', ctypes.c_ulong),  | 
|         ('ExAttr5', ctypes.c_ulong),  | 
|         ('Faction', ctypes.c_int),  | 
|         ('InfamyValue', ctypes.c_ulong),  | 
|         ('OfficialRank', ctypes.c_ubyte),  | 
|         ('IsFindByLabel', ctypes.c_ubyte),  | 
|         ('IsCloseFriendLabel', ctypes.c_ubyte),  | 
|         ('Signature', ctypes.c_char * 101),  | 
|         ('ChangeCoinPointTotal', ctypes.c_ulong),  | 
|         ('VIPLv', ctypes.c_ubyte),  | 
|         ('VIPLvForPhone', ctypes.c_ubyte),  | 
|         ('PhoneVIPStartTime', ctypes.c_double),  | 
|         ('PhoneVIPEndTime', ctypes.c_double),  | 
|         ('VsRoomId', ctypes.c_ulong),  | 
|         ('ExAttr6', ctypes.c_ulong),  | 
|         ('ExAttr7', ctypes.c_ulong),  | 
|         ('ExAttr8', ctypes.c_ulong),  | 
|         ('ExAttr9', ctypes.c_ulong),  | 
|         ('ExAttr10', ctypes.c_ulong),  | 
|         ('ModelMark', ctypes.c_ulong),  | 
|         ('FromDataMapID', ctypes.c_ulong),  | 
|         ('LastOrderId', ctypes.c_char * 40),  | 
|         ('PrizeCoin', ctypes.c_ulong),  | 
|         ('ExAttr11', ctypes.c_ulong),  | 
|         ('ExAttr12', ctypes.c_ulong),  | 
|         ('ExAttr13', ctypes.c_ulong),  | 
|         ('ExAttr14', ctypes.c_ulong),  | 
|         ('CreateRoleTime', ctypes.c_char * 30),  | 
|         ('ADOResult', ctypes.c_ulong),  | 
|         ('SID', ctypes.c_int),    #ÓÃÓÚУÑé  | 
|         ('VerNO', ctypes.c_ulong)   #ÓÃÓÚSIDУÑéʱ±È½Ï°æ±¾ºÅ  | 
|     ]  | 
|   | 
|     def __init__(self):  | 
|         Structure.__init__(self)  | 
|         self.clear()  | 
|   | 
|   | 
|     def clear(self):  | 
|         memset(addressof(self), 0, self.getLength())  | 
|   | 
|   | 
|     def readData(self, buf, pos = 0, length = 0):  | 
|         if not pos <= length:  | 
|             msg = error.formatMsg('error', error.ERROR_NO_150, '(pos = %s)> (length = %s)'%(pos, length))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         if len(buf) < pos + self.getLength():  | 
|             msg = error.formatMsg('error', error.ERROR_NO_151, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         self.clear()  | 
|         memmove(addressof(self), buf[pos:], self.getLength())  | 
|         return self.getLength()  | 
|   | 
|   | 
|     def getBuffer(self):  | 
|         buf = create_string_buffer(self.getLength())  | 
|         memmove(addressof(buf), addressof(self), self.getLength())  | 
|         return string_at(addressof(buf), self.getLength())  | 
|   | 
|     def getLength(self):  | 
|         return sizeof(tagDBPlayer)  | 
|   | 
|   | 
|     def getSID(self):  | 
|         return self.SID  | 
|   | 
|     def getRecord(self):  | 
|         '''×éÖ¯´æ´¢¼Ç¼'''  | 
|         rec = {}  | 
|         rec[u'PlayerID'] = self.PlayerID  | 
|         rec[u'AccID'] = fix_incomingText(self.AccID)  | 
|         rec[u'PlayerName'] = fix_incomingText(self.PlayerName)  | 
|         rec[u'AccState'] = self.AccState  | 
|         rec[u'IsDeleted'] = self.IsDeleted  | 
|         rec[u'GMLevel'] = self.GMLevel  | 
|         rec[u'Sex'] = self.Sex  | 
|         rec[u'Hair'] = self.Hair  | 
|         rec[u'HairColor'] = self.HairColor  | 
|         rec[u'Face'] = self.Face  | 
|         rec[u'FacePic'] = self.FacePic  | 
|         rec[u'Job'] = self.Job  | 
|         rec[u'ReincarnationLv'] = self.ReincarnationLv  | 
|         rec[u'LV'] = self.LV  | 
|         rec[u'TotalExp'] = self.TotalExp  | 
|         rec[u'FamilyID'] = self.FamilyID  | 
|         rec[u'FamilyName'] = fix_incomingText(self.FamilyName)  | 
|         rec[u'Country'] = self.Country  | 
|         rec[u'TeamHornor'] = self.TeamHornor  | 
|         rec[u'FamilyHornor'] = self.FamilyHornor  | 
|         rec[u'FamilyActiveValue'] = self.FamilyActiveValue  | 
|         rec[u'LastWeekFamilyActiveValue'] = self.LastWeekFamilyActiveValue  | 
|         rec[u'CountryHornor'] = self.CountryHornor  | 
|         rec[u'CountryLastWeekHornor'] = self.CountryLastWeekHornor  | 
|         rec[u'Mate'] = self.Mate  | 
|         rec[u'Gold'] = self.Gold  | 
|         rec[u'GoldPaper'] = self.GoldPaper  | 
|         rec[u'Silver'] = self.Silver  | 
|         rec[u'SilverPaper'] = self.SilverPaper  | 
|         rec[u'FightPoint'] = self.FightPoint  | 
|         rec[u'HappyPoint'] = self.HappyPoint  | 
|         rec[u'MapID'] = self.MapID  | 
|         rec[u'DataMapID'] = self.DataMapID  | 
|         rec[u'CopyMapID'] = self.CopyMapID  | 
|         rec[u'PosX'] = self.PosX  | 
|         rec[u'PosY'] = self.PosY  | 
|         rec[u'FromMapID'] = self.FromMapID  | 
|         rec[u'FromCopyMapID'] = self.FromCopyMapID  | 
|         rec[u'FromPosX'] = self.FromPosX  | 
|         rec[u'FromPosY'] = self.FromPosY  | 
|         rec[u'State'] = self.State  | 
|         rec[u'HP'] = self.HP  | 
|         rec[u'MP'] = self.MP  | 
|         rec[u'XP'] = self.XP  | 
|         rec[u'HPRestoreSetting'] = self.HPRestoreSetting  | 
|         rec[u'MPRestoreSetting'] = self.MPRestoreSetting  | 
|         rec[u'FreePoint'] = self.FreePoint  | 
|         rec[u'FreeSkillPoint'] = self.FreeSkillPoint  | 
|         rec[u'STR'] = self.STR  | 
|         rec[u'PNE'] = self.PNE  | 
|         rec[u'PHY'] = self.PHY  | 
|         rec[u'CON'] = self.CON  | 
|         rec[u'TotalSTR'] = self.TotalSTR  | 
|         rec[u'TotalPNE'] = self.TotalPNE  | 
|         rec[u'TotalPHY'] = self.TotalPHY  | 
|         rec[u'TotalCON'] = self.TotalCON  | 
|         rec[u'Setting'] = fix_incomingText(self.Setting)  | 
|         rec[u'PKValue'] = self.PKValue  | 
|         rec[u'FightPower'] = self.FightPower  | 
|         rec[u'ActiveValue'] = self.ActiveValue  | 
|         rec[u'PlayerType'] = self.PlayerType  | 
|         rec[u'BackpackLV'] = self.BackpackLV  | 
|         rec[u'WarehouseLV'] = self.WarehouseLV  | 
|         rec[u'HaveWarehousePsw'] = self.HaveWarehousePsw  | 
|         rec[u'WarehousePsw'] = fix_incomingText(self.WarehousePsw)  | 
|         rec[u'WarehouseLocked'] = self.WarehouseLocked  | 
|         rec[u'WarehouseGold'] = self.WarehouseGold  | 
|         rec[u'WarehouseSilver'] = self.WarehouseSilver  | 
|         rec[u'TeamID'] = self.TeamID  | 
|         rec[u'UseGoldType'] = self.UseGoldType  | 
|         rec[u'UseSilverType'] = self.UseSilverType  | 
|         rec[u'AttackMode'] = self.AttackMode  | 
|         rec[u'RebornMapID'] = self.RebornMapID  | 
|         rec[u'RebornPosX'] = self.RebornPosX  | 
|         rec[u'RebornPosY'] = self.RebornPosY  | 
|         rec[u'WeekOnlineTime'] = self.WeekOnlineTime  | 
|         rec[u'LastWeekOnlineTime'] = self.LastWeekOnlineTime  | 
|         rec[u'LogoffTime'] = fix_incomingText(self.LogoffTime)  | 
|         rec[u'IsHideMask'] = self.IsHideMask  | 
|         rec[u'DayProcessGameEventCount'] = self.DayProcessGameEventCount  | 
|         rec[u'LoginIP'] = fix_incomingText(self.LoginIP)  | 
|         rec[u'LoginTime'] = fix_incomingText(self.LoginTime)  | 
|         rec[u'OnlineTime'] = self.OnlineTime  | 
|         rec[u'FriendFavor'] = self.FriendFavor  | 
|         rec[u'TeamPrivity'] = self.TeamPrivity  | 
|         rec[u'OfflineMinutes'] = self.OfflineMinutes  | 
|         rec[u'Energy'] = self.Energy  | 
|         rec[u'ReceivedSalary'] = self.ReceivedSalary  | 
|         rec[u'EquipShowSwitch'] = self.EquipShowSwitch  | 
|         rec[u'LuckValue'] = self.LuckValue  | 
|         rec[u'ExAttr1'] = self.ExAttr1  | 
|         rec[u'ExAttr2'] = self.ExAttr2  | 
|         rec[u'ExAttr3'] = self.ExAttr3  | 
|         rec[u'ExAttr4'] = self.ExAttr4  | 
|         rec[u'ExAttr5'] = self.ExAttr5  | 
|         rec[u'Faction'] = self.Faction  | 
|         rec[u'InfamyValue'] = self.InfamyValue  | 
|         rec[u'OfficialRank'] = self.OfficialRank  | 
|         rec[u'IsFindByLabel'] = self.IsFindByLabel  | 
|         rec[u'IsCloseFriendLabel'] = self.IsCloseFriendLabel  | 
|         rec[u'Signature'] = fix_incomingText(self.Signature)  | 
|         rec[u'ChangeCoinPointTotal'] = self.ChangeCoinPointTotal  | 
|         rec[u'VIPLv'] = self.VIPLv  | 
|         rec[u'VIPLvForPhone'] = self.VIPLvForPhone  | 
|         rec[u'PhoneVIPStartTime'] = self.PhoneVIPStartTime  | 
|         rec[u'PhoneVIPEndTime'] = self.PhoneVIPEndTime  | 
|         rec[u'VsRoomId'] = self.VsRoomId  | 
|         rec[u'ExAttr6'] = self.ExAttr6  | 
|         rec[u'ExAttr7'] = self.ExAttr7  | 
|         rec[u'ExAttr8'] = self.ExAttr8  | 
|         rec[u'ExAttr9'] = self.ExAttr9  | 
|         rec[u'ExAttr10'] = self.ExAttr10  | 
|         rec[u'ModelMark'] = self.ModelMark  | 
|         rec[u'FromDataMapID'] = self.FromDataMapID  | 
|         rec[u'LastOrderId'] = fix_incomingText(self.LastOrderId)  | 
|         rec[u'PrizeCoin'] = self.PrizeCoin  | 
|         rec[u'ExAttr11'] = self.ExAttr11  | 
|         rec[u'ExAttr12'] = self.ExAttr12  | 
|         rec[u'ExAttr13'] = self.ExAttr13  | 
|         rec[u'ExAttr14'] = self.ExAttr14  | 
|         rec[u'CreateRoleTime'] = fix_incomingText(self.CreateRoleTime)  | 
|         rec[u'SID'] = self.SID  | 
|         rec[u'VerNO'] = self.VerNO  | 
|         return rec  | 
|   | 
|     def readRecord(self, rec):  | 
|         '''ÓÉÓÚMongoDB¶Á³öÀ´ÊÇunicode,ËùÓÐ×Ö·û´®ÐèÒª½øÐÐת»»'''  | 
|         self.PlayerID = rec.get(u'PlayerID', 0)  | 
|         self.AccID = fix_outgoingText(rec.get(u'AccID', u''))  | 
|         self.PlayerName = fix_outgoingText(rec.get(u'PlayerName', u''))  | 
|         self.AccState = rec.get(u'AccState', 0)  | 
|         self.IsDeleted = rec.get(u'IsDeleted', 0)  | 
|         self.GMLevel = rec.get(u'GMLevel', 0)  | 
|         self.Sex = rec.get(u'Sex', 0)  | 
|         self.Hair = rec.get(u'Hair', 0)  | 
|         self.HairColor = rec.get(u'HairColor', 0)  | 
|         self.Face = rec.get(u'Face', 0)  | 
|         self.FacePic = rec.get(u'FacePic', 0)  | 
|         self.Job = rec.get(u'Job', 0)  | 
|         self.ReincarnationLv = rec.get(u'ReincarnationLv', 0)  | 
|         self.LV = rec.get(u'LV', 0)  | 
|         self.TotalExp = rec.get(u'TotalExp', 0)  | 
|         self.FamilyID = rec.get(u'FamilyID', 0)  | 
|         self.FamilyName = fix_outgoingText(rec.get(u'FamilyName', u''))  | 
|         self.Country = rec.get(u'Country', 0)  | 
|         self.TeamHornor = rec.get(u'TeamHornor', 0)  | 
|         self.FamilyHornor = rec.get(u'FamilyHornor', 0)  | 
|         self.FamilyActiveValue = rec.get(u'FamilyActiveValue', 0)  | 
|         self.LastWeekFamilyActiveValue = rec.get(u'LastWeekFamilyActiveValue', 0)  | 
|         self.CountryHornor = rec.get(u'CountryHornor', 0)  | 
|         self.CountryLastWeekHornor = rec.get(u'CountryLastWeekHornor', 0)  | 
|         self.Mate = rec.get(u'Mate', 0)  | 
|         self.Gold = rec.get(u'Gold', 0)  | 
|         self.GoldPaper = rec.get(u'GoldPaper', 0)  | 
|         self.Silver = rec.get(u'Silver', 0)  | 
|         self.SilverPaper = rec.get(u'SilverPaper', 0)  | 
|         self.FightPoint = rec.get(u'FightPoint', 0)  | 
|         self.HappyPoint = rec.get(u'HappyPoint', 0)  | 
|         self.MapID = rec.get(u'MapID', 0)  | 
|         self.DataMapID = rec.get(u'DataMapID', 0)  | 
|         self.CopyMapID = rec.get(u'CopyMapID', 0)  | 
|         self.PosX = rec.get(u'PosX', 0)  | 
|         self.PosY = rec.get(u'PosY', 0)  | 
|         self.FromMapID = rec.get(u'FromMapID', 0)  | 
|         self.FromCopyMapID = rec.get(u'FromCopyMapID', 0)  | 
|         self.FromPosX = rec.get(u'FromPosX', 0)  | 
|         self.FromPosY = rec.get(u'FromPosY', 0)  | 
|         self.State = rec.get(u'State', 0)  | 
|         self.HP = rec.get(u'HP', 0)  | 
|         self.MP = rec.get(u'MP', 0)  | 
|         self.XP = rec.get(u'XP', 0)  | 
|         self.HPRestoreSetting = rec.get(u'HPRestoreSetting', 0)  | 
|         self.MPRestoreSetting = rec.get(u'MPRestoreSetting', 0)  | 
|         self.FreePoint = rec.get(u'FreePoint', 0)  | 
|         self.FreeSkillPoint = rec.get(u'FreeSkillPoint', 0)  | 
|         self.STR = rec.get(u'STR', 0)  | 
|         self.PNE = rec.get(u'PNE', 0)  | 
|         self.PHY = rec.get(u'PHY', 0)  | 
|         self.CON = rec.get(u'CON', 0)  | 
|         self.TotalSTR = rec.get(u'TotalSTR', 0)  | 
|         self.TotalPNE = rec.get(u'TotalPNE', 0)  | 
|         self.TotalPHY = rec.get(u'TotalPHY', 0)  | 
|         self.TotalCON = rec.get(u'TotalCON', 0)  | 
|         self.Setting = fix_outgoingText(rec.get(u'Setting', u''))  | 
|         self.PKValue = rec.get(u'PKValue', 0)  | 
|         self.FightPower = rec.get(u'FightPower', 0)  | 
|         self.ActiveValue = rec.get(u'ActiveValue', 0)  | 
|         self.PlayerType = rec.get(u'PlayerType', 0)  | 
|         self.BackpackLV = rec.get(u'BackpackLV', 0)  | 
|         self.WarehouseLV = rec.get(u'WarehouseLV', 0)  | 
|         self.HaveWarehousePsw = rec.get(u'HaveWarehousePsw', 0)  | 
|         self.WarehousePsw = fix_outgoingText(rec.get(u'WarehousePsw', u''))  | 
|         self.WarehouseLocked = rec.get(u'WarehouseLocked', 0)  | 
|         self.WarehouseGold = rec.get(u'WarehouseGold', 0)  | 
|         self.WarehouseSilver = rec.get(u'WarehouseSilver', 0)  | 
|         self.TeamID = rec.get(u'TeamID', 0)  | 
|         self.UseGoldType = rec.get(u'UseGoldType', 0)  | 
|         self.UseSilverType = rec.get(u'UseSilverType', 0)  | 
|         self.AttackMode = rec.get(u'AttackMode', 0)  | 
|         self.RebornMapID = rec.get(u'RebornMapID', 0)  | 
|         self.RebornPosX = rec.get(u'RebornPosX', 0)  | 
|         self.RebornPosY = rec.get(u'RebornPosY', 0)  | 
|         self.WeekOnlineTime = rec.get(u'WeekOnlineTime', 0)  | 
|         self.LastWeekOnlineTime = rec.get(u'LastWeekOnlineTime', 0)  | 
|         self.LogoffTime = fix_outgoingText(rec.get(u'LogoffTime', u''))  | 
|         self.IsHideMask = rec.get(u'IsHideMask', 0)  | 
|         self.DayProcessGameEventCount = rec.get(u'DayProcessGameEventCount', 0)  | 
|         self.LoginIP = fix_outgoingText(rec.get(u'LoginIP', u''))  | 
|         self.LoginTime = fix_outgoingText(rec.get(u'LoginTime', u''))  | 
|         self.OnlineTime = rec.get(u'OnlineTime', 0)  | 
|         self.FriendFavor = rec.get(u'FriendFavor', 0)  | 
|         self.TeamPrivity = rec.get(u'TeamPrivity', 0)  | 
|         self.OfflineMinutes = rec.get(u'OfflineMinutes', 0)  | 
|         self.Energy = rec.get(u'Energy', 0)  | 
|         self.ReceivedSalary = rec.get(u'ReceivedSalary', 0)  | 
|         self.EquipShowSwitch = rec.get(u'EquipShowSwitch', 0)  | 
|         self.LuckValue = rec.get(u'LuckValue', 0)  | 
|         self.ExAttr1 = rec.get(u'ExAttr1', 0)  | 
|         self.ExAttr2 = rec.get(u'ExAttr2', 0)  | 
|         self.ExAttr3 = rec.get(u'ExAttr3', 0)  | 
|         self.ExAttr4 = rec.get(u'ExAttr4', 0)  | 
|         self.ExAttr5 = rec.get(u'ExAttr5', 0)  | 
|         self.Faction = rec.get(u'Faction', 0)  | 
|         self.InfamyValue = rec.get(u'InfamyValue', 0)  | 
|         self.OfficialRank = rec.get(u'OfficialRank', 0)  | 
|         self.IsFindByLabel = rec.get(u'IsFindByLabel', 0)  | 
|         self.IsCloseFriendLabel = rec.get(u'IsCloseFriendLabel', 0)  | 
|         self.Signature = fix_outgoingText(rec.get(u'Signature', u''))  | 
|         self.ChangeCoinPointTotal = rec.get(u'ChangeCoinPointTotal', 0)  | 
|         self.VIPLv = rec.get(u'VIPLv', 0)  | 
|         self.VIPLvForPhone = rec.get(u'VIPLvForPhone', 0)  | 
|         self.PhoneVIPStartTime = rec.get(u'PhoneVIPStartTime', 0)  | 
|         self.PhoneVIPEndTime = rec.get(u'PhoneVIPEndTime', 0)  | 
|         self.VsRoomId = rec.get(u'VsRoomId', 0)  | 
|         self.ExAttr6 = rec.get(u'ExAttr6', 0)  | 
|         self.ExAttr7 = rec.get(u'ExAttr7', 0)  | 
|         self.ExAttr8 = rec.get(u'ExAttr8', 0)  | 
|         self.ExAttr9 = rec.get(u'ExAttr9', 0)  | 
|         self.ExAttr10 = rec.get(u'ExAttr10', 0)  | 
|         self.ModelMark = rec.get(u'ModelMark', 0)  | 
|         self.FromDataMapID = rec.get(u'FromDataMapID', 0)  | 
|         self.LastOrderId = fix_outgoingText(rec.get(u'LastOrderId', u''))  | 
|         self.PrizeCoin = rec.get(u'PrizeCoin', 0)  | 
|         self.ExAttr11 = rec.get(u'ExAttr11', 0)  | 
|         self.ExAttr12 = rec.get(u'ExAttr12', 0)  | 
|         self.ExAttr13 = rec.get(u'ExAttr13', 0)  | 
|         self.ExAttr14 = rec.get(u'ExAttr14', 0)  | 
|         self.CreateRoleTime = fix_outgoingText(rec.get(u'CreateRoleTime', u''))  | 
|         self.SID = rec['SID']  | 
|         self.VerNO = rec.get(u'VerNO', 0)  | 
|   | 
|   | 
|     def makeSID(self):  | 
|         self.SID = 0  | 
|         self.VerNO = CollectionVesionNO.tagDBPlayer_VersionNO  | 
|         self.SID = makeSID(self.getBuffer())  | 
|   | 
|     def adoLoad(self, collection):  | 
|         '''ʹÓÃKEY²éÕÒ²¢¶ÁÈ¡'''  | 
|         resultCollection = collection.find({'PlayerID':self.PlayerID})  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         #ÓÉÓÚÊÇKEY²éÕÒ£¬ËùÓÐÈç¹û´æÔÚ¾ÍÖ»ÓÐÒ»Ìõ¼Ç¼  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         return True  | 
|   | 
|     def adoLoadC(self, collection):  | 
|         '''ʹÓÃKEY²éÕÒ,½øÐÐУÑ飬²¢¶ÁÈ¡'''  | 
|         resultCollection = collection.find({'PlayerID':self.PlayerID})  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         #ÓÉÓÚÊÇKEY²éÕÒ£¬ËùÓÐÈç¹û´æÔÚ¾ÍÖ»ÓÐÒ»Ìõ¼Ç¼  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         saveSID = self.SID  | 
|         self.SID = 0  | 
|         if self.VerNO == CollectionVesionNO.tagDBPlayer_VersionNO:  | 
|             if not checkSID(self.getBuffer(), saveSID):  | 
|                 addSIDErrorCnt()  | 
|                 mylog.warning('SID checksum error!AccID = %s'%rec['AccID'])  | 
|   | 
|                 return False  | 
|         #УÑéͨ¹ý  | 
|         return True  | 
|   | 
|     def adoLoadCEx(self, collection, query):  | 
|         resultCollection = collection.find(query)  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         saveSID = self.SID  | 
|         self.SID = 0  | 
|         if self.VerNO == CollectionVesionNO.tagDBPlayer_VersionNO:  | 
|             if not checkSID(self.getBuffer(), saveSID):  | 
|                 addSIDErrorCnt()  | 
|                 mylog.warning('SID checksum error!query = %s'%query)  | 
|   | 
|                 return False  | 
|         #УÑéͨ¹ý  | 
|         return True  | 
|   | 
|   | 
|     def adoInsert(self, collection):  | 
|         '''Ö´ÐвåÈë'''  | 
|   | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.insert(rec, False, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|   | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                       | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!AccID = %s, error = %s, trycnt = %d'%(self.AccID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoInsertC(self, collection):  | 
|         self.makeSID()  | 
|         return self.adoInsert(collection)  | 
|   | 
|   | 
|     def adoUpdate(self, collection):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update({'PlayerID':self.PlayerID}, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|   | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!AccID = %s, error = %s, trycnt = %d'%(self.AccID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdateEx(self, collection, spec):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update(spec, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!AccID = %s, error = %s, trycnt = %d'%(self.AccID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdateC(self, collection):  | 
|         self.makeSID()  | 
|         return self.adoUpdate(collection)  | 
|   | 
|   | 
|     def adoUpdateExC(self, collection, spec):  | 
|         self.makeSID()  | 
|         return self.adoUpdateEx(collection, spec)  | 
|   | 
|   | 
|     def adoCheckUpdateC(self, collection):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find({'PlayerID':self.PlayerID})  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsertC(collection)  | 
|         return self.adoUpdateC(collection)  | 
|   | 
|   | 
|     def adoCheckUpdateCEx(self, collection, spec):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find(spec)  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsertC(collection, spec)  | 
|         return self.adoUpdateExC(collection, spec)  | 
|   | 
|   | 
|     def getAdoRecordsC(self, resultCollection):  | 
|         result = ''  | 
|         result = CommFunc.WriteDWORD(result, resultCollection.count())  | 
|         for rec in resultCollection:  | 
|             #УÑéSID  | 
|             self.readRecord(rec)  | 
|             saveSID = self.SID  | 
|             self.SID = 0  | 
|             if self.VerNO == CollectionVesionNO.tagDBPlayer_VersionNO:  | 
|                 if not checkSID(self.getBuffer(), saveSID):  | 
|                     addSIDErrorCnt()  | 
|                     mylog.warning('SID error AccID = %s'%self.AccID)  | 
|   | 
|             result += self.getBuffer()  | 
|         return result  | 
|   | 
|   | 
|     def adoQueryIndexC(self, collection):  | 
|         '''ÓÃË÷Òý×ֶβéÕÒ'''  | 
|         resultCollection = collection.find({'AccID':fix_incomingText(self.AccID)})  | 
|            | 
|         return self.getAdoRecordsC(resultCollection)  | 
|   | 
|   | 
|     def adoQueryCustomC(self, collection, queryDict):  | 
|         '''×Ô¶¨Òå²éÕÒ'''  | 
|         resultCollection = collection.find(queryDict)  | 
|   | 
|         return self.getAdoRecordsC(resultCollection)  | 
|           | 
|   | 
|     def adoQueryAllC(self, collection):  | 
|         '''²éѯËùÓÐ'''   | 
|         resultCollection = collection.find()  | 
|            | 
|         return self.getAdoRecordsC(resultCollection)  | 
|   | 
|   | 
|     def adoDeleteByIndex(self, collection):  | 
|         '''¸ù¾ÝË÷Òýɾ³ý'''  | 
|         trycnt = 0  | 
|         while(True):  | 
|             try:  | 
|                 collection.remove({'AccID':fix_incomingText(self.AccID)})  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:AccID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.AccID))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.AccID = %s, error = %s, trycnt = %d'%(self.AccID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|     def outputString(self):  | 
|         output = '''//Íæ¼ÒÏêϸÐÅÏ¢#tagDBPlayer:  | 
|             PlayerID = %s,  | 
|             AccID = %s,  | 
|             PlayerName = %s,  | 
|             AccState = %s,  | 
|             IsDeleted = %s,  | 
|             GMLevel = %s,  | 
|             Sex = %s,  | 
|             Hair = %s,  | 
|             HairColor = %s,  | 
|             Face = %s,  | 
|             FacePic = %s,  | 
|             Job = %s,  | 
|             ReincarnationLv = %s,  | 
|             LV = %s,  | 
|             TotalExp = %s,  | 
|             FamilyID = %s,  | 
|             FamilyName = %s,  | 
|             Country = %s,  | 
|             TeamHornor = %s,  | 
|             FamilyHornor = %s,  | 
|             FamilyActiveValue = %s,  | 
|             LastWeekFamilyActiveValue = %s,  | 
|             CountryHornor = %s,  | 
|             CountryLastWeekHornor = %s,  | 
|             Mate = %s,  | 
|             Gold = %s,  | 
|             GoldPaper = %s,  | 
|             Silver = %s,  | 
|             SilverPaper = %s,  | 
|             FightPoint = %s,  | 
|             HappyPoint = %s,  | 
|             MapID = %s,  | 
|             DataMapID = %s,  | 
|             CopyMapID = %s,  | 
|             PosX = %s,  | 
|             PosY = %s,  | 
|             FromMapID = %s,  | 
|             FromCopyMapID = %s,  | 
|             FromPosX = %s,  | 
|             FromPosY = %s,  | 
|             State = %s,  | 
|             HP = %s,  | 
|             MP = %s,  | 
|             XP = %s,  | 
|             HPRestoreSetting = %s,  | 
|             MPRestoreSetting = %s,  | 
|             FreePoint = %s,  | 
|             FreeSkillPoint = %s,  | 
|             STR = %s,  | 
|             PNE = %s,  | 
|             PHY = %s,  | 
|             CON = %s,  | 
|             TotalSTR = %s,  | 
|             TotalPNE = %s,  | 
|             TotalPHY = %s,  | 
|             TotalCON = %s,  | 
|             Setting = %s,  | 
|             PKValue = %s,  | 
|             FightPower = %s,  | 
|             ActiveValue = %s,  | 
|             PlayerType = %s,  | 
|             BackpackLV = %s,  | 
|             WarehouseLV = %s,  | 
|             HaveWarehousePsw = %s,  | 
|             WarehousePsw = %s,  | 
|             WarehouseLocked = %s,  | 
|             WarehouseGold = %s,  | 
|             WarehouseSilver = %s,  | 
|             TeamID = %s,  | 
|             UseGoldType = %s,  | 
|             UseSilverType = %s,  | 
|             AttackMode = %s,  | 
|             RebornMapID = %s,  | 
|             RebornPosX = %s,  | 
|             RebornPosY = %s,  | 
|             WeekOnlineTime = %s,  | 
|             LastWeekOnlineTime = %s,  | 
|             LogoffTime = %s,  | 
|             IsHideMask = %s,  | 
|             DayProcessGameEventCount = %s,  | 
|             LoginIP = %s,  | 
|             LoginTime = %s,  | 
|             OnlineTime = %s,  | 
|             FriendFavor = %s,  | 
|             TeamPrivity = %s,  | 
|             OfflineMinutes = %s,  | 
|             Energy = %s,  | 
|             ReceivedSalary = %s,  | 
|             EquipShowSwitch = %s,  | 
|             LuckValue = %s,  | 
|             ExAttr1 = %s,  | 
|             ExAttr2 = %s,  | 
|             ExAttr3 = %s,  | 
|             ExAttr4 = %s,  | 
|             ExAttr5 = %s,  | 
|             Faction = %s,  | 
|             InfamyValue = %s,  | 
|             OfficialRank = %s,  | 
|             IsFindByLabel = %s,  | 
|             IsCloseFriendLabel = %s,  | 
|             Signature = %s,  | 
|             ChangeCoinPointTotal = %s,  | 
|             VIPLv = %s,  | 
|             VIPLvForPhone = %s,  | 
|             PhoneVIPStartTime = %s,  | 
|             PhoneVIPEndTime = %s,  | 
|             VsRoomId = %s,  | 
|             ExAttr6 = %s,  | 
|             ExAttr7 = %s,  | 
|             ExAttr8 = %s,  | 
|             ExAttr9 = %s,  | 
|             ExAttr10 = %s,  | 
|             ModelMark = %s,  | 
|             FromDataMapID = %s,  | 
|             LastOrderId = %s,  | 
|             PrizeCoin = %s,  | 
|             ExAttr11 = %s,  | 
|             ExAttr12 = %s,  | 
|             ExAttr13 = %s,  | 
|             ExAttr14 = %s,  | 
|             CreateRoleTime = %s,  | 
|             ADOResult = %s,  | 
|             SID = %s,  | 
|             VerNO = %s,  | 
|             '''%(  | 
|                 self.PlayerID,  | 
|                 self.AccID,  | 
|                 self.PlayerName,  | 
|                 self.AccState,  | 
|                 self.IsDeleted,  | 
|                 self.GMLevel,  | 
|                 self.Sex,  | 
|                 self.Hair,  | 
|                 self.HairColor,  | 
|                 self.Face,  | 
|                 self.FacePic,  | 
|                 self.Job,  | 
|                 self.ReincarnationLv,  | 
|                 self.LV,  | 
|                 self.TotalExp,  | 
|                 self.FamilyID,  | 
|                 self.FamilyName,  | 
|                 self.Country,  | 
|                 self.TeamHornor,  | 
|                 self.FamilyHornor,  | 
|                 self.FamilyActiveValue,  | 
|                 self.LastWeekFamilyActiveValue,  | 
|                 self.CountryHornor,  | 
|                 self.CountryLastWeekHornor,  | 
|                 self.Mate,  | 
|                 self.Gold,  | 
|                 self.GoldPaper,  | 
|                 self.Silver,  | 
|                 self.SilverPaper,  | 
|                 self.FightPoint,  | 
|                 self.HappyPoint,  | 
|                 self.MapID,  | 
|                 self.DataMapID,  | 
|                 self.CopyMapID,  | 
|                 self.PosX,  | 
|                 self.PosY,  | 
|                 self.FromMapID,  | 
|                 self.FromCopyMapID,  | 
|                 self.FromPosX,  | 
|                 self.FromPosY,  | 
|                 self.State,  | 
|                 self.HP,  | 
|                 self.MP,  | 
|                 self.XP,  | 
|                 self.HPRestoreSetting,  | 
|                 self.MPRestoreSetting,  | 
|                 self.FreePoint,  | 
|                 self.FreeSkillPoint,  | 
|                 self.STR,  | 
|                 self.PNE,  | 
|                 self.PHY,  | 
|                 self.CON,  | 
|                 self.TotalSTR,  | 
|                 self.TotalPNE,  | 
|                 self.TotalPHY,  | 
|                 self.TotalCON,  | 
|                 self.Setting,  | 
|                 self.PKValue,  | 
|                 self.FightPower,  | 
|                 self.ActiveValue,  | 
|                 self.PlayerType,  | 
|                 self.BackpackLV,  | 
|                 self.WarehouseLV,  | 
|                 self.HaveWarehousePsw,  | 
|                 self.WarehousePsw,  | 
|                 self.WarehouseLocked,  | 
|                 self.WarehouseGold,  | 
|                 self.WarehouseSilver,  | 
|                 self.TeamID,  | 
|                 self.UseGoldType,  | 
|                 self.UseSilverType,  | 
|                 self.AttackMode,  | 
|                 self.RebornMapID,  | 
|                 self.RebornPosX,  | 
|                 self.RebornPosY,  | 
|                 self.WeekOnlineTime,  | 
|                 self.LastWeekOnlineTime,  | 
|                 self.LogoffTime,  | 
|                 self.IsHideMask,  | 
|                 self.DayProcessGameEventCount,  | 
|                 self.LoginIP,  | 
|                 self.LoginTime,  | 
|                 self.OnlineTime,  | 
|                 self.FriendFavor,  | 
|                 self.TeamPrivity,  | 
|                 self.OfflineMinutes,  | 
|                 self.Energy,  | 
|                 self.ReceivedSalary,  | 
|                 self.EquipShowSwitch,  | 
|                 self.LuckValue,  | 
|                 self.ExAttr1,  | 
|                 self.ExAttr2,  | 
|                 self.ExAttr3,  | 
|                 self.ExAttr4,  | 
|                 self.ExAttr5,  | 
|                 self.Faction,  | 
|                 self.InfamyValue,  | 
|                 self.OfficialRank,  | 
|                 self.IsFindByLabel,  | 
|                 self.IsCloseFriendLabel,  | 
|                 self.Signature,  | 
|                 self.ChangeCoinPointTotal,  | 
|                 self.VIPLv,  | 
|                 self.VIPLvForPhone,  | 
|                 self.PhoneVIPStartTime,  | 
|                 self.PhoneVIPEndTime,  | 
|                 self.VsRoomId,  | 
|                 self.ExAttr6,  | 
|                 self.ExAttr7,  | 
|                 self.ExAttr8,  | 
|                 self.ExAttr9,  | 
|                 self.ExAttr10,  | 
|                 self.ModelMark,  | 
|                 self.FromDataMapID,  | 
|                 self.LastOrderId,  | 
|                 self.PrizeCoin,  | 
|                 self.ExAttr11,  | 
|                 self.ExAttr12,  | 
|                 self.ExAttr13,  | 
|                 self.ExAttr14,  | 
|                 self.CreateRoleTime,  | 
|                 self.ADOResult,  | 
|                 self.SID,  | 
|                 self.VerNO  | 
|             )  | 
|         return output  | 
|   | 
|     def dumpString(self):  | 
|         output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(  | 
|                 self.PlayerID,  | 
|                 self.AccID,  | 
|                 self.PlayerName,  | 
|                 self.AccState,  | 
|                 self.IsDeleted,  | 
|                 self.GMLevel,  | 
|                 self.Sex,  | 
|                 self.Hair,  | 
|                 self.HairColor,  | 
|                 self.Face,  | 
|                 self.FacePic,  | 
|                 self.Job,  | 
|                 self.ReincarnationLv,  | 
|                 self.LV,  | 
|                 self.TotalExp,  | 
|                 self.FamilyID,  | 
|                 self.FamilyName,  | 
|                 self.Country,  | 
|                 self.TeamHornor,  | 
|                 self.FamilyHornor,  | 
|                 self.FamilyActiveValue,  | 
|                 self.LastWeekFamilyActiveValue,  | 
|                 self.CountryHornor,  | 
|                 self.CountryLastWeekHornor,  | 
|                 self.Mate,  | 
|                 self.Gold,  | 
|                 self.GoldPaper,  | 
|                 self.Silver,  | 
|                 self.SilverPaper,  | 
|                 self.FightPoint,  | 
|                 self.HappyPoint,  | 
|                 self.MapID,  | 
|                 self.DataMapID,  | 
|                 self.CopyMapID,  | 
|                 self.PosX,  | 
|                 self.PosY,  | 
|                 self.FromMapID,  | 
|                 self.FromCopyMapID,  | 
|                 self.FromPosX,  | 
|                 self.FromPosY,  | 
|                 self.State,  | 
|                 self.HP,  | 
|                 self.MP,  | 
|                 self.XP,  | 
|                 self.HPRestoreSetting,  | 
|                 self.MPRestoreSetting,  | 
|                 self.FreePoint,  | 
|                 self.FreeSkillPoint,  | 
|                 self.STR,  | 
|                 self.PNE,  | 
|                 self.PHY,  | 
|                 self.CON,  | 
|                 self.TotalSTR,  | 
|                 self.TotalPNE,  | 
|                 self.TotalPHY,  | 
|                 self.TotalCON,  | 
|                 self.Setting,  | 
|                 self.PKValue,  | 
|                 self.FightPower,  | 
|                 self.ActiveValue,  | 
|                 self.PlayerType,  | 
|                 self.BackpackLV,  | 
|                 self.WarehouseLV,  | 
|                 self.HaveWarehousePsw,  | 
|                 self.WarehousePsw,  | 
|                 self.WarehouseLocked,  | 
|                 self.WarehouseGold,  | 
|                 self.WarehouseSilver,  | 
|                 self.TeamID,  | 
|                 self.UseGoldType,  | 
|                 self.UseSilverType,  | 
|                 self.AttackMode,  | 
|                 self.RebornMapID,  | 
|                 self.RebornPosX,  | 
|                 self.RebornPosY,  | 
|                 self.WeekOnlineTime,  | 
|                 self.LastWeekOnlineTime,  | 
|                 self.LogoffTime,  | 
|                 self.IsHideMask,  | 
|                 self.DayProcessGameEventCount,  | 
|                 self.LoginIP,  | 
|                 self.LoginTime,  | 
|                 self.OnlineTime,  | 
|                 self.FriendFavor,  | 
|                 self.TeamPrivity,  | 
|                 self.OfflineMinutes,  | 
|                 self.Energy,  | 
|                 self.ReceivedSalary,  | 
|                 self.EquipShowSwitch,  | 
|                 self.LuckValue,  | 
|                 self.ExAttr1,  | 
|                 self.ExAttr2,  | 
|                 self.ExAttr3,  | 
|                 self.ExAttr4,  | 
|                 self.ExAttr5,  | 
|                 self.Faction,  | 
|                 self.InfamyValue,  | 
|                 self.OfficialRank,  | 
|                 self.IsFindByLabel,  | 
|                 self.IsCloseFriendLabel,  | 
|                 self.Signature,  | 
|                 self.ChangeCoinPointTotal,  | 
|                 self.VIPLv,  | 
|                 self.VIPLvForPhone,  | 
|                 self.PhoneVIPStartTime,  | 
|                 self.PhoneVIPEndTime,  | 
|                 self.VsRoomId,  | 
|                 self.ExAttr6,  | 
|                 self.ExAttr7,  | 
|                 self.ExAttr8,  | 
|                 self.ExAttr9,  | 
|                 self.ExAttr10,  | 
|                 self.ModelMark,  | 
|                 self.FromDataMapID,  | 
|                 self.LastOrderId,  | 
|                 self.PrizeCoin,  | 
|                 self.ExAttr11,  | 
|                 self.ExAttr12,  | 
|                 self.ExAttr13,  | 
|                 self.ExAttr14,  | 
|                 self.CreateRoleTime,  | 
|             )  | 
|         return output  | 
|   | 
|     #CharÊý×éÀàÐÍSet½Ó¿Ú,ʹÓøýӿڶԴËÀàÐÍÊý¾Ý¸³Öµ£¬·ÀÖ¹¸³ÖµµÄÊý¾Ý¹ý³¤±¨´í  | 
|     def SetAccID(self,Str):  | 
|         if len(Str)<=65:  | 
|             self.AccID = Str  | 
|         else:  | 
|             self.AccID = Str[:65]  | 
|               | 
|     def SetPlayerName(self,Str):  | 
|         if len(Str)<=33:  | 
|             self.PlayerName = Str  | 
|         else:  | 
|             self.PlayerName = Str[:33]  | 
|               | 
|     def SetFamilyName(self,Str):  | 
|         if len(Str)<=33:  | 
|             self.FamilyName = Str  | 
|         else:  | 
|             self.FamilyName = Str[:33]  | 
|               | 
|     def SetSetting(self,Str):  | 
|         if len(Str)<=1000:  | 
|             self.Setting = Str  | 
|         else:  | 
|             self.Setting = Str[:1000]  | 
|               | 
|     def SetWarehousePsw(self,Str):  | 
|         if len(Str)<=15:  | 
|             self.WarehousePsw = Str  | 
|         else:  | 
|             self.WarehousePsw = Str[:15]  | 
|               | 
|     def SetLogoffTime(self,Str):  | 
|         if len(Str)<=30:  | 
|             self.LogoffTime = Str  | 
|         else:  | 
|             self.LogoffTime = Str[:30]  | 
|               | 
|     def SetLoginIP(self,Str):  | 
|         if len(Str)<=20:  | 
|             self.LoginIP = Str  | 
|         else:  | 
|             self.LoginIP = Str[:20]  | 
|               | 
|     def SetLoginTime(self,Str):  | 
|         if len(Str)<=30:  | 
|             self.LoginTime = Str  | 
|         else:  | 
|             self.LoginTime = Str[:30]  | 
|               | 
|     def SetSignature(self,Str):  | 
|         if len(Str)<=101:  | 
|             self.Signature = Str  | 
|         else:  | 
|             self.Signature = Str[:101]  | 
|               | 
|     def SetLastOrderId(self,Str):  | 
|         if len(Str)<=40:  | 
|             self.LastOrderId = Str  | 
|         else:  | 
|             self.LastOrderId = Str[:40]  | 
|               | 
|     def SetCreateRoleTime(self,Str):  | 
|         if len(Str)<=30:  | 
|             self.CreateRoleTime = Str  | 
|         else:  | 
|             self.CreateRoleTime = Str[:30]  | 
|   | 
| #------------------------------------------------------  | 
| #Íæ¼ÒÕË»§ÐÅÏ¢#tagDSAccount  | 
| class tagDSAccount(Structure):  | 
|     _pack_ = 1  | 
|     _fields_ = [  | 
|         ('ACCID', ctypes.c_char * 65),  | 
|         ('Psw', ctypes.c_char * 33),  | 
|         ('PswLV2', ctypes.c_char * 33),  | 
|         ('LogNum', ctypes.c_ulong),  | 
|         ('AccountMoney', ctypes.c_ulong),  | 
|         ('AccountMoneyPaper', ctypes.c_ulong),  | 
|         ('Adult', ctypes.c_ubyte),  | 
|         ('RegIP', ctypes.c_char * 20),  | 
|         ('Presentee', ctypes.c_ubyte),  | 
|         ('GMLevelForGMTool', ctypes.c_ulong),  | 
|         ('TotalSavePoint', ctypes.c_ulong),  | 
|         ('TelLockState', ctypes.c_ubyte),  | 
|         ('szName', ctypes.c_char * 15),  | 
|         ('szSex', ctypes.c_char * 3),  | 
|         ('Age', ctypes.c_ushort),  | 
|         ('Birthday', ctypes.c_char * 21),  | 
|         ('QQ', ctypes.c_char * 19),  | 
|         ('Mail', ctypes.c_char * 41),  | 
|         ('Province', ctypes.c_char * 11),  | 
|         ('City', ctypes.c_char * 11),  | 
|         ('MTTUID', ctypes.c_longlong),  | 
|         ('IdCard', ctypes.c_char * 19),  | 
|         ('BalanceInfo', ctypes.c_ulong),  | 
|         ('AppID', ctypes.c_ulong),  | 
|         ('AreaID', ctypes.c_ulong),  | 
|         ('fobbiddenAccount', ctypes.c_ubyte),  | 
|         ('ApplyingAdult', ctypes.c_ubyte),  | 
|         ('SpreadedUser', ctypes.c_ubyte),  | 
|         ('Spreader', ctypes.c_ubyte),  | 
|         ('onlineSMSNotice', ctypes.c_ubyte),  | 
|         ('EkeyType', ctypes.c_ubyte),  | 
|         ('EkeyBindFlag', ctypes.c_ubyte),  | 
|         ('IPBan', ctypes.c_ubyte),  | 
|         ('RegisterTime', ctypes.c_char * 30),  | 
|         ('LastLoginTime', ctypes.c_char * 30),  | 
|         ('Operator', ctypes.c_char * 15),  | 
|         ('ADOResult', ctypes.c_ulong),  | 
|         ('SID', ctypes.c_int),    #ÓÃÓÚУÑé  | 
|         ('VerNO', ctypes.c_ulong)   #ÓÃÓÚSIDУÑéʱ±È½Ï°æ±¾ºÅ  | 
|     ]  | 
|   | 
|     def __init__(self):  | 
|         Structure.__init__(self)  | 
|         self.clear()  | 
|   | 
|   | 
|     def clear(self):  | 
|         memset(addressof(self), 0, self.getLength())  | 
|   | 
|   | 
|     def readData(self, buf, pos = 0, length = 0):  | 
|         if not pos <= length:  | 
|             msg = error.formatMsg('error', error.ERROR_NO_150, '(pos = %s)> (length = %s)'%(pos, length))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         if len(buf) < pos + self.getLength():  | 
|             msg = error.formatMsg('error', error.ERROR_NO_151, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         self.clear()  | 
|         memmove(addressof(self), buf[pos:], self.getLength())  | 
|         return self.getLength()  | 
|   | 
|   | 
|     def getBuffer(self):  | 
|         buf = create_string_buffer(self.getLength())  | 
|         memmove(addressof(buf), addressof(self), self.getLength())  | 
|         return string_at(addressof(buf), self.getLength())  | 
|   | 
|     def getLength(self):  | 
|         return sizeof(tagDSAccount)  | 
|   | 
|   | 
|     def getSID(self):  | 
|         return self.SID  | 
|   | 
|     def getRecord(self):  | 
|         '''×éÖ¯´æ´¢¼Ç¼'''  | 
|         rec = {}  | 
|         rec[u'ACCID'] = fix_incomingText(self.ACCID)  | 
|         rec[u'Psw'] = fix_incomingText(self.Psw)  | 
|         rec[u'PswLV2'] = fix_incomingText(self.PswLV2)  | 
|         rec[u'LogNum'] = self.LogNum  | 
|         rec[u'AccountMoney'] = self.AccountMoney  | 
|         rec[u'AccountMoneyPaper'] = self.AccountMoneyPaper  | 
|         rec[u'Adult'] = self.Adult  | 
|         rec[u'RegIP'] = fix_incomingText(self.RegIP)  | 
|         rec[u'Presentee'] = self.Presentee  | 
|         rec[u'GMLevelForGMTool'] = self.GMLevelForGMTool  | 
|         rec[u'TotalSavePoint'] = self.TotalSavePoint  | 
|         rec[u'TelLockState'] = self.TelLockState  | 
|         rec[u'szName'] = fix_incomingText(self.szName)  | 
|         rec[u'szSex'] = fix_incomingText(self.szSex)  | 
|         rec[u'Age'] = self.Age  | 
|         rec[u'Birthday'] = fix_incomingText(self.Birthday)  | 
|         rec[u'QQ'] = fix_incomingText(self.QQ)  | 
|         rec[u'Mail'] = fix_incomingText(self.Mail)  | 
|         rec[u'Province'] = fix_incomingText(self.Province)  | 
|         rec[u'City'] = fix_incomingText(self.City)  | 
|         rec[u'MTTUID'] = self.MTTUID  | 
|         rec[u'IdCard'] = fix_incomingText(self.IdCard)  | 
|         rec[u'BalanceInfo'] = self.BalanceInfo  | 
|         rec[u'AppID'] = self.AppID  | 
|         rec[u'AreaID'] = self.AreaID  | 
|         rec[u'fobbiddenAccount'] = self.fobbiddenAccount  | 
|         rec[u'ApplyingAdult'] = self.ApplyingAdult  | 
|         rec[u'SpreadedUser'] = self.SpreadedUser  | 
|         rec[u'Spreader'] = self.Spreader  | 
|         rec[u'onlineSMSNotice'] = self.onlineSMSNotice  | 
|         rec[u'EkeyType'] = self.EkeyType  | 
|         rec[u'EkeyBindFlag'] = self.EkeyBindFlag  | 
|         rec[u'IPBan'] = self.IPBan  | 
|         rec[u'RegisterTime'] = fix_incomingText(self.RegisterTime)  | 
|         rec[u'LastLoginTime'] = fix_incomingText(self.LastLoginTime)  | 
|         rec[u'Operator'] = fix_incomingText(self.Operator)  | 
|         rec[u'SID'] = self.SID  | 
|         rec[u'VerNO'] = self.VerNO  | 
|         return rec  | 
|   | 
|     def readRecord(self, rec):  | 
|         '''ÓÉÓÚMongoDB¶Á³öÀ´ÊÇunicode,ËùÓÐ×Ö·û´®ÐèÒª½øÐÐת»»'''  | 
|         self.ACCID = fix_outgoingText(rec.get(u'ACCID', u''))  | 
|         self.Psw = fix_outgoingText(rec.get(u'Psw', u''))  | 
|         self.PswLV2 = fix_outgoingText(rec.get(u'PswLV2', u''))  | 
|         self.LogNum = rec.get(u'LogNum', 0)  | 
|         self.AccountMoney = rec.get(u'AccountMoney', 0)  | 
|         self.AccountMoneyPaper = rec.get(u'AccountMoneyPaper', 0)  | 
|         self.Adult = rec.get(u'Adult', 0)  | 
|         self.RegIP = fix_outgoingText(rec.get(u'RegIP', u''))  | 
|         self.Presentee = rec.get(u'Presentee', 0)  | 
|         self.GMLevelForGMTool = rec.get(u'GMLevelForGMTool', 0)  | 
|         self.TotalSavePoint = rec.get(u'TotalSavePoint', 0)  | 
|         self.TelLockState = rec.get(u'TelLockState', 0)  | 
|         self.szName = fix_outgoingText(rec.get(u'szName', u''))  | 
|         self.szSex = fix_outgoingText(rec.get(u'szSex', u''))  | 
|         self.Age = rec.get(u'Age', 0)  | 
|         self.Birthday = fix_outgoingText(rec.get(u'Birthday', u''))  | 
|         self.QQ = fix_outgoingText(rec.get(u'QQ', u''))  | 
|         self.Mail = fix_outgoingText(rec.get(u'Mail', u''))  | 
|         self.Province = fix_outgoingText(rec.get(u'Province', u''))  | 
|         self.City = fix_outgoingText(rec.get(u'City', u''))  | 
|         self.MTTUID = rec.get(u'MTTUID', 0)  | 
|         self.IdCard = fix_outgoingText(rec.get(u'IdCard', u''))  | 
|         self.BalanceInfo = rec.get(u'BalanceInfo', 0)  | 
|         self.AppID = rec.get(u'AppID', 0)  | 
|         self.AreaID = rec.get(u'AreaID', 0)  | 
|         self.fobbiddenAccount = rec.get(u'fobbiddenAccount', 0)  | 
|         self.ApplyingAdult = rec.get(u'ApplyingAdult', 0)  | 
|         self.SpreadedUser = rec.get(u'SpreadedUser', 0)  | 
|         self.Spreader = rec.get(u'Spreader', 0)  | 
|         self.onlineSMSNotice = rec.get(u'onlineSMSNotice', 0)  | 
|         self.EkeyType = rec.get(u'EkeyType', 0)  | 
|         self.EkeyBindFlag = rec.get(u'EkeyBindFlag', 0)  | 
|         self.IPBan = rec.get(u'IPBan', 0)  | 
|         self.RegisterTime = fix_outgoingText(rec.get(u'RegisterTime', u''))  | 
|         self.LastLoginTime = fix_outgoingText(rec.get(u'LastLoginTime', u''))  | 
|         self.Operator = fix_outgoingText(rec.get(u'Operator', u''))  | 
|         self.SID = rec['SID']  | 
|         self.VerNO = rec.get(u'VerNO', 0)  | 
|   | 
|   | 
|     def makeSID(self):  | 
|         self.SID = 0  | 
|         self.VerNO = CollectionVesionNO.tagDSAccount_VersionNO  | 
|         self.SID = makeSID(self.getBuffer())  | 
|   | 
|     def adoLoad(self, collection):  | 
|         '''ʹÓÃKEY²éÕÒ²¢¶ÁÈ¡'''  | 
|         resultCollection = collection.find({'ACCID':fix_incomingText(self.ACCID)})  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         #ÓÉÓÚÊÇKEY²éÕÒ£¬ËùÓÐÈç¹û´æÔÚ¾ÍÖ»ÓÐÒ»Ìõ¼Ç¼  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         return True  | 
|   | 
|     def adoLoadC(self, collection):  | 
|         '''ʹÓÃKEY²éÕÒ,½øÐÐУÑ飬²¢¶ÁÈ¡'''  | 
|         resultCollection = collection.find({'ACCID':fix_incomingText(self.ACCID)})  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         #ÓÉÓÚÊÇKEY²éÕÒ£¬ËùÓÐÈç¹û´æÔÚ¾ÍÖ»ÓÐÒ»Ìõ¼Ç¼  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         saveSID = self.SID  | 
|         self.SID = 0  | 
|         if self.VerNO == CollectionVesionNO.tagDSAccount_VersionNO:  | 
|             if not checkSID(self.getBuffer(), saveSID):  | 
|                 addSIDErrorCnt()  | 
|                 mylog.warning('SID checksum error!ACCID = %s'%rec['ACCID'])  | 
|   | 
|                 return False  | 
|         #УÑéͨ¹ý  | 
|         return True  | 
|   | 
|     def adoLoadCEx(self, collection, query):  | 
|         resultCollection = collection.find(query)  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         saveSID = self.SID  | 
|         self.SID = 0  | 
|         if self.VerNO == CollectionVesionNO.tagDSAccount_VersionNO:  | 
|             if not checkSID(self.getBuffer(), saveSID):  | 
|                 addSIDErrorCnt()  | 
|                 mylog.warning('SID checksum error!query = %s'%query)  | 
|   | 
|                 return False  | 
|         #УÑéͨ¹ý  | 
|         return True  | 
|   | 
|   | 
|     def adoInsert(self, collection):  | 
|         '''Ö´ÐвåÈë'''  | 
|   | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.insert(rec, False, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|   | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                       | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!ACCID = %s, error = %s, trycnt = %d'%(self.ACCID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoInsertC(self, collection):  | 
|         self.makeSID()  | 
|         return self.adoInsert(collection)  | 
|   | 
|   | 
|     def adoUpdate(self, collection):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update({'ACCID':fix_incomingText(self.ACCID)}, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|   | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!ACCID = %s, error = %s, trycnt = %d'%(self.ACCID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdateEx(self, collection, spec):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update(spec, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!ACCID = %s, error = %s, trycnt = %d'%(self.ACCID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdateC(self, collection):  | 
|         self.makeSID()  | 
|         return self.adoUpdate(collection)  | 
|   | 
|   | 
|     def adoUpdateExC(self, collection, spec):  | 
|         self.makeSID()  | 
|         return self.adoUpdateEx(collection, spec)  | 
|   | 
|   | 
|     def adoCheckUpdateC(self, collection):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find({'ACCID':fix_incomingText(self.ACCID)})  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsertC(collection)  | 
|         return self.adoUpdateC(collection)  | 
|   | 
|   | 
|     def adoCheckUpdateCEx(self, collection, spec):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find(spec)  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsertC(collection, spec)  | 
|         return self.adoUpdateExC(collection, spec)  | 
|   | 
|   | 
|     def getAdoRecordsC(self, resultCollection):  | 
|         result = ''  | 
|         result = CommFunc.WriteDWORD(result, resultCollection.count())  | 
|         for rec in resultCollection:  | 
|             #УÑéSID  | 
|             self.readRecord(rec)  | 
|             saveSID = self.SID  | 
|             self.SID = 0  | 
|             if self.VerNO == CollectionVesionNO.tagDSAccount_VersionNO:  | 
|                 if not checkSID(self.getBuffer(), saveSID):  | 
|                     addSIDErrorCnt()  | 
|                     mylog.warning('SID error ACCID = %s'%self.ACCID)  | 
|   | 
|             result += self.getBuffer()  | 
|         return result  | 
|   | 
|   | 
|     def adoQueryIndexC(self, collection):  | 
|         '''ÓÃË÷Òý×ֶβéÕÒ'''  | 
|         resultCollection = collection.find({'ACCID':fix_incomingText(self.ACCID)})  | 
|            | 
|         return self.getAdoRecordsC(resultCollection)  | 
|   | 
|   | 
|     def adoQueryCustomC(self, collection, queryDict):  | 
|         '''×Ô¶¨Òå²éÕÒ'''  | 
|         resultCollection = collection.find(queryDict)  | 
|   | 
|         return self.getAdoRecordsC(resultCollection)  | 
|           | 
|   | 
|     def adoQueryAllC(self, collection):  | 
|         '''²éѯËùÓÐ'''   | 
|         resultCollection = collection.find()  | 
|            | 
|         return self.getAdoRecordsC(resultCollection)  | 
|   | 
|   | 
|     def adoDeleteByIndex(self, collection):  | 
|         '''¸ù¾ÝË÷Òýɾ³ý'''  | 
|         trycnt = 0  | 
|         while(True):  | 
|             try:  | 
|                 collection.remove({'ACCID':fix_incomingText(self.ACCID)})  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:ACCID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.ACCID))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.ACCID = %s, error = %s, trycnt = %d'%(self.ACCID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|     def outputString(self):  | 
|         output = '''//Íæ¼ÒÕË»§ÐÅÏ¢#tagDSAccount:  | 
|             ACCID = %s,  | 
|             Psw = %s,  | 
|             PswLV2 = %s,  | 
|             LogNum = %s,  | 
|             AccountMoney = %s,  | 
|             AccountMoneyPaper = %s,  | 
|             Adult = %s,  | 
|             RegIP = %s,  | 
|             Presentee = %s,  | 
|             GMLevelForGMTool = %s,  | 
|             TotalSavePoint = %s,  | 
|             TelLockState = %s,  | 
|             szName = %s,  | 
|             szSex = %s,  | 
|             Age = %s,  | 
|             Birthday = %s,  | 
|             QQ = %s,  | 
|             Mail = %s,  | 
|             Province = %s,  | 
|             City = %s,  | 
|             MTTUID = %s,  | 
|             IdCard = %s,  | 
|             BalanceInfo = %s,  | 
|             AppID = %s,  | 
|             AreaID = %s,  | 
|             fobbiddenAccount = %s,  | 
|             ApplyingAdult = %s,  | 
|             SpreadedUser = %s,  | 
|             Spreader = %s,  | 
|             onlineSMSNotice = %s,  | 
|             EkeyType = %s,  | 
|             EkeyBindFlag = %s,  | 
|             IPBan = %s,  | 
|             RegisterTime = %s,  | 
|             LastLoginTime = %s,  | 
|             Operator = %s,  | 
|             ADOResult = %s,  | 
|             SID = %s,  | 
|             VerNO = %s,  | 
|             '''%(  | 
|                 self.ACCID,  | 
|                 self.Psw,  | 
|                 self.PswLV2,  | 
|                 self.LogNum,  | 
|                 self.AccountMoney,  | 
|                 self.AccountMoneyPaper,  | 
|                 self.Adult,  | 
|                 self.RegIP,  | 
|                 self.Presentee,  | 
|                 self.GMLevelForGMTool,  | 
|                 self.TotalSavePoint,  | 
|                 self.TelLockState,  | 
|                 self.szName,  | 
|                 self.szSex,  | 
|                 self.Age,  | 
|                 self.Birthday,  | 
|                 self.QQ,  | 
|                 self.Mail,  | 
|                 self.Province,  | 
|                 self.City,  | 
|                 self.MTTUID,  | 
|                 self.IdCard,  | 
|                 self.BalanceInfo,  | 
|                 self.AppID,  | 
|                 self.AreaID,  | 
|                 self.fobbiddenAccount,  | 
|                 self.ApplyingAdult,  | 
|                 self.SpreadedUser,  | 
|                 self.Spreader,  | 
|                 self.onlineSMSNotice,  | 
|                 self.EkeyType,  | 
|                 self.EkeyBindFlag,  | 
|                 self.IPBan,  | 
|                 self.RegisterTime,  | 
|                 self.LastLoginTime,  | 
|                 self.Operator,  | 
|                 self.ADOResult,  | 
|                 self.SID,  | 
|                 self.VerNO  | 
|             )  | 
|         return output  | 
|   | 
|     def dumpString(self):  | 
|         output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(  | 
|                 self.ACCID,  | 
|                 self.Psw,  | 
|                 self.PswLV2,  | 
|                 self.LogNum,  | 
|                 self.AccountMoney,  | 
|                 self.AccountMoneyPaper,  | 
|                 self.Adult,  | 
|                 self.RegIP,  | 
|                 self.Presentee,  | 
|                 self.GMLevelForGMTool,  | 
|                 self.TotalSavePoint,  | 
|                 self.TelLockState,  | 
|                 self.szName,  | 
|                 self.szSex,  | 
|                 self.Age,  | 
|                 self.Birthday,  | 
|                 self.QQ,  | 
|                 self.Mail,  | 
|                 self.Province,  | 
|                 self.City,  | 
|                 self.MTTUID,  | 
|                 self.IdCard,  | 
|                 self.BalanceInfo,  | 
|                 self.AppID,  | 
|                 self.AreaID,  | 
|                 self.fobbiddenAccount,  | 
|                 self.ApplyingAdult,  | 
|                 self.SpreadedUser,  | 
|                 self.Spreader,  | 
|                 self.onlineSMSNotice,  | 
|                 self.EkeyType,  | 
|                 self.EkeyBindFlag,  | 
|                 self.IPBan,  | 
|                 self.RegisterTime,  | 
|                 self.LastLoginTime,  | 
|                 self.Operator,  | 
|             )  | 
|         return output  | 
|   | 
|     #CharÊý×éÀàÐÍSet½Ó¿Ú,ʹÓøýӿڶԴËÀàÐÍÊý¾Ý¸³Öµ£¬·ÀÖ¹¸³ÖµµÄÊý¾Ý¹ý³¤±¨´í  | 
|     def SetACCID(self,Str):  | 
|         if len(Str)<=65:  | 
|             self.ACCID = Str  | 
|         else:  | 
|             self.ACCID = Str[:65]  | 
|               | 
|     def SetPsw(self,Str):  | 
|         if len(Str)<=33:  | 
|             self.Psw = Str  | 
|         else:  | 
|             self.Psw = Str[:33]  | 
|               | 
|     def SetPswLV2(self,Str):  | 
|         if len(Str)<=33:  | 
|             self.PswLV2 = Str  | 
|         else:  | 
|             self.PswLV2 = Str[:33]  | 
|               | 
|     def SetRegIP(self,Str):  | 
|         if len(Str)<=20:  | 
|             self.RegIP = Str  | 
|         else:  | 
|             self.RegIP = Str[:20]  | 
|               | 
|     def SetszName(self,Str):  | 
|         if len(Str)<=15:  | 
|             self.szName = Str  | 
|         else:  | 
|             self.szName = Str[:15]  | 
|               | 
|     def SetszSex(self,Str):  | 
|         if len(Str)<=3:  | 
|             self.szSex = Str  | 
|         else:  | 
|             self.szSex = Str[:3]  | 
|               | 
|     def SetBirthday(self,Str):  | 
|         if len(Str)<=21:  | 
|             self.Birthday = Str  | 
|         else:  | 
|             self.Birthday = Str[:21]  | 
|               | 
|     def SetQQ(self,Str):  | 
|         if len(Str)<=19:  | 
|             self.QQ = Str  | 
|         else:  | 
|             self.QQ = Str[:19]  | 
|               | 
|     def SetMail(self,Str):  | 
|         if len(Str)<=41:  | 
|             self.Mail = Str  | 
|         else:  | 
|             self.Mail = Str[:41]  | 
|               | 
|     def SetProvince(self,Str):  | 
|         if len(Str)<=11:  | 
|             self.Province = Str  | 
|         else:  | 
|             self.Province = Str[:11]  | 
|               | 
|     def SetCity(self,Str):  | 
|         if len(Str)<=11:  | 
|             self.City = Str  | 
|         else:  | 
|             self.City = Str[:11]  | 
|               | 
|     def SetIdCard(self,Str):  | 
|         if len(Str)<=19:  | 
|             self.IdCard = Str  | 
|         else:  | 
|             self.IdCard = Str[:19]  | 
|               | 
|     def SetRegisterTime(self,Str):  | 
|         if len(Str)<=30:  | 
|             self.RegisterTime = Str  | 
|         else:  | 
|             self.RegisterTime = Str[:30]  | 
|               | 
|     def SetLastLoginTime(self,Str):  | 
|         if len(Str)<=30:  | 
|             self.LastLoginTime = Str  | 
|         else:  | 
|             self.LastLoginTime = Str[:30]  | 
|               | 
|     def SetOperator(self,Str):  | 
|         if len(Str)<=15:  | 
|             self.Operator = Str  | 
|         else:  | 
|             self.Operator = Str[:15]  | 
|   | 
| #------------------------------------------------------  | 
| #ÈËÎïÎïÆ·#tagRoleItem  | 
| class tagRoleItem(Structure):  | 
|     _pack_ = 1  | 
|     _fields_ = [  | 
|         ('ItemGUID', ctypes.c_char * 40),  | 
|         ('PlayerID', ctypes.c_ulong),  | 
|         ('ItemTypeID', ctypes.c_ulong),  | 
|         ('Count', ctypes.c_ushort),  | 
|         ('IsLocked', ctypes.c_ubyte),  | 
|         ('ItemPlaceType', ctypes.c_ubyte),  | 
|         ('ItemPlaceIndex', ctypes.c_ushort),  | 
|         ('IsBind', ctypes.c_ubyte),  | 
|         ('ItemStarLV', ctypes.c_ubyte),  | 
|         ('IdentifyPar', ctypes.c_ubyte),  | 
|         ('CurDurg', ctypes.c_ulong),  | 
|         ('MaxDurg', ctypes.c_ulong),  | 
|         ('CanPlaceStoneCount', ctypes.c_ubyte),  | 
|         ('ItemProperty', ctypes.c_ubyte),  | 
|         ('SoulProperty', ctypes.c_ushort),  | 
|         ('Maker', ctypes.c_ulong),  | 
|         ('MakerName', ctypes.c_char * 33),  | 
|         ('Stone1', ctypes.c_ulong),  | 
|         ('Stone2', ctypes.c_ulong),  | 
|         ('Stone3', ctypes.c_ulong),  | 
|         ('Stone4', ctypes.c_ulong),  | 
|         ('Stone5', ctypes.c_ulong),  | 
|         ('Stone6', ctypes.c_ulong),  | 
|         ('Stone7', ctypes.c_ulong),  | 
|         ('Stone8', ctypes.c_ulong),  | 
|         ('Stone9', ctypes.c_ulong),  | 
|         ('RemainHour', ctypes.c_ushort),  | 
|         ('CreateTime', ctypes.c_char * 30),  | 
|         ('IsRenZhu', ctypes.c_ubyte),  | 
|         ('EquipDefenseValue', ctypes.c_ulong),  | 
|         ('EquipMinAtkValue', ctypes.c_ulong),  | 
|         ('EquipMaxAtkValue', ctypes.c_ulong),  | 
|         ('UserDataLen', ctypes.c_ulong),  | 
|         ('UserData', ctypes.c_char_p),  | 
|         ('FitLV', ctypes.c_ubyte),  | 
|         ('Proficiency', ctypes.c_ulong),  | 
|         ('IsSuite', ctypes.c_ubyte),  | 
|         ('BaseHP', ctypes.c_ulong),  | 
|         ('BaseMagicDef', ctypes.c_ulong),  | 
|         ('MaxAddSkillCnt', ctypes.c_ubyte),  | 
|         ('PetID', ctypes.c_ulong),  | 
|         ('EquipMagicDefValue', ctypes.c_ulong),  | 
|         ('EquipMinMagicAtkValue', ctypes.c_ulong),  | 
|         ('EquipMaxMagicAtkValue', ctypes.c_ulong),  | 
|         ('ADOResult', ctypes.c_ulong),  | 
|         ('SID', ctypes.c_int),    #ÓÃÓÚУÑé  | 
|         ('VerNO', ctypes.c_ulong)   #ÓÃÓÚSIDУÑéʱ±È½Ï°æ±¾ºÅ  | 
|     ]  | 
|   | 
|     def __init__(self):  | 
|         Structure.__init__(self)  | 
|         self.clear()  | 
|   | 
|     def clear(self):  | 
|         self.ItemGUID = ''  | 
|         self.PlayerID = 0  | 
|         self.ItemTypeID = 0  | 
|         self.Count = 0  | 
|         self.IsLocked = 0  | 
|         self.ItemPlaceType = 0  | 
|         self.ItemPlaceIndex = 0  | 
|         self.IsBind = 0  | 
|         self.ItemStarLV = 0  | 
|         self.IdentifyPar = 0  | 
|         self.CurDurg = 0  | 
|         self.MaxDurg = 0  | 
|         self.CanPlaceStoneCount = 0  | 
|         self.ItemProperty = 0  | 
|         self.SoulProperty = 0  | 
|         self.Maker = 0  | 
|         self.MakerName = ''  | 
|         self.Stone1 = 0  | 
|         self.Stone2 = 0  | 
|         self.Stone3 = 0  | 
|         self.Stone4 = 0  | 
|         self.Stone5 = 0  | 
|         self.Stone6 = 0  | 
|         self.Stone7 = 0  | 
|         self.Stone8 = 0  | 
|         self.Stone9 = 0  | 
|         self.RemainHour = 0  | 
|         self.CreateTime = ''  | 
|         self.IsRenZhu = 0  | 
|         self.EquipDefenseValue = 0  | 
|         self.EquipMinAtkValue = 0  | 
|         self.EquipMaxAtkValue = 0  | 
|         self.UserDataLen = 0  | 
|         self.UserData = ''  | 
|         self.FitLV = 0  | 
|         self.Proficiency = 0  | 
|         self.IsSuite = 0  | 
|         self.BaseHP = 0  | 
|         self.BaseMagicDef = 0  | 
|         self.MaxAddSkillCnt = 0  | 
|         self.PetID = 0  | 
|         self.EquipMagicDefValue = 0  | 
|         self.EquipMinMagicAtkValue = 0  | 
|         self.EquipMaxMagicAtkValue = 0  | 
|   | 
|     def readData(self, buf, pos = 0, length = 0):  | 
|         if not pos <= length:  | 
|             msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         if len(buf) < pos + self.getLength():  | 
|             msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))  | 
|             mylog.error(msg)  | 
|         self.clear()  | 
|         self.ItemGUID, pos = CommFunc.ReadString(buf, pos, 40)  | 
|         self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.ItemTypeID, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Count, pos = CommFunc.ReadWORD(buf, pos)  | 
|         self.IsLocked, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.ItemPlaceType, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.ItemPlaceIndex, pos = CommFunc.ReadWORD(buf, pos)  | 
|         self.IsBind, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.ItemStarLV, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.IdentifyPar, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.CurDurg, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.MaxDurg, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.CanPlaceStoneCount, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.ItemProperty, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.SoulProperty, pos = CommFunc.ReadWORD(buf, pos)  | 
|         self.Maker, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.MakerName, pos = CommFunc.ReadString(buf, pos, 33)  | 
|         self.Stone1, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone2, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone3, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone4, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone5, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone6, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone7, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone8, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.Stone9, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.RemainHour, pos = CommFunc.ReadWORD(buf, pos)  | 
|         self.CreateTime, pos = CommFunc.ReadString(buf, pos, 30)  | 
|         self.IsRenZhu, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.EquipDefenseValue, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.EquipMinAtkValue, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.EquipMaxAtkValue, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.UserDataLen, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         tmp, pos = CommFunc.ReadString(buf, pos, self.UserDataLen)  | 
|         self.UserData = ctypes.c_char_p(tmp)  | 
|         self.FitLV, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.Proficiency, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.IsSuite, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.BaseHP, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.BaseMagicDef, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.MaxAddSkillCnt, pos = CommFunc.ReadBYTE(buf, pos)  | 
|         self.PetID, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.EquipMagicDefValue, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.EquipMinMagicAtkValue, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         self.EquipMaxMagicAtkValue, pos = CommFunc.ReadDWORD(buf, pos)  | 
|         return self.getLength()  | 
|   | 
|     def getBuffer(self):  | 
|         buf = ''  | 
|         buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 40, self.ItemGUID)  | 
|         buf = CommFunc.WriteDWORD(buf, self.PlayerID)  | 
|         buf = CommFunc.WriteDWORD(buf, self.ItemTypeID)  | 
|         buf = CommFunc.WriteWORD(buf, self.Count)  | 
|         buf = CommFunc.WriteBYTE(buf, self.IsLocked)  | 
|         buf = CommFunc.WriteBYTE(buf, self.ItemPlaceType)  | 
|         buf = CommFunc.WriteWORD(buf, self.ItemPlaceIndex)  | 
|         buf = CommFunc.WriteBYTE(buf, self.IsBind)  | 
|         buf = CommFunc.WriteBYTE(buf, self.ItemStarLV)  | 
|         buf = CommFunc.WriteBYTE(buf, self.IdentifyPar)  | 
|         buf = CommFunc.WriteDWORD(buf, self.CurDurg)  | 
|         buf = CommFunc.WriteDWORD(buf, self.MaxDurg)  | 
|         buf = CommFunc.WriteBYTE(buf, self.CanPlaceStoneCount)  | 
|         buf = CommFunc.WriteBYTE(buf, self.ItemProperty)  | 
|         buf = CommFunc.WriteWORD(buf, self.SoulProperty)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Maker)  | 
|         buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.MakerName)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone1)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone2)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone3)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone4)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone5)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone6)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone7)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone8)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Stone9)  | 
|         buf = CommFunc.WriteWORD(buf, self.RemainHour)  | 
|         buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 30, self.CreateTime)  | 
|         buf = CommFunc.WriteBYTE(buf, self.IsRenZhu)  | 
|         buf = CommFunc.WriteDWORD(buf, self.EquipDefenseValue)  | 
|         buf = CommFunc.WriteDWORD(buf, self.EquipMinAtkValue)  | 
|         buf = CommFunc.WriteDWORD(buf, self.EquipMaxAtkValue)  | 
|         buf = CommFunc.WriteDWORD(buf, self.UserDataLen)  | 
|         buf = CommFunc.WriteString(buf, self.UserDataLen, self.UserData)  | 
|         buf = CommFunc.WriteBYTE(buf, self.FitLV)  | 
|         buf = CommFunc.WriteDWORD(buf, self.Proficiency)  | 
|         buf = CommFunc.WriteBYTE(buf, self.IsSuite)  | 
|         buf = CommFunc.WriteDWORD(buf, self.BaseHP)  | 
|         buf = CommFunc.WriteDWORD(buf, self.BaseMagicDef)  | 
|         buf = CommFunc.WriteBYTE(buf, self.MaxAddSkillCnt)  | 
|         buf = CommFunc.WriteDWORD(buf, self.PetID)  | 
|         buf = CommFunc.WriteDWORD(buf, self.EquipMagicDefValue)  | 
|         buf = CommFunc.WriteDWORD(buf, self.EquipMinMagicAtkValue)  | 
|         buf = CommFunc.WriteDWORD(buf, self.EquipMaxMagicAtkValue)  | 
|         return buf  | 
|   | 
|     def getLength(self):  | 
|         length = 0  | 
|         length += sizeof(ctypes.c_char) * 40  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ushort)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ushort)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ushort)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_char) * 33  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ushort)  | 
|         length += sizeof(ctypes.c_char) * 30  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += self.UserDataLen  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ubyte)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         length += sizeof(ctypes.c_ulong)  | 
|         return length  | 
|   | 
|   | 
|     def getSID(self):  | 
|         return self.SID  | 
|   | 
|     def getRecord(self):  | 
|         '''×éÖ¯´æ´¢¼Ç¼'''  | 
|         rec = {}  | 
|         rec[u'ItemGUID'] = fix_incomingText(self.ItemGUID)  | 
|         rec[u'PlayerID'] = self.PlayerID  | 
|         rec[u'ItemTypeID'] = self.ItemTypeID  | 
|         rec[u'Count'] = self.Count  | 
|         rec[u'IsLocked'] = self.IsLocked  | 
|         rec[u'ItemPlaceType'] = self.ItemPlaceType  | 
|         rec[u'ItemPlaceIndex'] = self.ItemPlaceIndex  | 
|         rec[u'IsBind'] = self.IsBind  | 
|         rec[u'ItemStarLV'] = self.ItemStarLV  | 
|         rec[u'IdentifyPar'] = self.IdentifyPar  | 
|         rec[u'CurDurg'] = self.CurDurg  | 
|         rec[u'MaxDurg'] = self.MaxDurg  | 
|         rec[u'CanPlaceStoneCount'] = self.CanPlaceStoneCount  | 
|         rec[u'ItemProperty'] = self.ItemProperty  | 
|         rec[u'SoulProperty'] = self.SoulProperty  | 
|         rec[u'Maker'] = self.Maker  | 
|         rec[u'MakerName'] = fix_incomingText(self.MakerName)  | 
|         rec[u'Stone1'] = self.Stone1  | 
|         rec[u'Stone2'] = self.Stone2  | 
|         rec[u'Stone3'] = self.Stone3  | 
|         rec[u'Stone4'] = self.Stone4  | 
|         rec[u'Stone5'] = self.Stone5  | 
|         rec[u'Stone6'] = self.Stone6  | 
|         rec[u'Stone7'] = self.Stone7  | 
|         rec[u'Stone8'] = self.Stone8  | 
|         rec[u'Stone9'] = self.Stone9  | 
|         rec[u'RemainHour'] = self.RemainHour  | 
|         rec[u'CreateTime'] = fix_incomingText(self.CreateTime)  | 
|         rec[u'IsRenZhu'] = self.IsRenZhu  | 
|         rec[u'EquipDefenseValue'] = self.EquipDefenseValue  | 
|         rec[u'EquipMinAtkValue'] = self.EquipMinAtkValue  | 
|         rec[u'EquipMaxAtkValue'] = self.EquipMaxAtkValue  | 
|         rec[u'UserDataLen'] = self.UserDataLen  | 
|         rec[u'UserData'] = fix_incomingText(self.UserData)  | 
|         rec[u'FitLV'] = self.FitLV  | 
|         rec[u'Proficiency'] = self.Proficiency  | 
|         rec[u'IsSuite'] = self.IsSuite  | 
|         rec[u'BaseHP'] = self.BaseHP  | 
|         rec[u'BaseMagicDef'] = self.BaseMagicDef  | 
|         rec[u'MaxAddSkillCnt'] = self.MaxAddSkillCnt  | 
|         rec[u'PetID'] = self.PetID  | 
|         rec[u'EquipMagicDefValue'] = self.EquipMagicDefValue  | 
|         rec[u'EquipMinMagicAtkValue'] = self.EquipMinMagicAtkValue  | 
|         rec[u'EquipMaxMagicAtkValue'] = self.EquipMaxMagicAtkValue  | 
|         rec[u'SID'] = self.SID  | 
|         rec[u'VerNO'] = self.VerNO  | 
|         return rec  | 
|   | 
|     def readRecord(self, rec):  | 
|         '''ÓÉÓÚMongoDB¶Á³öÀ´ÊÇunicode,ËùÓÐ×Ö·û´®ÐèÒª½øÐÐת»»'''  | 
|         self.ItemGUID = fix_outgoingText(rec.get(u'ItemGUID', u''))  | 
|         self.PlayerID = rec.get(u'PlayerID', 0)  | 
|         self.ItemTypeID = rec.get(u'ItemTypeID', 0)  | 
|         self.Count = rec.get(u'Count', 0)  | 
|         self.IsLocked = rec.get(u'IsLocked', 0)  | 
|         self.ItemPlaceType = rec.get(u'ItemPlaceType', 0)  | 
|         self.ItemPlaceIndex = rec.get(u'ItemPlaceIndex', 0)  | 
|         self.IsBind = rec.get(u'IsBind', 0)  | 
|         self.ItemStarLV = rec.get(u'ItemStarLV', 0)  | 
|         self.IdentifyPar = rec.get(u'IdentifyPar', 0)  | 
|         self.CurDurg = rec.get(u'CurDurg', 0)  | 
|         self.MaxDurg = rec.get(u'MaxDurg', 0)  | 
|         self.CanPlaceStoneCount = rec.get(u'CanPlaceStoneCount', 0)  | 
|         self.ItemProperty = rec.get(u'ItemProperty', 0)  | 
|         self.SoulProperty = rec.get(u'SoulProperty', 0)  | 
|         self.Maker = rec.get(u'Maker', 0)  | 
|         self.MakerName = fix_outgoingText(rec.get(u'MakerName', u''))  | 
|         self.Stone1 = rec.get(u'Stone1', 0)  | 
|         self.Stone2 = rec.get(u'Stone2', 0)  | 
|         self.Stone3 = rec.get(u'Stone3', 0)  | 
|         self.Stone4 = rec.get(u'Stone4', 0)  | 
|         self.Stone5 = rec.get(u'Stone5', 0)  | 
|         self.Stone6 = rec.get(u'Stone6', 0)  | 
|         self.Stone7 = rec.get(u'Stone7', 0)  | 
|         self.Stone8 = rec.get(u'Stone8', 0)  | 
|         self.Stone9 = rec.get(u'Stone9', 0)  | 
|         self.RemainHour = rec.get(u'RemainHour', 0)  | 
|         self.CreateTime = fix_outgoingText(rec.get(u'CreateTime', u''))  | 
|         self.IsRenZhu = rec.get(u'IsRenZhu', 0)  | 
|         self.EquipDefenseValue = rec.get(u'EquipDefenseValue', 0)  | 
|         self.EquipMinAtkValue = rec.get(u'EquipMinAtkValue', 0)  | 
|         self.EquipMaxAtkValue = rec.get(u'EquipMaxAtkValue', 0)  | 
|         self.UserDataLen = rec.get(u'UserDataLen', 0)  | 
|         self.UserData = fix_outgoingText(rec.get(u'UserData', u''))  | 
|         self.FitLV = rec.get(u'FitLV', 0)  | 
|         self.Proficiency = rec.get(u'Proficiency', 0)  | 
|         self.IsSuite = rec.get(u'IsSuite', 0)  | 
|         self.BaseHP = rec.get(u'BaseHP', 0)  | 
|         self.BaseMagicDef = rec.get(u'BaseMagicDef', 0)  | 
|         self.MaxAddSkillCnt = rec.get(u'MaxAddSkillCnt', 0)  | 
|         self.PetID = rec.get(u'PetID', 0)  | 
|         self.EquipMagicDefValue = rec.get(u'EquipMagicDefValue', 0)  | 
|         self.EquipMinMagicAtkValue = rec.get(u'EquipMinMagicAtkValue', 0)  | 
|         self.EquipMaxMagicAtkValue = rec.get(u'EquipMaxMagicAtkValue', 0)  | 
|         self.SID = rec['SID']  | 
|         self.VerNO = rec.get(u'VerNO', 0)  | 
|   | 
|   | 
|     def makeSID(self):  | 
|         self.SID = 0  | 
|         self.VerNO = CollectionVesionNO.tagRoleItem_VersionNO  | 
|         self.SID = makeSID(self.getBuffer())  | 
|   | 
| #Can not implement adoLoadStr method:No key defined!  | 
| #Can not implement adoLoadCStr method:No key defined!  | 
|     def adoLoadCEx(self, collection, query):  | 
|         resultCollection = collection.find(query)  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         saveSID = self.SID  | 
|         self.SID = 0  | 
|         if self.VerNO == CollectionVesionNO.tagRoleItem_VersionNO:  | 
|             if not checkSID(self.getBuffer(), saveSID):  | 
|                 addSIDErrorCnt()  | 
|                 mylog.warning('SID checksum error!query = %s'%query)  | 
|   | 
|                 return False  | 
|         #УÑéͨ¹ý  | 
|         return True  | 
|   | 
|   | 
|     def adoInsert(self, collection):  | 
|         '''Ö´ÐвåÈë'''  | 
|   | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.insert(rec, False, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|   | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                       | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!ItemGUID = %s, error = %s, trycnt = %d'%(self.ItemGUID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoInsertC(self, collection):  | 
|         self.makeSID()  | 
|         return self.adoInsert(collection)  | 
|   | 
| #Can not implement adoUpdateStr method:No key defined!  | 
|   | 
|     def adoUpdateEx(self, collection, spec):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update(spec, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!ItemGUID = %s, error = %s, trycnt = %d'%(self.ItemGUID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdateC(self, collection):  | 
|         self.makeSID()  | 
|         return self.adoUpdate(collection)  | 
|   | 
|   | 
|     def adoUpdateExC(self, collection, spec):  | 
|         self.makeSID()  | 
|         return self.adoUpdateEx(collection, spec)  | 
|   | 
| #Can not implement adoCheckUpdateCStr method:No key defined!  | 
| #Can not implement adoCheckUpdateCExStr method:No key defined!  | 
|   | 
|     def getAdoRecordsC(self, resultCollection):  | 
|         result = ''  | 
|         result = CommFunc.WriteDWORD(result, resultCollection.count())  | 
|         for rec in resultCollection:  | 
|             #УÑéSID  | 
|             self.readRecord(rec)  | 
|             saveSID = self.SID  | 
|             self.SID = 0  | 
|             if self.VerNO == CollectionVesionNO.tagRoleItem_VersionNO:  | 
|                 if not checkSID(self.getBuffer(), saveSID):  | 
|                     addSIDErrorCnt()  | 
|                     mylog.warning('SID error ItemGUID = %s'%self.ItemGUID)  | 
|   | 
|             result += self.getBuffer()  | 
|         return result  | 
|   | 
|   | 
|     def adoQueryIndexC(self, collection):  | 
|         '''ÓÃË÷Òý×ֶβéÕÒ'''  | 
|         resultCollection = collection.find({'ItemGUID':fix_incomingText(self.ItemGUID)})  | 
|            | 
|         return self.getAdoRecordsC(resultCollection)  | 
|   | 
|   | 
|     def adoQueryCustomC(self, collection, queryDict):  | 
|         '''×Ô¶¨Òå²éÕÒ'''  | 
|         resultCollection = collection.find(queryDict)  | 
|   | 
|         return self.getAdoRecordsC(resultCollection)  | 
|           | 
|   | 
|     def adoQueryAllC(self, collection):  | 
|         '''²éѯËùÓÐ'''   | 
|         resultCollection = collection.find()  | 
|            | 
|         return self.getAdoRecordsC(resultCollection)  | 
|   | 
|   | 
|     def adoDeleteByIndex(self, collection):  | 
|         '''¸ù¾ÝË÷Òýɾ³ý'''  | 
|         trycnt = 0  | 
|         while(True):  | 
|             try:  | 
|                 collection.remove({'ItemGUID':fix_incomingText(self.ItemGUID)})  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:ItemGUID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.ItemGUID))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.ItemGUID = %s, error = %s, trycnt = %d'%(self.ItemGUID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|     def outputString(self):  | 
|         output = '''//ÈËÎïÎïÆ·#tagRoleItem:  | 
|             ItemGUID = %s,  | 
|             PlayerID = %s,  | 
|             ItemTypeID = %s,  | 
|             Count = %s,  | 
|             IsLocked = %s,  | 
|             ItemPlaceType = %s,  | 
|             ItemPlaceIndex = %s,  | 
|             IsBind = %s,  | 
|             ItemStarLV = %s,  | 
|             IdentifyPar = %s,  | 
|             CurDurg = %s,  | 
|             MaxDurg = %s,  | 
|             CanPlaceStoneCount = %s,  | 
|             ItemProperty = %s,  | 
|             SoulProperty = %s,  | 
|             Maker = %s,  | 
|             MakerName = %s,  | 
|             Stone1 = %s,  | 
|             Stone2 = %s,  | 
|             Stone3 = %s,  | 
|             Stone4 = %s,  | 
|             Stone5 = %s,  | 
|             Stone6 = %s,  | 
|             Stone7 = %s,  | 
|             Stone8 = %s,  | 
|             Stone9 = %s,  | 
|             RemainHour = %s,  | 
|             CreateTime = %s,  | 
|             IsRenZhu = %s,  | 
|             EquipDefenseValue = %s,  | 
|             EquipMinAtkValue = %s,  | 
|             EquipMaxAtkValue = %s,  | 
|             UserDataLen = %s,  | 
|             UserData = %s,  | 
|             FitLV = %s,  | 
|             Proficiency = %s,  | 
|             IsSuite = %s,  | 
|             BaseHP = %s,  | 
|             BaseMagicDef = %s,  | 
|             MaxAddSkillCnt = %s,  | 
|             PetID = %s,  | 
|             EquipMagicDefValue = %s,  | 
|             EquipMinMagicAtkValue = %s,  | 
|             EquipMaxMagicAtkValue = %s,  | 
|             ADOResult = %s,  | 
|             SID = %s,  | 
|             VerNO = %s,  | 
|             '''%(  | 
|                 self.ItemGUID,  | 
|                 self.PlayerID,  | 
|                 self.ItemTypeID,  | 
|                 self.Count,  | 
|                 self.IsLocked,  | 
|                 self.ItemPlaceType,  | 
|                 self.ItemPlaceIndex,  | 
|                 self.IsBind,  | 
|                 self.ItemStarLV,  | 
|                 self.IdentifyPar,  | 
|                 self.CurDurg,  | 
|                 self.MaxDurg,  | 
|                 self.CanPlaceStoneCount,  | 
|                 self.ItemProperty,  | 
|                 self.SoulProperty,  | 
|                 self.Maker,  | 
|                 self.MakerName,  | 
|                 self.Stone1,  | 
|                 self.Stone2,  | 
|                 self.Stone3,  | 
|                 self.Stone4,  | 
|                 self.Stone5,  | 
|                 self.Stone6,  | 
|                 self.Stone7,  | 
|                 self.Stone8,  | 
|                 self.Stone9,  | 
|                 self.RemainHour,  | 
|                 self.CreateTime,  | 
|                 self.IsRenZhu,  | 
|                 self.EquipDefenseValue,  | 
|                 self.EquipMinAtkValue,  | 
|                 self.EquipMaxAtkValue,  | 
|                 self.UserDataLen,  | 
|                 self.UserData,  | 
|                 self.FitLV,  | 
|                 self.Proficiency,  | 
|                 self.IsSuite,  | 
|                 self.BaseHP,  | 
|                 self.BaseMagicDef,  | 
|                 self.MaxAddSkillCnt,  | 
|                 self.PetID,  | 
|                 self.EquipMagicDefValue,  | 
|                 self.EquipMinMagicAtkValue,  | 
|                 self.EquipMaxMagicAtkValue,  | 
|                 self.ADOResult,  | 
|                 self.SID,  | 
|                 self.VerNO  | 
|             )  | 
|         return output  | 
|   | 
|     def dumpString(self):  | 
|         output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(  | 
|                 self.ItemGUID,  | 
|                 self.PlayerID,  | 
|                 self.ItemTypeID,  | 
|                 self.Count,  | 
|                 self.IsLocked,  | 
|                 self.ItemPlaceType,  | 
|                 self.ItemPlaceIndex,  | 
|                 self.IsBind,  | 
|                 self.ItemStarLV,  | 
|                 self.IdentifyPar,  | 
|                 self.CurDurg,  | 
|                 self.MaxDurg,  | 
|                 self.CanPlaceStoneCount,  | 
|                 self.ItemProperty,  | 
|                 self.SoulProperty,  | 
|                 self.Maker,  | 
|                 self.MakerName,  | 
|                 self.Stone1,  | 
|                 self.Stone2,  | 
|                 self.Stone3,  | 
|                 self.Stone4,  | 
|                 self.Stone5,  | 
|                 self.Stone6,  | 
|                 self.Stone7,  | 
|                 self.Stone8,  | 
|                 self.Stone9,  | 
|                 self.RemainHour,  | 
|                 self.CreateTime,  | 
|                 self.IsRenZhu,  | 
|                 self.EquipDefenseValue,  | 
|                 self.EquipMinAtkValue,  | 
|                 self.EquipMaxAtkValue,  | 
|                 self.UserDataLen,  | 
|                 self.UserData,  | 
|                 self.FitLV,  | 
|                 self.Proficiency,  | 
|                 self.IsSuite,  | 
|                 self.BaseHP,  | 
|                 self.BaseMagicDef,  | 
|                 self.MaxAddSkillCnt,  | 
|                 self.PetID,  | 
|                 self.EquipMagicDefValue,  | 
|                 self.EquipMinMagicAtkValue,  | 
|                 self.EquipMaxMagicAtkValue,  | 
|             )  | 
|         return output  | 
|   | 
|     #CharÊý×éÀàÐÍSet½Ó¿Ú,ʹÓøýӿڶԴËÀàÐÍÊý¾Ý¸³Öµ£¬·ÀÖ¹¸³ÖµµÄÊý¾Ý¹ý³¤±¨´í  | 
|     def SetItemGUID(self,Str):  | 
|         if len(Str)<=40:  | 
|             self.ItemGUID = Str  | 
|         else:  | 
|             self.ItemGUID = Str[:40]  | 
|               | 
|     def SetMakerName(self,Str):  | 
|         if len(Str)<=33:  | 
|             self.MakerName = Str  | 
|         else:  | 
|             self.MakerName = Str[:33]  | 
|               | 
|     def SetCreateTime(self,Str):  | 
|         if len(Str)<=30:  | 
|             self.CreateTime = Str  | 
|         else:  | 
|             self.CreateTime = Str[:30]  | 
|   | 
|   | 
| #------------------------------------------------------  | 
| #Íæ¼Ò¼¼Äܱí#tagRoleSkill  | 
| class tagRoleSkill(Structure):  | 
|     _pack_ = 1  | 
|     _fields_ = [  | 
|         ('PlayerID', ctypes.c_ulong),  | 
|         ('SkillID', ctypes.c_ushort),  | 
|         ('RemainTime', ctypes.c_ulong),  | 
|         ('Proficiency', ctypes.c_ulong),  | 
|         ('ADOResult', ctypes.c_ulong),  | 
|     ]  | 
|   | 
|     def __init__(self):  | 
|         Structure.__init__(self)  | 
|         self.clear()  | 
|   | 
|   | 
|     def clear(self):  | 
|         memset(addressof(self), 0, self.getLength())  | 
|   | 
|   | 
|     def readData(self, buf, pos = 0, length = 0):  | 
|         if not pos <= length:  | 
|             msg = error.formatMsg('error', error.ERROR_NO_150, '(pos = %s)> (length = %s)'%(pos, length))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         if len(buf) < pos + self.getLength():  | 
|             msg = error.formatMsg('error', error.ERROR_NO_151, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         self.clear()  | 
|         memmove(addressof(self), buf[pos:], self.getLength())  | 
|         return self.getLength()  | 
|   | 
|   | 
|     def getBuffer(self):  | 
|         buf = create_string_buffer(self.getLength())  | 
|         memmove(addressof(buf), addressof(self), self.getLength())  | 
|         return string_at(addressof(buf), self.getLength())  | 
|   | 
|     def getLength(self):  | 
|         return sizeof(tagRoleSkill)  | 
|   | 
|     def getRecord(self):  | 
|         '''×éÖ¯´æ´¢¼Ç¼'''  | 
|         rec = {}  | 
|         rec[u'PlayerID'] = self.PlayerID  | 
|         rec[u'SkillID'] = self.SkillID  | 
|         rec[u'RemainTime'] = self.RemainTime  | 
|         rec[u'Proficiency'] = self.Proficiency  | 
|         return rec  | 
|   | 
|     def readRecord(self, rec):  | 
|         '''ÓÉÓÚMongoDB¶Á³öÀ´ÊÇunicode,ËùÓÐ×Ö·û´®ÐèÒª½øÐÐת»»'''  | 
|         self.PlayerID = rec.get(u'PlayerID', 0)  | 
|         self.SkillID = rec.get(u'SkillID', 0)  | 
|         self.RemainTime = rec.get(u'RemainTime', 0)  | 
|         self.Proficiency = rec.get(u'Proficiency', 0)  | 
|   | 
| #Can not implement adoLoadStr method:No key defined!  | 
|   | 
|     def adoInsert(self, collection):  | 
|         '''Ö´ÐвåÈë'''  | 
|   | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.insert(rec, False, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|   | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                       | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
| #Can not implement adoUpdateStr method:No key defined!  | 
|   | 
|     def adoUpdateEx(self, collection, spec):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update(spec, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
| #Can not implement adoCheckUpdateStr method:No key defined!  | 
| #Can not implement adoCheckUpdateExStr method:No key defined!  | 
|   | 
|     def getAdoRecords(self, resultCollection):  | 
|         '''²éѯ½á¹û´ò°ü³É¶þ½øÖÆÁ÷'''  | 
|         result = ''  | 
|         result = CommFunc.WriteDWORD(result, resultCollection.count())  | 
|         for rec in resultCollection:  | 
|             self.readRecord(rec)  | 
|             result += self.getBuffer()  | 
|         return result  | 
|   | 
|   | 
|     def adoQueryIndex(self, collection):  | 
|         '''ÓÃË÷Òý×ֶβéÕÒ'''  | 
|         resultCollection = collection.find({'PlayerID':self.PlayerID})  | 
|            | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoQueryCustom(self, collection, queryDict):  | 
|         '''×Ô¶¨Òå²éѯ'''  | 
|         resultCollection = collection.find(queryDict)  | 
|   | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoQueryAll(self, collection):  | 
|         '''²éѯËùÓÐ'''   | 
|         resultCollection = collection.find()  | 
|            | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoDeleteByIndex(self, collection):  | 
|         '''¸ù¾ÝË÷Òýɾ³ý'''  | 
|         trycnt = 0  | 
|         while(True):  | 
|             try:  | 
|                 collection.remove({'PlayerID':self.PlayerID})  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:PlayerID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.PlayerID))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|     def outputString(self):  | 
|         output = '''//Íæ¼Ò¼¼Äܱí#tagRoleSkill:  | 
|             PlayerID = %s,  | 
|             SkillID = %s,  | 
|             RemainTime = %s,  | 
|             Proficiency = %s,  | 
|             ADOResult = %s,  | 
|             '''%(  | 
|                 self.PlayerID,  | 
|                 self.SkillID,  | 
|                 self.RemainTime,  | 
|                 self.Proficiency,  | 
|                 self.ADOResult,  | 
|             )  | 
|         return output  | 
|   | 
|     def dumpString(self):  | 
|         output = '''%1s\t%1s\t%1s\t%1s'''%(  | 
|                 self.PlayerID,  | 
|                 self.SkillID,  | 
|                 self.RemainTime,  | 
|                 self.Proficiency,  | 
|             )  | 
|         return output  | 
|   | 
| #------------------------------------------------------  | 
| #Íæ¼Ò³èÎï±í#tagRolePet  | 
| class tagRolePet(Structure):  | 
|     _pack_ = 1  | 
|     _fields_ = [  | 
|         ('PetID', ctypes.c_ulong),  | 
|         ('PlayerID', ctypes.c_ulong),  | 
|         ('NPCID', ctypes.c_ulong),  | 
|         ('Name', ctypes.c_char * 24),  | 
|         ('Friendliness', ctypes.c_ushort),  | 
|         ('HP', ctypes.c_ulong),  | 
|         ('MP', ctypes.c_ulong),  | 
|         ('Lv', ctypes.c_ushort),  | 
|         ('Exp', ctypes.c_ulong),  | 
|         ('HPTalent', ctypes.c_ushort),  | 
|         ('MPTalent', ctypes.c_ushort),  | 
|         ('PhysicAtkTalent', ctypes.c_ushort),  | 
|         ('MagicAtkTalent', ctypes.c_ushort),  | 
|         ('PhysicDefTalent', ctypes.c_ushort),  | 
|         ('MagicDefTalent', ctypes.c_ushort),  | 
|         ('BindType', ctypes.c_ubyte),  | 
|         ('STR', ctypes.c_ulong),  | 
|         ('PNE', ctypes.c_ulong),  | 
|         ('PHY', ctypes.c_ulong),  | 
|         ('CON', ctypes.c_ulong),  | 
|         ('Pos', ctypes.c_ubyte),  | 
|         ('DailyTrainCnt', ctypes.c_ubyte),  | 
|         ('RemainTrainTime', ctypes.c_ulong),  | 
|         ('UseCreatorDrugCnt', ctypes.c_ubyte),  | 
|         ('LeftPoints', ctypes.c_ushort),  | 
|         ('AIMode', ctypes.c_ubyte),  | 
|         ('IsBattle', ctypes.c_ubyte),  | 
|         ('BattlePower', ctypes.c_ulong),  | 
|         ('IncreateSkillCnt', ctypes.c_ubyte),  | 
|         ('TrainType', ctypes.c_ubyte),  | 
|         ('PetIndex', ctypes.c_ubyte),  | 
|         ('ADOResult', ctypes.c_ulong),  | 
|     ]  | 
|   | 
|     def __init__(self):  | 
|         Structure.__init__(self)  | 
|         self.clear()  | 
|   | 
|   | 
|     def clear(self):  | 
|         memset(addressof(self), 0, self.getLength())  | 
|   | 
|   | 
|     def readData(self, buf, pos = 0, length = 0):  | 
|         if not pos <= length:  | 
|             msg = error.formatMsg('error', error.ERROR_NO_150, '(pos = %s)> (length = %s)'%(pos, length))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         if len(buf) < pos + self.getLength():  | 
|             msg = error.formatMsg('error', error.ERROR_NO_151, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         self.clear()  | 
|         memmove(addressof(self), buf[pos:], self.getLength())  | 
|         return self.getLength()  | 
|   | 
|   | 
|     def getBuffer(self):  | 
|         buf = create_string_buffer(self.getLength())  | 
|         memmove(addressof(buf), addressof(self), self.getLength())  | 
|         return string_at(addressof(buf), self.getLength())  | 
|   | 
|     def getLength(self):  | 
|         return sizeof(tagRolePet)  | 
|   | 
|     def getRecord(self):  | 
|         '''×éÖ¯´æ´¢¼Ç¼'''  | 
|         rec = {}  | 
|         rec[u'PetID'] = self.PetID  | 
|         rec[u'PlayerID'] = self.PlayerID  | 
|         rec[u'NPCID'] = self.NPCID  | 
|         rec[u'Name'] = fix_incomingText(self.Name)  | 
|         rec[u'Friendliness'] = self.Friendliness  | 
|         rec[u'HP'] = self.HP  | 
|         rec[u'MP'] = self.MP  | 
|         rec[u'Lv'] = self.Lv  | 
|         rec[u'Exp'] = self.Exp  | 
|         rec[u'HPTalent'] = self.HPTalent  | 
|         rec[u'MPTalent'] = self.MPTalent  | 
|         rec[u'PhysicAtkTalent'] = self.PhysicAtkTalent  | 
|         rec[u'MagicAtkTalent'] = self.MagicAtkTalent  | 
|         rec[u'PhysicDefTalent'] = self.PhysicDefTalent  | 
|         rec[u'MagicDefTalent'] = self.MagicDefTalent  | 
|         rec[u'BindType'] = self.BindType  | 
|         rec[u'STR'] = self.STR  | 
|         rec[u'PNE'] = self.PNE  | 
|         rec[u'PHY'] = self.PHY  | 
|         rec[u'CON'] = self.CON  | 
|         rec[u'Pos'] = self.Pos  | 
|         rec[u'DailyTrainCnt'] = self.DailyTrainCnt  | 
|         rec[u'RemainTrainTime'] = self.RemainTrainTime  | 
|         rec[u'UseCreatorDrugCnt'] = self.UseCreatorDrugCnt  | 
|         rec[u'LeftPoints'] = self.LeftPoints  | 
|         rec[u'AIMode'] = self.AIMode  | 
|         rec[u'IsBattle'] = self.IsBattle  | 
|         rec[u'BattlePower'] = self.BattlePower  | 
|         rec[u'IncreateSkillCnt'] = self.IncreateSkillCnt  | 
|         rec[u'TrainType'] = self.TrainType  | 
|         rec[u'PetIndex'] = self.PetIndex  | 
|         return rec  | 
|   | 
|     def readRecord(self, rec):  | 
|         '''ÓÉÓÚMongoDB¶Á³öÀ´ÊÇunicode,ËùÓÐ×Ö·û´®ÐèÒª½øÐÐת»»'''  | 
|         self.PetID = rec.get(u'PetID', 0)  | 
|         self.PlayerID = rec.get(u'PlayerID', 0)  | 
|         self.NPCID = rec.get(u'NPCID', 0)  | 
|         self.Name = fix_outgoingText(rec.get(u'Name', u''))  | 
|         self.Friendliness = rec.get(u'Friendliness', 0)  | 
|         self.HP = rec.get(u'HP', 0)  | 
|         self.MP = rec.get(u'MP', 0)  | 
|         self.Lv = rec.get(u'Lv', 0)  | 
|         self.Exp = rec.get(u'Exp', 0)  | 
|         self.HPTalent = rec.get(u'HPTalent', 0)  | 
|         self.MPTalent = rec.get(u'MPTalent', 0)  | 
|         self.PhysicAtkTalent = rec.get(u'PhysicAtkTalent', 0)  | 
|         self.MagicAtkTalent = rec.get(u'MagicAtkTalent', 0)  | 
|         self.PhysicDefTalent = rec.get(u'PhysicDefTalent', 0)  | 
|         self.MagicDefTalent = rec.get(u'MagicDefTalent', 0)  | 
|         self.BindType = rec.get(u'BindType', 0)  | 
|         self.STR = rec.get(u'STR', 0)  | 
|         self.PNE = rec.get(u'PNE', 0)  | 
|         self.PHY = rec.get(u'PHY', 0)  | 
|         self.CON = rec.get(u'CON', 0)  | 
|         self.Pos = rec.get(u'Pos', 0)  | 
|         self.DailyTrainCnt = rec.get(u'DailyTrainCnt', 0)  | 
|         self.RemainTrainTime = rec.get(u'RemainTrainTime', 0)  | 
|         self.UseCreatorDrugCnt = rec.get(u'UseCreatorDrugCnt', 0)  | 
|         self.LeftPoints = rec.get(u'LeftPoints', 0)  | 
|         self.AIMode = rec.get(u'AIMode', 0)  | 
|         self.IsBattle = rec.get(u'IsBattle', 0)  | 
|         self.BattlePower = rec.get(u'BattlePower', 0)  | 
|         self.IncreateSkillCnt = rec.get(u'IncreateSkillCnt', 0)  | 
|         self.TrainType = rec.get(u'TrainType', 0)  | 
|         self.PetIndex = rec.get(u'PetIndex', 0)  | 
|   | 
|     def adoLoad(self, collection):  | 
|         '''ʹÓÃKEY²éÕÒ²¢¶ÁÈ¡'''  | 
|         resultCollection = collection.find({'PetID':self.PetID})  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         #ÓÉÓÚÊÇKEY²éÕÒ£¬ËùÓÐÈç¹û´æÔÚ¾ÍÖ»ÓÐÒ»Ìõ¼Ç¼  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         return True  | 
|   | 
|   | 
|     def adoInsert(self, collection):  | 
|         '''Ö´ÐвåÈë'''  | 
|   | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.insert(rec, False, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|   | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                       | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdate(self, collection):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update({'PetID':self.PetID}, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|   | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdateEx(self, collection, spec):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update(spec, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoCheckUpdate(self, collection):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find({'PetID':self.PetID})  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsert(collection)  | 
|         return self.adoUpdate(collection)  | 
|   | 
|   | 
|     def adoCheckUpdateEx(self, collection, spec):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find(spec)  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsert(collection)  | 
|         return self.adoUpdateEx(collection, spec)  | 
|   | 
|   | 
|     def getAdoRecords(self, resultCollection):  | 
|         '''²éѯ½á¹û´ò°ü³É¶þ½øÖÆÁ÷'''  | 
|         result = ''  | 
|         result = CommFunc.WriteDWORD(result, resultCollection.count())  | 
|         for rec in resultCollection:  | 
|             self.readRecord(rec)  | 
|             result += self.getBuffer()  | 
|         return result  | 
|   | 
|   | 
|     def adoQueryIndex(self, collection):  | 
|         '''ÓÃË÷Òý×ֶβéÕÒ'''  | 
|         resultCollection = collection.find({'PlayerID':self.PlayerID})  | 
|            | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoQueryCustom(self, collection, queryDict):  | 
|         '''×Ô¶¨Òå²éѯ'''  | 
|         resultCollection = collection.find(queryDict)  | 
|   | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoQueryAll(self, collection):  | 
|         '''²éѯËùÓÐ'''   | 
|         resultCollection = collection.find()  | 
|            | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoDeleteByIndex(self, collection):  | 
|         '''¸ù¾ÝË÷Òýɾ³ý'''  | 
|         trycnt = 0  | 
|         while(True):  | 
|             try:  | 
|                 collection.remove({'PlayerID':self.PlayerID})  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:PlayerID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.PlayerID))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|     def outputString(self):  | 
|         output = '''//Íæ¼Ò³èÎï±í#tagRolePet:  | 
|             PetID = %s,  | 
|             PlayerID = %s,  | 
|             NPCID = %s,  | 
|             Name = %s,  | 
|             Friendliness = %s,  | 
|             HP = %s,  | 
|             MP = %s,  | 
|             Lv = %s,  | 
|             Exp = %s,  | 
|             HPTalent = %s,  | 
|             MPTalent = %s,  | 
|             PhysicAtkTalent = %s,  | 
|             MagicAtkTalent = %s,  | 
|             PhysicDefTalent = %s,  | 
|             MagicDefTalent = %s,  | 
|             BindType = %s,  | 
|             STR = %s,  | 
|             PNE = %s,  | 
|             PHY = %s,  | 
|             CON = %s,  | 
|             Pos = %s,  | 
|             DailyTrainCnt = %s,  | 
|             RemainTrainTime = %s,  | 
|             UseCreatorDrugCnt = %s,  | 
|             LeftPoints = %s,  | 
|             AIMode = %s,  | 
|             IsBattle = %s,  | 
|             BattlePower = %s,  | 
|             IncreateSkillCnt = %s,  | 
|             TrainType = %s,  | 
|             PetIndex = %s,  | 
|             ADOResult = %s,  | 
|             '''%(  | 
|                 self.PetID,  | 
|                 self.PlayerID,  | 
|                 self.NPCID,  | 
|                 self.Name,  | 
|                 self.Friendliness,  | 
|                 self.HP,  | 
|                 self.MP,  | 
|                 self.Lv,  | 
|                 self.Exp,  | 
|                 self.HPTalent,  | 
|                 self.MPTalent,  | 
|                 self.PhysicAtkTalent,  | 
|                 self.MagicAtkTalent,  | 
|                 self.PhysicDefTalent,  | 
|                 self.MagicDefTalent,  | 
|                 self.BindType,  | 
|                 self.STR,  | 
|                 self.PNE,  | 
|                 self.PHY,  | 
|                 self.CON,  | 
|                 self.Pos,  | 
|                 self.DailyTrainCnt,  | 
|                 self.RemainTrainTime,  | 
|                 self.UseCreatorDrugCnt,  | 
|                 self.LeftPoints,  | 
|                 self.AIMode,  | 
|                 self.IsBattle,  | 
|                 self.BattlePower,  | 
|                 self.IncreateSkillCnt,  | 
|                 self.TrainType,  | 
|                 self.PetIndex,  | 
|                 self.ADOResult,  | 
|             )  | 
|         return output  | 
|   | 
|     def dumpString(self):  | 
|         output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(  | 
|                 self.PetID,  | 
|                 self.PlayerID,  | 
|                 self.NPCID,  | 
|                 self.Name,  | 
|                 self.Friendliness,  | 
|                 self.HP,  | 
|                 self.MP,  | 
|                 self.Lv,  | 
|                 self.Exp,  | 
|                 self.HPTalent,  | 
|                 self.MPTalent,  | 
|                 self.PhysicAtkTalent,  | 
|                 self.MagicAtkTalent,  | 
|                 self.PhysicDefTalent,  | 
|                 self.MagicDefTalent,  | 
|                 self.BindType,  | 
|                 self.STR,  | 
|                 self.PNE,  | 
|                 self.PHY,  | 
|                 self.CON,  | 
|                 self.Pos,  | 
|                 self.DailyTrainCnt,  | 
|                 self.RemainTrainTime,  | 
|                 self.UseCreatorDrugCnt,  | 
|                 self.LeftPoints,  | 
|                 self.AIMode,  | 
|                 self.IsBattle,  | 
|                 self.BattlePower,  | 
|                 self.IncreateSkillCnt,  | 
|                 self.TrainType,  | 
|                 self.PetIndex,  | 
|             )  | 
|         return output  | 
|   | 
|     #CharÊý×éÀàÐÍSet½Ó¿Ú,ʹÓøýӿڶԴËÀàÐÍÊý¾Ý¸³Öµ£¬·ÀÖ¹¸³ÖµµÄÊý¾Ý¹ý³¤±¨´í  | 
|     def SetName(self,Str):  | 
|         if len(Str)<=24:  | 
|             self.Name = Str  | 
|         else:  | 
|             self.Name = Str[:24]  | 
|   | 
|   | 
| #------------------------------------------------------  | 
| #Íæ¼Ò³èÎï¼¼Äܱí#tagPetSkill  | 
| class tagPetSkill(Structure):  | 
|     _pack_ = 1  | 
|     _fields_ = [  | 
|         ('PetID', ctypes.c_ulong),  | 
|         ('PlayerID', ctypes.c_ulong),  | 
|         ('SkillID', ctypes.c_ushort),  | 
|         ('RemainTime', ctypes.c_ulong),  | 
|         ('ADOResult', ctypes.c_ulong),  | 
|     ]  | 
|   | 
|     def __init__(self):  | 
|         Structure.__init__(self)  | 
|         self.clear()  | 
|   | 
|   | 
|     def clear(self):  | 
|         memset(addressof(self), 0, self.getLength())  | 
|   | 
|   | 
|     def readData(self, buf, pos = 0, length = 0):  | 
|         if not pos <= length:  | 
|             msg = error.formatMsg('error', error.ERROR_NO_150, '(pos = %s)> (length = %s)'%(pos, length))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         if len(buf) < pos + self.getLength():  | 
|             msg = error.formatMsg('error', error.ERROR_NO_151, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))  | 
|             mylog.error(msg)  | 
|             return -1  | 
|         self.clear()  | 
|         memmove(addressof(self), buf[pos:], self.getLength())  | 
|         return self.getLength()  | 
|   | 
|   | 
|     def getBuffer(self):  | 
|         buf = create_string_buffer(self.getLength())  | 
|         memmove(addressof(buf), addressof(self), self.getLength())  | 
|         return string_at(addressof(buf), self.getLength())  | 
|   | 
|     def getLength(self):  | 
|         return sizeof(tagPetSkill)  | 
|   | 
|     def getRecord(self):  | 
|         '''×éÖ¯´æ´¢¼Ç¼'''  | 
|         rec = {}  | 
|         rec[u'PetID'] = self.PetID  | 
|         rec[u'PlayerID'] = self.PlayerID  | 
|         rec[u'SkillID'] = self.SkillID  | 
|         rec[u'RemainTime'] = self.RemainTime  | 
|         return rec  | 
|   | 
|     def readRecord(self, rec):  | 
|         '''ÓÉÓÚMongoDB¶Á³öÀ´ÊÇunicode,ËùÓÐ×Ö·û´®ÐèÒª½øÐÐת»»'''  | 
|         self.PetID = rec.get(u'PetID', 0)  | 
|         self.PlayerID = rec.get(u'PlayerID', 0)  | 
|         self.SkillID = rec.get(u'SkillID', 0)  | 
|         self.RemainTime = rec.get(u'RemainTime', 0)  | 
|   | 
|     def adoLoad(self, collection):  | 
|         '''ʹÓÃKEY²éÕÒ²¢¶ÁÈ¡'''  | 
|         resultCollection = collection.find({'PetID':self.PetID,'SkillID':self.SkillID,})  | 
|   | 
|         if resultCollection.count() <= 0:  | 
|             return False  | 
|         #ÓÉÓÚÊÇKEY²éÕÒ£¬ËùÓÐÈç¹û´æÔÚ¾ÍÖ»ÓÐÒ»Ìõ¼Ç¼  | 
|         rec = resultCollection[0]  | 
|         #¶ÁÈ¡Êý¾Ý  | 
|         self.readRecord(rec)  | 
|         return True  | 
|   | 
|   | 
|     def adoInsert(self, collection):  | 
|         '''Ö´ÐвåÈë'''  | 
|   | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.insert(rec, False, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|   | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                       | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!PetID = %s, error = %s, trycnt = %d'%(self.PetID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdate(self, collection):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update({'PetID':self.PetID,'SkillID':self.SkillID,}, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|   | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!PetID = %s, error = %s, trycnt = %d'%(self.PetID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoUpdateEx(self, collection, spec):  | 
|         '''Ö´ÐиüÐÂ'''  | 
|         trycnt = 0  | 
|         rec = self.getRecord()  | 
|         while(True):  | 
|             try:  | 
|                 collection.update(spec, {'$set':rec}, False, False, True, True)  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!PetID = %s, error = %s, trycnt = %d'%(self.PetID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|   | 
|     def adoCheckUpdate(self, collection):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find({'PetID':self.PetID,'SkillID':self.SkillID,})  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsert(collection)  | 
|         return self.adoUpdate(collection)  | 
|   | 
|   | 
|     def adoCheckUpdateEx(self, collection, spec):  | 
|         '''¸ù¾ÝÇé¿öÖ´ÐвåÈë»ò¸üÐÂ'''  | 
|         resultCollection = collection.find(spec)  | 
|            | 
|         if resultCollection.count() <= 0:  | 
|             return self.adoInsert(collection)  | 
|         return self.adoUpdateEx(collection, spec)  | 
|   | 
|   | 
|     def getAdoRecords(self, resultCollection):  | 
|         '''²éѯ½á¹û´ò°ü³É¶þ½øÖÆÁ÷'''  | 
|         result = ''  | 
|         result = CommFunc.WriteDWORD(result, resultCollection.count())  | 
|         for rec in resultCollection:  | 
|             self.readRecord(rec)  | 
|             result += self.getBuffer()  | 
|         return result  | 
|   | 
|   | 
|     def adoQueryIndex(self, collection):  | 
|         '''ÓÃË÷Òý×ֶβéÕÒ'''  | 
|         resultCollection = collection.find({'PetID':self.PetID})  | 
|            | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoQueryCustom(self, collection, queryDict):  | 
|         '''×Ô¶¨Òå²éѯ'''  | 
|         resultCollection = collection.find(queryDict)  | 
|   | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoQueryAll(self, collection):  | 
|         '''²éѯËùÓÐ'''   | 
|         resultCollection = collection.find()  | 
|            | 
|         return self.getAdoRecords(resultCollection)  | 
|   | 
|   | 
|     def adoDeleteByIndex(self, collection):  | 
|         '''¸ù¾ÝË÷Òýɾ³ý'''  | 
|         trycnt = 0  | 
|         while(True):  | 
|             try:  | 
|                 collection.remove({'PetID':self.PetID})  | 
|                 break  | 
|             except pymongo.errors.OperationFailure, err:  | 
|                 if(DBConfig.TryCntOnWriteFail > trycnt):  | 
|                     trycnt += 1  | 
|                     continue  | 
|                 addADOExceptionCount()  | 
|                 mylog.info("%s.%s:PetID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.PetID))  | 
|                 msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.PetID = %s, error = %s, trycnt = %d'%(self.PetID, err, trycnt))  | 
|                 mylog.error(msg)  | 
|   | 
|                 return False  | 
|         return True  | 
|   | 
|     def outputString(self):  | 
|         output = '''//Íæ¼Ò³èÎï¼¼Äܱí#tagPetSkill:  | 
|             PetID = %s,  | 
|             PlayerID = %s,  | 
|             SkillID = %s,  | 
|             RemainTime = %s,  | 
|             ADOResult = %s,  | 
|             '''%(  | 
|                 self.PetID,  | 
|                 self.PlayerID,  | 
|                 self.SkillID,  | 
|                 self.RemainTime,  | 
|                 self.ADOResult,  | 
|             )  | 
|         return output  | 
|   | 
|     def dumpString(self):  | 
|         output = '''%1s\t%1s\t%1s\t%1s'''%(  | 
|                 self.PetID,  | 
|                 self.PlayerID,  | 
|                 self.SkillID,  | 
|                 self.RemainTime,  | 
|             )  | 
|         return output  | 
|   | 
| #WarnInfo%  | 
|   |