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

📄 pcs_snd_bkjhml1.pc

📁 unix 下用pro*c tuxedo 开发的东西
💻 PC
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*	File name		: Pcs_Snd_BKJHML1.pc	                       *				
*	Module ID		:				               *
*	Module Name	:                                                      *
*	Purpose		: Get BKML Data from BKMLFILE And Insert into DB       *
*	Author          : Mr. laishihong                                       *
*	Date Created	: 1999,07,14                                           *
*	Version		: Version 1.0                                          *
*	Environment	: Digital UNIX                                         *
*	Portability	: UNIX Platform                                        *
*	Warnings	:                                                      *
*	References	:                                                      *
*	Calling Syntax	:                                                      *
*	Parameters	: None                                                 *
*	Returns		: void                                                 *
*	Calling Function:                                                      *
*	Called Functions: When system startup                                  *
*	Datastores and usages:                                                 *                                       *
*        	   (a) Input                                                   *
* 	   (b) OutPut                                                          *       
*	Report		: None                                                 *
*	Screens		: None                                                 *
*	Messages Files	: None                                                 *
*	Change Log	:                                                      *
*	Change No. 	Date	Author	Reason For Change                      *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
*/

#include "stdio.h"
#include <stdlib.h>
#include <sqlcpr.h>
#include <signal.h>
#include "/usr/bkfx/include/Pcs_Snd_BKJHML1/cmdef.h"
#include "/usr/bkfx/include/Pcs_Snd_BKJHML1/Pcs_Snd_BKJHML1.h"
#include "/usr/bkfx/include/Pcs_Snd_BKJHML1/Function_define.h"

/*define the global varible which will get the sequence number*/
unsigned long lg_Key;

char *freememory;
FILE *FreeFileHandle;
char filename[MAX_LINE_LEN];
int  whichline;

void main(int argc,char* arg[])
{
	char *BKMLFileLength;
	char cOneLine[MAX_LINE_LEN+1];
	FILE *hBKMLFile;
	struct stBKMLFileRec stFileRec;
	struct stBKMLDBRec stDBRec;
	size_t FileLength;
	int retcode;
	char Error_Msg[10];
	char cCommand[100];

	ProcessError(LOG_NORMAL,"The application is beginning!", END);

	strcpy(filename, arg[1]);

	if( argc < 3 )
	{
		ProcessError(LOG_ERROR,"Three arguments expected!", END);
		movefile();
		exit(1);
	}

	hBKMLFile = fopen( arg[1], "r" );
	if( hBKMLFile == NULL )
	{
		ProcessError(LOG_ERROR,"Cannot open file: %s,The file may not exist!", arg[1]);
		movefile();
		exit(1);
	}
	
	FreeFileHandle = hBKMLFile;
	
	signal( SIGTERM, terminate );
	
	/*initial the database and the errorlog file */
	InitSndBKJHML1();
	
	/*calculate the length of the file and malloc the memory */
	FileLength=myapi_GetFileSize( hBKMLFile );
	if((BKMLFileLength = (char *)malloc( FileLength +1))==NULL)
	{
		ProcessError(LOG_ERROR,"variable <BKMLFileLength> memory Allocation error - aborting.",END);
		fclose(hBKMLFile);
		EXEC SQL ROLLBACK RELEASE;
		movefile();
		exit(1);
	}
	
	freememory = BKMLFileLength;
	
	/* read the file data into the buffer */
	ReadBKMLFileData(hBKMLFile, FileLength, BKMLFileLength);
	
	/* get the sequence number from the sys.dual table */
	EXEC SQL SELECT S_FSXH.NEXTVAL INTO :lg_Key FROM SYS.DUAL;
	
	/* insert a record into  the t_fsrz and t_hz table */
	CreateSndLogAndHZRec( arg[2] );
	
	/* insert a record into  the t_fsbkjhml */
	InsertBKJHMLRec();
	
	whichline = 0;
	while( myapi_ReadALine( cOneLine, BKMLFileLength ) ) /* read a line from the buffer */
	{
		whichline++;
		/* construct the structure of the fsbkjhml and fsbkjhmlnr */
		if( myapi_FillFileRecord( cOneLine, &stFileRec ) )
			myapi_ConvertToDBRecord( &stFileRec, &stDBRec );
		else
		{
			sprintf(Error_Msg, "%d", whichline);
			ProcessError(LOG_ERROR,"There are some error in line %s!", Error_Msg);
		}
		
		/*myapi_TestShowResult( &stFileRec, &stDBRec );	*/
		/* insert a record into the t_fsbkjhmlnr table */
		InsertSndBKJHMLNRRec( &stDBRec );
		
	}
		
	/* update the t_fsrz and t_hz table to locate the relative flag */
	UpdateSndLogRecStatus();
	
	fclose( hBKMLFile );
	free(BKMLFileLength);

	sprintf( cCommand, "rm -f %s", filename );
	system( cCommand );

	ProcessError(LOG_NORMAL,"The application ended!", END);
}

⌨️ 快捷键说明

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