def ChangeActivityStatusByTime():
    '''
	描述:根据时间修改所有活动数据
	参数: 无
	返回:成功True, 失败False
	'''
    Success = True
    if Success:
        try:
            Info = Activity.objects.all()
        except:
            Success = False
    if Success:
        try:
            for item in Info:
                if item.StatusGlobal != Constants.ACTIVITY_STATUS_GLOBAL_NORMAL:
                    continue
                TheCurrentTime = GlobalFunctions.GetCurrentTime()
                TheJoinStartTime = item.SignUpStartTime
                TheJoinEndTime = item.SignUpEndTime
                TheCheckStartTime = item.StartTime
                TheCheckEndTime = item.EndTime
                TheCurrentUser = item.CurrentUser
                TheMinUser = item.MinUser
                if item.StatusJoin == Constants.ACTIVITY_STATUS_JOIN_BEFORE:
                    if GlobalFunctions.JudgeWhetherSameMinute(
                            TheJoinStartTime):
                        item.StatusJoin = Constants.ACTIVITY_STATUS_JOIN_CONTINUE
                if item.StatusJoin != Constants.ACTIVITY_STATUS_JOIN_STOPPED:
                    if GlobalFunctions.JudgeWhetherSameMinute(TheJoinEndTime):
                        item.StatusJoin = Constants.ACTIVITY_STATUS_JOIN_STOPPED
                if item.StatusCheck == Constants.ACTIVITY_STATUS_CHECK_BEFORE:
                    if GlobalFunctions.JudgeWhetherSameMinute(
                            TheCheckStartTime
                    ) and TheCurrentUser >= TheMinUser:
                        item.StatusCheck = Constants.ACTIVITY_STATUS_CHECK_CONTINUE
                if item.StatusCheck != Constants.ACTIVITY_STATUS_CHECK_STOPPED:
                    if GlobalFunctions.JudgeWhetherSameMinute(TheCheckEndTime):
                        item.StatusCheck = Constants.ACTIVITY_STATUS_CHECK_STOPPED
                item.save()
        except:
            Success = False
    return Success
def CheckActivitySendMessage():
    '''
	描述:根据时间判断是否要推送活动即将开始的消息,并且控制消息的发送
	参数: 无
	返回:无
	'''
    Success = True
    if Success:
        if (int(time.time()) - lastAccessTokenSetTime > 5400):
            GlobalFunctions.SetAccessToken()
    if Success:
        try:
            Info = Activity.objects.all()
        except:
            Success = False
    if Success:
        try:
            for item in Info:
                if item.StatusGlobal != Constants.ACTIVITY_STATUS_GLOBAL_NORMAL:
                    continue
                TheStartTime = item.StartTime
                if GlobalFunctions.JudgeWhetherSameMinute(
                        TheStartTime -
                        Constants.TIME_BEFORE_MESSAGE_ACTIVITY_WILL_START_HOUR
                ):
                    SendTimedMessageActivity(
                        item.ID,
                        Constants.MESSAGE_TYPE_ACTIVITY_WILL_START_HOUR)
                elif GlobalFunctions.JudgeWhetherSameMinute(
                        TheStartTime - Constants.
                        TIME_BEFORE_MESSAGE_ACTIVITY_WILL_START_MINUTE):
                    SendTimedMessageActivity(
                        item.ID,
                        Constants.MESSAGE_TYPE_ACTIVITY_WILL_START_MINUTE)
        except:
            Success = False
    return Success