Chinaunix首页 | 论坛 | 博客
  • 博客访问: 666368
  • 博文数量: 77
  • 博客积分: 6055
  • 博客等级: 准将
  • 技术积分: 617
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-17 02:15
个人简介

一句话太少

文章分类

全部博文(77)

文章存档

2018年(1)

2015年(1)

2014年(1)

2013年(6)

2011年(1)

2010年(1)

2009年(4)

2008年(2)

2007年(21)

2006年(39)

我的朋友

分类:

2006-06-07 23:00:51

delphi中的代码:
procedure TForm1.Button1Click(Sender: TObject);
var
ret:Longint;
  SendBuf,RcvBuf,PKH_MC,PKH_DZ:pchar;
  fQF_JE:^Real;
  ilen,rlen:Longint;
  TPTTpinit:PTTpinit;
const
  M=32;
begin
  TPTTpinit:=PTTpinit(tpalloc('TPINIT',nil,sizeOf(PTTpinit)));
  //指定允许多线程调用
  TPTTpinit.Flags := M;
  ret := tpinit(TPTTpinit);
  if ret = -1 then
  begin
    showmessage('tpinit failed!');
    Exit;
  end;
  SendBuf := tpalloc('FML32', nil, 102400);
  RcvBuf := tpalloc('FML32', nil, 102400);
  fQF_JE :=  tpalloc('STRING', nil, 1024);
  PKH_MC :=  tpalloc('STRING', nil, 1024);
  PKH_DZ :=  tpalloc('STRING', nil, 1024);
  ilen := 10240;
  ret:=Fadd32(pointer(SendBuf),HBS_BH,pchar(Edit1.text),FLDLEN32(length(Edit1.text)));
  if ret = -1 then
  begin
    ShowMessage('Fadd failed!');
    tpfree(SendBuf);
    tpfree(RcvBuf);
    tpfree(PKH_MC);
    tpfree(PKH_DZ);
    tpfree(PAnsiChar(fQF_JE));
  tpfree(pchar(TPTTpinit));
    tpterm();
    Exit;
  end;
  ret := tpcall('TEST', SendBuf, longint(0), @RcvBuf, @rlen, 0);
  if ret = -1 then
  begin
    showmessage('tpcall failed!');
    tpfree(SendBuf);
    tpfree(RcvBuf);
    tpfree(PKH_MC);
    tpfree(PKH_DZ);
    tpfree(PAnsiChar(fQF_JE));
  tpfree(pchar(TPTTpinit));
    tpterm();
    Exit;
  end;
  ret := Fget32(pointer(RcvBuf),KH_MC,0,PKH_MC,0);
  if ret = -1 then
  begin
    showmessage('Fget KH_MC failed!');
    tpfree(sendbuf);
    tpfree(RcvBuf);
    tpfree(PKH_MC);
    tpfree(PKH_DZ);
    tpfree(PAnsiChar(fQF_JE));
  tpfree(pchar(TPTTpinit));
    tpterm();
    Exit;
  end;
  Label6.Caption := PKH_MC;
  ret := Fget32(pointer(RcvBuf),KH_DZ,0,PKH_DZ,0);
  if ret = -1 then
  begin
    showmessage('Fget KH_DZ failed!');
    tpfree(sendbuf);
    tpfree(RcvBuf);
    tpfree(PKH_MC);
    tpfree(PKH_DZ);
    tpfree(PAnsiChar(fQF_JE));
  tpfree(pchar(TPTTpinit));
    tpterm();
    Exit;
  end;
  Label7.Caption := PKH_DZ;
  ret := Fget32(PTFbfr32(RcvBuf),QF_JE,0,fQF_JE,0);
  if ret = -1 then
  begin
    showmessage('Fget QF_JE failed!');
    tpfree(sendbuf);
    tpfree(RcvBuf);
    tpfree(PKH_MC);
    tpfree(PKH_DZ);
    tpfree(PAnsiChar(fQF_JE));
  tpfree(pchar(TPTTpinit));
    tpterm();
    Exit;
  end;
  if fQF_JE^ > 0 then
    Label2.Caption:='结余'
  else
    Label2.Caption:='欠费';
  Edit2.Text := FloatToStr(fQF_JE^);
  tpfree(sendbuf);
  tpfree(RcvBuf);
  tpfree(PKH_MC);
  tpfree(PKH_DZ);
  tpfree(PAnsiChar(fQF_JE));
  tpfree(pchar(TPTTpinit));
  tpterm();
end;
 
tuxedo中server代码:
#include
#include
#include
#include
#include

EXEC SQL INCLUDE sqlca;
EXEC SQL BEGIN DECLARE SECTION;
char ahbs_bh[11]="";
char areturn[11]="";
char akh_mc[51]="";
short skf_mc = 0;
char akh_dz[51]="";
short skh_dz = 0;
char aqf_je[21]="";
char ass_df[11]="";
char strTransNo[2]="1";
char strCardNo[2]="1";
double CardMoney=0;
double UserMoney=0;
short Result=0;
char inUserNo[100];
char Description[100];
EXEC SQL VAR Description IS STRING(101);
EXEC SQL VAR inUserNo IS STRING(100);
EXEC SQL VAR strTransNo IS STRING(2);
EXEC SQL VAR strCardNo IS STRING(2);
EXEC SQL VAR areturn IS STRING(11);
EXEC SQL VAR ass_df IS STRING(11);
EXEC SQL VAR aqf_je IS STRING(21);
EXEC SQL VAR ahbs_bh IS STRING(11);
EXEC SQL VAR akh_mc IS STRING(51);
EXEC SQL VAR akh_dz IS STRING(51);
EXEC SQL END DECLARE SECTION;
TEST(TPSVCINFO *rqst)
{
FBFR32 *rcvbuf=NULL;
FBFR32 *sendbuf=NULL;
FLDLEN32 len=0;
FLDLEN32 sendlen = 1024;
rcvbuf = (FBFR32 *)rqst->data;
if (Fget32(rcvbuf,HBS_BH,0,(char *)&ahbs_bh,&len)==-1)
{
userlog("Fget failure!");
tpreturn(TPFAIL,0,rqst->data,0,0);
}
EXEC SQL select nvl(kh_mc,chr(0)),nvl(kh_dz,chr(0)) into :akh_mc,:akh_dz from dlyx.zl_yhjbqk where hbs_bh = :ahbs_bh;
if(sqlca.sqlcode!=0)
{
userlog("select from zl_yhjbqk failure,sqlcode=%ld,sqlerr=%s\n",sqlca.sqlcode,(char *)sqlca.sqlerrm.sqlerrmc);
strcpy(rqst->data,sqlca.sqlerrm.sqlerrmc);
tpreturn(TPFAIL,0,rqst->data,0,0);
}
EXEC ORACLE OPTION (RELEASE_CURSOR = YES);
EXEC SQL EXECUTE
BEGIN
  :areturn:=dlyx.czk_fnc_cxqf(:ahbs_bh,:UserMoney);
END;
END-EXEC;
userlog("aqf_je:%f",UserMoney);
if(sqlca.sqlcode!=0)
{
userlog("exec czk_fnc_cxqf failure,sqlcode=%ld,sqlerr=%s\n",sqlca.sqlcode,(char *)sqlca.sqlerrm.sqlerrmc);
strcpy(rqst->data,sqlca.sqlerrm.sqlerrmc);
tpreturn(TPFAIL,0,rqst->data,0,0);
}
sendbuf = (FBFR32 *)tpalloc("FML32",NULL,sendlen);
if (Fchg32(sendbuf,KH_MC,0,(char *)&akh_mc,50)== -1)
{
tpfree((char *)sendbuf);
tpreturn(TPFAIL,0,rqst->data,0,0);
}
if (Fchg32(sendbuf,KH_DZ,0,(char *)&akh_dz,50)== -1)
{
tpfree((char *)sendbuf);
tpreturn(TPFAIL,0,rqst->data,0,0);
}
userlog("UserMoney:%f",UserMoney);
if (Fchg32(sendbuf,QF_JE,0,(char *)&UserMoney,60)== -1)
{
tpfree((char *)sendbuf);
tpreturn(TPFAIL,0,rqst->data,0,0);
}
tpreturn(TPSUCCESS,0,(char *)sendbuf,0,0);
tpfree((char *)sendbuf);
}
CHARGEIN(TPSVCINFO *rqst)
{
FBFR32 *rcvbuf=NULL;
FBFR32 *sendbuf=NULL;
FLDLEN32 len=0;
FLDLEN32 sendlen = 1024;
rcvbuf = (FBFR32 *)rqst->data;
if (Fget32(rcvbuf,HBS_BH,0,(char *)&ahbs_bh,&len)==-1)
{
userlog("Fget failure!");
tpreturn(TPFAIL,0,rqst->data,0,0);
}
if (Fget32(rcvbuf,SS_DF,0,(char *)&ass_df,&len)==-1)
{
userlog("Fget failure!");
tpreturn(TPFAIL,0,rqst->data,0,0);
}
EXEC ORACLE OPTION (RELEASE_CURSOR = YES);
EXEC SQL EXECUTE
BEGIN
  :areturn:=dlyx.czk_fnc_cxqf(:ahbs_bh,:UserMoney);
END;
END-EXEC;
if(sqlca.sqlcode!=0)
{
userlog("select from gc_dfys failure,sqlcode=%ld,sqlerr=%s\n",sqlca.sqlcode,(char *)
sqlca.sqlerrm.sqlerrmc);
strcpy(rqst->data,sqlca.sqlerrm.sqlerrmc);
tpreturn(TPFAIL,0,rqst->data,0,0);
}
userlog("ssdf=%s\n",ass_df);
userlog("hbs_bh=%s\n",ahbs_bh);
EXEC SQL EXECUTE
BEGIN
  :areturn := dlyx.CZK_FNC_BalanceUserElecMoney(:strCardNo,:strTransNo,:ahbs_bh,:ass_df,:UserMoney);
END;
END-EXEC;
EXEC SQL COMMIT;
if(sqlca.sqlcode!=0)
{
userlog("EXEC CZK_FNC_BalanceUserElecMoney failure!");
strcpy(rqst->data,sqlca.sqlerrm.sqlerrmc);
tpreturn(TPFAIL,0,rqst->data,0,0);
}
sendbuf = (FBFR32 *)tpalloc("FML32",NULL,sendlen);
if (Fchg32(sendbuf,QF_JE,0,(char *)&UserMoney,(FLDLEN32)(sizeof(UserMoney)))== -1)
{
tpfree((char *)sendbuf);
userlog("Fchg failure!");
tpreturn(TPFAIL,0,rqst->data,0,0);
}
tpreturn( TPSUCCESS,0,(char *)sendbuf,0,0);
tpfree((char *)sendbuf);
}
CHECKUSER(TPSVCINFO *rqst)
{
 FBFR32 *rcvbuf;
 FBFR32 *sendbuf=NULL;
 FLDLEN32 flen=0;
 rcvbuf=(FBFR32*)rqst->data;
 
 sendbuf=(FBFR32*)tpalloc("FML32",NULL,512);
 flen=Fsizeof32(sendbuf);
 Finit32(sendbuf,flen);
 Fchg32(sendbuf,RET,0,0,(FLDLEN32)0);
 flen=sizeof(inUserNo);
 Fget32(rcvbuf,HBS_BH,0,inUserNo,&flen);
 userlog("strUserNo=%s\n",inUserNo);
 EXEC SQL EXECUTE
  BEGIN
  :Result:=dlyx.czk_fnc_checkuser(:inUserNo,:Description);
  END;
 END-EXEC;
 
 if(sqlca.sqlcode<0)
 {
  userlog("执行用户是否允许冲销电费函数失败!");
  Result=2;
    strcpy(Description,"");
 }
 Fchg32(sendbuf,KH_MC,0,(char*)&Description,(FLDLEN32)(sizeof(Description)));
 Fchg32(sendbuf,RET,0,(char*)&Result,(FLDLEN32)(sizeof(Result)));
 tpreturn(TPSUCCESS, 0, (char*)sendbuf, 0L, 0);
}
 
ubbconfig:
# (c) 2003 BEA Systems, Inc. All Rights Reserved.
# Copyright (c) 1994 Unix System Laboratories, Inc.
# All rights reserved
#
# THIS IS UNPUBLISHED PROPRIETARY
# SOURCE CODE OF Unix System Laboratories, Inc.
# The copyright notice above does not
# evidence any actual or intended
# publication of such source code.
#
#ident "@(#) samples/atmi/rpcsimp/ubbconfig $Revision: 1.5 $"
*RESOURCES
IPCKEY      123456
DOMAINID     simpapp
MODEL        SHM
MASTER       simple
MAXACCESSERS  100
MAXSERVERS    50
MAXSERVICES   100
LDBAL         N
PERM  0660
*MACHINES
SYDL01 LMID=simple
 APPDIR="d:\tuxedo"
 TUXCONFIG="d:\tuxedo\tuxconfig"
 TUXDIR="C:\bea\tuxedo8.1"
  TLOGDEVICE = "D:\tuxedo\TLOG"
  TLOGNAME=TLOG
  TLOGSIZE=100
 MAXWSCLIENTS=10
 CMPLIMIT="MAXLONG,MAXLONG"
 NETLOAD=1
 SPINCOUNT=1
*GROUPS
GROUP1 LMID=simple GRPNO=1
OPENINFO="Oracle_XA:Oracle_XA+Acc=P/username/password+SqlNet=YDGL+SesTm=3+MaxCur=5+LogDir=."
TMSNAME="TMS_ORA9i"    TMSCOUNT=2
*SERVERS
DEFAULT:
        CLOPT="-A"
test SRVGRP=GROUP1 SRVID=1
  CLOPT="-A"
  RQADDR=test
  RPPERM=0660    REPLYQ=Y   RPPERM=0660  MIN=20  MAX=40  CONV=N
  MAXGEN=1       GRACE=86400   RESTART=N
WSL SRVGRP=GROUP1 SRVID=1234
# CLOPT="-A -- -n
-x 10 -m 1 -M 10 -d "
CLOPT="-A -- -n //sydl01:9999 -m 2 -M 5 -x 6"
#
# TUXEDO-to-DCE Gateway
#simpgw SRVGRP=GROUP1 SRVID=2
*SERVICES
TEST
CHARGEIN
CHECKUSER
INSERT AUTOTRAN=Y
REMOVE AUTOTRAN=Y
QUERY
UPDATE AUTOTRAN=Y
*ROUTING
阅读(2506) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~