The following table contains information on the ISCApplicationEnvironment interface:
|
Signature |
Description |
Valid Arguments |
|---|---|---|
|
ISCPropertyBag PropertyBag(VARIANT Category[optional], VARIANT Name[optional], VARIANT AsString[optional]) |
Populates a property bag with one or more property values as indicated by Category and Name |
Category: VT_BSTR – Must be Application.API. Name:
AsString:
|
Example 32
The following example illustrates how to use the API to check messages from the API extended message log using C++. It assumes that there is an Application object from Example 1:
CString GetExtendedErrorInfo(ISCApplicationPtr & scAppPtr)
{
CString csExtendedErrors = "";
long index = 0;
// Do we have messages in the log?
variant_t val = scAppPtr->GetApplicationEnvironment()-> GetPropertyBag("Application.Api.MessageLog","Is Empty")-> GetValue(COleVariant(index));
if (val.vt == VT_BOOL && val.boolVal == false)
{
// Retrieve the log
val = m_scAppPtr->GetApplicationEnvironment()-> GetPropertyBag("Application.Api.MessageLog","Log")-> GetValue(COleVariant(index));
if (val.vt & VT_ARRAY)
{
// this is a SAFEARRAY
VARIANT HUGEP *pArray;
HRESULT hr;
// Get a pointer to the elements of the array.
hr = SafeArrayAccessData(val.parray, (void HUGEP**)&pArray);
if (FAILED(hr))
return csExtendedErrors;
long numErrors = 0;
VARIANT vValue = pArray[0]; // number of errors
if (vValue.vt == VT_I4)
numErrors = vValue.lVal;
// …
SafeArrayUnaccessData(val.parray);
}
}
}
The following example illustrates how to use the API to check messages from the API extended message log using Visual Basic .NET. It assumes that there is an Application object from Example 1:
Public Sub GetExtendedErrorInfo( ByRef scApp As SCAPI.Application )
Dim nSize As Integer
Dim nWarnings As Integer
Dim nErrors As Integer
Dim nIdx As Integer
Dim nMsgNumber As Integer
Dim aErrors() As Object
' Do we have messages in the log?
If scApp.ApplicationEnvironment.PropertyBag("Application.Api.MessageLog", _ "Is Empty").Value(0) = False Then
' Retrieve a log
aErrors = _
scApp.ApplicationEnvironment.PropertyBag("Application.Api.MessageLog", _ "Log").Value(0)
nSize = Int(aErrors(0))
nIdx = 1
nMsgNumber = 0
Do While nMsgNumber < nSize
Console.WriteLine("Error " & aErrors(nIdx) & " " + aErrors(nIdx + 2))
Select Case aErrors(nIdx + 1)
Case SCAPI.SC_MessageLogSeverityLevels.SCD_ESL_WARNING
nWarnings = nWarnings + 1
Case SCAPI.SC_MessageLogSeverityLevels.SCD_ESL_ERROR
nErrors = nErrors + 1
End Select
nIdx = nIdx + 8
nMsgNumber = nMsgNumber + 1
Loop
Console.WriteLine("Total number of errors in the transaction " & Str(nSize) & " with: " _& Str(nWarnings) & " warnings, " & Str(nErrors) & " errors.")
End If
End Sub
| Copyright © 2011 CA. All rights reserved. | Email CA Technologies about this topic |