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

📄 datafunc.h

📁 170话费催交系统
💻 H
📖 第 1 页 / 共 5 页
字号:
			(li_day>=lpcjarg->cjtime[0].start_day)&&(li_day<=lpcjarg->cjtime[0].end_day)&&
			 (((li_hour>lpcjarg->cjtime[0].start_hour)&&(li_hour<lpcjarg->cjtime[0].end_hour))||
			  ((li_hour==lpcjarg->cjtime[0].start_hour)&&(li_minute>=lpcjarg->cjtime[0].start_minute))||
			   ((li_hour==lpcjarg->cjtime[0].end_hour)&&(li_minute<=lpcjarg->cjtime[0].end_minute)))) {
				return TRUE;
		}
	}
	if(lpcjarg->cjtime_two == 1){
		if((li_month>=lpcjarg->cjtime[1].start_month)&&(li_month<=lpcjarg->cjtime[1].end_month)&&
			(li_day>=lpcjarg->cjtime[1].start_day)&&(li_day<=lpcjarg->cjtime[1].end_day)&&
			 (((li_hour>lpcjarg->cjtime[1].start_hour)&&(li_hour<lpcjarg->cjtime[1].end_hour))||
			  ((li_hour==lpcjarg->cjtime[1].start_hour)&&(li_minute>=lpcjarg->cjtime[1].start_minute))||
			   ((li_hour==lpcjarg->cjtime[1].end_hour)&&(li_minute<=lpcjarg->cjtime[1].end_minute)))) {
				return TRUE;
		}
	}
	if(lpcjarg->cjtime_three == 1){
		if((li_month>=lpcjarg->cjtime[2].start_month)&&(li_month<=lpcjarg->cjtime[2].end_month)&&
			(li_day>=lpcjarg->cjtime[2].start_day)&&(li_day<=lpcjarg->cjtime[2].end_day)&&
			 (((li_hour>lpcjarg->cjtime[2].start_hour)&&(li_hour<lpcjarg->cjtime[2].end_hour))||
			  ((li_hour==lpcjarg->cjtime[2].start_hour)&&(li_minute>=lpcjarg->cjtime[2].start_minute))||
			   ((li_hour==lpcjarg->cjtime[2].end_hour)&&(li_minute<=lpcjarg->cjtime[2].end_minute)))) {
				return TRUE;
		}
	}
	/*if((lpcjarg->cjtime_one != 1)&&(lpcjarg->cjtime_one != 1)&&(lpcjarg->cjtime_one != 1)) {
		return TRUE;
	}*/
	return FALSE;
}

/*************************************************************************
 *			Fuction    : int yin_seize(int i)
 *			Description: set abit off (j<MAXCHAN) prepare to dialout
 **************************************************************************/
int yin_seize(int i)
{
	long tsbits;
	int arcv,brcv,crcv,drcv,axmt,bxmt,cxmt,dxmt;
	int chan_ok=0;
	//char ls_i[10];

	if((tsbits=ATDT_TSSGBIT(dxinfo[i].dtdev))==AT_FAILURE){
		TRACE("ATDT_TSSGBIT() error");
		return -1;
	}
	arcv=(tsbits & DTSG_RCVA)?1:0;
	brcv=(tsbits & DTSG_RCVB)?1:0;
	crcv=(tsbits & DTSG_RCVC)?1:0;
	drcv=(tsbits & DTSG_RCVD)?1:0;
	axmt=(tsbits & DTSG_XMTA)?1:0;
	bxmt=(tsbits & DTSG_XMTB)?1:0;
	cxmt=(tsbits & DTSG_XMTC)?1:0;
	dxmt=(tsbits & DTSG_XMTD)?1:0;

	chan_ok=(arcv==1)&&(brcv==0)&&(crcv==1)&&(drcv==1);
	if(!chan_ok){
		TRACE("%s: RX(%d%d%d%d) ****** CPE Not Ready ***** %2d",
			dxinfo[i].dtdevname,arcv,brcv,crcv,drcv,i);
		chan_init(i);
		return 0;
	}

	chan_ok=(axmt==1)&&(bxmt==0)&&(cxmt==1)&&(dxmt==1);
	if(!chan_ok){
		TRACE("%s: TX(%d%d%d%d) ****** CO Not Ready ***** %2d",
			dxinfo[i].dtdevname,axmt,bxmt,cxmt,dxmt,i);
		chan_init(i);
		return 0;
	}
	
	if(dt_settssig(dxinfo[i].dtdev,DTB_ABIT,DTA_SUBMSK)!=0){
		TRACE("%s: dt_settssig() error",dxinfo[i].dtdevname);
		return -1;
	}
	dxinfo[i].chdevzt=CHDEVZT_B;
	telecount.all_count++;
	::SendMessage( myhwnd, WM_COPY, (WPARAM) 0, (LPARAM) 0);
	strcpy(dxinfo[i].chdevztmx,chdevztmx[1]);
	dxinfo[i].chtime=0;
	dxinfo[i].resettime=0;
	GetTime(teleinfo[i].qssj_time);
	//itoa(i+1,ls_i,10);
	itoa(CHDEVWORK,signlight[i].chn_value,10);
	//SetSemaphoneFile(ls_i,chnvalue,signlight[i].chn_value);
	//clr_output(i);
	//ChnPrintf(i+1,"_BEGIN",teleinfo[i].qssj_time);
	//ChnPrintf(i+1,"_STATE","摘机");
	init_count[i]=0;
	return 1;
}

/*************************************************************************
 *          Name: int chan_init(int i)
 *      Function: set dti device on hook
 *	    Parameter: channel cur_num
 *  Return value: 0, if successful
 *					 : -1, unsuccessful	 
 *************************************************************************/
int chan_init(int i)
{
	//char ls_i[10];
	//int devzt;

	dxinfo[i].chdevzt=CHDEVZT_A;
	strcpy(dxinfo[i].chdevztmx,chdevztmx[0]);
	dxinfo[i].chtime=0;
	dxinfo[i].bksig=SIGA_1;
	dxinfo[i].ani_num=0;
	dxinfo[i].dnis_num=0;
	dxinfo[i].Sending=0; //(=0 for DNIS),(=1 for ANI)
	//dxinfo[i].chdialcount=0;
	dt_settssigsim(dxinfo[i].dtdev,DTB_AON|DTB_BOFF|DTB_CON|DTB_DON);
	//devzt=CHDEVIDLE;
	//itoa(devzt,signlight[i].chn_value,10);
	itoa(CHDEVIDLE,signlight[i].chn_value,10);
	//itoa(i+1,ls_i,10);
	//SetSemaphoneFile(ls_i,chnvalue,signlight[i].chn_value);
	clr_output(i);
	//ChnPrintf(i+1,"_STATE","空闲");
	return 0;
}

/*************************************************************************
 *          Name: int chan_seton(int i)
 *      Function: set dti device on hook
 *	    Parameter: channel cur_num
 *  Return value: 0, if successful
 *					 : -1, unsuccessful	 
 *************************************************************************/
int chan_seton(int i)
{
	//char ls_i[10];
	//int devzt;

	//dxinfo[i].chdevzt=CHDEVZT_A;
	//strcpy(dxinfo[i].chdevztmx,chdevztmx[0]);
	dxinfo[i].chtime=0;
	dxinfo[i].bksig=SIGA_1;
	dxinfo[i].ani_num=0;
	dxinfo[i].dnis_num=0;
	dxinfo[i].Sending=0; //(=0 for DNIS),(=1 for ANI)
	dt_settssigsim(dxinfo[i].dtdev,DTB_AON|DTB_BOFF|DTB_CON|DTB_DON);
	//itoa(CHDEVIDLE,signlight[i].chn_value,10);
	//clr_output(i);
	return 0;
}

/************************************************************************
*     名称:UINT Cjwork(LPVOID pParam)
*     功能:催缴工作线程函数
************************************************************************/
UINT Cjwork(LPVOID pParam)
{
	long  evt_handle;
	long tmp_dev;
	long eventtype;
	int channel;

	while(1) {
		if(sr_waitevtEx(cjchdev, cjdevcounts, -1, &evt_handle)==-1){
			Sleep(30);
			TRACE("sr_waitevtEx error");
			continue;
		}

		tmp_dev = sr_getevtdev(evt_handle);
		eventtype = sr_getevttype(evt_handle);
		if((tmp_dev==cjchdev[0])&&(eventtype==USEREVT_KEYBOARD)){
            //AfxMessageBox("Stop the dialogic thread");
			break;
		}

		// Get the channel number from which the event was received.
		channel=0;
		while (channel < MAXDEVS) {
			if(dxinfo[channel].dtdev==tmp_dev) {
				break;
			}
			if(dxinfo[channel].chdev==tmp_dev) {
				break;
			}
			channel++;
		}

		if(channel >= MAXDEVS) 
			continue;

		if(Process(channel, evt_handle)!=0)
			break;
	}

    //结束时关闭所有通道
	end_prog();

	return(0);
}

/***************************************************************
 *	名称:int Process(int channel,unsigned long evt_handle)
 *	功能:催缴工作线程中调用到的处理函数
 **************************************************************/
int Process(int channel,unsigned long evt_handle)
{
	long eventtype;
	long *datap;
	DX_CST *cstp;
	long term;

	eventtype = sr_getevttype(evt_handle);
	dxinfo[channel].chtime=0;

	switch(eventtype){
	case DTEV_SIG: //event on DTI
		datap=(long*)sr_getevtdatap(evt_handle);
		if((*datap & DTMM_AON)==DTMM_AON){
			TRACE("%s: --- EVENT DATA: DTMM_AON",dxinfo[channel].dtdevname);
			//处理DTMM_AON事件(挂机,不处理)
		}
		if((*datap & DTMM_AOFF)==DTMM_AOFF){
			TRACE("%s: --- EVENT DATA: DTMM_AOFF",dxinfo[channel].dtdevname);
			//处理DTMM_AOFF事件(远端摘机,放催缴音)
			dxinfo[channel].chdevzt=CHDEVZT_E;
			telecount.success_count++;
			::SendMessage( myhwnd, WM_COPY, (WPARAM) 0, (LPARAM) 0);
			//发送屏显
			strcpy(dxinfo[channel].chdevztmx,chdevztmx[4]);
			strcpy(dxinfo[channel].chdevcjjg,"催缴成功");
			//ChnPrintf(channel+1,"_STATE","用户接听");
			yin_playf(channel);
		}
		if((*datap & DTMM_BON)==DTMM_BON){
			TRACE("%s: --- EVENT DATA: DTMM_BON",dxinfo[channel].dtdevname);
			//处理DTMM_BON事件(交换机应答,发一个playtone)
			dxinfo[channel].chdevzt=CHDEVZT_C;
			strcpy(dxinfo[channel].chdevztmx,chdevztmx[2]);
			//应答前先从缓冲区中读一条数据,
			if(Readdata(channel) == -1){
				return(0);
			}
			//写屏显信息
			//ChnPrintf(channel+1,"_STATE","拨催缴号");
			//ChnPrintf(channel+1,"_TELE",teleinfo[channel].num);
			yin_mfc(channel);
		}
		if((*datap & DTMM_BOFF)==DTMM_BOFF){
			TRACE("%s: --- EVENT DATA: DTMM_BOFF",dxinfo[channel].dtdevname);
			//处理DTMM_BOFF事件(远端挂机)
			//播音完成前用户挂机产生此事件时,通道停止播放催缴音
			switch(dxinfo[channel].chdevzt){
			case CHDEVZT_E:
				if(dxinfo[channel].playflag==1){
					dx_stopch(dxinfo[channel].chdev,EV_ASYNC);
				}
				else{
					//ChnPrintf(channel+1,"_STATE","用户挂机");
					strcpy(dxinfo[channel].chdevztmx,chdevztmx[6]);
					yin_fwaon(channel);
				}
				break;
			case CHDEVZT_B:
			case CHDEVZT_C:
			case CHDEVZT_D:
				strcpy(dxinfo[channel].chdevztmx,chdevztmx[6]);
				//ChnPrintf(channel+1,"_STATE","用户挂机");
				yin_fwaon(channel);
				break;
			}
		}
		break;
	case TDX_CST:
		cstp=(DX_CST*)sr_getevtdatap(evt_handle);
		switch (cstp->cst_event){
		case DE_TONEON:
			TRACE("--- EVENT DATA: DE_TONEON");
			//处理 DE_TONEON事件(接收bksig,并处理)
			yin_getbksig(channel,evt_handle);
			if(dxinfo[channel].chdevzt==CHDEVZT_D){
				strcpy(dxinfo[channel].chdevztmx,chdevztmx[3]);
				//ChnPrintf(channel+1,"_STATE","振铃");
			}
			break;
		case DE_TONEOFF:
			TRACE("--- EVENT DATA: DE_TONEOFF");
			//处理 DE_TONEOFF事件(接收完成,发送下一个playtone)
			yin_mfc(channel);
			break;
		}
	case TDX_PLAY: /* Play ENDS*/
		switch(dxinfo[channel].chdevzt){
		case CHDEVZT_E:
			dxinfo[channel].playflag=0;
			term=ATDX_TERMMSK(dxinfo[channel].chdev);
			if(term & TM_USRSTOP)
				TRACE("%s: Play ended by TM_USRSTOP",dxinfo[channel].chdevname);
				//break;
			if(term & TM_MAXTIME)
				TRACE("%s: Play ended by TM_MAXTIME",dxinfo[channel].chdevname);
			if(term & TM_EOD)
				TRACE("%s: Play ended by TM_EOD",dxinfo[channel].chdevname);
			//发送屏显
			//ChnPrintf(channel+1,"_STATE","写数据库日志");
			strcpy(dxinfo[channel].chdevztmx,chdevztmx[5]);
			dxinfo[channel].chdevzt=CHDEVZT_F;
			GetTime(teleinfo[channel].zzsj_time);
			//ChnPrintf(channel+1,"_END",teleinfo[channel].zzsj_time);
			teleinfo[channel].cjcount++;
			//SysPrintf("teleinfo %d , cjcount=%d",channel,teleinfo[channel].cjcount);
			datarecord.chdevno = channel;
			pRecordData.SetEvent();
			dt_settssig(dxinfo[channel].dtdev,DTB_ABIT,DTA_ADDMSK);
			chan_seton(channel);
			break;
		/*case CHDEVZT_G:
			//发送屏显
			strcpy(dxinfo[channel].chdevztmx,chdevztmx[7]);
			//ChnPrintf(channel+1,"_STATE","写数据库成功");
			yin_fwaon(channel);
			break;
		case CHDEVZT_F:
			strcpy(dxinfo[channel].chdevztmx,chdevztmx[8]);
			//ChnPrintf(channel+1,"_STATE","未写数据库");
			yin_fwaon(channel);
			break;
		case CHDEVZT_H:
			//发送屏显
			strcpy(dxinfo[channel].chdevztmx,chdevztmx[8]);
			//ChnPrintf(channel+1,"_STATE","写数据库失败");
			yin_fwaon(channel);
			break;*/
		}
		break;
	case TDX_PLAYTONE:
		TRACE("--- EVENT DATA: TDX_PLAYTONE");
		// TM_TONE不处理;
		break;
	case TDX_DIAL:
		TRACE("--- EVENT DATA: TDX_DIAL");
		//这里不是通过拨号建立通话方式
		break;
	default:
		TRACE("--- EVENT TYPE AND DATA: %ld UNKNOWN",eventtype);
		//产生了其它的不须处理的事件
		break;
	}  // end switch
	return(0);
}

/*************************************************************************
* Name : end_prog()
* Input: none.
* Des:   This function stops, setonhook and closes all channels
*
**************************************************************************/
int end_prog()
{
	int i;
	unsigned long ta=0L, tm=0L;

	//关闭通道
	for(i=0;i<MAXDEVS;i++){
		if(strcmp(signlight[i].app_id,cjappid)!=0){
			continue;
		}
		dx_stopch(dxinfo[i].chdev,EV_ASYNC);
		yin_fwaon(i);
		dx_close(dxinfo[i].chdev);
		dt_close(dxinfo[i].dtdev);
		strcpy(dxinfo[i].chdevztmx,"关闭");
		clr_output(i);
	}
	//关闭语音文件
	for(i=0;i<=MAXFILES;i++){
		if(dx_fileclose(szfile[i].filehandle)==-1){
			//AfxMessageBox("close file %s error",szfile[filenumber].filename);
		    TRACE("close file error");
		}
	}
	//AfxMessageBox("All channels closed");
	return 0;
}

/*************************************************************************
*			Fuction    : int yin_mfc(int channel) 
*			Description: MultiFrequencyControl Procedure
**************************************************************************/
int yin_mfc(int channel)
{
	int fwsig;

	//FW: 1  6  8  KA 5  0  4  5  3  6  4 SIGI_15 SIGII_3(KD)
	//BW:  A1 A1 A6 A1 A1 A1 A1 A1 A1 A1 A1   A3    B1(KB)
	//Where KA is the calling' s category
	//      DNIS=168, ANI=5045364

	//FW: 1  6  KA 5  0  4  5  3  6  4 SIGI_15 8  SIGII_3(KD)
	//BW:  A1 A6 A1 A1 A1 A1 A1 A1 A1 A1   A1   A3    B1(KB)
	//Where KA is the calling' s category
	//      DNIS=168, ANI=5045364, KD=SIGII_3, Local Call

	if(dxinfo[channel].bksig==SIGA_2) {//send from first digit
		dxinfo[channel].bksig=SIGA_1;
		dxinfo[channel].ani_num=0;
		dxinfo[channel].dnis_num=0;
		dxinfo[channel].Sending=0; //(=0 for DNIS),(=1 for ANI)
	}
	
	switch (dxinfo[channel].bksig){
	case SIGA_1:
		switch (dxinfo[channel].Sending){
		case 0: // Sending DNIS
			if(dxinfo[channel].dnis_num < sizeof(teleinfo[channel].num)) {
				fwsig=(teleinfo[channel].num[dxinfo[channel].dnis_num]=='0')?SIGI_10:(teleinfo[channel].num[dxinfo[channel].dnis_num]-0x31+SIGI_1);
				dxinfo[channel].dnis_num++;
				break;
			} 
			else { // = DNIS_LEN in case that no A6/A3 received
				fwsig=SIGI_1; // KA
				dxinfo[channel].Sending=1;
				break;
			}
			break;
		case 1: // Sending ANI
			/*This line is for special use, dedicate to hangup during MFC
			if((i % 2) && (dev[i].ani_num==2)) {
				yin_fwaon(i);
				return 0;
			}
			*********************************/

			if (dxinfo[channel].ani_num>=ani_len){
				fwsig=SIGI_15;
				dxinfo[channel].Sending=(dxinfo[channel].dnis_num < sizeof(teleinfo[channel].num))?2:3;
				//=2 means sending the left DNIS number
				//=3 means into Group_II, wait for SIGA_3				
				break;
			}
			else {
				fwsig=(Ani[dxinfo[channel].ani_num]=='0')?SIGI_10:(Ani[dxinfo[channel].ani_num]-0x31+SIGI_1);

⌨️ 快捷键说明

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