unit uss;

interface

uses
   emapi;

type
//   TRinComm = record
//      RITRXD, RITELLER, RIBRANCH, RISTATUS, RIRANK: String;
//   end;

//   TRoutComm = record
//      ROAVAIABLE, ROSTATEMENT, ROTRXSQNO, ROLIBID, ROWINDOWID, ROSYSDATE: String;
//      ROTRANSRVC: String;
//   end;

   TSinComm = record
      SIHOST, SIPORT: String;
      SITRXSRVC, SITRXD, SITRXSQNO, SITELLER, SIZONENO, SIBRANCH, SISTATUS, SIRANK, SISYSDATE: String;
   end;

   TTinComm = record
      TITRXD, TITRXSQNO, TITELLER, TIZONENO, TIBRANCH, TISTATUS, TIRANK, TISYSDATE: String;
      TIFIELD00, TIFIELD01, TIFIELD02, TIFIELD03, TIFIELD04: String;
      TIFIELD05, TIFIELD06, TIFIELD07, TIFIELD08, TIFIELD09: String;
      TIFIELD10, TIFIELD11, TIFIELD12, TIFIELD13, TIFIELD14: String;
      TIFIELD15, TIFIELD16, TIFIELD17, TIFIELD18, TIFIELD19: String;
   end;

   TSoutComm = record
      SOOVERID, SOSTATEMENT: String;
      SOFIELD00, SOFIELD01, SOFIELD02, SOFIELD03, SOFIELD04: String;
      SOFIELD05, SOFIELD06, SOFIELD07, SOFIELD08, SOFIELD09: String;
      SOFIELD10, SOFIELD11, SOFIELD12, SOFIELD13, SOFIELD14: String;
      SOFIELD15, SOFIELD16, SOFIELD17, SOFIELD18, SOFIELD19: String;
   end;


   TToutComm = record
      TOOVERID, TOSTATEMENT: String;
      TOFIELD00, TOFIELD01, TOFIELD02, TOFIELD03, TOFIELD04: String;
      TOFIELD05, TOFIELD06, TOFIELD07, TOFIELD08, TOFIELD09: String;
      TOFIELD10, TOFIELD11, TOFIELD12, TOFIELD13, TOFIELD14: String;
      TOFIELD15, TOFIELD16, TOFIELD17, TOFIELD18, TOFIELD19: String;
   end;

   TBuffer = record
      FIELD00, FIELD01, FIELD02, FIELD03, FIELD04: String;
      FIELD05, FIELD06, FIELD07, FIELD08, FIELD09: String;
      FIELD10, FIELD11, FIELD12, FIELD13, FIELD14: String;
      FIELD15, FIELD16, FIELD17, FIELD18, FIELD19: String;
   end;

const
   ID000 = 0;    OID000 = '0';    OSTATEMENT000 = '交易正常处理';
   ID001 = 1;    OID001 = '1';    OSTATEMENT001 = '交易不存在';
   ID002 = 2;    OID002 = '2';    OSTATEMENT002 = '柜员不存在';
   ID003 = 3;    OID003 = '3';    OSTATEMENT003 = '非本网点柜员';
   ID004 = 4;    OID004 = '4';    OSTATEMENT004 = '柜员状态不一致';
   ID005 = 5;    OID005 = '5';    OSTATEMENT005 = '柜员权限不足';
   ID006 = 6;    OID006 = '6';    OSTATEMENT006 = '界面位置未找到';
   ID007 = 7;    OID007 = '7';    OSTATEMENT007 = '交易界面未找到';
   ID008 = 8;    OID008 = '8';    OSTATEMENT008 = '交易处理成功';
   ID009 = 9;    OID009 = '9';    OSTATEMENT009 = '处理中遇到未知错误，交易失败';
   ID010 = 10;   OID010 = '10';   OSTATEMENT010 = '返回数据给终端';
   ID011 = 11;   OID011 = '11';   OSTATEMENT011 = '通信端口错，请检查服务器状态或网络状态';
   ID012 = 12;   OID012 = '12';   OSTATEMENT012 = '交易被取消';
   ID013 = 13;   OID013 = '13';   OSTATEMENT013 = '服务器交易处理进程未定义';
   ID014 = 14;   OID014 = '14';   OSTATEMENT014 = '密码错误';
   ID015 = 15;   OID015 = '15';   OSTATEMENT015 = '柜员已签到';
   ID016 = 16;   OID016 = '16';   OSTATEMENT016 = '交易处理错';
   ID017 = 17;   OID017 = '17';   OSTATEMENT017 = '柜员已签退';
   ID018 = 18;   OID018 = '18';   OSTATEMENT018 = '柜员未签到';
   ID019 = 19;   OID019 = '19';   OSTATEMENT019 = '柜员未签退';
   ID020 = 20;   OID020 = '20';   OSTATEMENT020 = '用户已销户';
   ID021 = 21;   OID021 = '21';   OSTATEMENT021 = '非当前使用柜员';
   ID022 = 22;   OID022 = '22';   OSTATEMENT022 = '系统柜员，禁止使用';
   ID023 = 23;   OID023 = '23';   OSTATEMENT023 = '管理柜员已存在';
   ID024 = 24;   OID024 = '24';   OSTATEMENT024 = '柜员级别不一致';

   RID000 = ID000;    RONORMAL        = OID000;   ROSTATNORMAL       = OSTATEMENT000;
   RID001 = ID009;    ROABNORMAL      = OID009;   ROSTATABNORMAL     = OSTATEMENT009;
   RID002 = ID001;    RONOTFOUNDTRX   = OID001;   ROSTATNOTFOUNDTRX  = OSTATEMENT001;
   RID003 = ID002;    RONOTFOUNDTEL   = OID002;   ROSTATNOTFOUNDTEL  = OSTATEMENT002;
   RID004 = ID006;    RONOTFOUNDLID   = OID006;   ROSTATNOTFOUNDLID  = OSTATEMENT006;
   RID005 = ID007;    RONOTFOUNDWID   = OID007;   ROSTATNOTFOUNDWID  = OSTATEMENT007;
   RID006 = ID003;    ROWRONGTELLER   = OID003;   ROSTATWRONGTELLER  = OSTATEMENT003;
   RID007 = ID004;    ROWRONGTELSTU   = OID004;   ROSTATWRONGTELSTU  = OSTATEMENT004;
   RID008 = ID005;    ROLOWRIGHTTEL   = OID005;   ROSTATLOWRIGHTTEL  = OSTATEMENT005;
   RID009 = ID011;    ROERRORCOMMPT   = OID011;   ROSTATERRORCOMMPT  = OSTATEMENT011;
   RID010 = ID014;    ROWRONGPASSWD   = OID014;   ROSTATWRONGPASSWD  = OSTATEMENT014;
   RID011 = ID015;    ROALEADYLOGON   = OID015;   ROSTATALEADYLOGON  = OSTATEMENT015;
   RID012 = ID016;    ROWRONGTRXWID   = OID016;   ROSTATWRONGTRXWID  = OSTATEMENT016;
   RID013 = ID017;    ROALEADYLOGOUT  = OID017;   ROSTATALEADYLOGOUT = OSTATEMENT017;
   RID014 = ID018;    ROHASNOTLOGON   = OID018;   ROSTATHASNOTLOGON  = OSTATEMENT018;
   RID015 = ID019;    ROHASNOTLOGOUT  = OID019;   ROSTATHASNOTLOGOUT = OSTATEMENT019;
   RID016 = ID020;    RONOTFOUNDBRNO  = OID020;   ROSTATNOTFOUNDBRNO = OSTATEMENT020;
   RID017 = ID024;    ROWRONGTELLVL   = OID024;   ROSTATWRONGTELLVL  = OSTATEMENT024;

   SID000 = ID000;    SONORMAL        = OID000;   SOSTATNORMAL        = OSTATEMENT000;
   SID001 = ID009;    SOABNORMAL      = OID009;   SOSTATABNORMAL      = OSTATEMENT009;
   SID002 = ID010;    SOTRANSFER      = OID010;   SOSTATTRANSFER      = OSTATEMENT010;
   SID003 = ID011;    SOERRORCOMMPT   = OID011;   SOSTATERRORCOMMPT   = OSTATEMENT011;
   SID004 = ID012;    SOCANCELEDTRX   = OID012;   SOSTATCANCELEDTRX   = OSTATEMENT012;
   SID005 = ID021;    SONOTCURTEL     = OID021;   SOSTATNOTCURTEL     = OSTATEMENT021;
   SID006 = ID022;    SOSYSTEMTELLER  = OID022;   SOSTATSYSTEMTELLER  = OSTATEMENT022;
   SID007 = ID023;    SOEXISTADMINTEL = OID023;   SOSTATEXISTADMINTEL = OSTATEMENT023;

   TID000 = ID000;    TONORMAL        = OID000;   TOSTATNORMAL       = OSTATEMENT000;
   TID001 = ID009;    TOABNORMAL      = OID009;   TOSTATABNORMAL     = OSTATEMENT009;
   TID002 = ID010;    TOTRANSFER      = OID010;   TOSTATTRANSFER     = OSTATEMENT010;
   TID003 = ID011;    TOERRORCOMMPT   = OID011;   TOSTATERRORCOMMPT  = OSTATEMENT011;
   TID004 = ID013;    TONOTDEFSVRPR   = OID013;   TOSTATNOTDEFSVRPR  = OSTATEMENT013;

   DBSYS_TELLER_LOGON    = 1;
   DBSYS_TELLER_LOGOUT   = 0;
   DBSYS_TELLER_DELETE   = 2;

function packTinComm(sinComm: TSinComm; sin: TBuffer): String;
function unpackTinComm(sin: String): TTinComm;

function packToutComm(toutComm: TToutComm): String;
function unpackToutComm(tout: String): TSoutComm;

implementation
{
function TTeller.packSinRACPKG(rinComm: TRinComm):String;
begin
  Result := Ut_IntoPackage(StartupParam.RequestHead, rinComm.RITRXD);
  Result := Ut_IntoPackage(Result, rinComm.RITELLER);
  Result := Ut_IntoPackage(Result, rinComm.RIBRANCH);
  Result := Ut_IntoPackage(Result, rinComm.RISTATUS);
  Result := Ut_IntoPackage(Result, rinComm.RIRANK);
end;

function TTeller.RACUNPKG(routString: String):TRoutComm;
var
  tmp: String;
begin
  tmp := routString;

  Result.ROAVAIABLE   := Ut_OutOfPackage(tmp, tmp);
  Result.ROSTATEMENT  := Ut_OutOfPackage(tmp, tmp);
  Result.ROTRXSQNO    := Ut_OutOfPackage(tmp, tmp);
  Result.ROLIBID      := Ut_OutOfPackage(tmp, tmp);
  Result.ROWINDOWID   := Ut_OutOfPackage(tmp, tmp);
  Result.ROSYSDATE    := Ut_OutOfPackage(tmp, tmp);
  Result.ROTRANSRVC   := Ut_OutOfPackage(tmp, tmp);
end;
}
{*********************************************************}
{********** Terminal Package Analysis Utilities **********}
{**********             B.E.G.I.N                *********}
{*********************************************************}
function packTinComm(sinComm: TSinComm; sin: TBuffer): String;
begin
   Result := '';
   Result := Ut_IntoPackage(Result, sinComm.SITRXSRVC);

   Result := Ut_IntoPackage(Result, sinComm.SITRXD);
   Result := Ut_IntoPackage(Result, sinComm.SITRXSQNO);
   Result := Ut_IntoPackage(Result, sinComm.SITELLER);
   Result := Ut_IntoPackage(Result, sinComm.SIZONENO);
   Result := Ut_IntoPackage(Result, sinComm.SIBRANCH);
   Result := Ut_IntoPackage(Result, sinComm.SISTATUS);
   Result := Ut_IntoPackage(Result, sinComm.SIRANK);
   Result := Ut_IntoPackage(Result, sinComm.SISYSDATE);
   Result := Ut_IntoPackage(Result, sin.FIELD00);
   Result := Ut_IntoPackage(Result, sin.FIELD01);
   Result := Ut_IntoPackage(Result, sin.FIELD02);
   Result := Ut_IntoPackage(Result, sin.FIELD03);
   Result := Ut_IntoPackage(Result, sin.FIELD04);
   Result := Ut_IntoPackage(Result, sin.FIELD05);
   Result := Ut_IntoPackage(Result, sin.FIELD06);
   Result := Ut_IntoPackage(Result, sin.FIELD07);
   Result := Ut_IntoPackage(Result, sin.FIELD08);
   Result := Ut_IntoPackage(Result, sin.FIELD09);
   Result := Ut_IntoPackage(Result, sin.FIELD10);
   Result := Ut_IntoPackage(Result, sin.FIELD11);
   Result := Ut_IntoPackage(Result, sin.FIELD12);
   Result := Ut_IntoPackage(Result, sin.FIELD13);
   Result := Ut_IntoPackage(Result, sin.FIELD14);
   Result := Ut_IntoPackage(Result, sin.FIELD15);
   Result := Ut_IntoPackage(Result, sin.FIELD16);
   Result := Ut_IntoPackage(Result, sin.FIELD17);
   Result := Ut_IntoPackage(Result, sin.FIELD18);
   Result := Ut_IntoPackage(Result, sin.FIELD19);
end;

function unpackTinComm(sin: String): TTinComm;
var
   tmpStr: String;
begin
   tmpStr := sin;
   Result.TITRXD      := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TITRXSQNO   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TITELLER    := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIZONENO    := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIBRANCH    := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TISTATUS    := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIRANK      := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TISYSDATE   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD00   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD01   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD02   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD03   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD04   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD05   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD06   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD07   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD08   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD09   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD10   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD11   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD12   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD13   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD14   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD15   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD16   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD17   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD18   := Ut_OutOfPackage(tmpStr, tmpStr);
   Result.TIFIELD19   := Ut_OutOfPackage(tmpStr, tmpStr);
end;

function packToutComm(toutComm: TToutComm): String;
begin
   Result := '';
   Result := Ut_IntoPackage(Result, toutComm.TOOVERID); // 可用标志
   Result := Ut_IntoPackage(Result, toutComm.TOSTATEMENT); // 情况说明

   Result := Ut_IntoPackage(Result, toutComm.TOFIELD00); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD01); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD02); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD03); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD04); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD05); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD06); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD07); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD08); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD09); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD10); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD11); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD12); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD13); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD14); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD15); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD16); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD17); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD18); // 返回数据场
   Result := Ut_IntoPackage(Result, toutComm.TOFIELD19); // 返回数据场
end;

function unpackToutComm(tout: String): TSoutComm;
var
   tmpStr: String;
begin
   tmpStr := tout;
   Result.SOOVERID    := Ut_OutOfPackage(tmpStr, tmpStr); // 可用标志
   Result.SOSTATEMENT := Ut_OutOfPackage(tmpStr, tmpStr); // 情况说明

   Result.SOFIELD00   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD01   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD02   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD03   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD04   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD05   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD06   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD07   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD08   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD09   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD10   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD11   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD12   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD13   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD14   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD15   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD16   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD17   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD18   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
   Result.SOFIELD19   := Ut_OutOfPackage(tmpStr, tmpStr); // 返回数据场
end;






end.
