Example #1
0
 /// <summary>
 /// Add the specified message, week, beginTime, endTime, isCycle and secondInterval.
 /// </summary>
 /// <param name="message">Message.</param>
 /// <param name="week">Week.</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, DayOfWeek week, string beginTime, string endTime, bool isCycle, int secondInterval)
 {
     TimeListener.Append(new PlanConfig(DoBroadcast, week, beginTime, endTime, isCycle, secondInterval)
     {
         Name = "BroadcastTimer", Target = message
     });
 }
Example #2
0
        /// <summary>
        /// Add the specified message, week, beginTime, endTime, isCycle and secondInterval.
        /// </summary>
        /// <param name="message">Message.</param>
        /// <param name="week">Week.</param>
        /// <param name="beginTime">Begin time.</param>
        /// <param name="endTime">End time. void</param>
        /// <param name="isCycle">If set to <c>true</c> is cycle. void</param>
        /// <param name="secondInterval">Second interval. void</param>
        public void Add(NoticeMessage message, DayOfWeek week, string beginTime, string endTime, bool isCycle, int secondInterval)
        {
            var planConfig = PlanConfig.EveryWeekPlan(DoBroadcast, "BroadcastTimer", week, beginTime);

            planConfig.Target = message;
            TimeListener.Append(planConfig);
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="match"></param>
 /// <returns></returns>
 public bool Remove(Predicate <NoticeMessage> match)
 {
     return(TimeListener.Remove(m =>
     {
         if (m.Target is NoticeMessage)
         {
             var temp = (NoticeMessage)m.Target;
             return match(temp);
         }
         return false;
     }));
 }
Example #4
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);
            }
        }
Example #5
0
 public bool Remove(Guid messageId)
 {
     return(TimeListener.Remove(m =>
     {
         if (m.Target is NoticeMessage)
         {
             var temp = (NoticeMessage)m.Target;
             return Equals(temp.Id, messageId);
         }
         return false;
     }));
 }
        void Init()
        {
            var        cache   = new ShareCacheStruct <ShareRealItemCnt>();
            List <int> itemIds = GameConfigMgr.Instance().getHappyDataKeys();

            memoryRealInfoDataModel.HappyData hd = null;
            for (int i = 0; i < itemIds.Count; ++i)
            {
                if (null == cache.FindKey(itemIds[i])) // first add
                {
                    ShareRealItemCnt sric = new ShareRealItemCnt();
                    hd          = GameConfigMgr.Instance().getHappyData(itemIds[i]);
                    sric.itemID = hd.itemID;
                    sric.num    = hd.RefleshNum;
                    cache.Add(sric);
                }
            }

            string timestr = GameConfigMgr.Instance().getString("timer_item_cnt", "600000,600000");

            string[] tt = timestr.Split(',');
            int      b0 = int.Parse(tt[0]);
            int      b1 = int.Parse(tt[1]);

            TimerMgr.Singleton().add(typeof(RealItemCntUpdate).ToString(), actionrealItemCnt, b0, b1);

            bool openDebug = GameConfigMgr.Instance().getInt("timer_open_debug", 0) == 1;

            if (openDebug)
            {
                timestr = GameConfigMgr.Instance().getString("time_hdm_cnt", "600000,600000");
                tt      = timestr.Split(',');
                b0      = int.Parse(tt[0]);
                b1      = int.Parse(tt[1]);
                TimerMgr.Singleton().add("HappyModeData_EnterNum", action_HappyModeData_enterNum, b0, b1);
            }
            else
            {
                //每天05点执行
                try
                {
                    timestr = GameConfigMgr.Instance().getString("time_hdm_cnt_timming", "05:15");
                }
                catch
                {
                    timestr = "05:15";
                }
                TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryDayExecute, "EveryDayTask", timestr));
                ConsoleLog.showNotifyInfo("HappyModeData_EnterNum begin:" + timestr);
            }
        }
Example #7
0
        /// <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);
        }
Example #8
0
        void init()
        {
            bool openDebug = GameConfigMgr.Instance().getInt("timer_open_debug", 0) == 1;

            if (openDebug)
            {
                string   debugParm = GameConfigMgr.Instance().getString("timer_user_ranking_clear", "330000,330000");
                string[] words     = debugParm.Split(',');
                TimerMgr.Singleton().add("RankingClear", ccccc, int.Parse(words[0]), int.Parse(words[1]));
            }
            else
            {
                string theStr = GameConfigMgr.Instance().getString("timer_user_ranking_clear_timming", "05:00");
                //每天0点执行
                TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryWeekExecute, "EveryDayTask", theStr));
                ConsoleLog.showNotifyInfo("timer_user_ranking_clear_timming begin:" + theStr);
            }
        }
 public sortMethod(sortType t, string parm, PlanCallback f)
 {
     _f = f;
     if (sortType.None == t)
     {
     }
     else if (sortType.Interval == t)
     {
         string [] p = parm.Split(',');
         int       p1 = 0, p2 = 0;
         try
         {
             p1 = int.Parse(p[0]);
             p2 = int.Parse(p[1]);
         }
         catch (Exception e)
         {
             p1 = 1000;
             p2 = 1000 * 60 * 60;
         }
         _timer = new Timer(timeCb, null, p1, p2);
     }
     else if (sortType.Timing == t)
     {
         string[] timers = parm.Split(',');
         for (int i = 0; i < timers.Length; ++i)
         {
             try
             {
                 DateTime dt = Convert.ToDateTime(timers[i]);
             }
             catch (Exception e)
             {
                 ConsoleLog.showErrorInfo(i, e.Message + ":datePase Error;" + timers[i]);
                 continue;
             }
             TimeListener.Append(PlanConfig.EveryDayPlan(_f, "EveryDayTask", timers[i]));
         }
     }
     else if (sortType.week == t)
     {
     }
 }
Example #10
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();
        }
        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;
            }
        }
Example #12
0
 /// <summary>
 /// Registers a new time listener
 /// </summary>
 /// <param name="listener">
 /// The listener to register
 /// </param>
 public void registerListener(TimeListener listener)
 {
     listeners.Add(listener);
 }
Example #13
0
        public static void Init()
        {
            PlanConfig planConfig = new PlanConfig(Rank, true, ConfigEnvSet.GetInt("Rank.SJT"), "");

            TimeListener.Append(planConfig);
        }
Example #14
0
        private static ScriptRuntimeScope InitScriptRuntimeScope()
        {
            //star compile
            if (Interlocked.Exchange(ref _isCompiling, 1) == 0)
            {
                ScriptRuntimeDomain runtimeDomain = null;
                try
                {
                    string runtimePath = MathUtils.RuntimePath ?? MathUtils.RuntimeBinPath;

                    runtimeDomain = new ScriptRuntimeDomain(typeof(ScriptRuntimeDomain).Name, new[] { _settupInfo.RuntimePath, });
                    foreach (var assemblyName in AppDomain.CurrentDomain.GetAssemblies())//_settupInfo.ReferencedAssemblyNames)
                    {
                        ////排除System的dll
                        //if (string.IsNullOrEmpty(assemblyName) ||
                        //    !Path.IsPathRooted(assemblyName)) continue;
                        string key = Path.GetFileNameWithoutExtension(assemblyName.GetName().Name);

                        runtimeDomain.AddAssembly(key, assemblyName);
                    }
                    var scope = runtimeDomain.CreateScope(_settupInfo);
                    //ignore error, allow model is empty.
                    if (scope == null)
                    {
                        if (_runtimeDomain == null)
                        {
                            _runtimeDomain = runtimeDomain;
                        }
                        return(scope);
                    }

                    //update befor
                    bool isFirstRun = _runtimeDomain == null;
                    if (!isFirstRun && _settupInfo.ModelChangedBefore != null)
                    {
                        if (_runtimeDomain.Scope.ModelAssembly != null)
                        {
                            _settupInfo.ModelChangedBefore(_runtimeDomain.Scope.ModelAssembly);
                        }
                        TimeListener.Clear();
                        if (_runtimeDomain.MainInstance != null)
                        {
                            _runtimeDomain.MainInstance.Stop();
                        }
                    }
                    runtimeDomain.Scope.InitDll();
                    runtimeDomain.Scope.Init();
                    runtimeDomain.Scope.InitCsharp();

                    runtimeDomain.MainInstance = (dynamic)runtimeDomain.Scope.Execute(_settupInfo.ScriptMainProgram, _settupInfo.ScriptMainTypeName);
                    if (_runtimeDomain != null)
                    {
                        //unload pre-domain
                        _runtimeDomain.Dispose();
                    }
                    _runtimeDomain = runtimeDomain;
                    EntitySchemaSet.EntityAssembly = scope.ModelAssembly;
                    //update after
                    if (!isFirstRun && _settupInfo.ModelChangedAfter != null && scope.ModelAssembly != null)
                    {
                        _settupInfo.ModelChangedAfter(scope.ModelAssembly);
                    }
                    else if (scope.ModelAssembly != null)
                    {
                        ProtoBufUtils.LoadProtobufType(scope.ModelAssembly);
                        EntitySchemaSet.LoadAssembly(scope.ModelAssembly);
                    }
                    PrintCompiledMessage();
                    //replace runtime
                    if (!isFirstRun && runtimeDomain.MainInstance != null)
                    {
                        runtimeDomain.MainInstance.ReStart();
                    }
                    return(scope);
                }
                finally
                {
                    Interlocked.Exchange(ref _isCompiling, 0);
                }
            }
            else
            {
                TraceLog.WriteLine("{1} {0} has not compiled in other thread.", "model", DateTime.Now.ToString("HH:mm:ss"));
            }
            return(null);
        }
Example #15
0
 public void add(TimeListener listener)
 {
     Listeners.Add(listener);
 }
 public virtual void StartServer()
 {
     //每天0点执行
     TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryDayExecute, "EveryDayTask", "00:00"));
 }