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);
        }
      });

    }
Beispiel #2
0
 private void _processCallback(AjaxRequestDelegate callback, Object sender, AjaxResponseEventArgs args) {
   //Utl.UiThreadInvoke(() => {
     if (callback != null) callback(sender, args);
     this._processQueue();
   //});
 }
Beispiel #3
0
 public void Rollback(AjaxRequestDelegate callback) {
   this._exec(null, callback, SQLTransactionCmd.Rollback, false);
 }
Beispiel #4
0
 public void Commit(AjaxRequestDelegate callback) {
   this._exec(null, callback, SQLTransactionCmd.Commit, false);
 }
Beispiel #5
0
 public void Exec(Params bioPrms, AjaxRequestDelegate callback, Boolean silent) {
   this._exec(bioPrms, callback, SQLTransactionCmd.Nop, silent);
 }
Beispiel #6
0
 public void Exec(Params bioPrms, AjaxRequestDelegate callback) {
   this._exec(bioPrms, callback, SQLTransactionCmd.Nop, false);
 }
 public void Load(Params bioPrms, AjaxRequestDelegate callback, JsonStoreFilter locate, Int64? pageSize, Int64? startFrom) {
   this._load(CJSRequestGetType.GetData, bioPrms, callback, locate, pageSize, startFrom, null);
 }
 public void Post(AjaxRequestDelegate callback, String trunsactionID) {
   this._post(callback, trunsactionID, SQLTransactionCmd.Nop);
 }
 public void Post(AjaxRequestDelegate callback) {
   this._post(callback, null, SQLTransactionCmd.Nop);
 }
 public void LoadSelectedPks(AjaxRequestDelegate callback, String selection) {
   this._load(CJSRequestGetType.GetSelectedPks, null, callback, null, 0, null, selection);
 }
    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);
      }
    }
 public void Load(AjaxRequestDelegate callback) {
   this.Load(null, callback);
 }
 public void Load(Params bioPrms, AjaxRequestDelegate callback) {
   this.Load(bioPrms, callback, null);
 }
 public void Load(Params bioPrms, AjaxRequestDelegate callback, JsonStoreFilter locate) {
   this.Load(bioPrms, callback, locate, null, null);
 }
 internal override RmtClientRequest createRequest(RmtClientRequestCmd cmd, Params bioParams, Boolean silent, AjaxRequestDelegate callback) {
   var rslt = this.creRequestOfClient<DSFetchClientRequest>(cmd, bioParams, silent, callback);
   rslt.ExecBioCode = this.ExecBioCode;
   return rslt;
 }
 internal override RmtClientRequest createRequest(RmtClientRequestCmd cmd, Params bioParams, Boolean silent, AjaxRequestDelegate callback) {
   var rslt = this.creRequestOfClient<LongOpClientRequest>(cmd, bioParams, silent, callback);
   rslt.Pipe = this.PipeName;
   rslt.SessionUID = this.SessionUID;
   return rslt;
 }
 public void runProc(Params bioParams, String selection, AjaxRequestDelegate callback) {
   this.Selection = selection;
   //this.ExecBioParams = execBioParams;
   this.RunProc(bioParams, callback);
 }
    private void _load (
      CJSRequestGetType getType,
      Params bioPrms, 
      AjaxRequestDelegate callback, 
      JsonStoreFilter locate, 
      Int64? pageSize,
      Int64? startFrom,
      String selection
    ) {
      var v_selection = selection;
      var v_locate = locate;
      if (pageSize.HasValue)
        this.PageSize = pageSize.Value;
      if (startFrom.HasValue)
        this.StartFrom = startFrom.Value;

      if (this.AjaxMng == null)
        throw new EBioException("Свойство \"ajaxMng\" должно быть определено!");
      if (String.IsNullOrEmpty(this.BioCode))
        throw new EBioException("Свойство \"bioCode\" должно быть определено!");

      this._doBeforLoadData(bla => {
        if (bla.Cancel) {
          return;
        }
        if (bioPrms != null) {
          if (this.BioParams == null)
            this.BioParams = bioPrms.Clone() as Params;
          else {
            this.BioParams.Clear();
            this.BioParams = this.BioParams.Merge(bioPrms, true);
          }
        } else {
          if (this.BioParams == null)
            this.BioParams = new Params();
        }

        var isMetadataObsolete = false;
        var isFirstLoad = false;
        this._detectIsFirstLoad(this.BioCode, this.BioParams, ref isMetadataObsolete, ref isFirstLoad);
        if (isFirstLoad) {
          this.StartFrom = 0;
        }

        this._lastRequestedBioCode = this.BioCode;
        JsonStoreSort sortDefinition = null;
        if (!isMetadataObsolete && (this.DS0 != null)) {
          var cv = (this.DS0 as ICollectionView);
          if (cv != null)
            sortDefinition = this._genJSSortDefinition(cv.SortDescriptions);
        }

        this._lastRequestedParams = (Params)this.BioParams.Clone();
        var reqst = new JsonStoreRequestGet {
          BioCode = this.BioCode,
          getType = getType,
          BioParams = this.BioParams,
          Prms = null,
          Packet = new JsonStoreData {
            Limit = this.PageSize,
            Start = this.StartFrom,
            IsFirstLoad = isFirstLoad,
            IsMetadataObsolete = isMetadataObsolete,
            Locate = v_locate
          },
          Sort = sortDefinition,
          selection = v_selection,
          Callback = (sndr, args) => {
            try {
              Type rowType = null;
              var rq = (JsonStoreRequest)args.Request;
              var rsp = args.Response as JsonStoreResponse;
              if (rsp != null) {
                if ((rsp.packet != null) && (rsp.packet.Rows != null)) {
                  if (BioGlobal.Debug) {
                    if (rsp.Ex != null)
                      throw new EBioException("Unhandled exception!!!! silent:[" + rq.Silent + "]", rsp.Ex);
                  }
                  if (rq.Packet.IsMetadataObsolete) {
                    this._metadata = rsp.packet.MetaData;
                    var fldDefs = _creFldDefsRmt(this._metadata);
                    rowType = this._creRowType(fldDefs);
                    this.DS0 = this._creDSInst(rowType);
                  }

                  this._doOnJsonStoreResponseSuccess(rq, rsp);

                  this._loadDS(rowType, rsp);

                  this._doOnJsonStoreDSLoaded(this.DS0, rq, rsp);

                  if (rq.Packet.Locate != null) 
                    this._lastLocatedRow = this._locateInternal(rq.Packet.Locate);

                } else {
                  if (BioGlobal.Debug) {
                    var m = "Bad response: ";
                    if (rsp.packet == null)
                      m = m + "rsp.packet=null;";
                    else if (rsp.packet.Rows == null)
                      m = m + "rsp.packet.rows=null;";
                    throw new EBioException(m);
                  }
                }
              } else {
                //if (BioGlobal.Debug) {
                //  var biorsp = args.Response as BioResponse;
                //  if (biorsp == null)
                //    throw new EBioException("Bad response: biorsp=null");
                //}
              }
            } finally {
              this._doOnAfterLoadData(args);
              if (callback != null) callback(this, args);
            }
          }
        };
        this.AjaxMng.Request(reqst);


      });
    }