public static void Main(string[] args) { // create service collection var services = new ServiceCollection(); ConfigureServices(services); // create service provider var serviceProvider = services.BuildServiceProvider(); // Get appsettings //var config = serviceProvider.GetService<IOptions<AppSettings>>().Value; // Find path to the _SECRETS folder string credentialsFilePath; string secrets = GMFileAccess.FindParentFolderWithName("_SECRETS"); // If it exists look there for Google Application Credentials. if (secrets != null) { credentialsFilePath = Path.Combine(secrets, "TranscribeAudio.json"); } else { Console.WriteLine("ERROR: Can't located Google Application Credentials"); return; } // Google Cloud libraries automatically use the environment variable GOOGLE_APPLICATION_CREDENTIALS // to authenticate to Google Cloud. Here we set this variable to the path of the credentials file, // which is defined in appsettings.json in the _SECRETS folder Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credentialsFilePath); serviceProvider.GetService <TranslateDocs>().Run(args); }
static void Main(string[] args) { ////LoadDatabase loadDatabase = new LoadDatabase(); string projectFolder = GMFileAccess.FindParentFolderWithName("DevelopLoadDatabase"); string sampleDataFile = Path.Combine(projectFolder, "SampleTranscriptViewModel.json"); ////loadDatabase.LoadSampleData(sampleDataFile); }
private static void ConfigureServices(IServiceCollection services) { var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); // add configured instance of logging services.AddSingleton(new LoggerFactory() .AddConsole() .AddDebug()); // add logging services.AddLogging(); // build configuration // appsettings.json is copied to the output folder during the build. // Otherwise, we would need to set appsettingsdir as follows: // string appsettingsdir = Directory.GetCurrentDirectory() + @"\..\..\.."; // Location of appsettings.json string appsettingsdir = Directory.GetCurrentDirectory(); string devSettingFile = $"appsettings.{environmentName}.json"; // Find path to the _SECRETS folder string secrets = GMFileAccess.FindParentFolderWithName("_SECRETS"); // If it exists look there for environment settings file. if (secrets != null) { devSettingFile = Path.Combine(secrets, $"appsettings.{environmentName}.json"); } var configuration = new ConfigurationBuilder() // TODO - The following path will only work in development. // It isn't yet decided how WorkflowApp will run in production. // Will it be a separate .EXE or a .LIB loaded by WebApp? .SetBasePath(appsettingsdir) .AddJsonFile("appsettings.json", false) .AddJsonFile(devSettingFile, optional: true) .Build(); services.AddOptions(); services.Configure <AppSettings>(configuration.GetSection("AppSettings")); services.Configure <AppSettings>(myOptions => { // Modify paths to be full paths. myOptions.DatafilesPath = GMFileAccess.GetFullPath(myOptions.DatafilesPath); myOptions.TestfilesPath = GMFileAccess.GetFullPath(myOptions.TestfilesPath); myOptions.GoogleApplicationCredentials = GMFileAccess.GetFullPath(myOptions.GoogleApplicationCredentials); }); // add services //services.AddTransient<IOptions<AppSettings>>(); services.AddTransient <ApplicationDbContext>(); services.AddTransient <dBOperations>(); services.AddTransient <RecordingProcess>(); services.AddTransient <TranscribeAudio>(); services.AddTransient <TranscriptProcess>(); //services.AddTransient<ILoadTranscript, LoadTranscript_Stub>(); services.AddTransient <AddtagsRepository>(); services.AddTransient <FixasrRepository>(); services.AddTransient <IMeetingRepository, MeetingRepository_Stub>(); services.AddTransient <IGovBodyRepository, GovBodyRepository_Stub>(); services.AddTransient <WF_RetrieveOnlineFiles>(); services.AddTransient <WF_ProcessReceivedFiles>(); services.AddTransient <WF_ProcessRecordings>(); services.AddTransient <WF_ProcessTranscripts>(); services.AddTransient <WF_ProcessTagged>(); services.AddTransient <WF_ProcessProofread>(); services.AddTransient <WF_LoadDatabase>(); // add app services.AddTransient <WorkflowController>(); }