コード例 #1
0
    public IDbConnection CreateConnection(String connStr, String workspaceSchema, Action<DBConnBeforeEventArgs> beforeDBConnectCallback, 
                                                                  Action<DBConnAfterEventArgs> afterDBConnectCallback) {
      if (beforeDBConnectCallback != null) {
        var args = new DBConnBeforeEventArgs {
          Cancel = false,
          ConnectionString = connStr
        };
        beforeDBConnectCallback(args);
        if (args.Cancel) return null;
        connStr = args.ConnectionString; 
      }
      IDbConnection result = this._factory.CreateConnection();
      if (!String.IsNullOrEmpty(connStr) && (result != null)) {
        result.ConnectionString = connStr;
        try {
          result.Open();
        } catch (ThreadAbortException) {
          throw;
        } catch (Exception ex) {
          throw new EBioDBConnectionError("Ошибка соединения с базой данных. Сообщение сервера: " + ex.Message, ex);
        }
        if (!String.IsNullOrEmpty(workspaceSchema)) {
          SQLCmd.ExecuteScript(result, "ALTER SESSION SET CURRENT_SCHEMA=" + workspaceSchema.ToUpper(), null, 60);
        }
        if (afterDBConnectCallback != null) {
          var args = new DBConnAfterEventArgs {
            Connection = result
          };
          afterDBConnectCallback(args);
        }

      }
      return result;
    }
コード例 #2
0
ファイル: DBSession.cs プロジェクト: tormoz70/Bio.Framework.8
 private void _beforeDBConnectCallback(DBConnBeforeEventArgs args) {
   var e = this.BeforeDBConnectEvent;
   if (e != null)
     e(this, args);
 }