Пример #1
0
        private static void SetupFactory(ILoggerFactory logFactory)
        {
            string host     = Environment.GetEnvironmentVariable("MAGNUM_FIREBASE_URL");
            string key      = Environment.GetEnvironmentVariable("MAGNUM_FIREBASE_KEY");
            string user     = Environment.GetEnvironmentVariable("MAGNUM_DB_USERNAME");
            string password = Environment.GetEnvironmentVariable("MAGNUM_DB_PASSWORD");
            string bucket   = Environment.GetEnvironmentVariable("MAGNUM_FIREBASE_BUCKET");

            Microsoft.Extensions.Logging.ILogger logger = logFactory.CreateLogger <FirebaseNoSqlContext>();

            FirebaseNoSqlContext ctx = new FirebaseNoSqlContext();

            ctx.SetLogger(logger);
            ctx.Authenticate(host, key, user, password);

            var storageCtx = new FirebaseStorageContext();

            storageCtx.Authenticate(bucket, key, user, password);

            FactoryBusinessOperation.SetStorageContext(storageCtx);
            FactoryBusinessOperation.SetNoSqlContext(ctx);
            FactoryBusinessOperation.SetLoggerFactory(logFactory);
            FactoryBusinessOperation.RegisterBusinessOperations(BusinessErpOperations.GetInstance().ExportedServicesList());

            FactoryCacheContext.RegisterCaches(BusinessErpCaches.GetInstance().ExportedServicesList());
            FactoryCacheContext.SetLoggerFactory(logFactory);
        }
Пример #2
0
        private static void Init()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging(builder => builder.AddSerilog());
            var serviceProvider = serviceCollection.BuildServiceProvider();

            Log.Logger = new LoggerConfiguration()
                         .Enrich.FromLogContext()
                         .WriteTo.Console()
                         .CreateLogger();

            var loggerFactory = serviceProvider.GetService <ILoggerFactory>();

            FactoryApplication.SetLoggerFactory(loggerFactory);

            FactoryBusinessOperation.ClearRegisteredItems();
            FactoryBusinessOperation.RegisterBusinessOperations(BusinessErpOperations.GetInstance().ExportedServicesList());

            string       host     = Environment.GetEnvironmentVariable("ONIX_ERP_DB_HOST");
            string       dbname   = Environment.GetEnvironmentVariable("ONIX_ERP_DB_NAME");
            string       user     = Environment.GetEnvironmentVariable("ONIX_ERP_DB_USER");
            string       password = Environment.GetEnvironmentVariable("ONIX_ERP_DB_PASSWORD");
            DbCredential crd      = new DbCredential(host, 5432, dbname, user, password, "pgsql");

            OnixErpDbContext ctx = new OnixErpDbContext(crd);

            ctx.SetLoggerFactory(loggerFactory);
            FactoryBusinessOperation.SetDatabaseContext(ctx);
            FactoryBusinessOperation.SetLoggerFactory(loggerFactory);

            Assembly asm = Assembly.GetExecutingAssembly();

            FactoryDbContext.RegisterDbContext(asm, "OnixErpDbContextPgSql", "OnixBusinessErpApp.OnixErpDbContextPgSql");
        }
Пример #3
0
        public BaseTest()
        {
            FactoryBusinessOperation.ClearRegisteredItems();
            FactoryBusinessOperation.RegisterBusinessOperations(BusinessErpOperations.GetInstance().ExportedServicesList());

            FactoryCacheContext.ClearRegisteredItems();
            FactoryCacheContext.RegisterCaches(BusinessErpCaches.GetInstance().ExportedServicesList());
        }
 public static void LoadBusinessOperations()
 {
     if (!isLoad)
     {
         var servicesList = BusinessErpOperations.GetInstance().ExportedServicesList();
         FactoryBusinessOperation.RegisterBusinessOperations(servicesList);
         isLoad = true;
     }
 }
        public Startup(IConfiguration configuration)
        {
            var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .AddFilter("Its", LogLevel.Warning)
                .AddConsole();
            });

            string host     = Environment.GetEnvironmentVariable("ONIX_ERP_DB_HOST");
            string dbname   = Environment.GetEnvironmentVariable("ONIX_ERP_DB_NAME");
            string user     = Environment.GetEnvironmentVariable("ONIX_ERP_DB_USER");
            string password = Environment.GetEnvironmentVariable("ONIX_ERP_DB_PASSWORD");

            crd = new DbCredential(host, 5432, dbname, user, password, "pgsql");

            Configuration = configuration;

            FactoryBusinessOperation.RegisterBusinessOperations(BusinessErpOperations.GetInstance().ExportedServicesList());
            FactoryBusinessOperation.SetLoggerFactory(loggerFactory);
        }
Пример #6
0
        public static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                Console.WriteLine("Missing application name!!!");
                return;
            }

            FactoryBusinessOperation.ClearRegisteredItems();
            FactoryBusinessOperation.RegisterBusinessOperations(BusinessErpOperations.GetInstance().ExportedServicesList());

            FactoryCacheContext.ClearRegisteredItems();
            FactoryCacheContext.RegisterCaches(BusinessErpCaches.GetInstance().ExportedServicesList());

            string appName = args[0];

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging(builder => builder.AddSerilog());

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var loggerFactory   = serviceProvider.GetService <ILoggerFactory>();

            Log.Logger = new LoggerConfiguration()
                         .Enrich.FromLogContext()
                         .WriteTo.Console()
                         .CreateLogger();

            FactoryConsoleApplication.SetLoggerFactory(loggerFactory);
            IApplication app = FactoryConsoleApplication.CreateConsoleApplicationObject(appName);

            OptionSet opt = app.CreateOptionSet();

            opt.Parse(args);

            app.Run();
        }
Пример #7
0
 public void OneTimeSetUp()
 {
     FactoryBusinessOperation.ClearRegisteredItems();
     FactoryBusinessOperation.RegisterBusinessOperations(BusinessErpOperations.GetInstance().ExportedServicesList());
 }