Skip to content

Commit

Permalink
* Proper fix for DNET-146.
Browse files Browse the repository at this point in the history
* Small refactoring.
  • Loading branch information
cincuranet committed Mar 10, 2012
1 parent 51f5c0f commit 87f0280
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 14 deletions.
2 changes: 2 additions & 0 deletions NETProvider/source/FirebirdSql/Data/Services/FbBackup.cs
Expand Up @@ -101,6 +101,8 @@ public void Execute()

this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);

this.Open();

// Start execution
this.StartTask();

Expand Down
16 changes: 16 additions & 0 deletions NETProvider/source/FirebirdSql/Data/Services/FbConfiguration.cs
Expand Up @@ -44,6 +44,8 @@ public void SetSqlDialect(int sqlDialect)
this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
this.StartSpb.Append(IscCodes.isc_spb_prp_set_sql_dialect, sqlDialect);

this.Open();

// Start execution
this.StartTask();

Expand All @@ -59,6 +61,8 @@ public void SetSweepInterval(int sweepInterval)
this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
this.StartSpb.Append(IscCodes.isc_spb_prp_sweep_interval, sweepInterval);

this.Open();

// Start execution
this.StartTask();

Expand All @@ -74,6 +78,8 @@ public void SetPageBuffers(int pageBuffers)
this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
this.StartSpb.Append(IscCodes.isc_spb_prp_page_buffers, pageBuffers);

this.Open();

// Start execution
this.StartTask();

Expand Down Expand Up @@ -118,6 +124,8 @@ public void DatabaseOnline()
this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
this.StartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_db_online);

this.Open();

// Start execution
this.StartTask();

Expand All @@ -133,6 +141,8 @@ public void ActivateShadows()
this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
this.StartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_activate);

this.Open();

// Start execution
this.StartTask();

Expand All @@ -157,6 +167,8 @@ public void SetForcedWrites(bool forcedWrites)
this.StartSpb.Append(IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_async);
}

this.Open();

// Start execution
this.StartTask();

Expand All @@ -180,6 +192,8 @@ public void SetReserveSpace(bool reserveSpace)
this.StartSpb.Append(IscCodes.isc_spb_prp_reserve_space, (byte)IscCodes.isc_spb_prp_res_use_full);
}

this.Open();

// Start execution
this.StartTask();

Expand All @@ -203,6 +217,8 @@ public void SetAccessMode(bool readOnly)
this.StartSpb.Append(IscCodes.isc_spb_prp_access_mode, (byte)IscCodes.isc_spb_prp_am_readwrite);
}

this.Open();

// Start execution
this.StartTask();

Expand Down
2 changes: 2 additions & 0 deletions NETProvider/source/FirebirdSql/Data/Services/FbLog.cs
Expand Up @@ -45,6 +45,8 @@ public void Execute()

this.StartSpb.Append(IscCodes.isc_action_svc_get_ib_log);

this.Open();

// Start execution
this.StartTask();

Expand Down
2 changes: 2 additions & 0 deletions NETProvider/source/FirebirdSql/Data/Services/FbRestore.cs
Expand Up @@ -120,6 +120,8 @@ public void Execute()
this.StartSpb.Append(IscCodes.isc_spb_res_page_size, (int)this.pageSize);
this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);

this.Open();

// Start execution
this.StartTask();

Expand Down
14 changes: 12 additions & 2 deletions NETProvider/source/FirebirdSql/Data/Services/FbSecurity.cs
Expand Up @@ -17,6 +17,8 @@
*/

using System;
using System.Collections;

using FirebirdSql.Data.Common;

namespace FirebirdSql.Data.Services
Expand Down Expand Up @@ -88,6 +90,8 @@ public void AddUser(FbUserData user)
this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
}

this.Open();

// Start execution
this.StartTask();

Expand All @@ -113,6 +117,8 @@ public void DeleteUser(FbUserData user)
this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
}

this.Open();

// Start execution
this.StartTask();

Expand Down Expand Up @@ -169,6 +175,8 @@ public void ModifyUser(FbUserData user)
this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
}

this.Open();

// Start execution
this.StartTask();

Expand All @@ -183,12 +191,14 @@ public FbUserData DisplayUser(string userName)
this.StartSpb.Append(IscCodes.isc_action_svc_display_user);
this.StartSpb.Append(IscCodes.isc_spb_sec_username, userName);

this.Open();

// Start execution
this.StartTask();

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

System.Collections.ArrayList info = base.ParseQueryInfo(buffer);
ArrayList info = base.ParseQueryInfo(buffer);

this.Close();

Expand All @@ -214,7 +224,7 @@ public FbUserData[] DisplayUsers()

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

System.Collections.ArrayList info = base.ParseQueryInfo(buffer);
ArrayList info = base.ParseQueryInfo(buffer);

this.Close();

Expand Down
12 changes: 1 addition & 11 deletions NETProvider/source/FirebirdSql/Data/Services/FbService.cs
Expand Up @@ -199,12 +199,9 @@ protected void Close()

protected void StartTask()
{
bool shouldClose = false;
if (this.state == FbServiceState.Closed)
{
// Attach to Service Manager
this.Open();
shouldClose = true;
throw new InvalidOperationException("Service is Closed.");
}

try
Expand All @@ -216,13 +213,6 @@ protected void StartTask()
{
throw new FbException(ex.Message, ex);
}
finally
{
if (shouldClose)
{
this.Close();
}
}
}

protected byte[] QueryService(byte[] items)
Expand Down
2 changes: 2 additions & 0 deletions NETProvider/source/FirebirdSql/Data/Services/FbStatistical.cs
Expand Up @@ -62,6 +62,8 @@ public void Execute()
this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);

this.Open();

// Start execution
this.StartTask();

Expand Down
2 changes: 2 additions & 0 deletions NETProvider/source/FirebirdSql/Data/Services/FbTrace.cs
Expand Up @@ -53,6 +53,7 @@ public void Start(string sessionName)
this.StartSpb.Append(IscCodes.isc_spb_trc_name, sessionName);
this.StartSpb.Append(IscCodes.isc_spb_trc_cfg, config);

this.Open();
this.StartTask();
this.ProcessServiceOutput();
}
Expand Down Expand Up @@ -97,6 +98,7 @@ void DoSimpleAction(int action, int? sessionID = null)
if (sessionID.HasValue)
this.StartSpb.Append(IscCodes.isc_spb_trc_id, (int)sessionID);

this.Open();
this.StartTask();
this.ProcessServiceOutput();
}
Expand Down
4 changes: 3 additions & 1 deletion NETProvider/source/FirebirdSql/Data/Services/FbValidation.cs
Expand Up @@ -54,7 +54,7 @@ public FbValidation()

public void Execute()
{
if (String.IsNullOrEmpty(this.Database))
if (string.IsNullOrEmpty(this.Database))
{
throw new FbException("Validation should be used against a specific database");
}
Expand All @@ -68,6 +68,8 @@ public void Execute()
this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);

this.Open();

// Start execution
this.StartTask();

Expand Down

0 comments on commit 87f0280

Please sign in to comment.