📄 myapi.pc
字号:
ReadBufMsg(buf_data, 6, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.kq_id = -1;
else
{
stDBRecord_id.kq_id = 0;
strcpy(stDBRecord.kq, cElement );
}
ReadBufMsg(buf_data, 12, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.tykh_id = -1;
else
{
stDBRecord_id.tykh_id = 0;
strcpy(stDBRecord.tykh, cElement );
}
ReadBufMsg(buf_data, 6, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.jb_id = -1;
else
{
stDBRecord_id.jb_id = 0;
strcpy(stDBRecord.jb, cElement );
}
ReadBufMsg(buf_data, 2, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.pc_id = -1;
else
{
stDBRecord_id.pc_id = 0;
stDBRecord.pc = (int)atoi(cElement);
}
ReadBufMsg(buf_data, 2, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.kz_id = -1;
else
{
stDBRecord_id.kz_id = 0;
stDBRecord.kz = (int)atoi(cElement);
}
ReadBufMsg(buf_data, 4, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.bym_id = -1;
else
{
stDBRecord_id.bym_id = 0;
stDBRecord.bym = (int)atoi(cElement);
}
ReadBufMsg(buf_data, 1, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.xyf_id = -1;
else
{
stDBRecord_id.xyf_id = 0;
strcpy(stDBRecord.xyf, cElement );
}
ReadBufMsg(buf_data, 5, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.bbdyfl_id = -1;
else
{
stDBRecord_id.bbdyfl_id = 0;
stDBRecord.bbdyfl = (float)atof(cElement);
}
ReadBufMsg(buf_data, 5, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.wbdyfl_id = -1;
else
{
stDBRecord_id.wbdyfl_id = 0;
stDBRecord.wbdyfl = (float)atof(cElement);
}
ReadBufMsg(buf_data, 5, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.bblsfl_id = -1;
else
{
stDBRecord_id.bblsfl_id = 0;
stDBRecord.bblsfl = (float)atof(cElement);
}
ReadBufMsg(buf_data, 5, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.wblsfl_id = -1;
else
{
stDBRecord_id.wblsfl_id = 0;
stDBRecord.wblsfl = (float)atof(cElement);
}
ReadBufMsg(buf_data, 160, cElement );
trim(cElement);
if (cElement[0] == '\0')
stDBRecord_id.bz_id = -1;
else
{
stDBRecord_id.bz_id = 0;
strcpy(stDBRecord.bz, cElement );
}
stDBRecord.key = MsgHeader.fsxh;
strcpy(stDBRecord.sjbh, CAPITAL_CODE);
InsertSndBKHZMLNRRec(&stDBRecord);
insert_count++;
if (insert_count == COMMIT_FREQUENCE)
{
EXEC SQL COMMIT WORK;
insert_count = 0;
}
}
EXEC SQL COMMIT WORK;
UpdateSndLogRecStatus( MsgHeader.fsxh );
strcat( buf_HZ_Msg, CAPITAL_CODE );
strcat( buf_HZ_Msg, MsgHeader.sjbh );
if(MQBKSend_Syn(strlen(buf_HZ_Msg), buf_HZ_Msg, 0, "HZ") <0)
{
ProcessError(LOG_ERROR, "Call funtion MQBKSend_Syn failed!",END);
MQBKBack();
}
else
{
if(MQBKCmit() < 0)
{
ProcessError(LOG_ERROR,"Calling Funtion MQBKCmit() Failed!",END);
MQBKBack();
}
#ifdef DEBUG
printf("it's ok =%ld\n",strlen(buf_HZ_Msg));
#endif
}
}
int ReadBufMsg( char *BKML_Msg, int n, char *element )
{
int i;
element[0]='\0';
for(i=0; i<n; i++)
{
if( BKML_Msg[turn] !='\0')
element[i] = BKML_Msg[turn++];
else
{
ProcessError(LOG_NORMAL,"It's the end of the buffer!",END);
return(0);
}
}
element[i] = '\0';
return(1);
}
/*insert a record into the t_fsrz and t_hz table */
int CreateSndLogAndHZRec(unsigned long lg_Key, char *province_code )
{
char sjfl = SJFL_BKMM;
char sjzt = JSRZ_UNDER_RCV;
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL INSERT INTO T_JSRZ VALUES (:lg_Key, :sjfl, :sjzt, :province_code, SYSDATE );
return(1);
}
/* insert a record into the t_jsbkhzml table */
int InsertBKHZMLRec(unsigned long lg_Key, int nf, char *province_code )
{
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL INSERT INTO T_JSBKHZML VALUES (:nf, :province_code, :lg_Key);
EXEC SQL COMMIT WORK;
return(1);
}
/* insert the record into the t_jsbkhzmlnr table */
int InsertSndBKHZMLNRRec(struct stBKMLDBRec *stDBRecord )
{
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL INSERT INTO T_JSBKHZMLNR VALUES (:stDBRecord->bkdh, :stDBRecord->bkmc :stDBRecord_id.bkmc_id,
:stDBRecord->fbkj :stDBRecord_id.fbkj_id, :stDBRecord->cbrq :stDBRecord_id.cbrq_id,
:stDBRecord->dj :stDBRecord_id.dj_id, :stDBRecord->yj :stDBRecord_id.yj_id,
:stDBRecord->jj :stDBRecord_id.jj_id, :stDBRecord->bnj :stDBRecord_id.bnj_id,
:stDBRecord->nj :stDBRecord_id.nj_id, :stDBRecord->hzddjdrq :stDBRecord_id.hzddjdrq_id,
:stDBRecord->fxfw :stDBRecord_id.fxfw_id, :stDBRecord->kq :stDBRecord_id.kq_id,
:stDBRecord->tykh :stDBRecord_id.tykh_id, :stDBRecord->jb :stDBRecord_id.jb_id,
:stDBRecord->pc :stDBRecord_id.pc_id, :stDBRecord->kz :stDBRecord_id.kz_id,
:stDBRecord->bym :stDBRecord_id.bym_id, :stDBRecord->xyf :stDBRecord_id.xyf_id,
:stDBRecord->bbdyfl :stDBRecord_id.bbdyfl_id, :stDBRecord->wbdyfl :stDBRecord_id.wbdyfl_id,
:stDBRecord->bblsfl :stDBRecord_id.bblsfl_id, :stDBRecord->wblsfl :stDBRecord_id.wblsfl_id,
:stDBRecord->bz :stDBRecord_id.bz_id, :stDBRecord->sjbh, :stDBRecord->key);
return(1);
}
/* update the table to locate the relative flag */
int UpdateSndLogRecStatus( unsigned long lg_Key )
{
char sjzt = JSRZ_WAITFOR_COV;
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL UPDATE T_JSRZ SET SJZT = :sjzt, JSSJ = SYSDATE
WHERE JSXH = :lg_Key;
EXEC SQL COMMIT WORK;
return(1);
}
/*delete the ' ' or '\n' of a string at the begin and end*/
void trim(char *CAline)
{
int i,j;
char temp_string[100];
i=strlen(CAline);
if( CAline[i]!='\0' )
ProcessError(LOG_ERROR,"It's not a string ended by '\0'!",END);
/*delete the end ' ' or '\n' */
while(i>0)
{
if(CAline[i-1]==' '||CAline[i-1]=='\n')
CAline[i-1]='\0';
else
break;
i--;
}
i=0;j=0;
/*delete the head ' ' or '\n' */
while( CAline[i]!='\0' )
{
if(CAline[i]==' '||CAline[i]=='\n')
i++;
else
{
for (j=0;CAline[i]!='\0';i++,j++)
CAline[j]=CAline[i];
break;
}
}
CAline[j]='\0';
}
void ProcessError( char *LOG, char *sErrorMessage1, char *sErrorMessage2 )
{
FILE* hErrorFile;
char cDateTime[100],tempstr[100];
int i,j,len,n;
long filesize;
char bakfile[100];
tempstr[0]='\0';
len=strlen(sErrorMessage1);
for(i=0;i<=len;i++)
{
if(sErrorMessage1[i]=='%')
{
n=i;
if(len!=i+1)
{
for(j=0;j<200&&sErrorMessage1[i+2]!='\0';j++,i++)
tempstr[j]=sErrorMessage1[i+2];
tempstr[j]='\0';
}
break;
}
if(sErrorMessage1[i]=='\0')
{
n=i;
tempstr[0] = '\0';
break;
}
}
sErrorMessage1[n]='\0';
hErrorFile = fopen( ERROR_LOG_FILE, "a" );
if( hErrorFile == NULL )
{
printf( "Critical! Cannot open ERROR_LOG_FILE for append or cannot create!\n");
return;
}
fseek( hErrorFile, 0 ,SEEK_END );
filesize = ftell(hErrorFile);
if (filesize > 5242880)
{
fclose(hErrorFile );
sprintf(bakfile, "mv %s %s.bak", ERROR_LOG_FILE, ERROR_LOG_FILE);
system(bakfile);
hErrorFile = fopen( ERROR_LOG_FILE, "a" );
if( hErrorFile == NULL )
{
printf( "Critical! Cannot open ERROR_LOG_FILE for append or cannot create!\n");
return;
}
}
fseek( hErrorFile, 0 ,SEEK_END );
fputs( "\n",hErrorFile);
fputs( LOG ,hErrorFile);
printf("\n%s",LOG);
fputs( sErrorMessage1,hErrorFile );
printf("%s",sErrorMessage1);
fputs( sErrorMessage2,hErrorFile );
printf("%s",sErrorMessage2);
fputs( tempstr,hErrorFile );
printf("%s\n",tempstr);
fputs( "\n",hErrorFile);
fclose( hErrorFile );
sprintf( cDateTime, "date >> %s\n", ERROR_LOG_FILE );
system( cDateTime );
system( "date");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -