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);
            }
        }
Exemplo n.º 2
0
 public SqlProcessInformationService(IProcessInformationCollector[] collectors,
                                     ProcessInformationDatabase database)
     : base(collectors, 15)
 {
     _database = database;
     _database.SetupOnce();
 }
Exemplo n.º 3
0
        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;
 }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        public bool Up(DatabaseBase database)
        {
            // Do the update, if it returns true, add the version entry in the database
            var result = DoActualUpgrade();

            return(result);
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 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);
        }
Exemplo n.º 14
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);
     }
 }
Exemplo n.º 15
0
 public string GetSql(DatabaseBase database)
 {
     if (database == null)
     {
         throw new NullReferenceException("database cannot be null or empty");
     }
     return(QueryBuilderFactory.GetTruncateQuery(database, this.mTable));
 }
Exemplo n.º 16
0
 public string GetSql(DatabaseBase database)
 {
     if (database == null)
     {
         throw new NullReferenceException("database cannot be null");
     }
     return(QueryBuilderFactory.GetInsertQuery(database, this, (Parameters)null));
 }
Exemplo n.º 17
0
 public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex)
 {
     if (dataReader.IsDBNull(columnIndex))
     {
         return(null);
     }
     return((DateTimeOffset?)dataReader.GetValue(columnIndex));
 }
Exemplo n.º 18
0
 public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex)
 {
     if (Convert.IsDBNull(dataReader[columnIndex]))
     {
         return(0);
     }
     return(dataReader.GetInt32(columnIndex));
 }
Exemplo n.º 19
0
 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));
 }
Exemplo n.º 20
0
 private string GetSql(DatabaseBase database, Parameters parameters)
 {
     if (database == null)
     {
         throw new CooqDataException.CooqPreconditionException("database cannot be null");
     }
     return(QueryBuilderFactory.GetDeleteQuery(database, this, parameters));
 }
Exemplo n.º 21
0
Arquivo: Min.cs Projeto: gunivan/cooq
 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));
 }
Exemplo n.º 22
0
 public override object GetValue(DatabaseBase database, DbDataReader dataReader, int columnIndex)
 {
     if (dataReader.IsDBNull(columnIndex))
     {
         return(null);
     }
     return(new Guid?(dataReader.GetGuid(columnIndex)));
 }
Exemplo n.º 23
0
 private string GetSql(DatabaseBase database, Parameters parameters)
 {
     if (database == null)
     {
         throw new NullReferenceException("database cannot be null");
     }
     return(QueryBuilderFactory.GetUpdateQuery(database, this, parameters));
 }
Exemplo n.º 24
0
        /// <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;
        }
Exemplo n.º 25
0
        /// <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;
        }
Exemplo n.º 26
0
        /// <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());
        }
Exemplo n.º 27
0
        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;
        }
Exemplo n.º 28
0
        /// <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 = ?";
        }
Exemplo n.º 29
0
        /// <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);
        }
Exemplo n.º 30
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);
        }