private void Bk_OnCurrentDatabaseChanged(DatabaseBase currentDB, List <PositionBackupInfo> positionBackupInfos, string deviceName) { if (!String.IsNullOrEmpty(deviceName)) //had device { btn_CreateDevice.Enabled = false; btn_Backup.Enabled = true; } else { btn_CreateDevice.Enabled = true; btn_Backup.Enabled = false; } //setup listview lsv_BackupVersions.Items.Clear(); lsv_BackupVersions.View = View.Details; lsv_BackupVersions.OwnerDraw = true; lbl_BackupCount.Text = positionBackupInfos.Count.ToString(); foreach (var item in positionBackupInfos) { ListViewItem row = new ListViewItem(new string[] { item.Position.ToString(), item.Description, item.BackupDateTime.ToString("MM/dd/yyyy HH:mm:ss"), item.UserBackup }); lsv_BackupVersions.Items.Add(row); } }
public SqlProcessInformationService(IProcessInformationCollector[] collectors, ProcessInformationDatabase database) : base(collectors, 15) { _database = database; _database.SetupOnce(); }
public string GetDeleteQuery(DatabaseBase database, DeleteBuilder deleteBuilder, Parameters parameters) { StringBuilder stringBuilder = new StringBuilder("DELETE FROM "); stringBuilder.Append(deleteBuilder.Table.Name).Append(" AS ").Append(deleteBuilder.Table.Alias); if (deleteBuilder.WhereCondition != null) { stringBuilder.Append(" WHERE ").Append(GetConditionSql(database, deleteBuilder.WhereCondition, parameters)); } if (deleteBuilder.ReturnColumns != null && deleteBuilder.ReturnColumns.Length > 0) { stringBuilder.Append(" RETURNING "); int index = 0; while (index < deleteBuilder.ReturnColumns.Length) { if (index > 0) { stringBuilder.Append(","); } stringBuilder.Append(deleteBuilder.ReturnColumns[index].Name); checked { ++index; } } } return(stringBuilder.ToString()); }
private void routerAdded(DatabaseBase <Router> database, Router router) { router.Inputs.Foreach(input => LabelableObjectRegister.Instance.Register(input)); router.Outputs.Foreach(output => LabelableObjectRegister.Instance.Register(output)); router.Inputs.ItemsAdded += routerInputsAdded; router.Outputs.ItemsAdded += routerOutputsAdded; }
public void SetConfiguration(EndpointConfiguration configuration) { this.Configuration = configuration; this.ReloadAt = DateTime.Now; // Instance of Db switch (Configuration.DatabaseType.ToUpper()) { case "SQLITE": db = DatabaseBase.Build <SqliteConnection>(new[] { Configuration.ConnectionString }); break; // case "MSSQL": // case "SQLSERVER": // db = DatabaseBase.Build<SqlConnection>(new[] { Config.ConnectionString }); // break; // // case "MARIADB": // case "MYSQL": // db = DatabaseBase.Build<MySqlConnection>(new[] { Config.ConnectionString }); // break; // // case "NODE": // case "NODEJS": // nodeService = new CrudNodeService(config.Name); // break; } }
public bool Up(DatabaseBase database) { // Do the update, if it returns true, add the version entry in the database var result = DoActualUpgrade(); return(result); }
public async Task ConnectAsync(CancellationToken cancellationToken = default) { if (Charset.GetCharset(_options.Charset) == null) { throw FbException.Create("Invalid character set specified"); } try { _db = await ClientFactory.CreateDatabaseAsync(_options, cancellationToken).ConfigureAwait(false); _db.Charset = Charset.GetCharset(_options.Charset); _db.Dialect = _options.Dialect; _db.PacketSize = _options.PacketSize; var dpb = BuildDpb(_db, _options); if (string.IsNullOrEmpty(_options.UserID) && string.IsNullOrEmpty(_options.Password)) { await _db.AttachWithTrustedAuthAsync(dpb, _options.Database, _options.CryptKey, cancellationToken).ConfigureAwait(false); } else { await _db.AttachAsync(dpb, _options.Database, _options.CryptKey, cancellationToken).ConfigureAwait(false); } } catch (IscException ex) { throw FbException.Create(ex); } }
public void Connect() { if (Charset.GetCharset(_options.Charset) == null) { throw FbException.Create("Invalid character set specified"); } try { _db = ClientFactory.CreateDatabase(_options); _db.Charset = Charset.GetCharset(_options.Charset); _db.Dialect = _options.Dialect; _db.PacketSize = _options.PacketSize; var dpb = BuildDpb(_db, _options); if (string.IsNullOrEmpty(_options.UserID) && string.IsNullOrEmpty(_options.Password)) { _db.AttachWithTrustedAuth(dpb, _options.Database, _options.CryptKey); } else { _db.Attach(dpb, _options.Database, _options.CryptKey); } } catch (IscException ex) { throw FbException.Create(ex); } }
public async Task Connect(AsyncWrappingCommonArgs async) { if (Charset.GetCharset(_options.Charset) == null) { throw new FbException("Invalid character set specified"); } try { _db = await ClientFactory.CreateDatabase(_options, async).ConfigureAwait(false); _db.Charset = Charset.GetCharset(_options.Charset); _db.Dialect = _options.Dialect; _db.PacketSize = _options.PacketSize; var dpb = BuildDpb(_db, _options); if (string.IsNullOrEmpty(_options.UserID) && string.IsNullOrEmpty(_options.Password)) { await _db.AttachWithTrustedAuth(dpb, _options.DataSource, _options.Port, _options.Database, _options.CryptKey, async).ConfigureAwait(false); } else { await _db.Attach(dpb, _options.DataSource, _options.Port, _options.Database, _options.CryptKey, async).ConfigureAwait(false); } } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
private static DatabaseParameterBufferBase BuildDpb(DatabaseBase db, ConnectionString options) { var dpb = db.CreateDatabaseParameterBuffer(); dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { options.Dialect, 0, 0, 0 }); dpb.Append(IscCodes.isc_dpb_lc_ctype, options.Charset); if (options.DbCachePages > 0) { dpb.Append(IscCodes.isc_dpb_num_buffers, options.DbCachePages); } if (!string.IsNullOrEmpty(options.UserID)) { dpb.Append(IscCodes.isc_dpb_user_name, options.UserID); } if (!string.IsNullOrEmpty(options.Role)) { dpb.Append(IscCodes.isc_dpb_sql_role_name, options.Role); } dpb.Append(IscCodes.isc_dpb_connect_timeout, options.ConnectionTimeout); dpb.Append(IscCodes.isc_dpb_process_id, GetProcessId()); dpb.Append(IscCodes.isc_dpb_process_name, GetProcessName(options)); dpb.Append(IscCodes.isc_dpb_client_version, GetClientVersion()); if (options.NoDatabaseTriggers) { dpb.Append(IscCodes.isc_dpb_no_db_triggers, 1); } if (options.NoGarbageCollect) { dpb.Append(IscCodes.isc_dpb_no_garbage_collect, (byte)0); } return(dpb); }
public RemoteEvent(DatabaseBase database) { LocalId = 0; RemoteId = 0; _events = new List <string>(); _database = database; }
public virtual void CurrentDatabaseHadChanged(DatabaseBase currentDB, List <PositionBackupInfo> positionBackupInfos = null, string deviceName = null) { if (OnCurrentDatabaseChanged != null) { if (positionBackupInfos == null) { positionBackupInfos = GetAllPositionBackupVersions().ToList <PositionBackupInfo>(); bool hadDevice = CurrentDBHadDevice(); if (!hadDevice && positionBackupInfos.Count != 0) // name of device is not default { DeviceName = GetCurrentDeviceOfDB(); QueryStrings.CurrentDevice = DeviceName; } else if (hadDevice) { DeviceName = QueryStrings.CurrentDevice; } else if (!hadDevice) { DeviceName = null; } } OnCurrentDatabaseChanged(currentDB, positionBackupInfos, DeviceName); } }
/// <summary> /// Updates the participants tables for record. /// </summary> /// <param name="record">The record.</param> /// <param name="database">The database.</param> /// <returns></returns> public int UpdateParticipantsTablesForRecord(Record record, DatabaseBase database) { var recordTemplate = record.RecordTemplate; var tableInfo = recordTemplate.GetTableInfo(); int participantsFieldCount = tableInfo.GetParticipantsFieldCount(); if (participantsFieldCount == 0) { return(0); } for (int i = 0; i < participantsFieldCount; i++) { FieldInfo participantsFieldInfo = tableInfo.ParticipantsFieldInfos[i]; var fieldPos = recordTemplate.GetFieldPos(participantsFieldInfo.FieldId); if (fieldPos < 0) { continue; } UPCRMRecordParticipantWriter pw = new UPCRMRecordParticipantWriter(record.InfoAreaId, participantsFieldInfo, database); pw.UpdateValueForRecordId(record.GetValue(fieldPos), record.RecordId); } return(0); }
/// <summary> /// Register the database. /// </summary> /// <param name="db">The <see cref="DatabaseBase"/>.</param> public static async Task RegisterDatabaseAsync(DatabaseBase db) { if (DbTables == null) { DbTables = await DbTable.LoadTablesAndColumnsAsync(db, false).ConfigureAwait(false); } }
public string GetSql(DatabaseBase database) { if (database == null) { throw new NullReferenceException("database cannot be null or empty"); } return(QueryBuilderFactory.GetTruncateQuery(database, this.mTable)); }
public string GetSql(DatabaseBase database) { if (database == null) { throw new NullReferenceException("database cannot be null"); } return(QueryBuilderFactory.GetInsertQuery(database, this, (Parameters)null)); }
public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex) { if (dataReader.IsDBNull(columnIndex)) { return(null); } return((DateTimeOffset?)dataReader.GetValue(columnIndex)); }
public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex) { if (Convert.IsDBNull(dataReader[columnIndex])) { return(0); } return(dataReader.GetInt32(columnIndex)); }
public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex) { if (database.DatabaseType == DatabaseType.POSTGRESQL) { return(new DateTimeOffset(dataReader.GetDateTime(columnIndex))); } return((DateTimeOffset)dataReader.GetValue(columnIndex)); }
private string GetSql(DatabaseBase database, Parameters parameters) { if (database == null) { throw new CooqDataException.CooqPreconditionException("database cannot be null"); } return(QueryBuilderFactory.GetDeleteQuery(database, this, parameters)); }
public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex) { if (dataReader.IsDBNull(columnIndex)) return null; if (dataReader.GetFieldType(columnIndex) == typeof (long)) return new int?(Convert.ToInt32(dataReader.GetInt64(columnIndex))); return new int?(dataReader.GetInt32(columnIndex)); }
public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex) { if (dataReader.IsDBNull(columnIndex)) { return(null); } return(new Guid?(dataReader.GetGuid(columnIndex))); }
private string GetSql(DatabaseBase database, Parameters parameters) { if (database == null) { throw new NullReferenceException("database cannot be null"); } return(QueryBuilderFactory.GetUpdateQuery(database, this, parameters)); }
/// <summary> /// Register the database. /// </summary> /// <param name="db">The <see cref="DatabaseBase"/>.</param> /// <param name="refDataSchema">The reference data schema.</param> public static async Task RegisterDatabaseAsync(DatabaseBase db, string refDataSchema) { if (DbTables == null) { DbTables = await Table.LoadTablesAndColumnsAsync(db, refDataSchema).ConfigureAwait(false); } RefDataSchema = refDataSchema; }
/// <summary> /// Register the database. /// </summary> /// <param name="db">The <see cref="DatabaseBase"/>.</param> /// <param name="refDataSchema">The reference data schema.</param> public static void RegisterDatabase(DatabaseBase db, string refDataSchema) { if (DbTables == null) { DbTables = Table.LoadTablesAndColumns(db, refDataSchema); } RefDataSchema = refDataSchema; }
/// <summary> /// Undoes the by inserting with transaction. /// </summary> /// <param name="database">The database.</param> /// <returns>0, if success, else error number</returns> private int UndoByInsertingWithTransaction(DatabaseBase database) { StringBuilder statementString = new StringBuilder(); StringBuilder parameters = new StringBuilder(); statementString.Append($"INSERT INTO CRM_{this.RecordIdentification.InfoAreaId()} ("); bool first = true; foreach (UPCRMUndoField undoField in this.FieldDictionary.Values) { if (string.IsNullOrEmpty(undoField.OldValue)) { continue; } if (first) { first = false; parameters.Append("?"); } else { statementString.Append(", "); parameters.Append(", ?"); } statementString.Append(undoField.FieldName); } if (first) { return(0); } statementString.Append($") VALUES ({parameters})"); DatabaseStatement statement = new DatabaseStatement(database); if (!statement.Prepare(statementString.ToString())) { return(-1); } int parameterCount = 0; foreach (UPCRMUndoField undoField in this.FieldDictionary.Values) { if (string.IsNullOrEmpty(undoField.OldValue)) { continue; } statement.Bind(parameterCount++, undoField.OldValue); } return(statement.Execute()); }
public GdsTransaction(DatabaseBase db) { if (!(db is GdsDatabase)) { throw new ArgumentException($"Specified argument is not of {nameof(GdsDatabase)} type."); } _database = (GdsDatabase)db; State = TransactionState.NoTransaction; }
/// <summary> /// Initializes a new instance of the <see cref="UPCRMRecordParticipantWriter"/> class. /// </summary> /// <param name="infoAreaId">The information area identifier.</param> /// <param name="fieldInfo">The field information.</param> /// <param name="database">The database.</param> public UPCRMRecordParticipantWriter(string infoAreaId, FieldInfo fieldInfo, DatabaseBase database) { this.InfoAreaId = infoAreaId; this.FieldId = fieldInfo.FieldId; this.Database = database; string tableName = $"CRM_{this.InfoAreaId}_PART_{fieldInfo.DatabaseFieldName}"; this.InsertStatementSql = $"INSERT INTO {tableName} (recid, nr, repId, repOrgGroupId, attendance) VALUES (?,?,?,?,?)"; this.DeleteStatementSql = $"DELETE FROM {tableName} WHERE recid = ?"; }
/// <summary> /// Checks the after cache save. /// </summary> /// <param name="database">The database.</param> /// <returns>0, if success, else error number</returns> public int CheckAfterCacheSave(DatabaseBase database) { if (this.Mode.StartsWith("New") && this.Record != null) { this.RecordIdentification = this.Record.RecordIdentification; this.UndoOperation = "Delete"; } return(0); }
public MongoDbContext(string connectionstring, string databasename, string jobcollection) { Client = new MongoClient(connectionstring); DatabaseBase = Client.GetDatabase(databasename); Students = DatabaseBase.GetCollection <StudentModel>("Users"); var indexModel = new CreateIndexModel <StudentModel>(Builders <StudentModel> .IndexKeys.Text(x => x.Tags)); Students.Indexes.CreateOne(indexModel); Companies = DatabaseBase.GetCollection <CompanyModel>("Users"); Jobs = DatabaseBase.GetCollection <JobModel>(jobcollection); }