This ASP page can be used from the WebAdmin tool to set the refresh options for the agent. The possible refresh options are:
the files to include
the directory containing the files.
The functional highlights from this page are listed below.
Dim m_strProjectName ' the Project Name
Dim m_prj ' the Project Object
Dim m_strChnItmPath ' the Channel/Item Name
Dim m_chn ' the Channel Object
Dim m_options ' the refresh options dictionary
m_strProjectName = Request.QueryString(g_strKeyProjectName)
m_strChnItmPath = Request.QueryString(g_strKeyChnItmPath)
Set m_prj = PrjLoadFromName(m_strProjectName)
Set m_chn = ChnItmFromPrj(m_prj,m_strChnItmPath)
Set m_options = m_chn.RefreshOptions
In this case, we see that the Project object is loaded from the name sent in the query string of the request. The Project then loads this project, and fetches the appropriate IChannel dispinterface. Through this dispinterface is fetches the dispinterface on the RefreshOptions collection in the Channel object.
The following subroutine is invoked if the form submission has occurred with the options set in the form elements. In this case, the hidden form variable "Action" is set to some value, and the appropriate action is taken with the RefreshOptions collection. In the script below, the RefreshOptions collection (Dictionary Class) dispinterface is stored in the variable m_Options. The sections with comments added are listed in bold.
Sub SavePage(prj)
Dim strFileName
Dim rgFileName, I
strFileName = Request.Form("FileName")
' This is the name of the new file to add
rgFileName = m_options.Item("Files")
' This is an array of values indexed under the
' agent option "Files" here
If Request.Form("Action") = "Add" Then
DebugWriteNameValue "vartype", vartype(rgFileName)
If IsArray(rgFileName) Then
For I = 0 To UBound(rgFileName)
DebugWriteNameValue "rgFileName(I): ", rgFileName(I)
If strFileName = rgFileName(I) Then
WriteClientAlert "You already added this one."
Exit Sub
End If
Next
AddArrayElement rgFileName, strFileName
' If the file has not already been added, it
' is added here
Else
ReDim rgFileName(0)
rgFileName(0) = strFileName
' in this case, the array was empty. So assign
' the first element to be the name of the file
' to add
DebugWriteNameValue "vartype(rgFileName)", vartype(rgFileName)
DebugWriteNameValue "strFileName", strFileName
End If
m_options.Item("Files") = rgFileName
' here we now set the RefreshOptions key "Files" to
' the array of file names. This is done each
' time a file is added
Elseif Request.Form("Action") = "Remove" Then
RemoveArrayElement rgFileName, CInt(Request.Form("idx"))
m_options.Item("Files") = rgFileName
' for the "Remove" action, the array element
' holding that file name is removed and the shortened
' array is set to the RefreshOptions collection under the
' key "Files"
Elseif Request.Form("Action") = "Edit" Then
rgFileName(CInt(Request.Form("idx"))) = strFileName
m_options.Item("Files") = rgFileName
Here we update the "Files" option again
Elseif Request.Form("Action") = "DirChange" Then
m_options.Item("Directory") = CStr(Request.Form("Directory"))
' The User clicked the "ChangeDir" button on the form.
' Here we change the directory string pointed to by the
' RefreshOption key "Directory"
m_options.Item("Files") = rgFileName
End If
SaveProject prj
' This calls the method Project.Save for the project
End Sub