Announcement

Collapse
No announcement yet.

Difference between aspx and vb.net

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

  • Difference between aspx and vb.net

    I'm trying to create a aspx page and had assumed that I could plug in my vb.net code.

    I have a function that parses Homeseer events in vb.net that works but chokes when I try it in aspx. (Thanks Adam for heads up on the vb.net part)

    PHP Code:
    Public Function getEvents()

        
    Dim cnt As Integer hs.EventCount
        Dim arrEvents
    () As String
        Dim i 
    As Integer 0

        
    If cnt 0 Then

            Dim evntGroups 
    As strEventGroupData() = hs.Event_Group_Info_All()
            For 
    Each evntGrp As strEventGroupData In evntGroups

                
    Try
                    
    Dim evnts As strEventData() = hs.Event_Info_Group(evntGrp.GroupID)

                    For 
    Each evnt As strEventData In evnts


                        
    If evnt.GroupName "XM Radio" Then
                            
    ' hs.Writelog("Test", evnt.GroupName & "   " & evnt.Event_Name)
                            ReDim Preserve arrEvents(i)
                            arrEvents(i) = evnt.Event_Name
                            i = i + 1
                        End If
                    Next
                Catch ex As Exception
                    '            'ProcessError(plugin.instance, ex, "SlimServerXML - GenPage()")
                    '            
    hs.WriteLog("Opps"ex.message)
                
    End Try
                
    'Return Nothing
            Next
        End If
        Return arrEvents
    End Function 
    If I try to use this function in an aspx page I get the following error.
    Type 'strEventGroupData' is not defined.

    Here is the line that is causing the problem.

    PHP Code:
    Dim evntGroups As strEventGroupData() = hs.Event_Group_Info_All() 
    Anyone run into this? I'm assuming that I have to declare strEventGroupData but the help page indicates that the return is a type structure. Don't know what that is. This works in a scripting environment, so I'm assuming that I have to declare something that I'm missing.

    Thanks
    Don

  • #2
    Don,

    In vb.net scripts, Homeseer puts a wrapper on the script that you don't see, and it establishes the hs class in your script, so that you can just do hs.whatever and it works.

    In ASPX (at least in the HS2 version, which is the only one I know), you need to do it yourself. So in your getEvents() function, just insert this line near the top:

    Dim hs As Scheduler.hsapplication = Context.Items("Content")

    My guess is you will be fine then.

    Steve

    Comment


    • #3
      Hi Steve:

      Thanks for the quick reply.

      I have this on the top of my aspx page.

      PHP Code:
          Dim hs As Scheduler.hsapplication
          Dim plugin 
      As HomeSeerAPI.PluginAccess

       hs 
      Context.Items("Content"
      I'm assuming this is the hs3 version of that.
      Don

      Comment


      • #4
        I'm pretty sure all variable values are not preserved between events in an ASPX page, so you may have to put the hs = into each sub / function in your page. Try just inserting that line into the routine that is failing.

        Steve

        Comment


        • #5
          Still no go....
          Don

          Comment


          • #6
            I just realized I was giving you bum information anyway. I thought the reference to hs was failing, but you clearly said it was the class type you were declaring.

            Since I don't know anything about HS3 I am not sure what reference you need, but I would be you need some sort of IMPORT, like

            <% IMPORT namespace="some homeseer library" %>

            Steve

            Comment


            • #7
              Thanks, I'll take a peek at Scheduler in the Object Explorer and see what I see.
              edit:

              You called it Steve. The missing code was <%@ Import Namespace="HomeseerAPI" %>

              Thanks for your help.
              Last edited by donstephens; August 9th, 2014, 05:26 PM.
              Don

              Comment

              Working...
              X