标签:
所谓的“真3层”有时候是需要客户端上传数据集的TPARAMS到中间件的。
现在,高版本的DATASNAP的远程方法其实也是直接可以传输TPARAMS类型的变量,但是DELPHI7(七爷)、六爷它们是不支持的。
高版本的DATASNAP要让六爷、七爷它们调用,不能直接传TPARAMS,得转换。
procedure VariantToParams(input: OleVariant; par: TParams);
var
  n, i: integer;
begin
  try
    n := 0;
    i := 0;
    par.Clear;
    while VarArrayHighBound(input, 1) >= (n + 5) do
    begin
      par.CreateParam(TFieldType(input[n + 1]), input[n + 2], TParamType(input[n + 4]));
      par.Items[i].Value := input[n + 3];
      par.Items[i].Size := input[n + 5];
      n := n + 5;
      i := i + 1;
    end;
  except
    Exit;
  end;
end;
function ParamsToVariant(par: TParams): OleVariant;
var
  n, i: integer;
begin
  try
    Result := VarArrayCreate([1, par.Count * 5], VarVariant);
    n := 0;
    i := 0;
    while par.Count > i do
    begin
      Result[n + 1] := Ord(par.Items[i].DataType);
      Result[n + 2] := par.Items[i].Name;
      Result[n + 3] := par.Items[i].Value;
      Result[n + 4] := ord(par.Items[i].ParamType);
      Result[n + 5] := par.Items[i].Size;
      i := i + 1;
      n := n + 4;
    end;
    result := Result;
  except
    Exit;
  end;
end;
标签:
原文地址:http://www.cnblogs.com/hnxxcxg/p/4887962.html