コード例 #1
0
        public static void MainLoop(Config.Config config, CancellationToken token)
        {
            var scheduler = StdSchedulerFactory.GetDefaultScheduler();

            CronJob(scheduler, config.FtpExportPlan, typeof(FtpExportJob));
            CronJob(scheduler, config.FtpImportPlan, typeof(FtpImportJob));
            scheduler.Start();
            token.Register(() => scheduler.Shutdown());

            while (!token.IsCancellationRequested)
            {
                try {
                    var logger = new MemorableLogger(log);
                    IList <object[]> users;
                    using (var session = Factory.OpenSession()) {
                        users = session.CreateSQLQuery("select Id, FtpFileType from Customers.Users where UseFtpGateway = 1")
                                .List <object[]>();
                    }
                    foreach (var user in users)
                    {
                        var userId      = (uint)user[0];
                        var ftpFileType = (ProtocolType)Convert.ToInt16(user[1]);
                        try {
                            log.Debug($"Обработка пользователя {userId}");
                            token.ThrowIfCancellationRequested();
                            ProcessUser(config, userId, ftpFileType);
                            logger.Forget(userId);
                        } catch (Exception e) {
                            if (e is OperationCanceledException)
                            {
                                return;
                            }
                            logger.Error($"Ошибка при обработке пользователя {userId}", e, userId);
                        }
                    }
                    token.WaitHandle.WaitOne(config.LookupTime);
                    token.ThrowIfCancellationRequested();
                } catch (Exception e) {
                    if (e is OperationCanceledException)
                    {
                        return;
                    }
                    log.Error("Ошибка при обработке", e);
                }
            }
        }
コード例 #2
0
 public CertificateCatalogHandler()
 {
     doNotSmapLogger = new MemorableLogger(_logger);
 }