Ejemplo n.º 1
0
 /// <summary>取消定时</summary>
 public static void Unschedule(this IAgent agent, IEnumerable <long> idList)
 {
     foreach (var id in idList)
     {
         QuartzTimer.Remove(id);
     }
 }
Ejemplo n.º 2
0
        /// <summary>取消定时</summary>
        public static void Unschedule(this IAgent agent, long id)
        {
            if (id <= 0)
            {
                return;
            }

            QuartzTimer.Remove(id);
        }
Ejemplo n.º 3
0
        /// <summary>定时任务/每每天</summary>
        public static long AddDailySchedule <TH>(this IAgent agent, int hour, int minute, Param param = null, long unscheduleId = 0) where TH : ITimerHandler
        {
            if (unscheduleId > 0)
            {
                agent.Unschedule(unscheduleId);
            }
            if (HotfixMgr.IsFromHotfix(param))
            {
                LOGGER.Fatal($"不能添加hotfix工程的类型作为Schedule参数 4 {typeof(TH)} {param.GetType()}");
                return(-1);
            }
            getAgentInfo(agent, out var actorId, out var actorAgentType);
            long id = QuartzTimer.AddDailySchedule(hour, minute, actorId, actorAgentType, typeof(TH).FullName, param);

            return(id);
        }
Ejemplo n.º 4
0
        /// <summary>定时任务/一次性</summary>
        public static long AddOnceSchedule <TH>(this IAgent agent, DateTime dateTime, Param param = null, long unscheduleId = 0) where TH : ITimerHandler
        {
            if (unscheduleId > 0)
            {
                agent.Unschedule(unscheduleId);
            }
            if (HotfixMgr.IsFromHotfix(param))
            {
                LOGGER.Fatal($"不能添加hotfix工程的类型作为Schedule参数 3  {typeof(TH)} {param.GetType()}");
                return(-1);
            }
            if (Settings.Ins.IsDebug && !isListenerLegal <TH>(agent))
            {
                return(-1);
            }

            getAgentInfo(agent, out var actorId, out var actorAgentType);
            long id = QuartzTimer.AddOnceSchedule(dateTime, actorId, actorAgentType, typeof(TH).FullName, param);

            return(id);
        }
Ejemplo n.º 5
0
        public async Task <bool> Stop()
        {
            try
            {
                await QuartzTimer.Stop();

                await ChannelManager.RemoveAll();

                await GlobalDBTimer.Singleton.OnShutdown();

                await ActorManager.RemoveAll();

                await TcpServer.Stop();

                await HttpServer.Stop();

                return(true);
            }catch (Exception e)
            {
                LOGGER.Fatal(e.ToString());
                return(false);
            }
        }