コード例 #1
0
ファイル: Program.cs プロジェクト: steffendx/GoNorth
        /// <summary>
        /// Configures the database
        /// </summary>
        /// <returns>Task</returns>
        private static async Task ConfigureDb()
        {
            do
            {
                string connectionString = MessageService.GetMongoDbConnectionString();
                AppSettingUpdater.AddOrUpdateAppSetting((config) => config.MongoDb.ConnectionString = connectionString);
                string databaseName = MessageService.GetMongoDbDatabasename();
                AppSettingUpdater.AddOrUpdateAppSetting((config) => config.MongoDb.DbName = databaseName);

                MessageService.PrintVerifyingDatabase();
                try
                {
                    ServiceProvider serviceProvider = ServiceProviderBuilder.BuildServiceProvider();
                    IDbSetup        dbSetup         = serviceProvider.GetService <IDbSetup>();
                    await dbSetup.SetupDatabaseAsync();

                    MessageService.PrintSuccessVerifyingDatabase();
                    break;
                }
                catch (Exception ex)
                {
                    MessageService.PrintErrorVerifyingDatabase(ex);
                }
            }while(true);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: steffendx/GoNorth
        /// <summary>
        /// Configures the email settings
        /// </summary>
        /// <returns>Task</returns>
        private static async Task ConfigureEMail()
        {
            do
            {
                string smtpServer = MessageService.GetSmtpServer();
                if (string.IsNullOrEmpty(smtpServer))
                {
                    MessageService.PrintEMailConfigSkip();
                    break;
                }

                try
                {
                    AppSettingUpdater.AddOrUpdateAppSetting((config) => config.Email.SmtpServer = smtpServer);
                    int port = MessageService.GetSmtpPort();
                    AppSettingUpdater.AddOrUpdateAppSetting((config) => config.Email.SmtpPort = port);
                    bool useSsl = MessageService.GetSmtpUseSsl();
                    AppSettingUpdater.AddOrUpdateAppSetting((config) => config.Email.SmtpUseSSL = useSsl);
                    string smtpUsername = MessageService.GetSmtpUsername();
                    AppSettingUpdater.AddOrUpdateAppSetting((config) => config.Email.SmtpUsername = smtpUsername);
                    string smtpPasword = MessageService.GetSmtpPassword();
                    AppSettingUpdater.AddOrUpdateAppSetting((config) => config.Email.SmtpPassword = smtpPasword);
                    string smtpTestReceiver = MessageService.GetSmtpTestReceiver();

                    MessageService.PrintVerifyingStmp();

                    ServiceProvider serviceProvider = ServiceProviderBuilder.BuildServiceProvider();
                    IEmailSender    emaiLSender     = serviceProvider.GetService <IEmailSender>();
                    await emaiLSender.SendEmailAsync(smtpTestReceiver, "GoNorth - Mail Test", "Mail test successful.");

                    MessageService.PrintSuccessVerifyingSmtpServer();
                    break;
                }
                catch (Exception ex)
                {
                    MessageService.PrintErrorVerifyingSmtpServer(ex);
                }
            }while(true);
        }