Пример #1
1
//
//    Save
//    ====
//
//    Save the information for this object to the AuditDataFile
//
bool CLocaleScanner::SaveData	(CAuditDataFile* pAuditDataFile)
{
	CLogFile log;
	log.Write("CLocaleScanner::SaveData Start" ,true);

	CString strValue;

	// Add the Category for memory
	CAuditDataFileCategory category(HARDWARE_CLASS);

	// Each audited item gets added an a CAuditDataFileItem to the category
	CAuditDataFileItem l1(V_LOCALE_CODEPAGE ,m_iCodePage);
	CAuditDataFileItem l2(V_LOCALE_CALENDARTYPE ,m_strCalendarType);
	CAuditDataFileItem l3(V_LOCALE_COUNTRY ,m_strCountry);
	CAuditDataFileItem l4(V_LOCALE_COUNTRYCODE ,m_iCountryCode);
	CAuditDataFileItem l5(V_LOCALE_CURRENCY ,m_strCurrency);
	CAuditDataFileItem l6(V_LOCALE_DATEFORMAT ,m_strDateFormat);
	CAuditDataFileItem l7(V_LOCALE_LANGUAGE ,m_strLanguage);
	CAuditDataFileItem l8(V_LOCALE_LOCALLANGUAGE ,m_strLocaleLocalLanguage);
	CAuditDataFileItem l9(V_LOCALE_OEM_CODEPAGE ,m_iOEMCodePage);
	CAuditDataFileItem l10(V_LOCALE_TIMEFORMAT ,m_strTimeFormat);
	CAuditDataFileItem l11(V_LOCALE_TIMEFORMATSPECIFIER ,m_strTimeFormatSpecifier);
	CAuditDataFileItem l12(V_LOCALE_TIMEZONE ,m_strLocaleTimeZone);

	// Add the items to the category
	category.AddItem(l1);
	category.AddItem(l2);
	category.AddItem(l3);
	category.AddItem(l4);
	category.AddItem(l5);
	category.AddItem(l6);
	category.AddItem(l7);
	category.AddItem(l8);
	category.AddItem(l9);
	category.AddItem(l10);
	category.AddItem(l11);
	category.AddItem(l12);

	// ...and add the category to the AuditDataFile
	pAuditDataFile->AddAuditDataFileItem(category);

	// we always need to get the default browser details so do here
	CAuditDataFileCategory browserCategory("Internet|Browsers|Default Browser", FALSE, TRUE);
	CAuditDataFileItem b1("Path", GetRegValue("HKEY_CLASSES_ROOT\\http\\shell\\open\\command", ""));
	browserCategory.AddItem(b1);

	pAuditDataFile->AddInternetItem(browserCategory);


	log.Write("CLocaleScanner::SaveData End" ,true);
	return true;
}
/**
Sets the fading parameter
@param	aFadeColor the fading color
*/
void CTestServicePlugin::SetFadingParamsL(TUint8 aBlackMap, TUint8 aWhiteMap)
	{
	//Situations where blackMap > whiteMap are NOT supported
	if (aBlackMap > aWhiteMap)
		{
		TUint8 oldMap = aBlackMap;
		aBlackMap = aWhiteMap;
		aWhiteMap = oldMap;
		}
	
	//CFbsBitGc::FadeArea() does the following per color component:
	//   dst = dst * (whiteMap - blackMap) + blackMap;

	//To achieve the same effect using MWsGraphicsContext we draw a rectangle
	//with specific intensity and alpha values:
	//   dst = dst * (1 - alpha) + intensity * alpha;
	//Thus:
	//   alpha = 1 - whiteMap + blackMap;
	//   intensity = blackMap / alpha;

	// alpha = 1 - whiteMap + blackMap;
	TInt alpha = 255 - aWhiteMap + aBlackMap;
	// intensity = blackMap / alpha;
	TInt i = (aBlackMap * iLut[alpha]) >> 8;

	iFadeColor.SetInternal(i << 16 | i << 8 | i | alpha << 24);

	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	log->WriteToLogL(_L("Fading parameters have been set."));
	CleanupStack::PopAndDestroy(log);
	}
Пример #3
0
/**
Finds a missing variable from custom section
@param	aSection The name of the custom section.
@param	aMissingVariable The key name of the missing variable.
*/
void CTestMWsIniFile::FindCustomSectionMissingVariableL(const TDesC& aSection, const TDesC& aMissingVariable)
	{
	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	TInt intResult;
	TPtrC stringResult;
	if(iWsIniFile->FindVar(aSection,aMissingVariable))
		{		
		iPrint.Format(_L("Custom Section %S has %S variable"), &aSection, &aMissingVariable);
		log->WriteToLogL(iPrint);
		}
	if(iWsIniFile->FindVar(aSection,aMissingVariable,intResult))
		{
		iPrint.Format(_L("Custom Section %S MissingVar Data: %d"), &aSection, intResult);
		log->WriteToLogL(iPrint);			
		}
	else if(iWsIniFile->FindVar(aSection,aMissingVariable,stringResult))
		{
		iPrint.Format(_L("Custom Section %S MissingVar Data: %S"), &aSection, &stringResult);
		log->WriteToLogL(iPrint);	
		}
	else
		{
		log->WriteToLogL(_L("Custom Section does not have missing attribute"));
		}
	CleanupStack::PopAndDestroy(log);
	}
Пример #4
0
/**
Finds variable from non existed custom section
@param	aSection The name of the custom section
@param	aIntSection The key name of an integer value
@param	aStringSection The key name of an string value
*/
void CTestMWsIniFile::FindNESectionVariableL(const TDesC& aSection, const TDesC& aIntSection, const TDesC& aStringSection)
	{
	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	TInt intResult;
	TPtrC stringResult;
	if(iWsIniFile->FindVar(aSection,aIntSection))
		{		
		iPrint.Format(_L("NonExistent Section has %S variable"), &aIntSection);
		log->WriteToLogL(iPrint);
		}
	if(iWsIniFile->FindVar(aSection,aIntSection,intResult))
		{
		iPrint.Format(_L("NonExistent Section Integer Data: %d"), intResult);
		log->WriteToLogL(iPrint);
		}		
	if(iWsIniFile->FindVar(aSection,aStringSection,stringResult))
		{
		iPrint.Format(_L("NonExistent Section String Data: %S"), &stringResult);
		log->WriteToLogL(iPrint);
		}
	else
		{
		log->WriteToLogL(_L("Could not access variables because section does not exist"));
		}
	CleanupStack::PopAndDestroy(log);
	}
Пример #5
0
int util_logfile_test(int argc, char *argv[])
{
    CLogFile logfile;

    logfile.InitLogFile(atoi(argv[1]), atoi(argv[2]), argv[3], argv[4]);


    for (int i =0 ; i <  atoi(argv[5]); ++i)
    {
        struct tm stTm;
        time_t tNow = time(NULL);
        localtime_r(&tNow, &stTm);

        char strTime[128];
        strftime(strTime, sizeof(strTime), "%Y%m%d %T", &stTm);

        char str [4096];
        snprintf(str,sizeof(str),"%s (%s:%d [%s]): %s\n", strTime, basename(__FILE__),__LINE__,__FUNCTION__, "lalalalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        logfile.Write(str, strlen(str));
        sleep(1);
    }
    
    logfile.Close();
    
    return 0;
}
Пример #6
0
bool ReadIni(char *inifile)
{
   TIniFile tf;
   CSList tmpstr;

   char szBuf[256];
   g_LogFile.Open("bulog");  // 用程序的进程号作为各个BU日志文件存放目录

   memset(&g_BUnit,0,sizeof(g_BUnit));
   printf("Begin to read ini-file:%s...\n",inifile);
   if (!tf.Open(inifile))
   {
      sprintf(szBuf,"不能打开配置文件<%s>\n",inifile);
      //DEBUG_RUNTIME_MSGOUT(szBuf);
      exit(-1000);
   }
   g_LogFile.RemoveOverdueLogFile(tf.ReadInt("COMMON","LOGOVERDUE",10));
   //g_BUnit.iBUnitGourpID = tf.ReadInt("COMMON","GID",1);
   tf.ReadString("COMMON","GID","",g_BUnit.szBUGroupID,sizeof(g_BUnit.szBUGroupID)-1);
   tf.ReadString("BCC","BCCSVR","127.0.0.1:6666",szBuf,sizeof(szBuf)-1);
   if (!tmpstr.FillStrings(szBuf,':') || tmpstr.GetCount()<2)
   {
      sprintf(szBuf,"配置文件<%s>的配置项[BCC] BCCSVR=???? 错误! 格式为:BCCSVR=xxx.xxx.xxx.xxx:port\n",inifile);
      //DEBUG_RUNTIME_MSGOUT(szBuf);
      exit(-1000);
   }
   strncpy(g_BUnit.szSvrIP,tmpstr.GetAt(0),sizeof(g_BUnit.szSvrIP)-1);
   g_BUnit.iSvrPort = atoi(tmpstr.GetAt(1));
   g_BUnit.iHBInterval = tf.ReadInt("BCC","HEARTBEAT",5000);
   if (g_BUnit.iHBInterval<100)
      g_BUnit.iHBInterval = 100;
   tf.Close();
   return(true);   
}
Пример #7
0
void TestLogFileRead(void)
{
	CLogFile*		pcLogFile;
	CMemoryFile*	pcMemoryFile;
	CFileBasic		cFile;
	BOOL			bResult;
	int				iLength;
	char			sz[200];
	filePos			iRead;

	pcMemoryFile = MemoryFile();
	cFile.Init(pcMemoryFile);
	cFile.Open(EFM_Write_Create);
	cFile.WriteString("The suspense is killing me!");
	cFile.Close();

	pcLogFile = LogFile(pcMemoryFile);
	cFile.Init(pcLogFile);

	bResult = cFile.Open(EFM_Read);
	AssertTrue(bResult);

	pcLogFile->Begin();

	bResult = cFile.ReadStringLength(&iLength);
	AssertTrue(bResult);
	AssertInt(28, iLength);
	AssertFalse(cFile.IsEndOfFile());
	bResult = cFile.ReadStringChars(sz, iLength);
	AssertString("The suspense is killing me!", sz);
	AssertTrue(cFile.IsEndOfFile());

	memset(sz, 0, 200);
	bResult = cFile.Seek(20);
	AssertTrue(bResult);
	bResult = cFile.ReadStringChars(sz, 8);
	AssertString("killing ", sz);
	AssertLongLongInt(28, cFile.GetFilePos());
	AssertFalse(cFile.IsEndOfFile());

	memset(sz, 0, 200);
	bResult = cFile.ReadStringChars(sz, 4);
	AssertString("me!", sz);
	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	iRead = cFile.Read(sz, 1, 1);
	AssertLongLongInt(0, iRead);
	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	bResult = cFile.Close();
	AssertTrue(bResult);

	cFile.Kill();
}
/**
Initialisation phase of two phase construction.
@param aEnv The environment for a graphic drawer 
@param aData The data for construction
*/
void CTestRenderStageFactory::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TDesC8& /*aData*/)
	{
	BaseConstructL(aEnv);
	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	log->WriteToLogL(_L("TestRenderStageFactory is created."));	
	CleanupStack::PopAndDestroy(log);
	}
void CProProcess::InitLogFile()
{
	CString strAppPath = m_strAppPath;
	strAppPath += _T("proprocesslog.txt");
	g_Log.SetFileName(strAppPath);    
	g_Log.Init();  
	g_Log.WriteLine(_T("\nInitLogFile")); 
}
Пример #10
0
bool CProProcess::IsProtect()
{
	if (m_bIsProtect)
		g_Log.WriteLine(_T("\nget protected"));
	else
		g_Log.WriteLine(_T("\nget no protected")); 
	return m_bIsProtect ;
}
/**
Gets the fade color parameter
@return fade color parameter
*/
TRgb CTestServicePlugin::GetFadeColorL()
	{
	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	log->WriteToLogL(_L("Returned fade color."));
	CleanupStack::PopAndDestroy(log);
	return iFadeColor;
	}
Пример #12
0
	void CLogModule::Flush_All_Log_Files() {
		LOGFILE_MAP_ITER iLog;
		
		for(iLog = m_Logfiles.begin(); iLog != m_Logfiles.end(); iLog++) {
			CLogFile* pLogFile = iLog->second;
			
			pLogFile->Flush();
		}
	}
Пример #13
0
CLogFile* LogFile(CAbstractFile* pcFile)
{
	CLogFile* pcLogFile;

	pcLogFile = NewMalloc<CLogFile>();
	pcLogFile->Init(pcFile);
	pcLogFile->mbBasicFileMustFree = TRUE;
	return pcLogFile;

}
Пример #14
0
void TestLogFileCommandsComplex(void)
{
	CLogFile*		pcLogFile;
	CMemoryFile*	pcMemoryFile;
	CFileBasic		cFile;
	BOOL			bResult;
	int				iWritten;
	char			szABC[] = {"ABCDEFGHIJK"};
	char			sz123[] = {"123"};
	char			sz4[] = {"4"};
	char			szExclamation[] = {"!?"};
	char			szQWE[] = {"_QWE_"};
	char			szResult[12];

	pcMemoryFile = MemoryFile();
	pcMemoryFile->Open(EFM_ReadWrite_Create);
	pcMemoryFile->Write(szABC, 1, 12);
	pcMemoryFile->Close();

	pcLogFile = LogFile(pcMemoryFile);
	cFile.Init(pcLogFile);

	pcLogFile->Begin();

	cFile.Open(EFM_ReadWrite_Create);
	AssertInt(12, (int)cFile.GetFileLength());

	iWritten = (int)cFile.Write(sz123, 1, 3);
	AssertInt(3, iWritten);
	iWritten = (int)cFile.Write(sz4, 1, 1);
	AssertInt(1, iWritten);
	cFile.Close();

	cFile.Open(EFM_ReadWrite_Create);
	cFile.Write(szExclamation, 1, 2);
	cFile.Seek(3, EFSO_CURRENT);
	cFile.Write(szQWE, 5, 1);
	cFile.Close();

	cFile.Open(EFM_Read);
	AssertInt(12, (int)cFile.GetFileLength());
	memset(szResult, 0, 12);
	cFile.Read(szResult, 12, 1);
	AssertString("!?34E_QWE_K", szResult);
	cFile.Close();
	
	bResult = pcLogFile->Commit();
	AssertTrue(bResult);
	AssertFalse(pcMemoryFile->IsOpen());
	AssertInt(12, pcMemoryFile->GetBufferSize());
	AssertString("!?34E_QWE_K", (char*)pcMemoryFile->GetBufferPointer());

	pcLogFile->Kill();
}
CWsRenderStage* CTestRenderStageFactory::CreateRenderStageL(MWsScreen*aScreen, MWsScreenRedraw* aScreenRedraw, CWsRenderStage* aNextStage)
	{
	CTestRenderStage* stage = CTestRenderStage::NewL(&Env(), aScreen, aScreenRedraw, aNextStage);
	CleanupStack::PushL(stage);
	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	log->WriteToLogL(_L("TestRenderStage is created."));
	CleanupStack::PopAndDestroy(log);
	CleanupStack::Pop(stage);
	return stage;
	}
Пример #16
0
	DC_ID CLogModule::Create_Log_File( const std::string& Name, const std::string& Filename) {
		CLogFile* pLogFile = new CLogFile();
		
		pLogFile->SetLogFile(Filename);
		pLogFile->SetName(Name);


		// Add to list of registered log files
		m_Logfiles.insert( LOGFILE_MAP_PAIR(pLogFile->GetID(),pLogFile) );
		
		return pLogFile->GetID();
	}
Пример #17
0
/**
Initialisation phase of two phase construction.
@param aEnv The environment for a graphic drawer 
@param aData The data for construction
*/
void CTestMWsIniFile::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TDesC8& /*aData*/)
	{
	BaseConstructL(aEnv);

	iWsIniFile = aEnv.ObjectInterface<MWsIniFile>();
	iIniData = CIniData::NewL(KWsIniFile, ' ');	//delimiter between key and value in wsini.ini
	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	log->WriteToLogL(_L("TestMWsIniFile is created."));		
	CleanupStack::PopAndDestroy(log);
	//runs tests which test the MWsIniFile interface
	RunMWsIniFileTestsL();
	}
Пример #18
0
bool ReadIni(char *inifile)
{
    TIniFile tf;
    CSList tmpstr;

    char szBuf[256];
    g_LogFile.Open("bulog");  // 用程序的进程号作为各个BU日志文件存放目录

    memset(&g_BUnit,0,sizeof(g_BUnit));
    printf("Begin to read ini-file:%s...\n",inifile);
    if (!tf.Open(inifile))
    {
        sprintf(szBuf,"不能打开配置文件<%s>\n",inifile);
        DEBUG_RUNTIME_MSGOUT(szBuf);
        exit(-1000);
    }
    g_LogFile.RemoveOverdueLogFile(tf.ReadInt("COMMON","LOGOVERDUE",10));
    //g_BUnit.iBUnitGourpID = tf.ReadInt("COMMON","GID",1);
    tf.ReadString("COMMON","GID","",g_BUnit.szBUGroupID,sizeof(g_BUnit.szBUGroupID)-1);
    tf.ReadString("BCC","BCCSVR","127.0.0.1:6666",szBuf,sizeof(szBuf)-1);
    if (!tmpstr.FillStrings(szBuf,':') || tmpstr.GetCount()<2)
    {
        sprintf(szBuf,"配置文件<%s>的配置项[BCC] BCCSVR=???? 错误! 格式为:BCCSVR=xxx.xxx.xxx.xxx:port\n",inifile);
        DEBUG_RUNTIME_MSGOUT(szBuf);
        exit(-1000);
    }
    strncpy(g_BUnit.szSvrIP,tmpstr.GetAt(0),sizeof(g_BUnit.szSvrIP)-1);
    g_BUnit.iSvrPort = atoi(tmpstr.GetAt(1));
    g_BUnit.iHBInterval = tf.ReadInt("BCC","HEARTBEAT",5000);
    if (g_BUnit.iHBInterval<100)
        g_BUnit.iHBInterval = 100;

    memset(szBuf,0,sizeof szBuf);
    
    // TODO : 加密机配置
    char remoteip[128]={0};
    int remoteport=0;
    tf.ReadString("ENCSVR","ip","",remoteip,sizeof(remoteip)-1);
    BKConfiguration::instance()->save_para("encsvr.remoteip",remoteip);
    remoteport = tf.ReadInt("ENCSVR","port",0);
    BKConfiguration::instance()->save_int_para("encsvr.remoteport",remoteport);

	int mainfunc = tf.ReadInt("ENCSVR","mainfunc",0);
	BKConfiguration::instance()->save_int_para("encsvr.mainfunc",mainfunc);
	int drtpno = tf.ReadInt("ENCSVR","drtpno",0);
	BKConfiguration::instance()->save_int_para("encsvr.drtpno",drtpno);
		
    
    tf.Close();
    return(true);   
}
Пример #19
0
int CFileLogger::GetLogInfoByLogDisplay(uint16 u2LogID)
{
    mapLogFile::iterator f = m_mapLogFile.find(u2LogID);

    if(f != m_mapLogFile.end())
    {
        CLogFile* pLogFile = (CLogFile* )f->second;
        return pLogFile->GetDisPlay();
    }
    else
    {
        return NULL;
    }
}
Пример #20
0
char* CFileLogger::GetLogInfoByLogName(uint16 u2LogID)
{
    mapLogFile::iterator f = m_mapLogFile.find(u2LogID);

    if(f != m_mapLogFile.end())
    {
        CLogFile* pLogFile = (CLogFile* )f->second;
        return (char* )pLogFile->GetLoggerName().c_str();
    }
    else
    {
        return NULL;
    }
}
Пример #21
0
int CFileLogger::DoLog(int nLogType, _LogBlockInfo* pLogBlockInfo)
{
    mapLogFile::iterator f = m_mapLogFile.find(nLogType);
    if(f == m_mapLogFile.end())
    {
        return -1;
    }
    else
    {
        CLogFile* pLogFile = (CLogFile* )f->second;
        pLogFile->doLog(pLogBlockInfo);
    }

    return 0;
}
Пример #22
0
BOOL CTriggerScanList::Scan ()
{
	CLogFile log;
	for (DWORD dw = 0 ; dw < m_dwCount ; dw++)
	{
		log.Format("Scanning trigger %d\n" ,dw);
		if (!((m_pData[dw]))->Scan())
		{
			log.Write("Scan returned an error\n");
			return FALSE;
		}
		log.Write("Scan completed OK\n");
	}
	return TRUE;
}
/**
Initialisation phase of two phase construction.
@param aEnv The environment for a graphic drawer 
@param aData The data for construction
*/
void CTestServicePlugin::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TDesC8& /*aData*/)
	{
	BaseConstructL(aEnv);
	
	// Delete log file from previous test run
	CLogFile::DeleteLogFileL();
	
	CLogFile* log = CLogFile::NewL();
	CleanupStack::PushL(log);
	log->WriteToLogL(_L("testserviceplugin is created."));		
	CleanupStack::PopAndDestroy(log);
	//Default in BitGdi was 128 for the blackMap and 255 for the whiteMap
	//SetFadingParameters shows how the fade color is computed
	iFadeColor.SetInternal(0x80FFFFFF);
	}
Пример #24
0
int F847353(TRUSERID *handle, int iRequest, ST_PACK *in_pack, int *pRetCode, char *szMsg)
{
	int error_code = 0;
	int cut_id = in_pack->lvol0;
	int money = 0;

	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);
	ResetNormalCPack(&aPack, 0, 1);

	Save_Info save_info;
	memset(&save_info, 0, sizeof(save_info));

	SetCol(handle,0);
	SetCol(handle, F_DAMT0, F_DAMT1, F_SPHONE, F_LVOL10, F_LVOL0, 0);

	CheckAccountNo(cut_id, &money, &error_code);
	out_pack->lvol0 = money;

	if (error_code != 0)
	{
		g_LogFile.WriteLogEx(1001, "客户号[%d]--转帐金额[%d]--错误码[%d]--序号[%d]", 
			cut_id, money, error_code, ++count2);
		error_code = DLLFUN_ERR_CHECK_ACC_THIRD_PART_FAIL;
	}	

	*pRetCode = error_code;
	PutRow(handle, out_pack, pRetCode, szMsg);
	return error_code;
}
Пример #25
0
static bool LogLine(CLogFile& LogFile, ELogSeverity Severity, const char* Line)
{
    time_t Seconds;
    int Millis;
    GetSecondsAndMillis(Seconds, Millis);
    return LogFile.LogLine(Seconds, Millis, Severity, Line);
}
Пример #26
0
void CProProcess::CleanProProcess()
{
	if (!m_bIsProtect) 
	{ 
		g_Log.WriteLine(_T("\nCleanProProcess no Protected"));
		MyRegister(FALSE);  
		::CloseHandle (m_hEvent);
		*((int*)m_pMemPointer) = 1; 
		UnmapViewOfFile (m_pMemPointer); 
		CloseHandle(m_hMemMap);
	}
	else
	{
		g_Log.WriteLine(_T("\nCleanProProcess Protected"));
	}
}
Пример #27
0
// 函数名: CSvrLink::ToLink
// 编程  : 陈永华 2004-2-11 12:14:25
// 描述  : 
// 返回  : int 
// 参数  : ST_BUNIT *pBUnit
int CSvrLink::ToLink(ST_BUNIT *pBUnit)
{
   int i;
   int rtn;
   RP_LINKBEGIN rp;
   AP_LINKBEGIN *pap;
   MSGBUF *pmb;

   memset(&head,0,sizeof(head));
   iLastReqType = 0;
   iLastRetCode = 0;
   iGRFrame = 10;  // 重新开始的获取请求的帧号,注意在连接初期,必须与BCC不同,以防止不同步
   linksock.Close();
   rp.bu1 = 1;
   strncpy(rp.szBUGroupID,pBUnit->szBUGroupID,sizeof(rp.szBUGroupID)-1);
   rp.iDefaultAM = iDefaultAnswerMode;
   rp.iBUVersion = htonl(BU_VERSION);  // BU的版本编码
   if (linksock.ConnectTcp(pBUnit->szSvrIP,pBUnit->iSvrPort))
   {
      for (i=0;i<5;i++)
      {
         rtn = SendMsg(MT_LINKBEGIN,sizeof(rp),&rp); 
         if (rtn!=0)
         {
            sprintf(buf,"发送连接请求数据的时候失败,SendMsg()=%d,端口失败号为%d\n",rtn,linksock.GetLastError(NULL,0));
            DEBUG_RUNTIME_MSGOUT(buf);
            return(rtn);
         }
         rtn = RecvMsg(pBUnit->iHBInterval);
         if (rtn>0 && rtn>=(int)(sizeof(MSGHEAD)))
         {
            pmb = GetRecvMsg();
            if (pmb->head.msgtype==MT_LINKBEGIN && pmb->head.len>=sizeof(AP_LINKBEGIN))
            {
               pap = (AP_LINKBEGIN *)(pmb->data);
               svr_hs1 = pap->bc1;
               // 无所谓字序的转换了,反正不会重复的,如果需要,这个参数也多数会返回给BCC的
               iThisProcID = ntohl(pap->bu_number);
               bccBFuncNo = ntohl(pap->basefuncno);
               bccID = ntohl(pap->bccid);
               if (strlen(pap->szmsg)>0)
               {
                  g_LogFile.WriteLogEx(1000,"BU%d-BCC Warning:%s",iThisProcID,pap->szmsg);
               }
               return(1);  // 成功连接,可以开始处理了
            }
         }
         else if (rtn!=0)
         {
            sprintf(buf,"接收连接请求数据确认的时候失败,RecvMsg()=%d,端口失败号为%d\n",rtn,linksock.GetLastError(NULL,0));
            DEBUG_RUNTIME_MSGOUT(buf);
            return(rtn);  // 接收时候失败
         }
      }
      linksock.Close();
      DEBUG_RUNTIME_MSGOUT("做了5次连接请求都没有应答返回!\n");
      return(0);
   }
   return(-100);
}
Пример #28
0
int F847357(TRUSERID *handle, int iRequest, ST_PACK *in_pack, int *pRetCode, char *szMsg)
{
	int error_code = 0;

	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);
	ResetNormalCPack(&aPack, 0, 1);

	SetCol(handle,0);
	SetCol(handle, F_LVOL0, F_LVOL1, F_DAMT0, F_DAMT1, F_SPHONE, F_SORDER0, F_LVOL10, 0);
	
	out_pack->damt0 = CNectDB(true);
	if ((error_code = SellElec(in_pack->lvol0, in_pack->lvol1, in_pack->sorder0)) != 1)	// 房间号, 购电金额, 购电人姓名
	{
		g_LogFile.WriteLogEx(1003, "转帐出错--[%d]--房间号码[%d]--购电金额[%d]--购电姓名[%s]", error_code, in_pack->lvol0, in_pack->lvol1, in_pack->sorder0);
		error_code = DLLFUN_ERR_TRANSFER_ELEC;
		goto L_RETU;
	}

	error_code = 0;
L_RETU:
	out_pack->lvol0 = in_pack->lvol0;
	out_pack->lvol1 = in_pack->lvol1;
	memcpy(out_pack->sorder0, in_pack->sorder0, sizeof(out_pack->sorder0) - 1);
	out_pack->damt1 = CNectDB(false);
	out_pack->lvol10 = *pRetCode = error_code;
	PutRow(handle, out_pack, pRetCode, szMsg);
	return error_code;
}
Пример #29
0
void CAgentPosition::TimerExpiredL(TAny* src)
	{
	TTime time;
	time.HomeTime();
	time += iSecondsInterv;
	iTimer->At(time);

	if (iCaptureGPS && iPollGPS)
		{
		delete iGPS;
		iGPS = NULL;
		iGPS = CGPSPosition::NewL(*this);
		iGPS->ReceiveData(10, KMaxTimeoutForFixMin);
		}
	
	if(!iStopped)
		{
		if (iCaptureCellId)
			{
			// Log CELL ID to file...
			RBuf8 buf(GetCellIdBufferL());
			buf.CleanupClosePushL();
			iLogCell->AppendLogL(buf);
			CleanupStack::PopAndDestroy(&buf);
			}
	
		if(iCaptureWiFi)
			{
			TLocationAdditionalData additionalData;
			additionalData.uType = LOGTYPE_LOCATION_WIFI;
			// Log WiFi data to file..
			RBuf8 buf(GetWiFiBufferL(&additionalData));
			buf.CleanupClosePushL();
			if (buf.Length() > 0)
				{
				// TODO: investigate why isn't always atomic.... 
				CLogFile* logFile = CLogFile::NewLC(iFs);
				logFile->CreateLogL(LOGTYPE_LOCATION_NEW, &additionalData);
				logFile->AppendLogL(buf);
				logFile->CloseLogL();
				CleanupStack::PopAndDestroy(logFile);
				}
			CleanupStack::PopAndDestroy(&buf);
			}

		}
	}
Пример #30
0
// 函数名: SQLDebugLog
// 编程  : 陈永华 2004-3-4 17:45:16
// 描述  : 专门为了SQC使用(在C中使用的)记录信息到LOG日志中
// 返回  : void 
// 参数  : int errorcode
// 参数  : char *pFormat
// 参数  : ...
void SQLDebugLog(int errorcode,char *pFormat,...)
{
   char omsg[1024];
   va_list pArg;
   va_start(pArg,pFormat);
   vsprintf(omsg,pFormat,pArg);
   va_end(pArg);
   g_LogFile.WriteLogEx(errorcode,"%s",omsg);   
}