| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package EventProcess  | 
| #  | 
| # @todo: Í³¼ÆÊý¾Ý¸øOSS  | 
| # @author Alee  | 
| # @date 2012-03-23 22:00  | 
| # @version 1.2  | 
| #  | 
| # ÏêϸÃèÊö: Í³¼ÆÊý¾Ý¸øOSS  | 
| # @change: "2012-07-13 15:00" wdb Ôö¼Óossº¯Êý£¬Í³¼Æ¼ÓÈëʱ¼ä  | 
| # @change: "2012-10-22 10:00" linyonggui Ä¿Ç°²»ÐèÒª¼Ç¼´ËÊý¾Ý   | 
| #------------------------------------------------------------------------------   | 
| """Version = 2012-10-22 10:00"""  | 
| #------------------------------------------------------------------------------   | 
| import EventShellProxy  | 
| from Common import mylog  | 
|   | 
| import datetime  | 
| #------------------------------------------------------------------------------   | 
|   | 
| DBConfig = __import__('Config.DBConfig')  | 
|   | 
| #Ö°ÒµÊýÁ¿  | 
| Def_Job_Count = 4  | 
|   | 
| #-------------------------------------------------------------------------------  | 
| #OnDay  | 
| #Àý×ÓEventShellProxy.GetEventShellProxy().SendEvent(1, "1111\x00111",8)  | 
| ## OnDayµ÷ÓÃͳ¼ÆÊý¾Ý·¢¸øEventServer  | 
| # @param db Êý¾Ý¿âʵÀýdbUser  | 
| # @return None  | 
| def OnDayProcess(db):  | 
|   | 
|     return  | 
|       | 
|     playerColl = db["tagDBPlayer"]  | 
|       | 
|     #ͳ¼Æ²»Í¬Ö°ÒµµÄÐÅÏ¢  | 
|     for i in range(Def_Job_Count):  | 
|         result = SumInfoByJob(playerColl, i)  | 
|         DR_SumJobLVInfo(result, i)  | 
|       | 
|   | 
| ##·¢ËÍʼþ¼Ç¼¸øEventShell  | 
| # @param eventTypeStr: Ê¼þÀàÐͱêʶ  | 
| # @param dataDict: Ê¼þ×Öµä  | 
| # @return None  | 
| def SendEventPack(eventTypeStr, dataStr):  | 
|   | 
|     EventShellProxy.GetEventShellProxy().SendEventEx(eventTypeStr, len(eventTypeStr), dataStr, len(dataStr))  | 
|       | 
|     #test = 'test'  | 
|     #testDict = str({'content':123456, 'content2':'sfsa'})  | 
|     #EventShellProxy.GetEventShellProxy().SendEventEx(test, len(test), testDict, len(testDict))  | 
|       | 
|     return  | 
|   | 
|   | 
| ##·¢ËÍʼþ¼Ç¼¸øEventShell  | 
| # @param eventTypeStr: Ê¼þÀàÐͱêʶ  | 
| # @param dataDict: Ê¼þ×Öµä  | 
| # @return None  | 
| def SendEventPackByDict(eventTypeStr, dataDict):  | 
|     dataDict["time"] = str(datetime.datetime.today()).split(".")[0]  | 
|       | 
|     dataStr = str(dataDict)  | 
|     EventShellProxy.GetEventShellProxy().SendEventEx(eventTypeStr, len(eventTypeStr), dataStr, len(dataStr))  | 
|     return  | 
|   | 
| ##ͳ¼ÆÖ°ÒµµÈ¼¶ÒøÁ½ÐÅÏ¢  | 
| # @param playerColl Íæ¼Ò¼¯ºÏ  | 
| # @param job Ö°Òµ±êʶ  | 
| # @return None  | 
| def SumInfoByJob(playerColl, job):  | 
|     #¼¯ºÏ£¨±í£©  | 
|     jobLVList = playerColl.group(  | 
|                          key={'LV':1},  | 
|                          initial={'count':0, 'SilverSum':0},  | 
|                          condition={'Job':job},  | 
|                          reduce="function(obj, prev) {prev.count++; prev.SilverSum += obj.Silver}",  | 
|                          finalize="function(prev) {prev.SilverAve = prev.SilverSum/prev.count}"  | 
|                          )  | 
|       | 
|     mylog.info('---------type: %s'%type(jobLVList))  | 
|       | 
|     timeDict = {'time' : str(datetime.datetime.today()).split(".")[0]}  | 
|       | 
|       | 
|     jobLVStr = ''  | 
|     for dictInfo in jobLVList:  | 
|         dictInfo.update(timeDict)  | 
|           | 
|         jobLVStr = jobLVStr + str(dictInfo) + '\n'  | 
|       | 
|     mylog.info('%s'%jobLVStr)  | 
|     return jobLVStr  | 
|       | 
| #===============================================================================  | 
| # //01 01 Í³¼ÆÖ°ÒµÃ¿¸öµÈ¼¶µÄÊýÁ¿ºÍÒø×ÓÊýÁ¿¼°Æ½¾ùÊý#tagSumJobLV  | 
| #   | 
| # struct tagSumJobLV  | 
| # {  | 
| #    tagHead    Head;  | 
| #    DWORD    InfoLen;  | 
| #    char    JobLVInfo[InfoLen];  | 
| # };  | 
| #===============================================================================  | 
| def DR_SumJobLVInfo(jobLVInfo, job):  | 
|   | 
|     #·¢ËÍ·â°ü  | 
|     SendEventPack("SumJobLVInfo_%s"%job, jobLVInfo)  | 
|     return  | 
|   |