/// <summary> /// Retrieves the marker format. /// </summary> /// <param name="providerName">Name of the provider.</param> /// <returns> /// The parameter marker format. /// </returns> private string RetrieveMarkerFormat(string providerName) { string parameterMarkerFormat = "@{0}"; // 1. check if we have it configured DatabaseSetting databaseSetting = _databaseSettingCollection[providerName]; if (databaseSetting != null && !string.IsNullOrWhiteSpace(databaseSetting.ParameterMarkerFormat)) { parameterMarkerFormat = databaseSetting.ParameterMarkerFormat; _log.DebugFormat("Got from configuration the parameter marker format '{0}' for provider '{1}'", parameterMarkerFormat, providerName); } else { // 4. if not, then try to get it from GetSchema(). SqlClient has a bug here. using (DbConnection connection = this.CreateConnection()) { connection.Open(); try { DataTable dataTable = connection.GetSchema(DbMetaDataCollectionNames.DataSourceInformation); parameterMarkerFormat = dataTable.Rows[0][DbMetaDataColumnNames.ParameterMarkerFormat].ToString(); _log.DebugFormat("Got from GetSchema the parameter marker format '{0}' for provider '{1}'", parameterMarkerFormat, providerName); } catch (Exception e) { _log.Error("Provider does not support DbMetaDataCollectionNames.DataSourceInformation or DbMetaDataColumnNames.ParameterMarkerFormat", e); } } } return(parameterMarkerFormat); }
private void ConnectDatabase() { // first check if database can be reached if (this.connectionManager.CheckConnection(this.Name)) { this.Database = new Database( this.Name, DatabaseSetting.GetDatabaseSetting(this.Id).Path, DatabaseSetting.GetDatabaseSetting(this.Id).IgnoredSchemas, this.connectionManager, this.fileSystemAccess, this.processManager, this.differenceCreator, this.sQLFileTester, initializeData: false); this.Error = false; this.ErrorMessage = string.Empty; } else { // could not connect to the database this.ErrorMessage = $"Connection to Database '{this.Name}' cannot be established!"; this.Error = true; } }
public CatalogDbContext(DatabaseSetting setting) { var client = new MongoClient(setting.ConnectionString); _database = client.GetDatabase(setting.DatabaseName); _setting = setting; }
private async Task Update(DatabaseSetting dbSetting, DvcsScriptRepositoryBase.RevisionIdentifierBase sourceChangeset) { ICollection <BuildItem> buildItems; using (var connection = new SqlConnection(dbSetting.ConnectionString)) { await connection.OpenAsync(); using (var transaction = connection.BeginTransaction()) { var fileSystem = new FileSystem(); var db = dbSetting.Create(connection, transaction); var gitProcess = new ExternalProcess(pathToGit.FullName); var dvcsScriptRepo = new GitScriptRepository(dbSetting.ScriptsPath, dbSetting.ServerName, dbSetting.DatabaseName, gitProcess, fileSystem, sqlParser, new ConsoleLogger(SeverityLevel.Warning), false); dvcsScriptRepo.SourceChangeset = sourceChangeset; buildItems = await db.GetChangedBuildItemsAsync(dvcsScriptRepo); transaction.Commit(); } } await DispatcherInvoke(() => { ((MainWindowViewModel)DataContext).IsReady = true; ((MainWindowViewModel)DataContext).IsDone = false; ObservableCollection <BuildItemViewModel> itemsCollection = new ObservableCollection <BuildItemViewModel> (buildItems.Select(x => new BuildItemViewModel(x, Dispatcher))); ((MainWindowViewModel)DataContext).Items = itemsCollection; }); }
//Enviar public static void OnlySendRecords(DatabaseSetting conf, string documentType) { List <CONRecord> Rec = new List <CONRecord>(); try { CONRecord select = (CONRecord)EasyApp.Current.eToolsServer().Execute(new CONRecord { IsSend = false, DocumentType = documentType }, Actions.Find, Options.All, conf.Name, ""); if (select != null) { Rec.AddRange(select.Entities); } if (Rec != null && Rec.Count > 0) { CONSQL send = (CONSQL)EasyApp.Current.eToolsServer().Execute(new CONSQL { Records = Rec }, Actions.Generate, Options.All, conf.Name, ""); Console.WriteLine("Tarea: Enviar correctamente"); } else { Console.WriteLine("Tarea: No hay registros para enviar"); } } catch (Exception e) { Console.WriteLine("Error al ejecutar el proceso de envio " + e.Message); } }
private async Task Build(IEnumerable <BuildItem> items, DatabaseSetting dbSetting, DvcsScriptRepositoryBase.RevisionIdentifierBase sourceChangeset) { using (var connection = new SqlConnection(dbSetting.ConnectionString)) { await connection.OpenAsync(); using (var transaction = connection.BeginTransaction()) { var db = dbSetting.Create(connection, transaction); if (await db.BuildAsync(items)) { transaction.Commit(); } } } await DispatcherInvoke(() => { ((MainWindowViewModel)DataContext).IsReady = true; ((MainWindowViewModel)DataContext).IsDone = true; var vm = ((MainWindowViewModel)DataContext); Properties.Settings.Default.LastChangeset = vm.SourceChangeset as DvcsScriptRepositoryBase.ChangesetId; Properties.Settings.Default.LastTag = vm.SourceChangeset as DvcsScriptRepositoryBase.Tag; Properties.Settings.Default.Save(); }); }
private void ProfileDeleteButton_Click(object sender, EventArgs e) { DatabaseSetting DBSet = FindDBSetting(this.ProfileComboBox.Text); if (DBSet == null) { this.ProfileComboBox.Text = ""; this.MSSQLServerNameComboBox.Text = ""; this.MSSQLLogin.Text = ""; this.MSSQLPass.Text = ""; this.WinAuthCheckBox.Checked = true; this.QueryTextBox.Text = ""; this.QueryUpdateTime.Text = "30"; } else { this.ProfileComboBox.Text = ""; this.MSSQLServerNameComboBox.Text = ""; this.MSSQLLogin.Text = ""; this.MSSQLPass.Text = ""; this.WinAuthCheckBox.Checked = true; this.QueryTextBox.Text = ""; this.QueryUpdateTime.Text = "30"; this.ProfileComboBox.Text = ""; this.ProfileComboBox.Items.Remove(DBSet.SettingName); AllDatabaseSettings.DeleteDatabaseSetting(DBSet); SaveIntoReg(); } }
public override void AddDefaultConfig(DatabaseSetting confg) { confg.Types.Add(typeof(CONEquivalenceDetailMap)); confg.Types.Add(typeof(CONEquivalenceMap)); confg.Types.Add(typeof(CONErrorMap)); confg.Types.Add(typeof(CONIntegratorConfigurationMap)); confg.Types.Add(typeof(CONIntegratorMap)); confg.Types.Add(typeof(CONRecordDetailMap)); confg.Types.Add(typeof(CONRecordMap)); confg.Types.Add(typeof(CONSQLDetailMap)); confg.Types.Add(typeof(CONSQLParameterMap)); confg.Types.Add(typeof(CONSQLMap)); confg.Types.Add(typeof(CONSQLSendMap)); confg.Types.Add(typeof(CONStructureAssociationMap)); confg.Types.Add(typeof(CONStructureDetailMap)); confg.Types.Add(typeof(CONStructureMap)); confg.Types.Add(typeof(SECCompanyMap)); confg.Types.Add(typeof(SECConnectionMap)); confg.Types.Add(typeof(SECRolePermissionMap)); confg.Types.Add(typeof(SECRoleMap)); confg.Types.Add(typeof(SECUserCompanyMap)); confg.Types.Add(typeof(SECUserMap)); confg.Types.Add(typeof(EXTFileOperaMap)); confg.Types.Add(typeof(EXTFileOperaDetailMap)); confg.Types.Add(typeof(CONWSEquivalenciasFormasPagoMap)); confg.Types.Add(typeof(WSCONCESIONEMap)); confg.Types.Add(typeof(WSCONCESIONESTIENDAMap)); PersistenceManager.SetConfigure(confg); }
public ElementNotFeededValidator(ILogger <ElementNotFeededValidator> logger, InMemoryNetworkState inMemoryNetworkState, PostgresWriter postgresWriter, IOptions <DatabaseSetting> databaseSetting, IProducer eventProducer, IOptions <KafkaSetting> kafkaSetting) { _logger = logger; _inMemoryNetworkState = inMemoryNetworkState; _postgresWriter = postgresWriter; _databaseSetting = databaseSetting.Value; _eventProducer = eventProducer; _kafkaSetting = kafkaSetting.Value; }
public AddressConsumer(ITypesenseClient client, ILogger <AddressConsumer> logger, IPostgresWriter postgresWriter, IOptions <KafkaSetting> kafkaSetting, IOptions <DatabaseSetting> databaseSetting, IOptions <TypesenseSetting> typesenseSetting) { _client = client; _logger = logger; _postgresWriter = postgresWriter; _kafkaSetting = kafkaSetting.Value; _databaseSetting = databaseSetting.Value; _typesenseSetting = typesenseSetting.Value; }
public DatabaseModelProjectCreator(IProjectCreator projectCreator, DatabaseSetting dbSetting, String connectionString) { this._projectCreator = projectCreator; this._dbSetting = dbSetting; this.Name = projectCreator.Name; this.Namespace = projectCreator.Namespace; this._path = projectCreator.Path; this._connectionString = connectionString; }
public DatabaseSetting GetDatabaseSetting(string settingName) { DatabaseSetting setting = DataBaseSettings.Find(x => x.Name == settingName); if (setting == null) { throw new ArgumentException("La configuración " + settingName + " no existe"); } return(setting); }
private void StartTaskAddCommand() { var dc = new BotDataContext(this.UserCD); var data = new BotCommand_TaskAdd.CommandData(); var rBotCommand = dc.BotCommand_Add(DatabaseSetting.NewGuid(), this.UserCD, BotCommandName.TaskAdd, null , DateTimeInfo.GetNow().AddMinutes(BotCommand_TaskAdd.ExpireMinutes), JsonConvert.SerializeObject(data)); var cm = new BotCommand_TaskAdd(this.RecipientID, this.BotCD, rBotCommand); cm.ResponseMessage(); }
public MSSQLWriter( ILogger <MSSQLWriter> logger, IOptions <DatabaseSetting> databaseSetting, IOptions <KafkaSetting> kafkaSetting ) { _logger = logger; _databaseSetting = databaseSetting.Value; _kafkaSetting = kafkaSetting.Value; }
/// <summary> /// Saves the properties of the database in the settings file. /// </summary> private void Save() { var newDatabases = DatabaseSetting.GetDatabaseSettings(); newDatabases.Single(d => d.Id == this.Id).Name = this.Database.Name; newDatabases.Single(d => d.Id == this.Id).Path = this.Database.Path; newDatabases.Single(d => d.Id == this.Id).IgnoredSchemas = this.Database.IgnoredSchemas.ToList(); SettingsManager.Get().Setting.DatabaseSettings = newDatabases; SettingsManager.Get().Save(); this.EditMode = false; }
public PSQLWriter( ILogger <PSQLWriter> logger, IOptions <DatabaseSetting> databaseSetting, IOptions <KafkaSetting> kafkaSetting ) { _logger = logger; _databaseSetting = databaseSetting.Value; _kafkaSetting = kafkaSetting.Value; NpgsqlConnection.GlobalTypeMapper.UseNetTopologySuite(); }
//lee el archivo de opera y lo guarda en las tablas del EasyConnect public static void ReadFileOpera(DatabaseSetting conf) { try { var opera = (EXTFileOpera)EasyApp.Current.eToolsServer().Execute(new EXTFileOpera(), Actions.Process, Options.All, conf.Name, ""); Console.WriteLine("Archivo de Opera Leido y Guardado Correctamente"); } catch (Exception e) { Console.WriteLine("Error al intentar guardar Archivo Opera " + e.Message); } }
private void ProfileSaveButton_Click(object sender, EventArgs e) { if (this.ProfileComboBox.Text.Length > 0) { } else if ((this.ProfileComboBox.Text.Length == 0) && (this.MSSQLServerNameComboBox.Text.Length > 0)) { DateTime localDate = DateTime.Now; this.ProfileComboBox.Text = this.MSSQLServerNameComboBox.Text + "-" + localDate.ToShortDateString(); } else { DateTime localDate = DateTime.Now; this.ProfileComboBox.Text = "Default-" + localDate.ToShortDateString(); } foreach (DatabaseSetting DB in this.AllDatabaseSettings.DBList) { DB.LastUsed = false; } DatabaseSetting DBSet = FindDBSetting(this.ProfileComboBox.Text); if (DBSet == null) { DatabaseSetting NewDBSet = new DatabaseSetting(); NewDBSet.SettingName = this.ProfileComboBox.Text; NewDBSet.MSSQLName = this.MSSQLServerNameComboBox.Text; NewDBSet.MSSQLLogin = this.MSSQLLogin.Text; NewDBSet.MSSQLPass = this.MSSQLPass.Text; NewDBSet.MSSQLWInAuth = this.WinAuthCheckBox.Checked; NewDBSet.Query = this.QueryTextBox.Text; NewDBSet.LastUsed = true; NewDBSet.Update = Convert.ToInt32(this.QueryUpdateTime.Text, 10); AllDatabaseSettings.SaveDatabaseSetting(NewDBSet); this.ProfileComboBox.Items.Add(NewDBSet.SettingName); } else { DBSet.SettingName = this.ProfileComboBox.Text; DBSet.MSSQLName = this.MSSQLServerNameComboBox.Text; DBSet.MSSQLLogin = this.MSSQLLogin.Text; DBSet.MSSQLPass = this.MSSQLPass.Text; DBSet.MSSQLWInAuth = this.WinAuthCheckBox.Checked; DBSet.Query = this.QueryTextBox.Text; DBSet.Update = Convert.ToInt32(this.QueryUpdateTime.Text, 10); DBSet.LastUsed = true; } this.QueryTimerTextBox.Text = this.QueryUpdateTime.Text; SaveIntoReg(); }
/// <summary> /// Removes the given database and all of its settings. /// </summary> /// <remarks>Does not delete the Postgres SQL database.</remarks> private async void Remove() { var messageBox = MainWindowViewModel.GetMessageBox( "Are you sure you want to remove the database? This will not delete the Database but will remove it from the list of the APE.PostgreSQL.Teamwork tool", "Remove the database", MessageBoxButton.YesNo); var result = await MainWindowViewModel.ShowDialog(messageBox); if (result == MaterialMessageBoxResult.Yes) { DatabaseSetting.Remove(this.Id); this.Removed?.Invoke(this, EventArgs.Empty); } }
public DatafordelereDatabaseWriter( ILogger <DatafordelereDatabaseWriter> logger, IOptions <KafkaSetting> kafkaSetting, IOptions <DatabaseSetting> databaseSetting, IDatabaseWriter databaseWriter, IPostgresWriter postgresWriter ) { _logger = logger; _kafkaSetting = kafkaSetting.Value; _databaseSetting = databaseSetting.Value; _databaseWriter = databaseWriter; _postgresWriter = postgresWriter; }
/// <summary> /// 取数据库连接 /// </summary> /// <param name="connStr">数据库连接字符串</param> /// <returns></returns> public static DbConnection GetOpenConnection(DatabaseSetting databaseSetting) { if (databaseSetting.DBType.ToUpper() == "MYSQL") { var connection = new MySqlConnection(databaseSetting.ConnectionString); connection.Open(); return(connection); } else { var connection = new SqlConnection(databaseSetting.ConnectionString); connection.Open(); return(connection); } }
private void Disconnect() { this.ExecuteInTask(() => { try { var name = DatabaseSetting.GetDatabaseSetting(this.Id).Name; this.connectionManager.ExecuteCommandNonQuery(SQLTemplates.DisconnectDatabase(name)); } catch (Exception ex) { Log.Error("Exception while executing Action in Task", ex); } }); }
private void ProfileComboBox_SelectedIndexChanged(object sender, EventArgs e) { DatabaseSetting DBSet = FindDBSetting(this.ProfileComboBox.Text); if (DBSet != null) { this.ProfileComboBox.Text = DBSet.SettingName; this.MSSQLServerNameComboBox.Text = DBSet.MSSQLName; this.WinAuthCheckBox.Checked = DBSet.MSSQLWInAuth; this.MSSQLLogin.Text = DBSet.MSSQLLogin; this.MSSQLPass.Text = DBSet.MSSQLPass; this.QueryTextBox.Text = DBSet.Query; this.QueryUpdateTime.Text = DBSet.Update.ToString(); this.QueryTimerTextBox.Text = DBSet.Update.ToString(); DBSet.LastUsed = true; } try { this.SQLTable.Columns.Clear(); } finally { } }
public IDatabase Build(DatabaseSetting settings) { IDatabase database = null; switch (settings.Type) { case DatabaseType.SQLite: database = PrepareSqlLiteDb(settings.SqLiteFolder); break; } if (database == null) { _logger.Error("Database could not be created, exiting..."); Environment.Exit(1); } return(database); }
public static void AddXtraSpurtDependency(this IServiceCollection services) { var env = services.BuildServiceProvider().GetService <IWebHostEnvironment>(); var Configuration = services.BuildServiceProvider().GetService <IConfiguration>(); var databaseSetting = new DatabaseSetting(); // Bind Database setting to databasesetting variable Configuration.Bind("DatabaseSetting", databaseSetting); // DI : Configure DatabaseSetting Options => The options pattern uses classes to provide strongly typed access to groups of related settings services.Configure <DatabaseSetting>(options => Configuration?.GetSection("DatabaseSetting").Bind(options)); if (string.IsNullOrWhiteSpace(databaseSetting.Type) || string.IsNullOrWhiteSpace(databaseSetting.ConnectionString)) { throw new Exception("Verify Database Settings in appsetting.json or appsetting.{Environment}.json"); } switch (databaseSetting.Type) { case "sqlserver": services.RegisterSqlServerDbContexts(databaseSetting.ConnectionString); break; case "pgsql": services.RegisterPgSqlDbContexts(databaseSetting.ConnectionString); break; case "mysql": services.RegisterMySQLDbContexts(databaseSetting.ConnectionString); break; case "mariadb": services.RegisterMariaDbContexts(databaseSetting.ConnectionString); break; default: throw new ArgumentException($"XtraSpurt Does Not Support : {databaseSetting.Type}"); } services.AddXtraSpurtIdentity(); }
private void CheckData() { // verify that database exists with a connection if (!string.IsNullOrWhiteSpace(this.DatabaseName)) { this.DatabaseExists = this.connectionManager.CheckConnection(this.DatabaseName); } if (string.IsNullOrWhiteSpace(this.DatabaseName) || string.IsNullOrWhiteSpace(this.DatabasePath) || DatabaseSetting.GetDatabaseSettings().Any(d => d.Name == this.DatabaseName && d.Path == this.DatabasePath) || !this.DatabaseExists) { this.DataChecked = false; } else { this.DataChecked = true; } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Catalog Api", Version = "v1" }); }); var databseSetting = new DatabaseSetting(); _configuration.GetSection(nameof(DatabaseSetting)).Bind(databseSetting); databseSetting.ConnectionString = Environment.GetEnvironmentVariable("ConnectionString"); services.AddSingleton(databseSetting); services.AddSingleton <ICatalogDbContext, CatalogDbContext>(); services.AddTransient <IProductRepository, ProductRepository>(); services.AddTransient <IProductService, ProductService>(); }
partial void AddDatabaseViewModelCtor() { this.InitializeCommands(); this.ExecuteInTask(this.SearchDatabaseDirectories, (exec) => this.Loading = exec); this.Databases = this.connectionManager.ExecuteCommand <string>(SQLTemplates.GetAllTables()); this.Databases.Remove(SettingsManager.Get().Setting.Id); // remove databases which are already added foreach (var db in DatabaseSetting.GetDatabaseSettings()) { this.Databases.Remove(db.Name); } if (this.Databases.Count == 1) { this.DatabaseName = this.Databases.Single(); } }
private void CreateDatabase() { new Task(() => { try { var name = DatabaseSetting.GetDatabaseSetting(this.Id).Name; this.connectionManager.ExecuteCommandNonQuery(SQLTemplates.CreateDatabase(name)); // connect to database and update default data this.ConnectDatabase(); this.UpdateData(); // do not remove this, else the edit mode will be finished when something else calls this this.StartImport(); } catch (Exception ex) { Log.Error("Exception while executing Action in Task", ex); } }).Start(); }
/// <summary> /// Adds the databases to the list and updates there data. /// </summary> public void UpdateDatabases() { lock (this) { // only update values if databases changed if (this.unfilteredDatabases == null || this.unfilteredDatabases.Count != DatabaseSetting.GetDatabaseSettings().Count) { // unregister the old events if (this.unfilteredDatabases != null) { foreach (var database in this.unfilteredDatabases) { database.Removed -= this.DatabaseRemoved; } } this.unfilteredDatabases = new List <DatabaseDisplayData>(); foreach (var setting in DatabaseSetting.GetDatabaseSettings()) { var databaseDisplayData = new DatabaseDisplayData(this.connectionManager, this.fileSystemAccess, this.processManager, this.differenceCreator, this.sQLFileTester, setting.Id); databaseDisplayData.Removed += this.DatabaseRemoved; this.uiDispatcher.Invoke(() => this.unfilteredDatabases.Add(databaseDisplayData)); } var databases = this.unfilteredDatabases.Where(d => string.IsNullOrWhiteSpace(this.FilterText) || d.Database.Name.ToLower().Contains(this.FilterText.ToLower())); this.Databases = new List <DatabaseDisplayData>(databases); } // update each database in its own task so the slow ones don't // delay the others foreach (var database in this.unfilteredDatabases) { this.ExecuteInTask(() => database.UpdateData()); } Log.Info("Databases successfully updated"); } }