Beispiel #1
0
        public static void Main() {
            var loggerFactory = new LoggerFactory();
            loggerFactory.AddNLog();
            loggerFactory.DefaultLogLevel = LogLevel.Trace;
            var logger = loggerFactory.CreateLogger<Program>();

            var serviceProvider = ServiceProvider.FindAndGetServiceProvider(typeof(EveryMinuteJob), loggerFactory);

            for (int i = 0; i < 5; i++) {
                Task.Run(() => {
                    var cronService = new CronService(serviceProvider.GetService<ICacheClient>(), loggerFactory);

                    // every minute
                    cronService.Add(serviceProvider.GetService<EveryMinuteJob>(), "* * * * *");

                    // every even minute
                    cronService.Add(() => serviceProvider.GetService<EvenMinuteJob>(), "*/2 * * * *");

                    logger.Info($"Cron Service ({i}) Running on {Thread.CurrentThread.ManagedThreadId}");
                    cronService.Run();
                });
            }

            Console.ReadKey();
        }
Beispiel #2
0
        private static void Main()
        {
            LogEntry.New().Info().Message($"*** {InstanceName} v{InstanceVersion} started ***").Log(Logger);

            try
            {
                var cronService = new CronService();
                RobotJob.Scheduler = cronService.Scheduler;

                cronService.Scheduler.ScheduleJob <RobotScheduleUpdater>(
                    name: nameof(RobotScheduleUpdater),
                    cronExpression: Configuration.Load <Program, Global>().RobotConfigUpdaterSchedule,
                    startImmediately: false
                    );

                ServiceStarter.Start(cronService);
            }
            catch (Exception ex)
            {
                LogEntry.New().Error().Exception(ex).Message("Error starting service.").Log(Logger);
            }

            if (Environment.UserInteractive)
            {
                Console.ReadKey();
            }
        }
Beispiel #3
0
 public void Initial()
 {
     CronService.GetInstance().scheduler((_Closure_0024__._0024I7_002D0 != null) ? _Closure_0024__._0024I7_002D0 : (_Closure_0024__._0024I7_002D0 = delegate
     {
         DAOManager.LunaDAO.UpdataLuna();
     }), "0 0 9 ? * *");
     log.Info((object)"露娜系统统计服务初始化!");
 }
Beispiel #4
0
        private PayRewardService()
        {
            log = LogManager.GetLogger(typeof(PayRewardService));
            XmlDataHandle <PayRewardTemplates> .LoadFile(ref _payRewards, ".\\configs\\payrewards\\pay_rewards.xml");

            log.InfoFormat("载入 {0} 个奖励配置!", (object)_payRewards.Count);
            Initialize();
            CronService.GetInstance().scheduler(ResetRewards, "0 0 0 ? * *");
        }
Beispiel #5
0
 public GameInfo(int id, string ip, string password)
 {
     slbs      = new List <Slb>();
     _id       = id;
     _ip       = ip;
     _password = password;
     ProcessItem();
     CronService.GetInstance().scheduler(ProcessItem, "0 0/2 * ? * *");
 }
Beispiel #6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            CronService.ScheduleJobs();
        }
        public async Task Do(ITurnContext <IMessageActivity> turnContext)
        {
            var activity = turnContext.Activity as Activity;

            if (activity != null && activity.Conversation != null)
            {
                CronService.StopPushing();
                await turnContext.SendActivityAsync(MessageFactory.Text("You have successfully stop pushing the notifications."));
            }
        }
Beispiel #8
0
        public static void Main()
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
                System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

                //try
                //{
                //    Test();
                //}
                //catch (Exception err)
                //{

                //}

                AppDomain.CurrentDomain.UnhandledException += UnhandledException;
                Util.RemoveMenu();
                Util.RegeditCloseEvent(ref handler, add: true);
                Console.Title = title;
                Util.SystemInfo();
                Stopwatch stopwatch = Stopwatch.StartNew();
                CronService.GetInstance().Initialize();
                Util.Section("服务配置");
                Configs.LoadConfig();
                Util.Section("核心服务");
                DAOManager.Initialize();
                KeyGen.Initial();
                GameService.LoadGameservers();
                BannedIpController.Initialize();
                LunaController.GetInstance().Initial();
                Util.Section("网络服务");
                AionPacketFactory.GetInstance();
                LoginListener.GetInstance().Start();
                GamePacketFactory.GetInstance();
                GameListener.GetInstance().Start();
                Util.Section("充值奖励");
                PayRewardService.GetInstance();
                Util.Section("");
                stopwatch.Stop();
                string text  = string.Format("登陆服务器启动完成,耗时{0}秒!", ((double)stopwatch.ElapsedMilliseconds / 1000.0).ToString("0.00"));
                string text2 = "使用快捷键 Ctrl + C 关闭服务并保存数据!";
                Console.WriteLine(new string(' ', Conversions.ToInteger(Util.StringLength(text))) + text);
                Console.WriteLine(new string(' ', Conversions.ToInteger(Util.StringLength(text2))) + text2);
                Util.Section("");
                if (LoginConfig.WORKING_MEMORY_SET_ENABLE)
                {
                    WorkingMemorySet.GetInstance().Initialize(LoginConfig.WORKING_MEMORY_SET_CRON);
                }
            }
            catch (Exception err)
            {
                log.Error(err.Message, err);
            }
        }
Beispiel #9
0
 private void Initialize()
 {
     foreach (PayRewardTemplate reward in _payRewards.rewards)
     {
         if (reward.IsActive())
         {
             _activeRewards.Add(reward);
         }
     }
     log.InfoFormat("初始化 {0} 个有效充值奖励模板!", (object)_activeRewards.Count);
     CronService.GetInstance().scheduler(InitializeReward, "0 0/1 * ? * *");
 }
Beispiel #10
0
        [InlineData("2020-08-07 09:01", "2020-09-07 00:01", "0 9 ? * *", false)] // every day
        public void HasTimeCome_ShouldReturnExpectedResult(string now, string sendDate, string schedule, bool expectedResult)
        {
            var dateTime = DateTime.SpecifyKind(DateTime.ParseExact(sendDate, "yyyy-MM-dd hh:mm", null), DateTimeKind.Utc);
            var nowTime  = DateTime.SpecifyKind(DateTime.ParseExact(now, "yyyy-MM-dd hh:mm", null), DateTimeKind.Utc);

            _dateTimeServiceMock
            .Setup(s => s.Now())
            .Returns(nowTime);
            var service = new CronService(_dateTimeServiceMock.Object);

            var result = service.HasTimeCome(dateTime, TimeSpan.FromMinutes(60), schedule);

            result.Should().Be(expectedResult);
        }
Beispiel #11
0
        public static void Main()
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

                System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                AppDomain.CurrentDomain.UnhandledException += UnhandledException;
                Console.Title = title;
                Util.SystemInfo();
                Stopwatch stopwatch = Stopwatch.StartNew();
                CronService.GetInstance().Initialize();
                Util.Section("核心配置");
                Configs.LoadConfig();
                Util.Section("数据连接");
                DAOManager.Initialize();
                Util.Section("注册服务");
                GameService.Load();
                Util.Section("网络服务");
                NewLateBinding.LateCall(SlbService.GetInstance(), null, "Start", new object[0], null, null, null, IgnoreReturn: true);
                ChatPacketFactory.GetInstance();
                AionListener.GetInstance().Start();
                GamePacketFactory.GetInstance();
                GameListener.GetInstance().Start();
                Util.Section("");
                stopwatch.Stop();
                string text = string.Format("聊天服务器启动完成,耗时{0}秒!", ((double)stopwatch.ElapsedMilliseconds / 1000.0).ToString("0.00"));
                Console.WriteLine(new string(' ', Conversions.ToInteger(Util.StringLength(text))) + text);
                Util.Section("");
                if (ChatConfig.WORKING_MEMORY_SET_ENABLE)
                {
                    WorkingMemorySet.GetInstance().Initialize(ChatConfig.WORKING_MEMORY_SET_CRON);
                }
            }
            catch (Exception err)
            {
                log.Error(err.Message, err);
            }
        }
Beispiel #12
0
 public RecurringModule(CronService cron)
 {
     _cron = cron;
 }
Beispiel #13
0
 public CronModule(CronService cron)
 {
     _cron = cron;
 }
Beispiel #14
0
        public void GetNextOccurence_Theory_Throws(string cronText)
        {
            Action action = () => CronService.GetNextOccurence(cronText, DateTime.MinValue, TimeZoneInfo.Utc);

            action.Should().ThrowExactly <CronParseException>();
        }
Beispiel #15
0
 public void IsWithinThreshold_Theory(DateTime utcNow, DateTime?nextOccurenceUtc, TimeSpan threshold, bool expected)
 {
     CronService.IsWithinThreshold(utcNow, nextOccurenceUtc, threshold)
     .Should().Be(expected);
 }
Beispiel #16
0
 public void GetNextOccurence_Theory(string cronText, DateTime nowUtc, TimeZoneInfo timeZoneInfo, DateTime?expected)
 {
     CronService.GetNextOccurence(cronText, nowUtc, timeZoneInfo)
     .Should().Be(expected);
 }
Beispiel #17
0
 public void Start()
 {
     ProcessItem();
     CronService.GetInstance().scheduler(ProcessItem, "0 0/2 * ? * *");
 }