예제 #1
0
        /// <summary>
        /// 停止
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public override async Task StopAsync(CancellationToken cancellationToken)
        {
            Data.Clear();
            foreach (var line in Lines)
            {
                line.Stop();
            }
            Lines.Clear();
            Lines = null;

            _helper = null;
            _store  = null;

            await base.StopAsync(cancellationToken);
        }
예제 #2
0
        /// <summary>
        /// 启动
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public override async Task StartAsync(CancellationToken cancellationToken)
        {
            Data = new Dictionary <string, object>();
            var _configuration = _serviceScopeFactory.CreateScope().ServiceProvider.GetRequiredService <IConfiguration>();

            ConnectionString      = _configuration["Configurations:ConnectionString"];
            RedisConnectionString = _configuration["Configurations:Redis"];

            _store = new CollectorStoreImple(ConnectionString);
            RedisHelper.Initialization(new CSRedis.CSRedisClient(RedisConnectionString));
            _helper = new BatchHelper(_store);

            await LoadLinesAsync();

            await base.StartAsync(cancellationToken);
        }