コード例 #1
0
		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();
			}
		}
コード例 #2
0
		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();
			}
		}
コード例 #3
0
		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();
			}
		}
コード例 #4
0
		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();
			}
		}
コード例 #5
0
		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();
		}
コード例 #6
0
		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();
		}
コード例 #7
0
		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();
		}
コード例 #8
0
		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();
			}
		}
コード例 #9
0
		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();
			}
		}
コード例 #10
0
		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();
			}
		}
コード例 #11
0
		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();
			}
		}
コード例 #12
0
		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();
			}
		}
コード例 #13
0
		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))) ;
		}
コード例 #14
0
		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();
			}
		}
コード例 #15
0
		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();
		}
コード例 #16
0
		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;
		}
コード例 #17
0
		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();
		}
コード例 #18
0
		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();
		}
コード例 #19
0
		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();
		}
コード例 #20
0
		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();
		}
コード例 #21
0
		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();
		}
コード例 #22
0
		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();
		}
コード例 #23
0
		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;
		}
コード例 #24
0
		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];
		}
コード例 #25
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();
		}
コード例 #26
0
		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();
		}