📄 lc55.c
字号:
#include "D4ALL.h"
typedef struct {
char type1[3];
char callPhone[17];
char type2[3];
char calledPhone[25];
char answerTime[7];
char endTime[7];
char timesInSec[7];
char timesInMin[6];
char callDate[5];
char inComing[5];
char outGoing[5];
} PhoneStruct;
static char initBSHead[4]={ 2, 0, 0, 0 };
static int getPhoneStruct(unsigned char *p,PhoneStruct *pps)
{
unsigned long Times,Minute;
char buf[40];
char ch;
int i,j,isError=False;
memset(pps,0,sizeof(PhoneStruct));
if (*p==0xEE) return isError;
strcpy(pps->type1,"01");
strcpy(pps->type2,"01");
for (i=0,j=0; i<8; i++)
{
if ((buf[j++]=getHigh(*(p+i+1)))>'9') isError=True;
if (j>=PhoneLength) break;
if ((buf[j++]=getLow(*(p+i+1)))>'9') isError=True;
if (j>=PhoneLength) break;
}
buf[j]=0;
strcpy(pps->callPhone,buf);
memset(buf,0,sizeof(buf));
for (i=0; i<12; i++)
{
ch=getHigh(*(p+9+i));
if (ch>'9') break;
buf[2*i]=ch;
ch=getLow(*(p+9+i));
if (ch>'9') break;
buf[2*i+1]=ch;
}
strcpy(pps->calledPhone,buf);
buf[0]=getHigh(*(p+28));
buf[1]=getLow(*(p+28));
buf[2]=getHigh(*(p+29));
buf[3]=getLow(*(p+29));
buf[4]=getHigh(*(p+30));
buf[5]=getLow(*(p+30));
buf[6]=0;
strcpy(pps->answerTime,buf);
buf[0]=getLow(*(p+34));
buf[1]=getHigh(*(p+35));
buf[2]=getLow(*(p+35));
buf[3]=getHigh(*(p+36));
buf[4]=getLow(*(p+36));
buf[5]=getHigh(*(p+37));
buf[6]=0;
strcpy(pps->endTime,buf);
Times=0;
ch=getLow(*(p+38))-'0';
Times+=36000lu*(unsigned long)ch;
ch=getHigh(*(p+39))-'0';
Times+=3600lu*(unsigned long)ch;
ch=getLow(*(p+39))-'0';
Times+=600lu*(unsigned long)ch;
ch=getHigh(*(p+40))-'0';
Times+=60lu*(unsigned long)ch;
ch=getLow(*(p+40))-'0';
Times+=10lu*(unsigned long)ch;
ch=getHigh(*(p+41))-'0';
Times+=(unsigned long)ch;
if (Times==0)
{
ch=getLow(*(p+41))-'0';
if (ch!=0) Times++;
}
if (Times<LimitCountSecond) Times=0;
Minute=Times/60lu;
if ((Times%60lu)!=0) Minute++;
sprintf(buf,"%06lu",Times);
strcpy(pps->timesInSec,buf);
sprintf(buf,"%05lu",Minute);
strcpy(pps->timesInMin,buf);
buf[0]=getHigh(*(p+26));
buf[1]=getLow(*(p+26));
buf[2]=getHigh(*(p+27));
buf[3]=getLow(*(p+27));
buf[4]=0;
strcpy(pps->callDate,buf);
buf[0]=getHigh(*(p+21));
buf[1]=getLow(*(p+21));
buf[2]=getHigh(*(p+22));
buf[3]=getLow(*(p+22));
buf[4]=0;
strcpy(pps->inComing,buf);
buf[0]=getHigh(*(p+23));
buf[1]=getLow(*(p+23));
buf[2]=getHigh(*(p+24));
buf[3]=getLow(*(p+24));
buf[4]=0;
strcpy(pps->outGoing,buf);
return isError;
}
static void ConvertToDBFFormat(DataInfo *pdata)
{
long len,total,curr;
int retValue,retCode,rc;
int FLAG = 0;
int CASE,isError;
int x1,y1;
TEST Test;
char filename[MAXPATH];
unsigned i,j,index,count;
unsigned char *p;
long offset;
PhoneStruct Phone;
char buf[100];
CODE4 CodeBase;
FIELD4INFO *field_info;
DATA4 *dataSource, *dataDest;
FIELD4 *field_type1, *field_callPhone;
FIELD4 *field_type2, *field_calledPhone;
FIELD4 *field_answerTime, *field_endTime;
FIELD4 *field_timesInSec, *field_timesInMin;
FIELD4 *field_callDate, *field_inComing;
FIELD4 *field_outGoing, *field_ArcNo;
len=pdata->DataLen;
total=len;
curr=0L;
retValue=getFileName(DBFFormat,filename);
if (retValue==False) return;
strcpy(buf,filename);
strcat(buf,DATA_DBF);
unlink(buf);
strcpy(filename,"LCINIT55.DBF");
changePath(filename,DataFilePath);
d4init(&CodeBase);
CodeBase.safety = 0;
dataSource = d4open(&CodeBase,filename);
e4exit_test(&CodeBase);
field_info = d4field_info(dataSource);
dataDest = d4create(&CodeBase,buf,field_info,0);
u4free(field_info);
field_type1 = d4field_j(dataDest,1);
field_callPhone = d4field_j(dataDest,2);
field_type2 = d4field_j(dataDest,3);
field_calledPhone = d4field_j(dataDest,4);
field_answerTime = d4field_j(dataDest,5);
field_endTime = d4field_j(dataDest,6);
field_timesInSec = d4field_j(dataDest,7);
field_timesInMin = d4field_j(dataDest,8);
field_callDate = d4field_j(dataDest,9);
field_inComing = d4field_j(dataDest,10);
field_outGoing = d4field_j(dataDest,11);
strcpy(filename,DLGPATH);
strcat(filename,"\\PROCESS.DLG");
ReadDialogWindows(filename);
DialogTab = 2;
x1=DialogWindows.x1;
y1=DialogWindows.y1;
strcpy(DialogWindows.text,"数据库格式处理进度窗口");
strcpy(DialogLabel[0].text,"当前正在进行数据转换 ...");
SetDialogPath(DLGPATH);
CreateDialogWindows();
while(!FLAG)
{
BOY_GET_TEST(&Test);
CASE=GetDialogWindows(&Test);
switch(CASE)
{
case WM_MOVE:
x1=DialogWindows.x1;
y1=DialogWindows.y1;
ShowBar( x1, y1, curr, total );
break;
case 101:
case WM_CLOSE:
FLAG=1;
retCode=True;
continue;
}
if (curr>=total)
{
FLAG=1;
retCode=True;
continue;
}
rc=ReadDataSource(pdata,curr);
if (rc!=True)
{
FLAG=1;
retCode=False;
continue;
}
p=DiskBuffer+3; //4;
for (count=0; count<37; count++)
{
if (*p==0xEE) break;
isError=getPhoneStruct(p,&Phone);
p+=0x38; //0x37;
if (isError!=True)
{
d4append_start(dataDest,0);
f4assign(field_type1,Phone.type1);
f4assign(field_callPhone,Phone.callPhone);
f4assign(field_type2,Phone.type2);
f4assign(field_calledPhone,Phone.calledPhone);
f4assign(field_answerTime,Phone.answerTime);
f4assign(field_endTime,Phone.endTime);
f4assign(field_timesInSec,Phone.timesInSec);
f4assign(field_timesInMin,Phone.timesInMin);
f4assign(field_callDate,Phone.callDate);
f4assign(field_inComing,Phone.inComing);
f4assign(field_outGoing,Phone.outGoing);
d4append(dataDest);
}
}
curr+=nBytePerBlock;
ShowBar( x1, y1, curr, total );
}
CloseDialogWindows();
d4close_all(&CodeBase);
if (retCode==False)
{
ErrorAccessFile();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -