public ActivityRollingMsgRefresher(int msgId, System.DateTime beginTime, string refreshMinute, string refreshHour, string refreshWeek) { this.MsgId = msgId; string cronFormat = string.Format("{0} {1} * * {2}", refreshMinute, refreshHour, refreshWeek); m_TimerScheduler = new TimerScheduler(); m_TimerScheduler.m_TimerRegular = cronFormat; m_TimerScheduler.ParseTimerRegular(); if (!m_TimerScheduler.isLegalTimer) { EB.Debug.LogError("TimeRefresher cronFormat is illegal"); return; } m_TimerScheduler.GetNext(beginTime, out m_RefreshTime); }
public TimeRefresher(string name, System.DateTime beginTime, int refreshHour, int refreshMinute) { this.Name = name; string cronFormat = string.Format("{0} {1} * * *", refreshMinute, refreshHour); m_TimerScheduler = new TimerScheduler(); m_TimerScheduler.m_TimerRegular = cronFormat; m_TimerScheduler.ParseTimerRegular(); if (!m_TimerScheduler.isLegalTimer) { EB.Debug.LogError("TimeRefresher cronFormat is illegal"); return; } m_TimerScheduler.GetNext(beginTime, out m_RefreshTime); }
public string GetTimeTip(bool withColar = false, bool isBool = false) { string timeStr = string.Empty; System.DateTime now = Data.ZoneTimeDiff.GetServerTime();// EB.Time.LocalNow; var mStartCronJobs = EventTemplateManager.Instance.GetCronJobsByName("InfiniteCompete_start"); string[] start = mStartCronJobs.interval.Split(' '); System.DateTime startdate = new System.DateTime(); if (start.Length == 6) { TimerScheduler timerScheduler = new TimerScheduler(); timerScheduler.m_TimerRegular = string.Format("{0} {1} {2} {3} {4}", start[1], start[2], start[3], start[4], start[5]); timerScheduler.ParseTimerRegular(); if (!timerScheduler.isLegalTimer) { EB.Debug.LogError("GetStartDateTime: cronFormat is illegal"); } timerScheduler.GetNext(now, out startdate); } var mStopCronJobs = EventTemplateManager.Instance.GetCronJobsByName("InfiniteCompete_stop"); string[] stop = mStopCronJobs.interval.Split(' '); System.DateTime stopdate = new System.DateTime(); if (stop.Length == 6) { TimerScheduler timerScheduler = new TimerScheduler(); timerScheduler.m_TimerRegular = string.Format("{0} {1} {2} {3} {4}", stop[1], stop[2], stop[3], stop[4], stop[5]); timerScheduler.ParseTimerRegular(); if (!timerScheduler.isLegalTimer) { EB.Debug.LogError("GetEndDateTime: cronFormat is illegal"); } timerScheduler.GetNext(now, out stopdate); } var mRewardCronJobs = EventTemplateManager.Instance.GetCronJobsByName("InfiniteCompeteReward"); string[] reward = mRewardCronJobs.interval.Split(' '); System.DateTime rewarddate = new System.DateTime(); if (reward.Length == 6) { TimerScheduler timerScheduler = new TimerScheduler(); timerScheduler.m_TimerRegular = string.Format("{0} {1} {2} {3} {4}", reward[1], reward[2], reward[3], reward[4], reward[5]); timerScheduler.ParseTimerRegular(); if (!timerScheduler.isLegalTimer) { EB.Debug.LogError("GetRewardDateTime: cronFormat is illegal"); } timerScheduler.GetNext(now, out rewarddate); } string color = (withColar)?"42fe79": "ffffff"; int resultIndex = 0; double nextStart = (startdate - now).TotalSeconds; double nextStop = (stopdate - now).TotalSeconds; double nextReward = (rewarddate - now).TotalSeconds; if (nextStop - nextStart > 0) { if (nextReward - nextStart > 0) { resultIndex = 3;//等下一次开启 } else { resultIndex = 2;//结算期间 } } else { resultIndex = 1;//开启期间 } switch (resultIndex) { case 1: { //活动开启期间 if (isBool) { return("open"); } var span = stopdate - now; //EB.Time.LocalNow; string time = string.Format(EB.Localizer.GetString("ID_codefont_in_NationHudController_7771"), span.Days, span.Hours, span.Minutes); timeStr = string.Format("{0}[{1}]{2}[-]", EB.Localizer.GetString("ID_uifont_in_LadderUI_LeftEndTime_6"), color, time); } break; case 2: { //活动结算期间 if (isBool) { return("end"); } var span = rewarddate - now; //EB.Time.LocalNow; string time = string.Format(EB.Localizer.GetString("ID_codefont_in_NationHudController_7771"), span.Days, span.Hours, span.Minutes); timeStr = string.Format("{0}[{1}]{2}[-]", EB.Localizer.GetString("ID_ULTIMATE_COMPETE_TIME_TIP"), color, time); } break; case 3: { //等待下赛季 if (isBool || withColar) { return("close"); } var span = startdate - now; //EB.Time.LocalNow; string time = string.Format(EB.Localizer.GetString("ID_codefont_in_NationHudController_7771"), span.Days, span.Hours, span.Minutes); timeStr = string.Format("{0}[{1}]{2}[-]", EB.Localizer.GetString("ID_ULTIMATE_COMPETE_TIME_TIP2"), color, time); } break; } return(timeStr); }
private int GetNextRequestTime(string path) { System.DateTime next; m_TimerScheduler.GetNext(System.TimeZone.CurrentTimeZone.ToLocalTime(EB.Time.FromPosixTime(EB.Time.Now)), out next); return(EB.Time.ToPosixTime(System.TimeZone.CurrentTimeZone.ToUniversalTime(next)) /*+ UnityEngine.Random.Range(1, 20)*/); }
public void MoveNext(DateTime dateTime) { m_TimerScheduler.GetNext(dateTime, out m_RefreshTime); }