Ejemplo n.º 1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            DbInstaller.Install(Configuration, services);
            MVCInstaller.Install(services);
        }
Ejemplo n.º 2
0
        private static void BeforeInstall(ILogger logger)
        {
            // When building this project, copy libs/*.dll to output directory.
            logger.Debug("Dll installs.");
            new DLLInstaller(logger).Install();

            logger.Debug("Database installs.");
            DbInstaller.Install();
        }
Ejemplo n.º 3
0
        public void InitDatabase()
        {
            DbInstaller.Install();

            _logger = new LoggerConfiguration()
                      .MinimumLevel.Debug()
                      .WriteTo.File("./log.txt").CreateLogger();
            HostLogger.UseLogger(new SerilogLogWriterFactory.SerilogHostLoggerConfigurator(_logger));

            mock = new Mock <IWebApiConnector>();
            mock.Setup(api => api.FindProjectWorkerByFaceId("2", GlobalConfig.ProjectCode)).ReturnsAsync("2222222");
            mock.Setup(api => api.CheckIn(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 8, 11, 30), "gate01")).ReturnsAsync(true);
            mock.Setup(api => api.CheckIn(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 12, 11, 30), "gate01")).ReturnsAsync(false);
            mock.Setup(api => api.CheckOut(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 10, 11, 30))).ReturnsAsync(true);
            mock.Setup(api => api.CheckOut(GlobalConfig.ProjectCode, "2222222", new DateTime(2018, 1, 13, 14, 11, 30))).ReturnsAsync(false);
        }
Ejemplo n.º 4
0
        public void InitDb()
        {
            DbInstaller.Install();

            _connector = new SqliteConnector();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var logger = new LoggerConfiguration()
                         .ReadFrom.AppSettings()
                         .WriteTo.RollingFile(Path.Combine(ZKTecoConfig.AppRootFolder, "logs", "info{Date}.log"), retainedFileCountLimit: 10)
                         .CreateLogger();

            HostFactory.Run(cfg =>
            {
                cfg.UseSerilog(logger);

                cfg.UseNinject(new ZKTecoModule());

                cfg.BeforeInstall(_ =>
                {
                    // When building this project, copy libs/*.dll to output directory.
                    logger.Information("RegisterDLLs starts...");
#if x64
                    //x64
                    RegisterDLLs("sdk_install", "x64", logger);
#else
                    //x86
                    RegisterDLLs("sdk_install", "x86", logger);
#endif
                    logger.Information("RegisterDLLs ends.");

                    logger.Information("InstallSyncDatabase starts...");

                    DbInstaller.Install();

                    logger.Information("InstallSyncDatabase ends.");
                });

                cfg.AfterUninstall(() =>
                {
                    logger.Information("UnregisterDLLs starts...");
#if x64
                    //x64
                    RegisterDLLs("sdk_uninstall", "x64", logger);
#else
                    //x86
                    RegisterDLLs("sdk_uninstall", "x86", logger);
#endif
                    logger.Information("UnregisterDLLs ends.");
                });

                cfg.Service <ZKTecoServiceControl>(x =>
                {
                    x.ConstructUsingNinject();
                    x.WhenStarted((s, h) => s.Start(h));
                    x.WhenStopped((s, h) => s.Stop(h));

                    // retry failed attendance logs.
                    x.UseQuartzNinject();
                    x.ScheduleQuartzJob(q =>
                    {
                        q.WithJob(() =>
                        {
                            return(JobBuilder.Create <ResendAttendancesJob>().WithIdentity("retryJob", "syncbackend").Build());
                        }).AddTrigger(() =>
                        {
                            return(TriggerBuilder.Create()
                                   .WithIdentity("retryTrigger", "syncbackend")
                                   .StartNow()
                                   .WithSimpleSchedule(b => b.WithIntervalInHours(1).RepeatForever())
                                   .Build());
                        });
                    });
                });

                cfg.RunAsLocalService();
                cfg.StartAutomatically();

                cfg.SetServiceName("ZKTeco-SyncBackendService");
                cfg.SetDisplayName("ZKTeco Sync Backend Service");
                cfg.SetDescription("ZKTeco Synchronize attendance log to CTMS.");

                cfg.OnException(ex =>
                {
                    logger.Error("OnException: {@ex}", ex);
                });
            });
        }