public void Execute() { try { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_backup); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_bkp_file, "stdout"); StartSpb.Append(IscCodes.isc_spb_options, (int)Options); Open(); StartTask(); ReadOutput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void Start(string sessionName) { try { string config = DatabasesConfigurations.ToString() + (ServiceConfiguration != null ? ServiceConfiguration.ToString() : string.Empty); StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_trace_start); if (!string.IsNullOrEmpty(sessionName)) StartSpb.Append(IscCodes.isc_spb_trc_name, sessionName); StartSpb.Append(IscCodes.isc_spb_trc_cfg, config); Open(); StartTask(); ProcessServiceOutput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void Execute() { try { StartSpb = new ServiceParameterBuffer(); // Configure Spb StartSpb.Append(IscCodes.isc_action_svc_db_stats); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_options, (int)_options); Open(); // Start execution StartTask(); // Process service output ProcessServiceOutput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void Execute() { if (string.IsNullOrEmpty(Database)) { throw new FbException("Validation should be used against a specific database"); } try { StartSpb = new ServiceParameterBuffer(); // Configure Spb StartSpb.Append(IscCodes.isc_action_svc_repair); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_options, (int)_options); Open(); // Start execution StartTask(); // Process service output ProcessServiceOutput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void SetSweepInterval(int sweepInterval) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_prp_sweep_interval, sweepInterval); Open(); StartTask(); Close(); }
public void SetPageBuffers(int pageBuffers) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_prp_page_buffers, pageBuffers); Open(); StartTask(); Close(); }
public void SetSqlDialect(int sqlDialect) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_prp_set_sql_dialect, sqlDialect); Open(); StartTask(); Close(); }
public void Execute() { try { // Configure Spb StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_get_ib_log); Open(); // Start execution StartTask(); // Process service output ProcessServiceOutput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void Execute() { try { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_restore); foreach (FbBackupFile bkpFile in _backupFiles) { StartSpb.Append(IscCodes.isc_spb_bkp_file, bkpFile.BackupFile); } StartSpb.Append(IscCodes.isc_spb_dbname, Database); if (Verbose) { StartSpb.Append(IscCodes.isc_spb_verbose); } if (PageBuffers.HasValue) StartSpb.Append(IscCodes.isc_spb_res_buffers, (int)PageBuffers); if (_pageSize.HasValue) StartSpb.Append(IscCodes.isc_spb_res_page_size, (int)_pageSize); StartSpb.Append(IscCodes.isc_spb_res_access_mode, (byte)(ReadOnly ? IscCodes.isc_spb_res_am_readonly : IscCodes.isc_spb_res_am_readwrite)); StartSpb.Append(IscCodes.isc_spb_options, (int)Options); Open(); StartTask(); if (Verbose) { ProcessServiceOutput(); } } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void Execute() { try { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_restore); StartSpb.Append(IscCodes.isc_spb_bkp_file, "stdin"); StartSpb.Append(IscCodes.isc_spb_dbname, Database); if (Verbose) { StartSpb.Append(IscCodes.isc_spb_verbose); } if (PageBuffers.HasValue) StartSpb.Append(IscCodes.isc_spb_res_buffers, (int)PageBuffers); if (pageSize.HasValue) StartSpb.Append(IscCodes.isc_spb_res_page_size, (int)pageSize); StartSpb.Append(IscCodes.isc_spb_options, (int)Options); Open(); StartTask(); ReadInput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void Execute() { try { // Configure Spb StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_nbak); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_nbk_level, _level); StartSpb.Append(IscCodes.isc_spb_nbk_file, BackupFile); StartSpb.Append(IscCodes.isc_spb_nbk_direct, DirectIO ? "ON" : "OFF"); StartSpb.Append(IscCodes.isc_spb_options, (int)Options); Open(); // Start execution StartTask(); ProcessServiceOutput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { // Close Close(); } }
public void Execute() { try { // Configure Spb StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_backup); StartSpb.Append(IscCodes.isc_spb_dbname, Database); foreach (FbBackupFile file in _backupFiles) { StartSpb.Append(IscCodes.isc_spb_bkp_file, file.BackupFile); if (file.BackupLength.HasValue) StartSpb.Append(IscCodes.isc_spb_bkp_length, (int)file.BackupLength); } if (Verbose) { StartSpb.Append(IscCodes.isc_spb_verbose); } StartSpb.Append(IscCodes.isc_spb_options, (int)Options); Open(); // Start execution StartTask(); if (Verbose) { ProcessServiceOutput(); } } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { // Close Close(); } }
void ReadInput() { var items = Verbose ? new byte[] { IscCodes.isc_info_svc_stdin, IscCodes.isc_info_svc_line } : new byte[] { IscCodes.isc_info_svc_stdin }; var response = Query(items); var length = GetLength(response); while (InputStream.Position < InputStream.Length) { if (length > 0) { var buffer = new byte[length]; var read = InputStream.Read(buffer, 0, length); Array.Resize(ref buffer, read); var spb = new ServiceParameterBuffer(); spb.Append(IscCodes.isc_info_svc_line, buffer); QuerySpb = spb; } response = Query(items); QuerySpb = null; length = GetLength(response); ProcessMessages(response); } while (ProcessMessages(Query(items))) ; }
void DoSimpleAction(int action, int? sessionID = null) { try { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(action); if (sessionID.HasValue) StartSpb.Append(IscCodes.isc_spb_trc_id, (int)sessionID); Open(); StartTask(); ProcessServiceOutput(); } catch (Exception ex) { throw new FbException(ex.Message, ex); } finally { Close(); } }
public void DatabaseShutdown(FbShutdownMode mode, int seconds) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); switch (mode) { case FbShutdownMode.Forced: StartSpb.Append(IscCodes.isc_spb_prp_shutdown_db, seconds); break; case FbShutdownMode.DenyTransaction: StartSpb.Append(IscCodes.isc_spb_prp_deny_new_transactions, seconds); break; case FbShutdownMode.DenyConnection: StartSpb.Append(IscCodes.isc_spb_prp_deny_new_attachments, seconds); break; } Open(); StartTask(); Close(); }
public FbUserData DisplayUser(string userName) { // Configure Spb StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_display_user); StartSpb.Append(IscCodes.isc_spb_sec_username, userName); Open(); // Start execution StartTask(); ArrayList info = Query(new byte[] { IscCodes.isc_info_svc_get_users }); Close(); if (info.Count == 0) { return null; } FbUserData[] users = (FbUserData[])info[0]; return (users != null && users.Length > 0) ? users[0] : null; }
public void DatabaseShutdown2(FbShutdownOnlineMode mode, FbShutdownType type, int seconds) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_prp_shutdown_mode, FbShutdownOnlineModeToIscCode(mode)); switch (type) { case FbShutdownType.ForceShutdown: StartSpb.Append(IscCodes.isc_spb_prp_force_shutdown, seconds); break; case FbShutdownType.AttachmentsShutdown: StartSpb.Append(IscCodes.isc_spb_prp_attachments_shutdown, seconds); break; case FbShutdownType.TransactionsShutdown: StartSpb.Append(IscCodes.isc_spb_prp_transactions_shutdown, seconds); break; } Open(); StartTask(); Close(); }
public void AddUser(FbUserData user) { if (user.UserName != null && user.UserName.Length == 0) { throw new InvalidOperationException("Invalid user name."); } if (user.UserPassword != null && user.UserPassword.Length == 0) { throw new InvalidOperationException("Invalid user password."); } // Configure Spb StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_add_user); StartSpb.Append(IscCodes.isc_spb_sec_username, user.UserName); StartSpb.Append(IscCodes.isc_spb_sec_password, user.UserPassword); if (user.FirstName != null && user.FirstName.Length > 0) { StartSpb.Append(IscCodes.isc_spb_sec_firstname, user.FirstName); } if (user.MiddleName != null && user.MiddleName.Length > 0) { StartSpb.Append(IscCodes.isc_spb_sec_middlename, user.MiddleName); } if (user.LastName != null && user.LastName.Length > 0) { StartSpb.Append(IscCodes.isc_spb_sec_lastname, user.LastName); } if (user.UserID != 0) { StartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID); } if (user.GroupID != 0) { StartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID); } if (user.GroupName != null && user.GroupName.Length > 0) { StartSpb.Append(IscCodes.isc_spb_sec_groupname, user.GroupName); } if (user.RoleName != null && user.RoleName.Length > 0) { StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName); } Open(); // Start execution StartTask(); Close(); }
public void SetAccessMode(bool readOnly) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_prp_access_mode, (byte)(readOnly ? IscCodes.isc_spb_prp_am_readonly : IscCodes.isc_spb_prp_am_readwrite)); Open(); StartTask(); Close(); }
public void SetReserveSpace(bool reserveSpace) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); if (reserveSpace) { StartSpb.Append(IscCodes.isc_spb_prp_reserve_space, (byte)IscCodes.isc_spb_prp_res); } else { StartSpb.Append(IscCodes.isc_spb_prp_reserve_space, (byte)IscCodes.isc_spb_prp_res_use_full); } Open(); StartTask(); Close(); }
public void ActivateShadows() { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_activate); Open(); StartTask(); Close(); }
public void DatabaseOnline2(FbShutdownOnlineMode mode) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); StartSpb.Append(IscCodes.isc_spb_prp_online_mode, FbShutdownOnlineModeToIscCode(mode)); Open(); StartTask(); Close(); }
internal ServiceParameterBuffer BuildSpb() { ServiceParameterBuffer spb = new ServiceParameterBuffer(); // SPB configuration spb.Append(IscCodes.isc_spb_version); spb.Append(IscCodes.isc_spb_current_version); spb.Append((byte)IscCodes.isc_spb_user_name, this.csManager.UserID); spb.Append((byte)IscCodes.isc_spb_password, this.csManager.Password); spb.Append((byte)IscCodes.isc_spb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); if (this.csManager.Role != null && this.csManager.Role.Length > 0) { spb.Append((byte)IscCodes.isc_spb_sql_role_name, this.csManager.Role); } return spb; }
public FbUserData[] DisplayUsers() { // Configure Spb StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_display_user); Open(); // Start execution StartTask(); ArrayList info = Query(new byte[] { IscCodes.isc_info_svc_get_users }); Close(); if (info.Count == 0) { return null; } return (FbUserData[])info[0]; }
public void SetForcedWrites(bool forcedWrites) { StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_properties); StartSpb.Append(IscCodes.isc_spb_dbname, Database); if (forcedWrites) { StartSpb.Append(IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_sync); } else { StartSpb.Append(IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_async); } Open(); StartTask(); Close(); }
public void DeleteUser(FbUserData user) { if (user.UserName != null && user.UserName.Length == 0) { throw new InvalidOperationException("Invalid user name."); } // Configure Spb StartSpb = new ServiceParameterBuffer(); StartSpb.Append(IscCodes.isc_action_svc_delete_user); StartSpb.Append(IscCodes.isc_spb_sec_username, user.UserName); if (user.RoleName != null && user.RoleName.Length > 0) { StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName); } Open(); // Start execution StartTask(); Close(); }