Ejemplo n.º 1
0
        public static void InitScheduler()
        {
            Task.Run(async() =>
            {
                ConsoleHelper.WriteLine("Initializing RSS Scheduler.");

                var baseId       = "rss-scheduler";
                var cronInMinute = 10;
                var rssService   = new RssService();

                ConsoleHelper.WriteLine("Getting list Chat ID");
                var listChatId = await rssService.GetListChatIdAsync();
                foreach (RssSetting row in listChatId)
                {
                    // var chatId = row["chat_id"].ToString();

                    var chatId      = row.ChatId;
                    var recurringId = $"{chatId}-{baseId}";

                    ConsoleHelper.WriteLine($"Creating Jobs for {chatId}");

                    RecurringJob.RemoveIfExists(recurringId);
                    RecurringJob.AddOrUpdate(recurringId, ()
                                             => RssHelper.ExecBroadcasterAsync(chatId), $"*/{cronInMinute} * * * *");
                }

                ConsoleHelper.WriteLine("Registering RSS Scheduler complete.");
            });
        }
Ejemplo n.º 2
0
        public static void InitScheduler()
        {
            Task.Run(async() =>
            {
                Log.Information("Initializing RSS Scheduler.");
                var rssService = new RssService();
                Log.Information("Getting list Chat ID");
                var listChatId = await rssService.GetListChatIdAsync()
                                 .ConfigureAwait(false);
                foreach (var rssSetting in listChatId)
                {
                    var chatId = rssSetting.ChatId.ToInt64().ReduceChatId();
                    RegisterScheduler(chatId);
                }

                Log.Information("Registering RSS Scheduler complete.");
            });
        }