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

📄 cgcdr.cpp

📁 Mysql的处理
💻 CPP
字号:
#include "oradb.h"/* NOTE: Sequece Id*/void C_MYSQL::DbCGCDRTest(S_CGCDR &pIn10){S_RESULT pOut10;//memset(&pIn10,0,sizeof(pIn10));pIn10.RecordType=5;pIn10.NetworkInitiatedPDPContext=9;memcpy(pIn10.ServedIMSI,"ServedIMSI",5);snprintf(pIn10.GGSNAddress,LEN_IpAddr+1,"201.40.7.58");memcpy(pIn10.ChargingID,"555555",5);memcpy(pIn10.AccessPointNameNI,"AccessPointNameNI",5);memcpy(pIn10.PDPTypeNumber,"PDPTypeNumber",5);snprintf(pIn10.ServedPDPAddress,LEN_IpAddr+1,"10.0.0.1");pIn10.DynamicAddressFlag=8;snprintf(pIn10.RecordOpenTime,LEN_DATETIME + 1,"080912031920");memcpy(pIn10.CallDuration,"6666666",5);snprintf(pIn10.Diagnostics,LEN_Diagnostics+1,"9");snprintf(pIn10.NodeID,LEN_NodeID+1,"NodeID");pIn10.APNSelectionMode=3;snprintf(pIn10.ServedMSISDN,LEN_ServedMSISDN+1,"ServedMSISDN");snprintf(pIn10.SgsnPlmnIdentifier,LEN_SgsnPlmnIdentifier+1,"SgsnPlmnIdentifier");memcpy(pIn10.ConsolidationResult,"33",2);pIn10.ChargingCharacterSelectionMode=2;snprintf(pIn10.ChargingCharacteristics,LEN_ChargingCharacteristics+1,"Charging");pIn10.AnonyAccessIndicator=7;snprintf(pIn10.RemotePdpAddr,LEN_IpAddr+1,"111.111.11.1");pIn10.FlagRead=9;//snprintf(pIn10.SeqId,LEN_SEQ + 1,"2");snprintf(pIn10.TableName,LEN_TABLENAME + 1,"CGCDR");pIn10.FlagRepeat=3;pIn10.FlagR499=4;snprintf(pIn10.GsnId,LEN_GSNID+1,"7878787878");snprintf(pIn10.SGSNIPAddress,LEN_IpAddr+1,"SGSNIPAddress");memcpy(pIn10.CauseForRecClosing,"77",2);memcpy(pIn10.RecordSequenceNumber,"101101",5);snprintf(pIn10.RecordExtensions,LEN_RecordExtensions+1,"RecordExtensions");memcpy(pIn10.LocalRecordSequeceNumnber,"80808080",5);}int C_MYSQL::DbCGCDRInsert(struct S_CGCDR* p, struct S_RESULT* pOut){	char szMsg[512];	char* TableName = p->TableName;	char* SeqId = p->SeqId;/*	char *GtpName=(char *)p->GtpName;	char *GtpId=(char *)p->GtpId;*/	int FlagRead = p->FlagRead;		/*1*/	int FlagRepeat = p->FlagRepeat;	int FlagR499 = p->FlagR499;	int NetworkInitiatedPDPContext = p->NetworkInitiatedPDPContext;	/*2*/	char *ServedIMSI = p->ServedIMSI;	char *ServedMSISDN = p->ServedMSISDN;	char *SGSNIPAddress = p->SGSNIPAddress;		/*3*/	char*  ChargingID = p->ChargingID;	char *GGSNAddress = p->GGSNAddress;	char *AccessPointNameNI = p->AccessPointNameNI;		/*4*/	int APNSelectionMode = p->APNSelectionMode;	char *PDPTypeNumber = p->PDPTypeNumber;	char *ServedPDPAddress = p->ServedPDPAddress;	char *RecordOpenTime = p->RecordOpenTime;	char *CallDuration = p->CallDuration;	/*5*/	char* CauseForRecClosing = p->CauseForRecClosing;	char *Diagnostics = p->Diagnostics;	char* RecordSequenceNumber = p->RecordSequenceNumber;	char *NodeID = p->NodeID;	char* LocalRecordSequeceNumnber = p->LocalRecordSequeceNumnber;		/*6*/	char* ChargingCharacteristics = p->ChargingCharacteristics;	int DynamicAddressFlag = p->DynamicAddressFlag;	char * ConsolidationResult = p->ConsolidationResult;	int ChargingCharacterSelectionMode = p->ChargingCharacterSelectionMode;	/* stamp */	char *DateCreated = p->DateCreated;	/*10*/	char *GsnId = p->GsnId;	char *RecordExtensions = p->RecordExtensions;	char *SgsnPlmnIdentifier = p->SgsnPlmnIdentifier; /* both for R4 & R99*/	int	AnonyAccessIndicator = p->AnonyAccessIndicator; /* only for R4 */	char *RemotePdpAddr = p->RemotePdpAddr; /* only for R4 */	char szSQL[SQLMAX];	char szSeqId[LEN_SEQ+1];	memset(szSQL,0,SQLMAX);	memset(szSeqId,0,LEN_SEQ+1);snprintf(szSQL, SQLMAX, "INSERT INTO %s (" "FLAGREPEAT," "FLAGR499," "NETWORKINITIATEDPDPCONTEXT,""SERVEDIMSI," "SERVEDMSISDN," "SGSNIPADDRESS," /* 8*/"CHARGINGID," "GGSNADDRESS," "ACCESSPOINTNAMENI,""APNSELECTIONMODE," "PDPTYPENUMBER," "SERVEDPDPADDRESS," "RECORDOPENTIME,"/* "SGSNCHANGE,"*//*15*/"CAUSEFORRECCLOSING," "DIAGNOSITICS," "RECORDSEQUENCENUMBER," "NODEID," "LOCALRECORDSEQUECENUMBER,""CHARGINGCHARACTERISTICS," "DYNAMICADDRESSFLAG," /* 22 */"CONSOLIDATIONRESULT," "CHARGINGCHARACTERSELECTIONMODE," "DATECREATED,""CALLDURATION,""GSNID,FLAGREAD"#ifdef EXT10cg1",RECORDEXTENSIONS"",SGSNPLMNIDENTIFIER"",ANONYMOUSACCESSINDICATOR"",REMOTEPDPADDRESS"#endif	") VALUES(""%d,%d,%d,""'%s','%s','%s',""%s,'%s','%s',""%d,'%s','%s','%s',""%s,%s,%s,'%s',%s,""'%s',%d,""%s,%d,NOW(),""%s,""%s,%d"#ifdef EXT10cg1",'%s'"",'%s'"",%d"",'%s'"#endif					")",	TableName,	FlagRepeat,	FlagR499,	NetworkInitiatedPDPContext,		ServedIMSI,	ServedMSISDN,	SGSNIPAddress,	ChargingID[0]==0?"NULL":ChargingID,	GGSNAddress,	AccessPointNameNI,		APNSelectionMode,	PDPTypeNumber,	ServedPDPAddress,	RecordOpenTime,		CauseForRecClosing[0]==0?"NULL":CauseForRecClosing,	Diagnostics[0]==0?"NULL": Diagnostics,	RecordSequenceNumber[0]==0?"NULL":RecordSequenceNumber,	NodeID,	LocalRecordSequeceNumnber[0]==0?"NULL":LocalRecordSequeceNumnber,	ChargingCharacteristics,	DynamicAddressFlag,	ConsolidationResult[0]==0?"NULL":ConsolidationResult,	ChargingCharacterSelectionMode,	CallDuration[0]==0?"NULL":CallDuration,GsnId[0]==0?"NULL":GsnId,FlagRead#ifdef EXT10cg1,RecordExtensions,SgsnPlmnIdentifier,AnonyAccessIndicator,RemotePdpAddr#endif);#ifdef _DEBUG	logOra(sErrLog, szSQL);#endif		Lock();	int res = mysql_real_query(myConnect, szSQL, strlen(szSQL));	if(res != 0)	{		Unlock();		onError();		return -1;	}	if(GetSeq(p->SeqId) != 0)	{		Unlock();		onError();		return -2;	}	Unlock();	return 0;}int C_MYSQL::DbCGCDRSelect(char* pInSzTableName, char* pWhere, struct S_CGCDR_LOAD** pOutCDR, int *number, struct S_RESULT* pOut){	char szMsg[512];	char GtpName[LEN_TABLENAME + 1];	char GtpId[LEN_SEQ + 1];		char SeqId[LEN_SEQ + 1];		int FlagRead;	int FlagRepeat;	int FlagR499;	int NetworkInitiatedPDPContext;	char ServedIMSI[17];	char ServedMSISDN[LEN_ServedMSISDN+1];	char SGSNIPAddress[46];	char CellIdentity[25];	char ChargingID[13];	char GGSNAddress[46];	char AccessPointNameNI[64];	int APNSelectionMode;	char PDPTypeNumber[9];	char ServedPDPAddress[46];	char RecordOpenTime[LEN_DATETIME + 1];	char CallDuration[13];/*	int SGSNChange;*/	char CauseForRecClosing[3];	char Diagnostics[LEN_Diagnostics+1];	char RecordSequenceNumber[11];	char NodeID[21];	char LocalRecordSequeceNumnber[11];	char ChargingCharacteristics[LEN_ChargingCharacteristics+1];	int DynamicAddressFlag;		char ConsolidationResult[3];	int ChargingCharacterSelectionMode;	char DateCreated[LEN_DATETIME + 1];	char GsnId[11];	char RecordExtensions[LEN_RecordExtensions+1];	char		SgsnPlmnIdentifier[LEN_SgsnPlmnIdentifier+1]; /* both for R4 & R99*/	int		AnonyAccessIndicator; /* only for R4 */	char		RemotePdpAddr[45+1]; /* only for R4 */	struct S_CGCDR_LOAD *pLCLOC = *pOutCDR;	int nNumber = 0;	char szSQL[SQLMAX];	char szSQL2[SQLMAX];	char szSQL3[SQLMAX];	struct S_CGCDR_LOAD* p2;	int j;	char * sz ;	short id[40];	*number = 0;	if(pLCLOC != NULL)	{		return -1;	}	snprintf(szSQL2, SQLMAX, 		"SELECT COUNT(*) FROM %s WHERE %s",		pInSzTableName, pWhere);	snprintf(szSQL, SQLMAX, 		"SELECT ""SEQID,""FLAGREAD,""FLAGREPEAT,""FLAGR499,""NETWORKINITIATEDPDPCONTEXT,""SERVEDIMSI,""GGSNADDRESS,""CHARGINGID,""SGSNIPADDRESS,""ACCESSPOINTNAMENI,""PDPTYPENUMBER,""SERVEDPDPADDRESS,""DYNAMICADDRESSFLAG,""DATE_FORMAT(RECORDOPENTIME,'%%Y%%m%%d%%H%%i%%s'),"//"RECORDOPENTIME,""CALLDURATION,""CAUSEFORRECCLOSING,""DIAGNOSITICS,""RECORDSEQUENCENUMBER,""NODEID,""RECORDEXTENSIONS,""LOCALRECORDSEQUECENUMBER,""APNSELECTIONMODE,""SERVEDMSISDN,""CHARGINGCHARACTERISTICS,""SGSNPLMNIDENTIFIER,""CONSOLIDATIONRESULT,""CHARGINGCHARACTERSELECTIONMODE,""ANONYMOUSACCESSINDICATOR,""REMOTEPDPADDRESS,""DATE_FORMAT(DATECREATED,'%%Y%%m%%d%%H%%i%%s'),""GSNID"		" FROM %s WHERE %s",		pInSzTableName, pWhere);//#ifdef _DEBUG//#ifdef LOG_SELECT//	logOra(sErrLog, szSQL);//#endif//#endif	Lock();    nNumber=DbCount(szSQL2,myConnect);	if(nNumber <= 0)	{		Unlock();		* number = 0;		return 0;	}	sz = (char *)malloc(SIZE_S_CGCDR_LOAD*nNumber);	memset(sz, 0, SIZE_S_CGCDR_LOAD*nNumber);	mysql_real_query(myConnect, szSQL, strlen(szSQL));	MYSQL_RES *res_ptr = mysql_store_result(myConnect);	if (res_ptr == NULL) 	{		Unlock();		onError();		return -1;	}	MYSQL_ROW sqlrow;#ifdef _DEBUG	logOra(sErrLog, "CURSOR...");#endif	for(j=0;j<nNumber;j++)	{	sqlrow = mysql_fetch_row(res_ptr);	p2 = (struct S_CGCDR_LOAD*)&sz[SIZE_S_CGCDR_LOAD*j];	if (sqlrow[2] != NULL) p2->FlagRepeat=atoi(sqlrow[2]);	if (sqlrow[3] != NULL) p2->FlagR499=atoi(sqlrow[3]);	if (sqlrow[4] != NULL) p2->NetworkInitiatedPDPContext=atoi(sqlrow[4]);	if (sqlrow[5] != NULL) memcpy(p2->ServedIMSI,sqlrow[5],16);	if (sqlrow[22] != NULL) memcpy(p2->ServedMSISDN,sqlrow[22],LEN_ServedMSISDN);	if (sqlrow[8] != NULL) memcpy(p2->SGSNIPAddress,sqlrow[8],45);	if (sqlrow[7] != NULL) memcpy(p2->ChargingID,sqlrow[7],sizeof(p2->ChargingID));	if (sqlrow[6] != NULL) memcpy(p2->GGSNAddress,sqlrow[6],45);	if (sqlrow[9] != NULL) memcpy(p2->AccessPointNameNI,sqlrow[9],63);	if (sqlrow[21] != NULL) p2->APNSelectionMode=atoi(sqlrow[21]);	if (sqlrow[10] != NULL) memcpy(p2->PDPTypeNumber,sqlrow[10],8);	if (sqlrow[11] != NULL) memcpy(p2->ServedPDPAddress,sqlrow[11],45);	if (sqlrow[13] != NULL) memcpy(p2->RecordOpenTime,sqlrow[13],LEN_DATETIME);	if (sqlrow[14] != NULL) memcpy(p2->CallDuration,sqlrow[14],13);	if (sqlrow[15] != NULL) memcpy(p2->CauseForRecClosing,sqlrow[15],3);	if (sqlrow[16] != NULL) memcpy(p2->Diagnostics,sqlrow[16],LEN_Diagnostics);	if (sqlrow[17] != NULL) memcpy(p2->RecordSequenceNumber,sqlrow[17],11);	if (sqlrow[18] != NULL) memcpy(p2->NodeID,sqlrow[18],20);	if (sqlrow[20] != NULL) memcpy(p2->LocalRecordSequeceNumnber,sqlrow[20],11);	if (sqlrow[23] != NULL) memcpy(p2->ChargingCharacteristics,sqlrow[23],LEN_ChargingCharacteristics);	if (sqlrow[12] != NULL) p2->DynamicAddressFlag=atoi(sqlrow[12]);		if (sqlrow[25] != NULL) memcpy(p2->ConsolidationResult,sqlrow[25],2);	if (sqlrow[26] != NULL) p2->ChargingCharacterSelectionMode=atoi(sqlrow[26]);	if (sqlrow[29] != NULL) memcpy(p2->DateCreated,sqlrow[29],LEN_DATETIME);	if (sqlrow[30] != NULL) memcpy(p2->GsnId,sqlrow[30],10);	if (sqlrow[0] != NULL) memcpy(p2->SeqId,sqlrow[0],20);	if (sqlrow[1] != NULL) p2->FlagRead=atoi(sqlrow[1]);if (sqlrow[19] != NULL) memcpy(p2->RecordExtensions,sqlrow[19],LEN_RecordExtensions);if (sqlrow[24] != NULL) memcpy(p2->SgsnPlmnIdentifier,sqlrow[24],LEN_SgsnPlmnIdentifier);if (sqlrow[27] != NULL) p2->AnonyAccessIndicator = atoi(sqlrow[27]);if (sqlrow[28] != NULL) memcpy(p2->RemotePdpAddr, sqlrow[28], 45);		if (pInSzTableName != NULL) memcpy(p2->TableName, pInSzTableName, LEN_TABLENAME);/*		snprintf(szSQL3, SQLMAX, 					"UPDATE %s SET FLAGREAD=1 WHERE SEQID='%s'", 					p2->TableName, p2->SeqId);		mysql_real_query(myConnect, szSQL3, strlen(szSQL3));*///	printf("SeqId:%s\n", p2->SeqId);	}		* pOutCDR = (struct S_CGCDR_LOAD*)sz;	* number = nNumber;			mysql_free_result(res_ptr);		if (mysql_errno(myConnect)) 	{		Unlock();		onError();				return -1;	}		Unlock();	return 0;}

⌨️ 快捷键说明

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