示例#1
0
            public IHost Init()
            {
                Platform = new PlatformDirectory();
                Platform.EnsureDtpServerDirectory();

                SetupConfiguration();
                SetupLogger();

                Log.Information("Getting the motors running...");

                // Renaming BuildWebHost to InitWebHost avoids problems with add-migration command.
                // IDesignTimeDbContextFactory implemented for add-migration specifically.
                webHost = CreateHostBuilder(null).Build();
                return(webHost);
            }
示例#2
0
        private void EnsureIpfsDir()
        {
            platformDirectory.EnsureDtpServerDirectory();

            if (Directory.Exists(IpfsDataPath))
            {
                return;
            }

            var local = new Shell();

            local.ExecuteInline($"ipfsinit.cmd", IpfsDataPath, IpfsExePath);

            CopyToIpfs("swarm.key"); // Copy the DTP network swarm key
        }
        public virtual void ConfigureDbContext(IServiceCollection services)
        {
            using (TimeMe.Track("ConfigureDbContext"))
            {
                var platform      = new PlatformDirectory();
                var dbName        = "trust.db";
                var dbDestination = "./trust.db";
                if (_hostingEnv.IsProduction())
                {
                    dbDestination = Path.Combine(platform.DatabaseDataPath, dbName);
                    platform.EnsureDtpServerDirectory();
                    if (!File.Exists(dbDestination))
                    {
                        File.Copy(Path.Combine(dbName), dbDestination);
                    }
                }

                services.AddDbContext <TrustDBContext>(options =>
                                                       options.UseSqlite($"Filename={dbDestination}", b => b.MigrationsAssembly("DtpCore"))
                                                       .ConfigureWarnings(warnings => warnings.Ignore(CoreEventId.IncludeIgnoredWarning))
                                                       );
            }
        }