Beispiel #1
0
    private void _exec(Params bioPrms, AjaxRequestDelegate callback, SQLTransactionCmd cmd, Boolean silent) {
      if (this.AjaxMng == null)
        throw new EBioException("Свойство \"ajaxMng\" должно быть определено!");
      if (String.IsNullOrEmpty(this.BioCode))
        throw new EBioException("Свойство \"bioCode\" должно быть определено!");
      this.BioParams = Params.PrepareToUse(this.BioParams, bioPrms);

      this._lastRequestedBioCode = this.BioCode;
      this.AjaxMng.Request(new BioSQLRequest {
        RequestType = RequestType.SQLR,
        BioCode = this.BioCode,
        BioParams = this.BioParams,
        transactionCmd = cmd,
        transactionID = this.TransactionID,
        Prms = null,
        Silent = silent,
        Callback = (sndr, args) => {
          if (args.Response.Success) {
            var rsp = args.Response as BioResponse;
            if (rsp != null){
              this._lastReturnedParams = (rsp.BioParams != null) ? rsp.BioParams.Clone() as Params : null;
              this.TransactionID = rsp.TransactionID;
            }
          }
          if (callback != null) callback(this, args);
        }
      });

    }
    protected void FinishTransaction(IDbConnection vConn, Boolean isPostRequest, SQLTransactionCmd cmd) {
      if (!isPostRequest) {
        if (vConn != null) {
          vConn.Close();
          vConn.Dispose();
        }
        return;
      }

      var vCommited = false;
      if (this.AutoCommitTransaction || (cmd == SQLTransactionCmd.Commit)) {
        vCommited = true;
        if (!String.IsNullOrEmpty(this.TransactionID))
          this.BioSession.Cfg.dbSession.StoreTransaction(this.TransactionID, null);
      } else if (cmd == SQLTransactionCmd.Rollback)
        this.BioSession.Cfg.dbSession.KillTransaction(this.TransactionID);
      if (vCommited || (cmd == SQLTransactionCmd.Rollback)) {
        if (vConn != null) {
          vConn.Close();
          vConn.Dispose();
        }
      }
    }
Beispiel #3
0
 public void Exec(Params bioPrms, AjaxRequestDelegate callback, SQLTransactionCmd cmd) {
   this._exec(bioPrms, callback, cmd, false);
 }
Beispiel #4
0
 public void Exec(Params bioPrms, AjaxRequestDelegate callback, SQLTransactionCmd cmd, Boolean silent) {
   this._exec(bioPrms, callback, cmd, silent);
 }
 public void Post(AjaxRequestDelegate callback, String trunsactionID, SQLTransactionCmd cmd) {
   this._post(callback, trunsactionID, cmd);
 }
    private void _post(AjaxRequestDelegate callback, String trunsactionID, SQLTransactionCmd cmd) {
      if (this.AjaxMng == null)
        throw new EBioException("Свойство \"ajaxMng\" должно быть определено!");
      if (String.IsNullOrEmpty(this.BioCode))
        throw new EBioException("Свойство \"bioCode\" должно быть определено!");

      var cancel = false;
      this._doBeforPostData(ref cancel);
      if (cancel) {
        return;
      }

      if (this.BioParams == null)
        this.BioParams = new Params();

      var v_rows = this._getChangesAsJSRows();
      if (v_rows.Count > 0) {
        JsonStoreRequest reqst = new JsonStoreRequestPost {
          BioCode = this.BioCode,
          BioParams = this.BioParams,
          Prms = null,
          transactionID = trunsactionID,
          transactionCmd = cmd,
          Packet = new JsonStoreData {
            MetaData = this._metadata,
            Rows = v_rows
          },
          Callback = (sndr, args) => {
            if (args.Response.Success) {
              var rsp = args.Response as JsonStoreResponse;
              if ((rsp != null) && (rsp.packet != null)) {
                this._applyPostingResults(rsp.packet);
              }
              this._clearChanges();
            }
            if (callback != null) callback(this, args);
            this._doAfterPostData(args);
          }
        };
        this.AjaxMng.Request(reqst);
      } else {
        var v_args = new AjaxResponseEventArgs {
          Request = null,
          Response = new AjaxResponse {
            Ex = null,
            Success = true,
            ResponseText = String.Empty
          },
          Stream = null
        };
        if (callback != null) callback(this, v_args);
        this._doAfterPostData(v_args);
      }
    }