24325381_isalg_operationlog

Upload: nicholas-shelton

Post on 12-Oct-2015

225 views

Category:

Documents


5 download

DESCRIPTION

Wincc Operation Log problem

TRANSCRIPT

#pragma code ("kernel32.dll")void GetLocalTime( LPSYSTEMTIME lpSystemTime);BOOL GetComputerNameA(LPSTR Computername, LPDWORD size);#pragma code()#ifndef RUN_ON_WEBNAVIGATOR#pragma code ("useadmin.dll")BOOL PWRTGetCurrentUser (LPTSTR dest, int bufsize );#pragma code()#endifint ISALG_OperationLog( long* psMsgNumber,char* pszSource, char* pszArea, char* pszEvent, char* pszBatch, char* pszUnit, double fOld, double fNew, char* pszComment ){MSG_RTDATA_INSTANCECOMMENT_STRUCT MsgCreateEx;CMN_ERROR scError;int iRet= FALSE;DWORD dwServiceID = 0;BOOL bOK;SYSTEMTIME time;DWORD dwBufSize = 256;BOOL Web;char szComputerName[256]= "";char szSource[256] = "";char szUnit[256] = "";char szEvent[256] = "";char szBatch[256] = "";char szUser[256] = "";char *szNoUser ;char *szWebUser = "";//======================================// INIT_MESSAGE_STRUCT//======================================memset(&MsgCreateEx,0,sizeof(MsgCreateEx));memset(&scError,0,sizeof(scError));GetLocalTime(&time);MsgCreateEx.stMsgTime = time;MsgCreateEx.dwMsgNr = *psMsgNumber; // Message Number; (default=12508141)MsgCreateEx.wPValueUsed = (WORD)(0x0000 ); // no real process value usedMsgCreateEx.wTextValueUsed = 0x001F; // text values 1 .. 5 used for textblocks 1 .. 5MsgCreateEx.dwFlags = MSG_FLAG_COMMENT | MSG_FLAG_TEXTVALUES;MsgCreateEx.dwMsgState = MSG_STATE_COME; if ( pszComment != NULL) { strncpy(MsgCreateEx.szComment, pszComment, sizeof (MsgCreateEx.szComment) - 1);}if(pszUnit != NULL){ strncpy(szUnit, pszUnit, sizeof (szUnit) - 1);}// replasce username, if not availble (below Web Navigator V7.0)// Get user-name#ifdef RUN_ON_WEBNAVIGATOR szWebUser = GetTagChar("@NOTP::@CurrentUser"); szNoUser = "--- unknown web-user ---";#else PWRTGetCurrentUser (szUser, sizeof (szUser)); szNoUser = "--- unknown user ---";#endif// replace username, if not availble (below Web Navigator V7.0)if (strlen(szUser) > 1){ strncpy (MsgCreateEx.szUser, szUser, 15 ); // 16 character - Endsign ('\0') }else {// strncpy (MsgCreateEx.szUser, szNoUser, strlen(szNoUser)); strncpy (MsgCreateEx.szUser, szNoUser, 15); // 16 character - Endsign ('\0') }GetComputerNameA(szComputerName, &dwBufSize);strncpy (MsgCreateEx.szComputerName, szComputerName, 15);if (pszSource!= NULL) { strncpy (szSource, pszSource, sizeof (szSource) - 1); strncpy ( MsgCreateEx.szInstance, pszSource, sizeof (MsgCreateEx.szInstance) - 1); strncpy ( MsgCreateEx.mtTextValue[0].szText, szSource, sizeof (MsgCreateEx.mtTextValue[0].szText) - 1);}if (pszArea!= NULL) {strncpy ( MsgCreateEx.mtTextValue[1].szText, pszArea, sizeof (MsgCreateEx.mtTextValue[1].szText) - 1);}if (pszEvent!= NULL){ sprintf (szEvent, "%s\\%s: %s new=%.3f old=%.3f [%s]" , szComputerName, MsgCreateEx.szUser, pszEvent, fNew, fOld, szUnit); strncpy (MsgCreateEx.mtTextValue[2].szText, szEvent, sizeof (MsgCreateEx.mtTextValue[2].szText) -1); strncpy (MsgCreateEx.mtTextValue[4].szText, szEvent, sizeof (MsgCreateEx.mtTextValue[4].szText) -1);}if (pszBatch != NULL){ strncpy (szBatch, pszBatch , sizeof (szBatch) - 1); strncpy (MsgCreateEx.mtTextValue[3].szText, szBatch, sizeof (MsgCreateEx.mtTextValue[3].szText) -1);}printf ("#I201: ISALG_OperationLog() - szSource=\"%s\" szEvent=\"%s\"\r\n", szSource, szEvent);printf ("MsgCreateEx.szUser: >%s%s