| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
|   | 
| ##@package GMT_ChangeEvent.py  | 
| # ¿ªÆôϵͳ»î¶¯  | 
| #  | 
| # @author wdb  | 
| # @date 2012-06-21  | 
| # @version 1.5  | 
| #  | 
| # @note:   | 
| # ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  | 
| #  | 
| # Ä£¿éÏêϸ˵  | 
| #¿ªÆôϵͳ»î¶¯  | 
| # @change: "2012-06-29 17:00" wdb ÐÞ¸ÄÈ¥³ýʱ¼äÉèÖôíÎó  | 
| # @change: "2012-07-30 11:30" wdb GM»Ø¸´Ï¸»¯£¬´úÂëÓÅ»¯  | 
| # @change: "2012-08-10 15:00" zhangxi ÐÞ¸ÄOSS¼Ç¼  | 
| # @change: "2014-09-25 20:00" hxp Ð޸ĿɿØÖƻ¿ª¹ØÊ±¼ä  | 
| # @change: "2014-09-26 12:00" hxp Ôö¼Ó¿ÉÉèÖû²ÎÊý£»¹Ø±Õ»î¶¯Ê±Ö´ÐйرÕÂß¼  | 
| #---------------------------------------------------------------------  | 
| """Version = 2014-09-26 12:00"""  | 
| #---------------------------------------------------------------------  | 
| #µ¼Èë  | 
| import GameWorld  | 
| import PlayerControl  | 
| import datetime  | 
| import DataRecordPack  | 
| import GMCommon  | 
| import ChConfig  | 
| #---------------------------------------------------------------------  | 
| #È«¾Ö±äÁ¿  | 
| #---------------------------------------------------------------------  | 
|   | 
| #---------------------------------------------------------------------  | 
| #Â߼ʵÏÖ  | 
| ## Ö´ÐÐÂß¼  | 
| #  @param orderId gmÃüÁîid  | 
| #  @param gmCmdDict   | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def OnExec(orderId, gmCmdDict):  | 
|     eventID = GameWorld.ToIntDef(gmCmdDict.get('eventID', ''))  | 
|     doType = gmCmdDict.get('doType', '')  | 
|           | 
|     if eventID not in GMCommon.GetGameServer_GM_GameID():  | 
|         GameWorld.DebugLog("GmStarAction.txt ÎÞ¸ÃʼþID=%s" % eventID)  | 
|         GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_InvalidEvent)  | 
|         return  | 
|   | 
|     eventManager = GameWorld.GetGameWorldEventManager()  | 
|     #¿ªÆô»î¶¯  | 
|     if doType == '':  | 
| #        #»î¶¯¿ªÆôʱ¼ä   | 
| #        eventStartTime = GameWorld.GetServerTime()  | 
| #        #»î¶¯¹Ø±Õʱ¼ä ,¹Ì¶¨Îª3Ììºó£¬½Ó¿ÚÒÔµ±Ç°Ê±¼äΪ±»¼õÊý£¬¹ÊÒª¼Ó¸ººÅ  | 
| #        eventCloseTime = GameWorld.GetDatetimeBySubDays(-3)  | 
| #          | 
| #        if not eventStartTime or not eventCloseTime \  | 
| #            or eventStartTime < datetime.datetime.today() \  | 
| #            or eventStartTime > eventCloseTime:  | 
| #            #²ÎÊý´íÎó  | 
| #            GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_InvalidTime)  | 
| #            return  | 
|           | 
|         eventStartTime = gmCmdDict.get("StartTime", "")  | 
|         eventCloseTime = gmCmdDict.get("EndTime", "")  | 
|         eventPar = gmCmdDict.get("eventPar", "")  | 
|           | 
|         if not eventStartTime or not eventCloseTime or eventStartTime >= eventCloseTime:  | 
|             GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_InvalidTime)  | 
|             return  | 
|           | 
|         #Èç¹û»î¶¯ÒѾ¿ªÆô,Ö´Ðи²¸Ç»î¶¯Âß¼  | 
|         GMCommon.CloseProcessingEvent(eventID)  | 
|           | 
|         #ÉèÖûÄÚÈݽø»î¶¯¹ÜÀíÆ÷  | 
|         addEvent = eventManager.AddActiveEvent(eventID)  | 
|         addEvent.SetEventID(eventID)  | 
|         addEvent.SetStartTime('%s'%eventStartTime)  | 
|         addEvent.SetEndTime('%s'%eventCloseTime)  | 
|         if eventPar:  | 
|             addEvent.SetPar('%s'%eventPar)  | 
|   | 
|         #ÉèÖÃΪδ¼¤»î״̬  | 
|         addEvent.SetIsProcessing(False)  | 
|         gmCmdDict['endTime'] = '%s'%eventCloseTime  | 
|           | 
|     #¹Ø±Õ»î¶¯  | 
|     else:  | 
|         activeEvent = eventManager.FindActiveEvent(eventID)  | 
|         if not activeEvent:  | 
|             #ûÓиĻ  | 
|             GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_NoTag)   | 
|             return  | 
|           | 
|         GMCommon.CloseProcessingEvent(eventID)  | 
|         eventManager.DelActiveEvent(eventID)  | 
|   | 
|     #Ö´Ðгɹ¦  | 
|     GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Success)      | 
|     # Á÷Ïò  | 
|     DataRecordPack.DR_ToolGMOperate(0, '', '', gmCmdDict.get(GMCommon.Def_GMKey_Type, ''), str(gmCmdDict))  | 
|     return  | 
|   | 
|   |