示例#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);
        }
      });

    }
示例#2
0
 private void _processCallback(AjaxRequestDelegate callback, Object sender, AjaxResponseEventArgs args) {
   //Utl.UiThreadInvoke(() => {
     if (callback != null) callback(sender, args);
     this._processQueue();
   //});
 }
示例#3
0
 public void Rollback(AjaxRequestDelegate callback) {
   this._exec(null, callback, SQLTransactionCmd.Rollback, false);
 }
示例#4
0
 public void Commit(AjaxRequestDelegate callback) {
   this._exec(null, callback, SQLTransactionCmd.Commit, false);
 }
示例#5
0
 public void Exec(Params bioPrms, AjaxRequestDelegate callback, Boolean silent) {
   this._exec(bioPrms, callback, SQLTransactionCmd.Nop, silent);
 }
示例#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);
 }
示例#10
0
 public void LoadSelectedPks(AjaxRequestDelegate callback, String selection) {
   this._load(CJSRequestGetType.GetSelectedPks, null, callback, null, 0, null, selection);
 }
示例#11
0
    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);
      }
    }
示例#12
0
 public void Load(AjaxRequestDelegate callback) {
   this.Load(null, callback);
 }
示例#13
0
 public void Load(Params bioPrms, AjaxRequestDelegate callback) {
   this.Load(bioPrms, callback, null);
 }
示例#14
0
 public void Load(Params bioPrms, AjaxRequestDelegate callback, JsonStoreFilter locate) {
   this.Load(bioPrms, callback, locate, null, null);
 }
示例#15
0
 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;
 }
示例#16
0
 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;
 }
示例#17
0
 public void runProc(Params bioParams, String selection, AjaxRequestDelegate callback) {
   this.Selection = selection;
   //this.ExecBioParams = execBioParams;
   this.RunProc(bioParams, callback);
 }
示例#18
0
    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);


      });
    }