forked from ddrilling/AsbCloudServer
55 lines
2.1 KiB
C#
55 lines
2.1 KiB
C#
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace AsbCloudWebApi
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
//new TraceListenerView(); // to trace mysterious errors
|
|
if(args?.Length > 0 )
|
|
{
|
|
if (args.Contains("db_init")) {
|
|
var connectionStringName = "DefaultConnection";
|
|
|
|
IConfigurationRoot configuration = new ConfigurationBuilder()
|
|
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
|
|
.AddJsonFile("appsettings.json")
|
|
.Build();
|
|
|
|
AsbCloudInfrastructure.DependencyInjection.MakeContext(configuration.GetConnectionString(connectionStringName));
|
|
Console.WriteLine("Óñïåøíî âûïîëíåíî.");
|
|
return;
|
|
}
|
|
WriteHelp();
|
|
return;
|
|
}
|
|
|
|
CreateHostBuilder(args).Build().Run();
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.UseStartup<Startup>();
|
|
});
|
|
|
|
private static void WriteHelp()
|
|
{
|
|
Console.WriteLine("Ïðè çàïóñêå áåç êëþ÷åé ïðîãðàììà ïðîñòî ñòàðòóåò â îáû÷íîì ðåæèìå.");
|
|
Console.WriteLine("Êëþ÷è äëÿ çàïóñêà:");
|
|
Console.WriteLine("db_init - ñîçäàòü êîíòåêñò ÁÄ è âûéòè.");
|
|
Console.WriteLine("Êîíòåêñò ñîçäàñòñÿ äëÿ ñòðîêè ïîäêëþ÷åíèÿ \"DefaultConnection\"");
|
|
Console.WriteLine("Ñîçäàíèå êîíòåêñòà ïðèâåäåò ê ñîçäàíèþ ÁÄ, åñëè åé íåò");
|
|
Console.WriteLine("è ïðèìåíåíèþ âñåõ ìèãðàöèé, åñëè ÁÄ óæå åñòü.");
|
|
Console.WriteLine("Äëÿ ñîçäàíèÿ êîíòåêñòà â ÁÄ äîëæíà áûòü ñîçäàíà ñõåìà public");
|
|
Console.WriteLine("");
|
|
}
|
|
}
|
|
}
|