Announcement

Collapse
No announcement yet.

UltraLog Update Broke Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pete
    replied
    Yes; SQLite.
    Attached Files

    Leave a comment:


  • beerygaz
    replied
    Pete, are you using SQL as your database?

    Leave a comment:


  • Pete
    replied
    Tested script again this morning with both of the instances of Homeseer (V44) and it worked fine this morning showing the following on the two boxes.
    The only changes over the last few days were a downgrade of the HS standard to V.44 and an upgrade of the HS Pro to V.44 from V.20.
    Note in the above post I tried it and it still was erroring out. Now its been a few days (more data?)

    Code:
    6/27/2012 2:01:17 PM  Event  Event Trigger "Gavin Test" 
    6/27/2012 2:01:17 PM  Event  Running script and waiting: gavin.vb

    Leave a comment:


  • Pete
    replied
    Upgraded/downgraded such that both HS Pro / HS Standard are identical versions (44). Same results as above with the older HSPro running the script fine and the newer HS Standard erroring out (very light database at this time).

    Leave a comment:


  • Pete
    replied
    Tested it on the two boxes with most current Ultralog. Different versions of HS on each; IE; V20 and V49. Errors on one.
    There is much more data on Homeseer Pro V.20 and only a few weeks of data on Homeseer Standard V.49.

    Homeseer Pro V.20

    6/25/2012 7:02:58 AM Event Event Trigger "Gavin Test"
    6/25/2012 7:02:58 AM Event Running script and waiting: gavin.vb
    Homeseer Standard V.49

    6/25/2012 7:12:01 AM Event Event Trigger "Gavin Test"
    6/25/2012 7:12:01 AM Event Running script and waiting: gavin.vb
    6/25/2012 7:12:01 AM Error Script compile error: Type 'DataTable' is not defined.on line 61
    6/25/2012 7:12:01 AM SCR Option Strict OffImports System.Dataimports Schedulerimports SystemPublic Module scriptcode4#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End Region '=========================================================== =================================== ' script interacts with the ultraLog plug-in database ' Rev 2010-12-23 '=========================================================== =================================== 'Example for use within a vb script: 'hs.RunEx("ultraLog.vb","getError","",True) '=========================================================== =================================== ' Constant declarations. '=========================================================== =================================== Const v_logging_name = "UltraLog Scripts" 'Logging / Script Name Const v_isDebug As Boolean = True 'Set the DEBUG status Const varStatusError As String = "X5" 'Device to hold most recent Error Const varStatusWarning As String = "X6" 'Device to hold most recent Warning '=========================================================== =================================== Public Sub Main(ByVal Parms As Object) End Sub 'get the most recent error from the log Public Sub getError(ByVal Parms As Object) If v_isDebug Then 'log raw information passed to script for debug purposes hs.WriteLog(v_logging_name, "Public Sub Main(): " & Parms) End If 'create a plug-in reference Dim hspi As Object = hs.plugin("ultralog") Dim pageSize As Integer = 25 Dim pageCur As Integer = 1 'the following are called by reference and are updated based on results Dim pageCount As Integer = 1 Dim recordCount As Integer = 0 Dim strSQL = "SELECT TOP 1 * FROM tblLog WHERE Log_Type LIKE '%Error%' ORDER BY ID DESC" Dim varDataTable As DataTable = hspi.ExecuteSQL(strSQL, recordCount, pageSize, pageCount, pageCur) Dim varDataTableReader As DataTableReader = varDataTable.CreateDataReader If varDataTableReader.HasRows Then While varDataTableReader.Read If v_isDebug Then hs.WriteLog(v_logging_name, varDataTableReader("Log_Data").ToString & " [" & varDataTableReader("Log_Type").ToString & "] " & varDataTableReader("Log_Date").ToString) End If 'update the status string of the Error device hs.SetDeviceString(varStatusError, varDataTableReader("Log_Data").ToString, True) End While End If End SubEnd Module

    Leave a comment:


  • beerygaz
    replied
    Sorry Pete, here's the whole script that should run, but still throws SQL errors for me.

    Code:
    Imports System.Data
    
    
        '==============================================================================================
        ' script interacts with the ultraLog plug-in database
        ' Rev 2010-12-23
        '==============================================================================================
    
        'Example for use within a vb script:
        'hs.RunEx("ultraLog.vb","getError","",True)
    
    
        '==============================================================================================
        '   Constant declarations.
        '==============================================================================================
        Const v_logging_name = "UltraLog Scripts"                'Logging / Script Name
        Const v_isDebug As Boolean = True                       'Set the DEBUG status
        Const varStatusError As String = "X5"                   'Device to hold most recent Error 
        Const varStatusWarning As String = "X6"                 'Device to hold most recent Warning  
        '==============================================================================================
    
    
        Public Sub Main(ByVal Parms As Object)
        End Sub
    
    
    
    
        'get the most recent error from the log
        Public Sub getError(ByVal Parms As Object)
    
            If v_isDebug Then
                'log raw information passed to script for debug purposes
                hs.WriteLog(v_logging_name, "Public Sub Main(): " & Parms)
            End If
    
    
            'create a plug-in reference
            Dim hspi As Object = hs.plugin("ultralog")
            Dim pageSize As Integer = 25
            Dim pageCur As Integer = 1
    
    
            'the following are called by reference and are updated based on results
            Dim pageCount As Integer = 1
            Dim recordCount As Integer = 0
            Dim strSQL = "SELECT TOP 1 * FROM tblLog WHERE Log_Type LIKE '%Error%' ORDER BY ID DESC"
            Dim varDataTable As DataTable = hspi.ExecuteSQL(strSQL, recordCount, pageSize, pageCount, pageCur)
    
    
            Dim varDataTableReader As DataTableReader = varDataTable.CreateDataReader
    
            If varDataTableReader.HasRows Then
                While varDataTableReader.Read
                    If v_isDebug Then
                        hs.WriteLog(v_logging_name, varDataTableReader("Log_Data").ToString & " [" & varDataTableReader("Log_Type").ToString & "] " & varDataTableReader("Log_Date").ToString)
                    End If
                    'update the status string of the Error device
                    hs.SetDeviceString(varStatusError, varDataTableReader("Log_Data").ToString, True)
                End While
            End If
    
    
        End Sub

    Leave a comment:


  • Pete
    replied
    Gavin,

    Ran the script and get these errors:

    Code:
    6/21/2012 10:46:42 AM  - Event - Running script and waiting: gavin-test.vb
    6/21/2012 10:46:42 AM  - Error - Script compile error: Name 'v_isDebug' is not declared.on line 16
    6/21/2012 10:46:42 AM  - SCR - Option Strict Offimports Schedulerimports SystemPublic Module scriptcode31#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin	<System.ContextStaticAttribute()> Public WithEvents hs As Scheduler.hsapplication	<System.ContextStaticAttribute()> Public WithEvents hsp As scheduler.hsp	<System.ContextStaticAttribute()> Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionPublic Sub getError(ByVal Parms As Object)        If v_isDebug Then            log raw information passed to script for debug purposes            hs.WriteLog(v_logging_name, "Public Sub Main(): " & Parms)        End If        'create a plug-in reference        Dim hspi As Object = hs.plugin("ultralog")        Dim pageSize As Integer = 25        Dim pageCur As Integer = 1        'the following are called by reference and are updated based on results        Dim pageCount As Integer = 1        Dim recordCount As Integer = 0        Dim strSQL = "SELECT TOP 1 * FROM tblLog WHERE Log_Type LIKE '%Error%' ORDER BY ID DESC"        Dim varDataTable As DataTable = hspi.ExecuteSQL(strSQL, recordCount, pageSize, pageCount, pageCur)        Dim varDataTableReader As DataTableReader = varDataTable.CreateDataReader        If varDataTableReader.HasRows Then            While varDataTableReader.Read                If v_isDebug Then                    hs.WriteLog(v_logging_name, varDataTableReader("Log_Data").ToString & " [" & varDataTableReader("Log_Type").ToString & "] " & varDataTableReader("Log_Date").ToString)                End If                'update the status string of the Error device                hs.SetDeviceString(varStatusError, varDataTableReader("Log_Data").ToString, True)            End While        End If    End Sub   End Module
    and

    Code:
    6/21/2012 10:45:20 AM  - Event - Running script and waiting: gavin-test.vb
    6/21/2012 10:45:20 AM  - Error - Script compile error: Type 'DataTable' is not defined.on line 32
    6/21/2012 10:45:20 AM  - SCR - Option Strict Offimports Schedulerimports SystemPublic Module scriptcode30#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin	<System.ContextStaticAttribute()> Public WithEvents hs As Scheduler.hsapplication	<System.ContextStaticAttribute()> Public WithEvents hsp As scheduler.hsp	<System.ContextStaticAttribute()> Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionPublic Sub getError(ByVal Parms As Object)        'If v_isDebug Then            'log raw information passed to script for debug purposes            'hs.WriteLog(v_logging_name, "Public Sub Main(): " & Parms)        'End If        'create a plug-in reference        Dim hspi As Object = hs.plugin("ultralog")        Dim pageSize As Integer = 25        Dim pageCur As Integer = 1        'the following are called by reference and are updated based on results        Dim pageCount As Integer = 1        Dim recordCount As Integer = 0        Dim strSQL = "SELECT TOP 1 * FROM tblLog WHERE Log_Type LIKE '%Error%' ORDER BY ID DESC"        Dim varDataTable As DataTable = hspi.ExecuteSQL(strSQL, recordCount, pageSize, pageCount, pageCur)        Dim varDataTableReader As DataTableReader = varDataTable.CreateDataReader        If varDataTableReader.HasRows Then            While varDataTableReader.Read                If v_isDebug Then                    hs.WriteLog(v_logging_name, varDataTableReader("Log_Data").ToString & " [" & varDataTableReader("Log_Type").ToString & "] " & varDataTableReader("Log_Date").ToString)                End If                'update the status string of the Error device                hs.SetDeviceString(varStatusError, varDataTableReader("Log_Data").ToString, True)            End While        End If    End Sub   End Module

    Leave a comment:


  • beerygaz
    replied
    I use a script to get the latest error HS posted from the database and set a device to that error for mail/reportng purposes.

    Code:
     Public Sub getError(ByVal Parms As Object)
    
            If v_isDebug Then
                'log raw information passed to script for debug purposes
                hs.WriteLog(v_logging_name, "Public Sub Main(): " & Parms)
            End If
    
    
            'create a plug-in reference
            Dim hspi As Object = hs.plugin("ultralog")
            Dim pageSize As Integer = 25
            Dim pageCur As Integer = 1
    
    
            'the following are called by reference and are updated based on results
            Dim pageCount As Integer = 1
            Dim recordCount As Integer = 0
            Dim strSQL = "SELECT TOP 1 * FROM tblLog WHERE Log_Type LIKE '%Error%' ORDER BY ID DESC"
            Dim varDataTable As DataTable = hspi.ExecuteSQL(strSQL, recordCount, pageSize, pageCount, pageCur)
    
    
            Dim varDataTableReader As DataTableReader = varDataTable.CreateDataReader
    
            If varDataTableReader.HasRows Then
                While varDataTableReader.Read
                    If v_isDebug Then
                        hs.WriteLog(v_logging_name, varDataTableReader("Log_Data").ToString & " [" & varDataTableReader("Log_Type").ToString & "] " & varDataTableReader("Log_Date").ToString)
                    End If
                    'update the status string of the Error device
                    hs.SetDeviceString(varStatusError, varDataTableReader("Log_Data").ToString, True)
                End While
            End If
    
    
        End Sub

    Leave a comment:


  • Pete
    replied
    Gavin,

    What script did it break?

    Reading your post convinced me to install the update as its been a while since I have updated Ultralog. I also installed it on HS box #2 from scratch.

    None the less I saw no errors with the updater/update on HS box #1 nor any with the new install on HS box #2.

    Prior to update though I did backup the HS directory just in case it did cause an issue.

    Leave a comment:


  • beerygaz
    started a topic UltraLog Update Broke Script

    UltraLog Update Broke Script

    UJ, the latest update from the updater now results in the following errors occuring in my logs:
    <table border="0" cellpadding="0" cellspacing="2" width="100%"><tbody><tr><td colspan="1" class="LOGDateTime1" align="left" nowrap="nowrap">2012/06/19 05:55:40 PM </td><td colspan="3" class="LOGType1" align="left"> Error </td><td colspan="8" class="LOGEntry1" align="left">Scripting runtime error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --- System.ArgumentException: Column 'Log_Data' does not belong to table . at System.Data.DataRow.GetDataColumn(String columnName) at System.Data.DataRow.get_Item(String columnName) at System.Data.DataTableReader.get_Item(String name) at scriptcode3.scriptcode3.getError(Object Parms) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Scheduler.VsaScriptHost.Invoke(String ModuleName, String MethodName, Object[] Arguments)</td></tr> <tr> <td colspan="1" class="LOGDateTime0" align="left" nowrap="nowrap">2012/06/19 05:55:40 PM </td><td colspan="3" class="LOGType0" align="left"> UltraLog Error </td><td colspan="8" class="LOGEntry0" align="left">An unexpected error occured in the ExecuteSQL() function/subroutine: [System.IndexOutOfRangeException: Cannot find table 0. at System.Data.DataTableCollection.get_Item(Int32 index) at HSPI_ULTRALOG.HSPI.ExecuteSQL(String strSQL, Int32& iRecordCount, Int32 iPageSize, Int32& iPageCount, Int32& iPageCur)]</td></tr></tbody></table>
    <table border="0" cellpadding="0" cellspacing="2" width="100%"><tbody><tr><td colspan="8" class="LOGEntry1" align="left">
    </td></tr><tr><td colspan="1" class="LOGDateTime0" align="left" nowrap="nowrap">
    </td><td colspan="3" class="LOGType0" align="left">
    </td><td colspan="8" class="LOGEntry0" align="left">
    </td></tr></tbody></table>
Working...
X