Set oAPI = CreateObject("Mom.ScriptAPI")
Set oBagState = oAPI.CreateTypedPropertyBag(StateDataType)
GetMonitorStatus
Sub GetMonitorStatus()
Dim e
Dim AnalysisDBConnStr
Dim Catalog
Set e = New Error
Set Catalog = MomCreateObject("ADOMD.Catalog")
e.Clear
On Error Resume Next
AnalysisDBConnStr = "Data Source=" & TargetDBServer & ";Initial Catalog=" & TargetAnalysisDBName & ";Provider=msolap; Integrated Security=SSPI;"
Catalog.ActiveConnection = AnalysisDBConnStr
e.Save
On Error Goto 0
If 0 <> e.number then
strMonitorStatus = "0"
strErrorDetail = SCRIPT_NAME & ": - Database " & TargetAnalysisDBName & " Failure on Server " & TargetDBServer & " Error Detail:" & e.Description
Else
strMonitorStatus = "1"
strErrorDetail = ""
End if
If bLogSuccessEvent Then
strMessage = "The script '" & SCRIPT_NAME & "' completed successfully in " & DateDiff("s", dtStart, Now) & " seconds."
CreateEvent EVENTID_SUCCESS, EVENT_TYPE_INFORMATION, strMessage
End If
oBagState.AddValue "State", strMonitorStatus
oBagState.AddValue "ErrorDetail", strErrorDetail
oAPI.AddItem oBagState
Call oAPI.ReturnItems
End Sub
Sub CreateEvent(lEventID, lEventType, strMessage)
oAPI.LogScriptEvent SCRIPT_NAME, lEventID, lEventType, strMessage
End Sub
Function MomCreateObject(ByVal sProgramId)
Dim oError
Set oError = New Error
On Error Resume Next
Set MomCreateObject = CreateObject(sProgramId)
oError.Save
On Error Goto 0
If oError.Number <> 0 Then ThrowScriptError "Unable to create automation object '" & sProgramId & "'", oError
End Function
Class Error
Private m_lNumber
Private m_sSource
Private m_sDescription
Private m_sHelpContext
Private m_sHelpFile
Public Sub Save()
m_lNumber = Err.number
m_sSource = Err.Source
m_sDescription = Err.Description
m_sHelpContext = Err.HelpContext
m_sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise m_lNumber, m_sSource, m_sDescription, m_sHelpFile, m_sHelpContext
End Sub
Public Sub Clear()
m_lNumber = 0
m_sSource = ""
m_sDescription = ""
m_sHelpContext = ""
m_sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = m_lNumber
End Property
Public Property Get Source()
Source = m_sSource
End Property
Public Property Get Description()
Description = m_sDescription
End Property
Public Property Get HelpContext()
HelpContext = m_sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = m_sHelpFile
End Property
End Class </Script></Contents>
<Unicode>1</Unicode>
</File>
</Files>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>