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

📄 unit1.~pas

📁 Delphi编写的东进语音卡实现的电话挂失系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
            $35:addindexplayfile(channelno,'.\voc\D5');
            $36:addindexplayfile(channelno,'.\voc\D6');
            $37:addindexplayfile(channelno,'.\voc\D7');
            $38:addindexplayfile(channelno,'.\voc\D8');
            $39:addindexplayfile(channelno,'.\voc\D9');
        end;
    end;
end;


procedure TMAINFORM.PlayMsg(channelno:integer);
var
   code,a:integer;
   p:pchar;
   s:string;
   Ret:integer;
begin
   push_play;
   feedsigfunc;
   case channel[channelno].Step of
   0:begin
       //
       if elapsetime(channelno,4)>=300 then  //
         begin
             showgrid.cells[2,channelno+1]:=loadstr(IDC_CALLERID_RECEIVEINGDTMF+stroffset);
             starttimer(channelno,4);
             channel[channelno].step:=1;
         end ;
       //
       channel[channelno].Callerid:=stralloc(32*sizeof(char));
       a:=getcalleridstr(channelno,channel[channelno].Callerid);
       if a=0 then
        begin
            if trim(showgrid.cells[2,channelno+1])<>loadstr(IDC_CALLERID_NOSIGNALRECEIVED+stroffset) then
            showgrid.cells[2,channelno+1]:=loadstr(IDC_CALLERID_NOSIGNALRECEIVED+stroffset);
        end;
       if a=1 then showgrid.cells[2,channelno+1]:=loadstr(IDC_CALLERID_RECEIVELEADINGSIGNAL+stroffset);
       if a=2 then showgrid.cells[2,channelno+1]:=loadstr(IDC_CALLERID_RECEIVEINGCALLERID+stroffset) ;
       if (a=3) or (a=4) then   //show FSK CALLERID ID if getcalleridstr returns 3 or 4
          begin
            s:=channel[channelno].Callerid;
            showgrid.cells[2,channelno+1]:='FSK  '+s;
            offhook(channelno);
            channel[channelno].step:=5;
            channel[channelno].Countdown:=0;
          end;
      strdispose(channel[channelno].Callerid);
     end;
   1:begin
         if elapsetime(channelno,4)<=400 then
                begin
                   if dtmfhit(channelno) then
                   channel[channelno].Step:=11;
                end
         else
             begin
                showgrid.cells[2,channelno+1]:=loadstr(IDC_CALLERID_NOCALLERID+stroffset);
                channel[channelno].dtmfid:='';
                channel[channelno].Step:=5;
                initdtmfbuf(channelno);
                offhook(channelno);
                exit;
             end;
      end;
   11:begin
         if dtmfhit(channelno) then //get dtmf callerid if the buffer is not empty
            begin
                code:=getdtmfcode(channelno);
                channel[channelno].dtmfid:=channel[channelno].dtmfid+convertdtmf(code)
            end
         else
            begin   //finish receiveing dtmf callerid
                showgrid.cells[2,channelno+1]:='DTMF  '+channel[channelno].dtmfid;
                channel[channelno].dtmfid:='';
                channel[channelno].Step:=5;
                initdtmfbuf(channelno);
                offhook(channelno);
            end
     end;
   5:begin    //execute ivr
         rsetindexplayfile(channelno);

         addindexplayfile(channelno,'.\voc\1-2.voc');
         showgrid.Cells[3,channelno+1]:='欢迎....请输入手机号以#号结束';
         initdtmfbuf(channelno);
         channel[channelno].PhoneNo:='';
         channel[channelno].Step:=6;
         starttimer(channelno,4);
         startindexplayfile(channelno);

      end;
    6:begin
         if elapsetime(channelno,4)>=WAIT_TIME then
         begin
             channel[channelno].Step:=100;   //错误
             exit;
         end;
         CheckIndexPlayFile(channelno);
         if dtmfhit(channelno) then StopIndexPlayFile(channelno);
         code:=getdtmfcode(channelno);
         if code<>-1 then
            begin
               starttimer(channelno,4);
               showgrid.Cells[3,channelno+1]:=showgrid.Cells[3,channelno+1]+convertdtmf(code);
               if(code>=1) and (code<=10) then
                   channel[channelno].PhoneNo:=channel[channelno].PhoneNo+convertdtmf(code);
            end;
         if length(channel[channelno].PhoneNo)>15 then //收到过长
         begin
                channel[channelno].Step:=100;   //错误
                exit;
         end;
         if (code=12) and (length(channel[channelno].PhoneNo)>5) then
         begin
                 rsetindexplayfile(channelno);
                 addindexplayfile(channelno,'.\voc\2-2.voc');
                 showgrid.Cells[3,channelno+1]:='请输入您的业务密码以#号键结束';
                 initdtmfbuf(channelno);
                 channel[channelno].Pwd:='';
                 channel[channelno].Step:=7;
                 starttimer(channelno,4);
                 startindexplayfile(channelno);
                 exit;
         end;

      end;
    7:begin
         if elapsetime(channelno,4)>=WAIT_TIME then
         begin
             channel[channelno].Step:=100;   //错误
             exit;
         end;
         CheckIndexPlayFile(channelno);
         if dtmfhit(channelno) then StopIndexPlayFile(channelno);
         code:=getdtmfcode(channelno);
         if code<>-1 then
            begin
               starttimer(channelno,4);
               showgrid.Cells[3,channelno+1]:=showgrid.Cells[3,channelno+1]+'*';
               if(code>=1) and (code<=10) then
                   channel[channelno].Pwd:=channel[channelno].Pwd+convertdtmf(code);
            end;
         if length(channel[channelno].Pwd)>6 then //收到过长
         begin
                channel[channelno].Step:=100;   //错误
                exit;
         end;
         if (code=12) and (length(channel[channelno].Pwd)>5) then
         begin
                //查询密码
                 Ret:=CheckPin(channel[channelno]);
                 if Ret=PIN_ERR then //密码错或帐号错
                 begin
                     rsetindexplayfile(channelno);
                     addindexplayfile(channelno,'.\voc\13-2.voc');
                     showgrid.Cells[3,channelno+1]:='您的手机号或业务密码不正确';
                     initdtmfbuf(channelno);
                     channel[channelno].Step:=100;
                     startindexplayfile(channelno);
                     exit;
                 end;
                 if(Ret<>SUCC) then
                 begin
                    channel[channelno].Step:=100;   //错误
                    exit;
                 end;
                 //查询卡信息
                 Ret:=QueryCard(channel[channelno]);
                 if(Ret=NO_CARD) then
                 begin
                     rsetindexplayfile(channelno);
                     addindexplayfile(channelno,'.\voc\12-2.voc');
                     showgrid.Cells[3,channelno+1]:='对不起,您没有可暂停充值的羊城通卡';
                     initdtmfbuf(channelno);
                     channel[channelno].Step:=100;
                     startindexplayfile(channelno);
                     exit;
                 end;
                 if(Ret<>SUCC) then
                 begin
                    channel[channelno].Step:=100;   //错误
                    exit;
                 end;
                 rsetindexplayfile(channelno);
                 addindexplayfile(channelno,'.\voc\3-2.voc');
                 PlayNumber(inttostr(channel[channelno].CardCount),channelno);
                 addindexplayfile(channelno,'.\voc\4-1.voc');
                 addindexplayfile(channelno,'.\voc\5-1.voc');//您可暂停的第
                 channel[channelno].Select:=1;
                 PlayNumber(inttostr(channel[channelno].Select),channelno);
                 addindexplayfile(channelno,'.\voc\6-1.voc');//张羊城通卡号为
                 PlayNumber(channel[channelno].CardNo[channel[channelno].select-1],channelno);
                 addindexplayfile(channelno,'.\voc\7-1.voc');//暂停次卡请按1,继续按2,退出请按0

                 initdtmfbuf(channelno);
                 channel[channelno].Step:=8;
                 starttimer(channelno,4);
                startindexplayfile(channelno);
                 exit;
         end;
      end;
    8:begin
         if elapsetime(channelno,4)>=WAIT_TIME then
         begin
             channel[channelno].Step:=100;   //错误
             exit;
         end;
         CheckIndexPlayFile(channelno);
         code:=getdtmfcode(channelno);//get the service dtmf code
         if code=1 then
            begin
               stopplayfile(channelno);
               //暂停卡
               Ret:=CancelCard(channel[channelno]);
               if(Ret<>SUCC) then
               begin
                     rsetindexplayfile(channelno);
                     addindexplayfile(channelno,'.\voc\10-2.voc');
                     showgrid.Cells[3,channelno+1]:='暂停充值失败,请稍候重试';
                     initdtmfbuf(channelno);
                     channel[channelno].Step:=100;
                     startindexplayfile(channelno);
                     exit;
               end;
               rsetindexplayfile(channelno);
               addindexplayfile(channelno,'.\voc\8-2.voc');
               PlayNumber(channel[channelno].CardNo[channel[channelno].select-1],channelno);
               addindexplayfile(channelno,'.\voc\9-2.voc');
               showgrid.Cells[3,channelno+1]:='您的羊城通卡'+channel[channelno].CardNo[channel[channelno].select]+'暂停充值成功';
               initdtmfbuf(channelno);
               channel[channelno].Step:=100;
               startindexplayfile(channelno);
               exit;
            end
         else if code=2 then
            begin
                 channel[channelno].Select:=channel[channelno].Select+1;
                 if channel[channelno].Select>=channel[channelno].CardCount+1 then
                 begin
                       rsetindexplayfile(channelno);
                       addindexplayfile(channelno,'.\voc\11-1.voc');
                       showgrid.Cells[3,channelno+1]:='已到最后一张羊城通卡,再见';
                       initdtmfbuf(channelno);
                       channel[channelno].Step:=100;
                       startindexplayfile(channelno);
                       exit;
                 end;

                 rsetindexplayfile(channelno);
                 addindexplayfile(channelno,'.\voc\5-1.voc');//您可暂停的第
                 PlayNumber(inttostr(channel[channelno].Select),channelno);
                 addindexplayfile(channelno,'.\voc\6-1.voc');//张羊城通卡号为
                 PlayNumber(channel[channelno].CardNo[channel[channelno].select-1],channelno);
                 addindexplayfile(channelno,'.\voc\7-1.voc');//暂停次卡请按1,继续按2,退出请按0

                 initdtmfbuf(channelno);
                 channel[channelno].Step:=8;
                 starttimer(channelno,4);
                 startindexplayfile(channelno);
            end
         else if code=10 then
            begin
               stopplayfile(channelno);
               channel[channelno].Step:=100;
            end;
      end;
   100:begin
       if checkindexplayfile(channelno)=1 then
       begin
         stopindexplayfile(channelno);
         channel[channelno].Step:=101;
       end;
     end;

   101:begin
       if checkchtype(channelno)=chtype_trunk then
       begin
           startsigcheck(channelno);
           hangup(channelno);
           initdtmfbuf(channelno);
           Sig_ResetCheck(channelno);

         startsigcheck(channelno);
         Sig_ResetCheck(channelno);
         initdtmfbuf(channelno);
         channel[channelno].Step:=0;
         channel[channelno].Idcount:=0;
         channel[channelno].Pwdcount:=0;
         channel[channelno].playing:=false;
         showgrid.cells[3,channelno+1]:='';
         showgrid.cells[2,channelno+1]:='';
       end;
       if checkchtype(channelno)=chtype_user then
       begin
         StartPlaySignal(channelno, SIG_BUSY1);
         channel[channelno].Step:=102;
       end;
      end;

   102:begin
         if RingDetect(channelno) = false then
         begin
            StartPlaySignal(channelno, SIG_STOP);
            initdtmfbuf(channelno);
            channel[channelno].Step:=0;
            channel[channelno].Idcount:=0;
            channel[channelno].Pwdcount:=0;
            channel[channelno].playing:=false;
            showgrid.cells[3,channelno+1]:='';
            showgrid.cells[2,channelno+1]:='';
         end;
       end;
     end;
   //end;
end;

function TMAINFORM.convertdtmf(sVal: integer): string;
begin
    case sval of
    10:result:='0';
    11:result:='*';
    12:result:='#';
    13:result:='A';
    14:result:='B';
    15:result:='C';
    0:result:='D';
    1..9:result:=inttostr(sval);
    -1:result:='';
    end;
end;
procedure TMAINFORM.FormActivate(Sender: TObject);
begin
    if initConn()<>SUCC then
    begin
        ShowMessage('找不到配置文件或数据库连接失败!');
        close;
    end;
end;

end.

⌨️ 快捷键说明

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