Now using single string for DB conns

This commit is contained in:
hak8or 2017-09-02 21:04:51 -04:00
parent ae782025f6
commit 6f326320cc
2 changed files with 6 additions and 5 deletions

View File

@ -22,13 +22,15 @@ namespace YTManager {
public IConfiguration Configuration { get; }
// String used for connecting to the database server.
public static string dbstr { get; } = "Host=192.168.1.130;Database=postgres;Username=postgres;Password=pass";
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
string constr = "Host=home.hak8or.com;Database=postgres;Username=postgres;Password=mysecretpassword";
services.AddHangfire(x => x.UsePostgreSqlStorage(constr));
services.AddDbContext<MediaDB>(options => options.UseNpgsql(constr));
services.AddHangfire(x => x.UsePostgreSqlStorage(dbstr));
services.AddDbContext<MediaDB>(options => options.UseNpgsql(dbstr));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

View File

@ -22,8 +22,7 @@ namespace YTManager.Tasks
// Get all the channels to update.
var ops = new DbContextOptionsBuilder<MediaDB>();
string constr = "Host=home.hak8or.com;Database=postgres;Username=postgres;Password=mysecretpassword";
ops.UseNpgsql(constr);
ops.UseNpgsql(YTManager.Startup.dbstr);
using (var dbcontext = new MediaDB(ops.Options)) {
var channels = dbcontext.Channels.ToList();