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

📄 cj.cpp

📁 电信语音系统源码
💻 CPP
字号:
//----------------------------------------------------------------------------
// 语音系统 - (C) Copyright 1997, 1997 by SCGT
//   Yy\Cj.cpp
//   源程序
//----------------------------------------------------------------------------
#include <owl\owlpch.h>

#include "Util.h"   // 工具
#include "Dbase.h"  // 数据库

#include "Tele.h"
#include "Yy.h"

enum
{
   cjDialing,
   cjPlaySentence,
   cjStartWait,
   cjWaiting,
   cjSeekNext,
};

enum
{
   tpPrivate = 0,
   tpPublic,
   tpNull,
};

enum
{
   fdCjTel = 0,
   fdCjCNo,
   fdCjType,
   fdCjMon,
   fdCjTotQf,
   fdCjTimes,
};

static WORD wStatus;
extern BOOL bCxBusy;

static int TimeCmp( struct time& curTime, int nHour, int nMinute )
{
   if( curTime.ti_hour < nHour) return -1;
   else if( curTime.ti_hour == nHour )
   {
      if( curTime.ti_min < nMinute ) return -1;
      else if( curTime.ti_min == nMinute ) return 0;
      else return 1;
   }
   else return 1;
}

static char* szCj[] =
{
     //0         1         2
     //012345678901234567890
/*00*/"第 1遍催缴",
/*01*/"──────────",
/*02*/"欠费用户99999个",
/*03*/"  已催缴99999个",
/*04*/"    还剩99999个",
/*05*/"──────────",
/*06*/"当前催缴用户",
/*07*/"──────────",
/*08*/"电话号码:12345678   ",
/*09*/"  合同号:12345678   ",
/*10*/"用户类别:单位       ",
/*11*/"  共欠费:123456.12元",
      NULL
};

static char nLastDay;
static void IncreaseCjOK()
{
   dbfCj->Go( config.nCjRec );
   dbfCj->Replace( FDCJ_TIMES, config.nCjTimes + 1 );

   config.nCjOK ++;
}

static void CheckCjOK()
{
   if( config.nCjOK + 10 < dbfCj->GetRecCount() ) return;
   config.nCjRec = 0;
   config.nCjOK = 0;
   config.nScanTimes[ 0 ] = 0;
   config.nScanTimes[ 1 ] = 0;
   config.nCjTimes ++;
   SaveConfig();
}

static BOOL CjHook( MMsg& msg )
{
   static char szTypeName[ 2 ][ 5 ] = { "个人", "单位" };
   static char szMoney[ 10 ];
   if( msg.lParam != config.nChCj ) return TRUE;

   extern BOOL bCjPause;  // Defined in Yy.cpp
   if( bCjPause )
   {
      ShowCjStatus( "暂停..." );
      HangUp( config.nChCj );
      wStatus = cjStartWait;
      return FALSE;
   }

   switch( msg.uMsg )
   {
      case WM_NULL:

        static DWORD dwTime;
        switch( wStatus )
        {
           case cjStartWait:

  	     HangUp( config.nChCj );
             ShowCjStatus( "等待1秒钟..." );
             dwTime = GetDosTime();
             wStatus = cjWaiting;
             break;

           case cjWaiting:

             static int nCjType;
             if( GetDosTime() - dwTime >= 15 )
             {
                struct dosdate_t curDate;
                _dos_getdate( &curDate );
                if( curDate.dayofweek != nLastDay )
                {
                   nLastDay = curDate.dayofweek;
                   dbfCj->Pack();
                   dbfCj->Save();
                   CheckCjOK();
                }
                struct time curTime;
                gettime( &curTime );
                if( ( curDate.dayofweek == 6 || // Sat.
                      curDate.dayofweek == 0    // Sun.
                    ) &&
                    ( ( TimeCmp( curTime, config.nCTSHour1, config.nCTSMin1 ) >= 0 &&
                        TimeCmp( curTime, config.nCTSHour2, config.nCTSMin2 ) <= 0
                      ) ||
                      ( TimeCmp( curTime, config.nCTSHour3, config.nCTSMin3 ) >= 0 &&
                        TimeCmp( curTime, config.nCTSHour4, config.nCTSMin4 ) <= 0
                      ) // 7:00 - 23:00
                    )
                  ) nCjType = tpPrivate;
                else if( ( TimeCmp( curTime, config.nCTGHour1, config.nCTGMin1 ) >= 0 &&
                           TimeCmp( curTime, config.nCTGHour2, config.nCTGMin2 ) <= 0 ) || // 7:00 - 8:00
                         ( TimeCmp( curTime, config.nCTGHour3, config.nCTGMin3 ) >= 0 &&
                           TimeCmp( curTime, config.nCTGHour4, config.nCTGMin4 ) <= 0 ) // 18:00 - 23:00
                       ) nCjType = tpPrivate;
                else if( ( TimeCmp( curTime, config.nCTDHour1, config.nCTDMin1 ) >= 0 &&
                           TimeCmp( curTime, config.nCTDHour2, config.nCTDMin2 ) <= 0 ) || // 8:00 - 12:00
                         ( TimeCmp( curTime, config.nCTDHour3, config.nCTDMin3 ) >= 0 &&
                           TimeCmp( curTime, config.nCTDHour4, config.nCTDMin4 ) <= 0 ) // 14:00 - 18:00
                       ) nCjType = tpPublic;
                else nCjType = tpNull;

                char* p[] = { "", "", "", "", "", NULL, NULL };
                if( nCjType != tpNull )
                {
                   static char szMsg[] = "搜索个人用户";
                   memcpy( szMsg + 4, szTypeName[ nCjType ], 4 );
                   p[ 5 ] = szMsg;
                   wStatus = cjSeekNext;
                }
                else
                {
                   p[ 5 ] = "休息时间";
                   wStatus = cjStartWait;
                }
                ShowCjTable( p );
             }
             break;

           case cjSeekNext:

             int nCount = ( int )dbfCj->GetRecCount();
             if( config.nCjOK >= nCount )
             {
                wStatus = cjStartWait;
                break;
             }

             config.nCjRec ++;
             if( config.nCjRec > nCount )
             {
                config.nCjRec = 0;
                config.nScanTimes[ nCjType ] ++;
             }

             dbfCj->Go( config.nCjRec );
             static char szTel[ flTel + 1 ];
             strcpy( szTel, dbfCj->GetStr( FDCJ_TEL ) );

             int nCjTimes = dbfCj->GetInt( FDCJ_TIMES );

             if( dbfCj->IsDeleted() ||
                 *szTel == ' ' ||
                 dbfCjFree->Seek( szTel ) )
             {
                if( nCjTimes == config.nCjTimes ) IncreaseCjOK();
             }
             else if( dbfCj->GetInt( FDCJ_TYPE ) == nCjType && nCjTimes == config.nCjTimes )
             {
                if( config.nScanTimes[ nCjType ] >= 5 )
                {
                   IncreaseCjOK();
                   break;
                }
                FormatNumber( nCjTimes + 1, szCj[ 0 ] + 2, 2 ); //
                FormatNumber( nCount, szCj[ 2 ] + 8, 5 ); //
                FormatNumber( config.nCjOK, szCj[ 3 ] + 8, 5 ); //
                FormatNumber( nCount - config.nCjOK, szCj[ 4 ] + 8, 5 ); //
                dbfCj->GetStr( FDCJ_TEL, szCj[ 8 ] + 9 ); //
                dbfCj->GetStr( FDCJ_CNO, szCj[ 9 ] + 9 ); //
                memcpy( szCj[ 10 ] + 9, szTypeName[ nCjType ], 4 );
                dbfCj->GetStr( FDCJ_TOTAL, szMoney );
                memcpy( szCj[ 11 ] + 9, szMoney, 9 );

                ShowCjTable( szCj );

                char str[ 15 ];
                //sprintf( str, "拨号: %s", szTel );
                sprintf( str, "拨:%s", szTel );
                ShowCjStatus( str );
                Dialing( config.nChCj, szTel );
                wStatus = cjDialing;
             }
             break;
        }
        return FALSE;

      case WM_MESSAGE:

        switch( msg.wParam )
        {
           case tmDialingOK:

             ShowCjStatus( "您已欠费..." );
             PlaySentence( config.nChCj, "CJ1.VOC", szMoney, "CJ2.VOC", NULL );
             wStatus = cjPlaySentence;
             return FALSE;

           case tmPlaySentenceOK:

             IncreaseCjOK();
             if( !bCxBusy ) SaveConfig();
             wStatus = cjStartWait;
             return FALSE;

           case tmDialingError:
           case tmPlaySentenceError:

             wStatus = cjStartWait;
             return FALSE;

           default:

             return TRUE;
        }
   }
   return TRUE;
}

void InitCj()
{
   struct dosdate_t d;
   _dos_getdate( &d );
   nLastDay = d.dayofweek;

   SetTeleHook( config.nChCj, CjHook );

   wStatus = cjStartWait;
}

void CloseCj()
{
   ResetTeleHook( config.nChCj );
}

⌨️ 快捷键说明

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