コード例 #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 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();
			}
		}
コード例 #3
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();
		}
コード例 #4
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();
			}
		}
コード例 #5
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();
			}
		}
コード例 #6
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();
			}
		}
コード例 #7
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();
			}
		}
コード例 #8
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();
			}
		}
コード例 #9
0
		public void Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
		{
			GenericResponse response = null;

			lock (this)
			{
				try
				{
					_database.XdrStream.Write(IscCodes.op_service_attach);
					_database.XdrStream.Write(0);
					_database.XdrStream.Write(service);
					_database.XdrStream.WriteBuffer(spb.ToArray());
					_database.XdrStream.Flush();

					response = _database.ReadGenericResponse();

					_handle = response.ObjectHandle;
				}
				catch (IOException ex)
				{
					_database.Detach();
					throw IscException.ForErrorCode(IscCodes.isc_net_write_err, ex);
				}
			}
		}
コード例 #10
0
		public void Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
		{
			GenericResponse response = null;

			lock (this)
			{
				try
				{
					this.database.Write(IscCodes.op_service_attach);
					this.database.Write(0);
					this.database.Write(service);
					this.database.WriteBuffer(spb.ToArray());
					this.database.Flush();

					response = this.database.ReadGenericResponse();

					this.handle = response.ObjectHandle;
				}
				catch (IOException)
				{
					this.database.Detach();

					throw new IscException(IscCodes.isc_net_write_err);
				}
			}
		}
コード例 #11
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();
		}
コード例 #12
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();
		}
コード例 #13
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();
		}
コード例 #14
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();
			}
		}
コード例 #15
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();
			}
		}
コード例 #16
0
		public void Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
		{
			lock (this)
			{
				try
				{
					if (this.connection == null)
					{
						this.connection = new GdsConnection();
					}

					this.connection.Connect(dataSource, port, 8192, Charset.DefaultCharset);

					this.connection.Send.Write(IscCodes.op_service_attach);
					this.connection.Send.Write(0);
					this.connection.Send.Write(service);
					this.connection.Send.WriteBuffer(spb.ToArray());
					this.connection.Send.Flush();

					try
					{
						this.handle = this.connection.ReadGenericResponse().ObjectHandle;
					}
					catch (IscException)
					{
						try
						{
							this.Detach();
						}
						catch
						{
						}

						throw;
					}
				}
				catch (IOException)
				{
					this.connection.Disconnect();

					throw new IscException(IscCodes.isc_net_write_err);
				}
			}
		}
コード例 #17
0
		public void Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
		{
			int[] statusVector = ExtConnection.GetNewStatusVector();
			int svcHandle = this.Handle;

			SafeNativeMethods.isc_service_attach(
				statusVector,
				(short)service.Length,
				service,
				ref	svcHandle,
				(short)spb.Length,
				spb.ToArray());

			// Parse status	vector
			this.ParseStatusVector(statusVector);

			// Update status vector
			this.handle = svcHandle;
		}
コード例 #18
0
		public void Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
		{
			// Clear the status vector
			this.ClearStatusVector();

			int svcHandle = this.Handle;

			fbClient.isc_service_attach(
				this.statusVector,
				(short)service.Length,
				service,
				ref	svcHandle,
				(short)spb.Length,
				spb.ToArray());

			// Parse status	vector
			this.ParseStatusVector(this.statusVector);

			// Update status vector
			this.handle = svcHandle;
		}
コード例 #19
0
		public void Start(ServiceParameterBuffer spb)
		{
			lock (this)
			{
				try
				{
					this.database.Write(IscCodes.op_service_start);
					this.database.Write(this.Handle);
					this.database.Write(0);
					this.database.WriteBuffer(spb.ToArray(), spb.Length);
					this.database.Flush();

					try
					{
						this.database.ReadResponse();
					}
					catch (IscException)
					{
						throw;
					}
				}
				catch (IOException)
				{
					throw new IscException(IscCodes.isc_net_write_err);
				}
			}
		}
コード例 #20
0
		public void Start(ServiceParameterBuffer spb)
		{
			int[] statusVector = ExtConnection.GetNewStatusVector();
			int svcHandle = this.Handle;
			int reserved = 0;

			SafeNativeMethods.isc_service_start(
				statusVector,
				ref	svcHandle,
				ref	reserved,
				(short)spb.Length,
				spb.ToArray());

			// Parse status	vector
			this.ParseStatusVector(statusVector);
		}
コード例 #21
0
		public void Query(
			ServiceParameterBuffer spb,
			int requestLength,
			byte[] requestBuffer,
			int bufferLength,
			byte[] buffer)
		{
			int[] statusVector = ExtConnection.GetNewStatusVector();
			int svcHandle = this.Handle;
			int reserved = 0;

			SafeNativeMethods.isc_service_query(
				statusVector,
				ref	svcHandle,
				ref	reserved,
				(short)spb.Length,
				spb.ToArray(),
				(short)requestLength,
				requestBuffer,
				(short)buffer.Length,
				buffer);

			// Parse status	vector
			this.ParseStatusVector(statusVector);
		}
コード例 #22
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();
		}
コード例 #23
0
 public abstract Task Query(ServiceParameterBuffer spb, int requestLength, byte[] requestBuffer, int bufferLength, byte[] buffer, AsyncWrappingCommonArgs async);
コード例 #24
0
		public void Start(ServiceParameterBuffer spb)
		{
			// Clear the status vector
			this.ClearStatusVector();

			int svcHandle = this.Handle;
			int reserved = 0;

			fbClient.isc_service_start(
				this.statusVector,
				ref	svcHandle,
				ref	reserved,
				(short)spb.Length,
				spb.ToArray());

			// Parse status	vector
			this.ParseStatusVector(this.statusVector);
		}
コード例 #25
0
 public abstract Task Attach(ServiceParameterBuffer spb, string dataSource, int port, string service, byte[] cryptKey, AsyncWrappingCommonArgs async);
コード例 #26
0
		protected string GetNextLine()
		{
			this.querySpb = new ServiceParameterBuffer();

			byte[] items = new byte[] { IscCodes.isc_info_svc_line };
			byte[] buffer = this.QueryService(items);

			ArrayList info = this.ParseQueryInfo(buffer);
			if (info.Count != 0)
			{
				return info[0] as string;
			}
			else
			{
				return null;
			}
		}
コード例 #27
0
		protected byte[] QueryService(byte[] items)
		{
			bool shouldClose = false;
			if (this.state == FbServiceState.Closed)
			{
				// Attach to Service Manager
				this.Open();
				shouldClose = true;
			}

			if (this.querySpb == null)
			{
				this.querySpb = new ServiceParameterBuffer();
			}

			try
			{
				// Response	buffer
				byte[] buffer = new byte[this.queryBufferSize];
				this.svc.Query(this.querySpb, items.Length, items, buffer.Length, buffer);
				return buffer;
			}
			finally
			{
				if (shouldClose)
				{
					this.Close();
				}
			}
		}
コード例 #28
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;
		}
コード例 #29
0
        protected byte[] QueryService(byte[] items)
        {
            if (this.state == FbServiceState.Closed)
            {
                // Attach to Service Manager
                this.Open();
            }

            if (this.querySpb == null)
            {
                this.querySpb = new ServiceParameterBuffer();
            }

            // Response	buffer
            byte[] buffer = new byte[this.queryBufferSize];

            this.svc.Query(this.querySpb, items.Length, items, buffer.Length, buffer);

            return buffer;
        }
コード例 #30
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))) ;
		}
コード例 #31
0
		public void Query(
			ServiceParameterBuffer	spb,
			int						requestLength,
			byte[]					requestBuffer,
			int						bufferLength,
			byte[]					buffer)
		{
			lock (this)
			{
				try
				{
					this.database.Write(IscCodes.op_service_info);	//	operation
					this.database.Write(this.Handle);				//	db_handle
					this.database.Write(0);										//	incarnation
					this.database.WriteBuffer(spb.ToArray(), spb.Length);		//	Service parameter buffer
					this.database.WriteBuffer(requestBuffer, requestLength);	//	request	buffer
					this.database.Write(bufferLength);				//	result buffer length

					this.database.Flush();

					GenericResponse response = this.database.ReadGenericResponse();

					int responseLength = bufferLength;

					if (response.Data.Length < bufferLength)
					{
						responseLength = response.Data.Length;
					}

					Buffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);
				}
				catch (IOException)
				{
					throw new IscException(IscCodes.isc_network_error);
				}
			}
		}
コード例 #32
0
 public abstract Task Start(ServiceParameterBuffer spb, AsyncWrappingCommonArgs async);
コード例 #33
0
		public void Query(
			ServiceParameterBuffer spb,
			int requestLength,
			byte[] requestBuffer,
			int bufferLength,
			byte[] buffer)
		{
			// Clear the status vector
			this.ClearStatusVector();

			int svcHandle = this.Handle;
			int reserved = 0;

			fbClient.isc_service_query(
				this.statusVector,
				ref	svcHandle,
				ref	reserved,
				(short)spb.Length,
				spb.ToArray(),
				(short)requestLength,
				requestBuffer,
				(short)buffer.Length,
				buffer);

			// Parse status	vector
			this.ParseStatusVector(this.statusVector);
		}