コード例 #1
0
        //[TestMethod]
        public void TimerPlanTest()
        {
            TimeListener.Append(PlanConfig.EveryMinutePlan((p) =>
            {
                Trace.WriteLine(p.Name + " time:" + DateTime.Now.ToString("HH:mm:ss-ms"));
            }, "plan1", "", DateTime.Now.AddMinutes(1).ToString("HH:mm:ss"), 1));

            while (TimeListener.HasWaitPlan)
            {
                Thread.Sleep(1000);
            }
        }
コード例 #2
0
ファイル: BroadcastTimer.cs プロジェクト: longshenwudu/TNet4
        /// <summary>
        /// Add the specified message, beginTime, endTime, isCycle and secondInterval.
        /// </summary>
        /// <param name="message">Message.</param>
        /// <param name="beginTime">Begin time.</param>
        /// <param name="endTime">End time.</param>
        /// <param name="isCycle">If set to <c>true</c> is cycle.</param>
        /// <param name="secondInterval">Second interval.</param>
        public void Add(NoticeMessage message, string beginTime, string endTime, bool isCycle, int secondInterval)
        {
            PlanConfig planConfig = null;

            if (isCycle)
            {
                planConfig = PlanConfig.EveryMinutePlan(DoBroadcast, "BroadcastTimer", beginTime, endTime, secondInterval);
            }
            else
            {
                planConfig = PlanConfig.OncePlan(DoBroadcast, "BroadcastTimer", beginTime);
            }
            planConfig.Target = message;
            TimeListener.Append(planConfig);
        }
コード例 #3
0
        protected override void OnStartAffer()
        {
            TimeListener.Append(PlanConfig.EveryMinutePlan(MsgDispatcher.Dispatcher, "Dispatcher", "00:00", "23:59", 1));

            TimeListener.Append(PlanConfig.EveryMinutePlan(DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "00:00", "23:59", 600));
            //TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "03:10"));

            ServerSet.LoadServerConfig();

            RankingFactory.Add(new LevelRanking());
            //RankingFactory.Add(new GuildRanking());
            RankingFactory.Start(60);

            // 设置竞技场排行不刷新
            Ranking <UserRank> levelRanking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);

            levelRanking.SetIntervalTimes(int.MaxValue);

            //// 设置公会排行不刷新
            //Ranking<GuildRank> guildRanking = RankingFactory.Get<GuildRank>(GuildRanking.RankingKey);
            //guildRanking.SetIntervalTimes(int.MaxValue);

            LevelRankingAllServerSet.LoadServerRanking();
        }
コード例 #4
0
        public static void Run()
        {
            //AppstoreClientManager.Current.InitConfig();
            //var dispatch = TaskDispatch.StartTask();
            //dispatch.Add(new StudyTask());

            lock (thisLock)
            {
                _isRunning = false;
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

#if NO_MERGE_SERVICE_DATA
            var httpHost = GetSection().HttpHost;
            var httpPort = GetSection().HttpPort;
            var httpName = GetSection().HttpName;
            if (!string.IsNullOrEmpty(httpHost))
            {
                var names = httpName.Split(',');
                new NewHttpListener(httpHost, httpPort, new HashSet <string>(names));
            }


            LoadGlobalData();

            // 上传该服务器的状态
            TimeListener.Append(PlanConfig.EveryMinutePlan(submitServerStatus, "submitServerStatus", "00:00", "23:59", ConfigurationManager.AppSettings["ServerStatusSendInterval"].ToInt()));
            // 自动机器人,64争霸赛
            TimeListener.Append(PlanConfig.EveryMinutePlan(LoopAction, "LoopAction", "00:00", "23:59", 3));
            // new GameActiveCenter(null);
            // new GuildGameActiveCenter(null);
            //每天执行用于整点刷新
            TimeListener.Append(PlanConfig.EveryDayPlan(UserHelper.DoZeroRefreshDataTask, "DoZeroRefreshDataTask", "00:00"));
            //TimeListener.Append(PlanConfig.EveryMinutePlan(UserHelper.DoZeroRefreshDataTask, "DoZeroRefreshDataTask", "08:00", "22:00", 60));
            //每天5点执行用于整点刷新
            TimeListener.Append(PlanConfig.EveryDayPlan(UserHelper.DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "05:00"));
            // 每周二,周五
            TimeListener.Append(PlanConfig.EveryWeekPlan(UserHelper.DoTuesdayRefreshTask, "TuesdayRefreshTask", DayOfWeek.Tuesday, "04:00"));
            //TimeListener.Append(PlanConfig.EveryWeekPlan(UserHelper.DoFridayRefreshTask, "FridayRefreshTask", DayOfWeek.Friday, "04:00"));

            DataHelper.InitData();

            InitRanking();


            if (DataHelper.IsFirstOpenService)
            {
                string ncikName    = string.Empty;
                var    botsNameSet = new ShareCacheStruct <Config_BotsName>();
                for (int i = 0; i < 5; ++i)
                {
                    ncikName  = botsNameSet.FindKey(random.Next(botsNameSet.Count)).String;
                    ncikName += botsNameSet.FindKey(random.Next(botsNameSet.Count)).Value;
                    UserCenterUser ucu = Util.CreateUserCenterUser(Util.GetRandomGUIDPwd(), "0000", GameEnvironment.ProductServerId);
                    Action1005.CreateRole(ucu.UserID, "", ucu.ServerID, ucu.OpenID, ucu.RetailID, ncikName, random.Next(1) + 1, "");
                }
            }
            //Bots.InitBots();

            //if (competition64 == null)
            //{
            //    competition64 = new Competition64();
            //    competition64.Initialize();
            //}

            GlobalRemoteService.Reuest();

            stopwatch.Stop();
            new BaseLog().SaveLog("系统全局运行环境加载所需时间:" + stopwatch.Elapsed.TotalMilliseconds + "ms");

            SendServerStatus(ServerStatus.Unhindered, 0);
#else
            MERGE_SERVICE.Run();
#endif
            lock (thisLock)
            {
                _isRunning = true;
            }
        }