コード例 #1
0
        public void Init(IDictionary rule, System.Action <Hashtable> callback = null)
        {
            if (rule == null)
            {
                return;
            }

            if (callback != null)
            {
                m_Callback = callback;
            }
            m_RequestURL = EB.Dot.String("url", rule, m_RequestURL);
            m_TimePath   = EB.Dot.String("time_path", rule, m_TimePath);
            m_Level      = EB.Dot.Integer("level", rule, m_Level);
            m_Parameters = EB.Dot.Object("parameters", rule, m_Parameters);

            string regular = EB.Dot.String("regular", rule, "");

            m_TimerScheduler = new TimerScheduler();
            m_TimerScheduler.m_TimerRegular = regular;
            m_TimerScheduler.ParseTimerRegular();
            if (!m_TimerScheduler.isLegalTimer)
            {
                EB.Debug.LogError("CronRefreshExcuter:Init m_TimerScheduler.Not isLegalTimer regular=" + regular);
                return;
            }

            m_NextRequestTime = GetNextRequestTime(m_TimePath);
            EB.Debug.Log("CronRefreshExcuter.Init: next time = {0}", EB.Time.FromPosixTime(m_NextRequestTime));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        void AddUserPrizeDataRefreshExcuter()
        {
            string taskRefreshTime = "0 0 0 * * *";
            //DataLookupsCache.Instance.SearchDataByID<string>("userTaskStatus.refreshTaskTime", out taskRefreshTime);
            Hashtable rule = Johny.HashtablePool.Claim();

            rule.Add("regular", TimerScheduler.AmendCronFormat(taskRefreshTime));
            rule.Add("url", "/sign_in/getUserPrizeData");
            CronRefreshExcuter excuter = new CronRefreshExcuter("refreshUserPrizeData", false);

            excuter.Init(rule, delegate(Hashtable hash) {
                if (hash != null)
                {
                    DataLookupsCache.Instance.CacheData(hash);
                    GameDataSparxManager.Instance.ProcessIncomingData(hash, false);
                }
            });
            AddCronRefreshExcuter(excuter);
        }
コード例 #5
0
        void AddTaskRefreshExcuter()
        {
            string taskRefreshTime;

            DataLookupsCache.Instance.SearchDataByID <string>("userTaskStatus.refreshTaskTime", out taskRefreshTime);
            Hashtable rule = Johny.HashtablePool.Claim();

            rule.Add("regular", TimerScheduler.AmendCronFormat(taskRefreshTime));
            rule.Add("url", "/mhjtasks/refreshTaskState");
            CronRefreshExcuter excuter = new CronRefreshExcuter("refreshTaskState");

            excuter.Init(rule, delegate(Hashtable hash) {
                string npcLocator;
                DataLookupsCache.Instance.SearchDataByID <string>(string.Format("tasks.{0}.event_count.locator", LTBountyTaskHudController.TaskID()), out npcLocator);
                LTBountyTaskHudController.DeleteMonster(npcLocator);
                DataLookupsCache.Instance.CacheData("user_prize_data.taskliveness_reward", string.Empty);      //重置任务完成情况
                DataLookupsCache.Instance.CacheData("user_prize_data.taskliveness.curr", 0);
                DataLookupsCache.Instance.CacheData("user_prize_data.taskliveness_week_reward", string.Empty); //重置任务完成情况
                DataLookupsCache.Instance.CacheData("user_prize_data.taskweekliveness.curr", 0);
                DataLookupsCache.Instance.CacheData("task_refresh", 1);
            });
            AddCronRefreshExcuter(excuter);
        }
コード例 #6
0
        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);
        }