⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dataoperat.pas

📁 SPServer.rar一个基于TCP/IP监听发送代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
     5:if (aSvcType=pSvcType)and(s=5) then Result:=5;
     6:if (aSvcType=pSvcType)and(s=6) then Result:=6;
     7:if (aSvcType=pSvcType)and(s=7) then Result:=7;
     8:if (aSvcType=pSvcType)and(s=8) then Result:=8;
     9:if (aSvcType=pSvcType)and(s=9) then Result:=9;
    end;
  end;
  aAppFalg:=Trim(frmServerDB.aqrSvcType.Fields[2].Text);
  if aAppFalg<>'' then pSvcType:=aAppFalg;
  frmServerDB.aqrSvcType.Close;
end;

//=============================重新发送信息===================================//
procedure AfreshSend(pSrcNo:string);
var
 psSrcNo:string;
 pChargeNo:string;
 pSvcType:string;
 pContent:string;
 pTry:Integer;
begin
 with frmServerDB.aqrRegister do
  begin
   Close;
   Parameters.ParamByName('p_SrcNo').Value:=pSrcNo;
   Open;
  end;
 if (frmServerDB.aqrRegister.RecordCount>0)and
    (frmServerDB.aqrRegister.Fields[4].Value<ReSendTry) then
    begin
     psSrcNo  :=Trim(frmServerDB.aqrRegister.Fields[0].Value);
     pChargeNo:=Trim(frmServerDB.aqrRegister.Fields[1].Value);
     pSvcType :=Trim(frmServerDB.aqrRegister.Fields[2].Value);
     pTry     :=frmServerDB.aqrRegister.Fields[4].Value;
    with frmServerDB.aSvcContent do
     begin
      Close;
      Parameters.ParamByName('p_SvcTypeName').Value:=pSvcType;
      Open;
     end;
     pContent :=Trim(frmServerDB.aSvcContent.Fields[2].Value);
     with frmServerDB.aUpdateTry do
      begin
       Close;
       Parameters.ParamByName('p_Try').Value:=pTry+1;
       Parameters.ParamByName('p_SrcNo').Value:=pSrcNo;
       ExecSQL;
      end;
     CurLogMsg(1,'==========信息重新发送==========');
     CurLogMsg(1,'被叫号码:'+pSrcNo);
     CurLogMsg(1,'服务类型:'+pSvcType);
     CurLogMsg(1,'信息内容:'+pContent);
    if FailRecord>0 then Dec(FailRecord);
     PostMess(2,1,psSrcNo,pChargeNo,pSvcType,pContent,SPNumber);
     SingleSend:=True;
   end;
end;

//===========================接收数据分析=====================================//
procedure StatemAssay(pSrcNo, pSvcType:string);
var
 i:Integer;
 aSvcType:string;
begin
if ResultCharegNo=1 then p_ChargeNo:=pSrcNo;   //被叫号码付费
if ResultCharegNo=0 then p_ChargeNo:='0';     //SP付费
aSvcType := UpperCase(Trim(pSvcType));       //转换服务类型大小写
if Copy(aSvcType,1,2)='ZC' then
 aSvcType:=Copy(aSvcType,1,2);
if (Length(aSvcType)>0)and(aSvcType<>'') then
 begin
   if SearchSvcType(aSvcType,0)>=0
    then begin
//=============H帮助信息====================//
     if aSvcType='H'
       then begin
        p_SvcType:=SP_SvcType;
        p_Content:=ResultMsg(101);
       end;
//==============取消定制用户=================//
     if aSvcType='193' then
       begin
        p_SvcType:=SP_SvcType;
        p_Content:=ResultMsg(103);
       end;
     if aSvctype='193QX' then
       begin
        p_SvcType:=SP_SvcType;
        p_Content:=ResultMsg(108);
       end;
     if aSvcType='D'
       then begin
        with frmServerDB.aqrRegister do
         begin
          Close;
          Parameters.ParamByName('p_SrcNo').Value:=pSrcNo;
          Open;
         end;
         if frmServerDB.aqrRegister.RecordCount=0
          then begin
           p_Content := ResultMsg(107);
           p_SvcType := SP_SvcType;
           Exit;
          end else
          //使用存储过程删除记录
          with frmServerDB.adeleteRegister do
           begin
            Parameters.ParamByName('@p_SrcNo').Value:=pSrcNo;
            Prepared;
            ExecProc;
            p_Content := ResultMsg(108);
            p_SvcType := SP_SvcType;
           end;
           frmServerDB.aqrRegister.Close;
         end;
//================用户查询服务===============//
       if aSvcType='C' then
        begin
         with frmServerDB.aSvcContent do
          begin
           Close;
           Parameters.ParamByName('p_SvcTypeName').Value:=pSvcType;
           Open;
          end;
          if frmServerDB.aSvcContent.RecordCount>0 then
           begin
            p_SvcType := Trim(frmServerDB.aSvcContent.Fields[1].Value);
            p_Content := Trim(frmServerDB.aSvcContent.Fields[2].Value);
            p_ChargeNo := pSrcNo;
            WriteCXRecord(ReadCXRecord+1);
            frm_smServer.lCXCount.Caption:=IntToStr(ReadCXRecord);
           end else
           begin
            p_Content:=ResultMsg(104);
            p_SvcType:=SP_SvcType;
           end;
           frmServerDB.aSvcContent.Close;
        end;
//===============用户定制信息的资料==================//
     if aSvcType='S' then
      begin
       with frmServerDB.aqrRegister do
        begin
         Close;
         Parameters.ParamByName('p_SrcNo').Value:=pSrcNo;
         Open;
        end;
        if frmServerDB.aqrRegister.RecordCount>0 then
          begin
           p_Content:=ResultMsg(106);
           p_SvcType:=SP_SvcType;
           frmServerDB.aqrRegister.Close;
          end else
          //使用存储过程Insert新的记录
           with frmServerDB.aInsertRegister do
            begin
             Parameters.ParamByName('@p_SrcNo').Value:=pSrcNo;
             Parameters.ParamByName('@p_ChargeNo').Value:=pSrcNo;
             Parameters.ParamByName('@p_SvcType').Value:=pSvcType;
             Parameters.ParamByName('@p_regDate').Value:=FormatDateTime('yyyymmddhhmmss',Now);
             Prepared;
             ExecProc;
             p_Content:=ResultMsg(105);
             p_SvcType:=SP_SvcType;
            end;
            frmServerDB.aqrRegister.Close;
          end;
/////////////////////////////////////////////////////////
       end else
     begin
      //输入错误的代码时
      p_Content:=ResultMsg(100);
      p_SvcType:=SP_SvcType;
     end;
     CurLogMsg(1,'==========收到服务器数据========');
     CurLogMsg(1,'主叫号码:'+pSrcNo);
     CurLogMsg(1,'请求代码:'+pSvcType);
     WriteSNDRecord(ReadSNDRecord+1);
     p_SrcNo:=pSrcNo;
     PostMess(2,1,p_SrcNo,p_ChargeNo,p_SvcType,p_Content,SPNumber);
   end;
end;

procedure ConnAddress(pHandle:DWord;pHand:byte;pIPAddress,pSPNumber:string;Falg:Integer);
var
 i:Integer;
begin
case Falg of
 1:
  with frmServerDB.tblConnAddress do
     begin
      Open;
      Insert;
      Fields[0].Value:=pHandle;
      Fields[1].Value:=pHand;
      Fields[2].Value:=pIPAddress;
      Fields[3].Value:=Now;
      Fields[4].Value:=pSPNumber;
      Post;
      Close;
     end;
 2:
  with frmServerDB.delConnAddress do
   begin
    Close;
    Parameters.ParamByName('pHandle').Value:=pHandle;
    ExecSQL;
   end;
 4:
   begin
     for i:=1 to frm_smServer.sgr3.RowCount do
     frm_smServer.sgr3.Rows[i].Clear;
     frm_smServer.sgr3.RowCount:=2;
     I:=1;
     frmServerDB.tblConnAddress.Close;
     frmServerDB.tblConnAddress.Open;
     frmServerDB.tblConnAddress.First;
      while not frmServerDB.tblConnAddress.Eof do
        begin
          with frm_smServer.sgr3 do
             with frmServerDB do
              begin
                Cells[0,i]:=tblConnAddressNetHandle.Text;
                Cells[1,i]:=tblConnAddressHand.Text;
                Cells[2,i]:=tblConnAddressIPAddress.Text;
                Cells[3,i]:=tblConnAddressUnitName.Text;
                Cells[4,i]:=tblConnAddressDateTime.Text;
              end;
             frmServerDB.tblConnAddress.Next;
             Inc(I);
             frm_smServer.sgr3.RowCount:=I;
          end;
        end;
     end;
end;

//写信息日志//
procedure  WriteMessageLog(pHandle:DWord;pHand:byte;pIPAddress,pUser,pCommandID,
                          pDestNo,pChargeNo,pSvcType,pContent,pSPNumber:string);
begin
with frmServerDB.tblMessageLog do
 begin
  Open;
  Insert;
  Fields[0].Value:=pHandle;
  Fields[1].Value:=pHand;
  Fields[2].Value:=pIPAddress;
  Fields[3].Value:=pSPNumber;
  Fields[4].Value:=pUser;
  Fields[5].Value:=pCommandID;
  Fields[6].Value:=pDestNo;
  Fields[7].Value:=pChargeNo;
  Fields[8].Value:=pSvcType;
  Fields[9].Value:=pContent;
  Fields[10].Value:=Now;
  Post;
  Close;
 end;
 with frm_smServer.sgr2 do
  begin
   if Trim(Cells[0,RowCount-1])<>'' then
    RowCount:=RowCount+1;
   Row:=RowCount-1; 
   Cells[0,RowCount-1]:=IntToStr(pHandle);
   Cells[1,RowCount-1]:=IntToStr(pHand);
   Cells[2,RowCount-1]:=pIPAddress;
   Cells[3,RowCount-1]:=pSPNumber;
   Cells[4,RowCount-1]:=pUser;
   Cells[5,RowCount-1]:=pCommandID;
   Cells[6,RowCount-1]:=pDestNo;
   Cells[7,RowCount-1]:=pChargeNo;
   Cells[8,RowCount-1]:=pSvcType;
   Cells[9,RowCount-1]:=pContent;
   Cells[10,RowCount-1]:=DateTimeToStr(Now);
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -