The following example demonstrates the rudimentary use of the Active Channel Server COM objects to store channel information. This example demonstrates
As a starting point, assume the CDF listed below is the desired CDF output. This CDF defines a "Color" channel that has most of the standard elements, including <LOGO>, <SCHEDULE>, <CHANNEL>, and <ITEM>. A VBScript script is listed next that would create the object-model representation of this information. Once created, the information is saved, and the CDF is then generated.
Sample "Color" Channel CDF Text
<?XML version="1.0"?>
<CHANNEL HREF="http://www.mysite.com/Channel/homepage.htm"
BASE="http://www.mysite.com/Channel/">
<TITLE>Sample "Color" Channel</TITLE>
<ABSTRACT>The sample color channel contains a red, green, and blue page for viewing.</ABSTRACT>
<LOGO HREF="logo_big.gif" STYLE="IMAGE-WIDE"/>
<LOGO HREF="logo_med.gif" STYLE="IMAGE"/>
<SCHEDULE STARTDATE="1997-09-23">
<INTERVALTIME DAY="1" />
<EARLIESTTIME HOUR="2" />
<LATESTTIME HOUR="6" />
</SCHEDULE>
<ITEM HREF="page1.htm">
<LOGO HREF="red.gif" STYLE="ICON"/>
<TITLE>The Red Page</TITLE>
<ABSTRACT>This is the abstract description for the red page.</ABSTRACT>
</ITEM>
<ITEM HREF="page2.htm">
<LOGO HREF="green.gif" STYLE="ICON"/>
<TITLE>The Green Page</TITLE>
<ABSTRACT>This is the abstract description for the green page.</ABSTRACT>
</ITEM>
<ITEM HREF="page3.htm">
<LOGO HREF="blue.gif" STYLE="ICON"/>
<TITLE>The Blue Page</TITLE>
<ABSTRACT>This is the abstract description for the blue page.</ABSTRACT>
</ITEM>
<ITEM HREF="scrnsave.htm">
<USAGE VALUE="ScreenSaver"></USAGE>
</ITEM>
</CHANNEL>
VBScript Example That Builds a Representation of the CDF Above.
The example that follows creates a Project object and all the necessary secondary objects to represent the CDF information above.
' Using VBScript and Windows Scripting Host Runtime Env
Dim Project
Set Project = CreateObject("Push.Project")
Project.Name="ColorChannel"
' Add the logos to the project
call Project.AddLogo("Top-Big","logo_big.gif", "IMAGE-WIDE")
call Project.AddLogo( "Top-Med","logo_med.gif", "IAMGE")
call Project.AddLogo( "Red" , "red.gif", "ICON")
call Project.AddLogo( "Green" , "green.gif", "ICON")
call Project.AddLogo( "Blue" , "blue.gif", "ICON")
' set up the channel
Project.Channel.HREF="http://www.mysite.com/Channel/homepage.htm"
Project.Channel.BASE="http://www.mysite.com/Channel/"
Project.Channel.Title="Sample "Color" Channel"
Project.Channel.Abstract="The sample color channel contains a red, green, and blue page for viewing."
' attach the logos to the channel itself
Project.Channel.LogoRefs.Add "Top-Big"
Project.Channel.LogoRefs.Add "Top-Med"
' set up the schedule element
Project.Channel.Schedule.Startdate=#1997-09-23#
Project.Channel.Schedule.Intervaltime=1
Project.Channel.Schedule.Earliesttime=2
Project.Channel.Schedule.Latesttime=6
' now add the items
Dim Item
' Red item
Set Item = Project.Channel.AddItem
Item.HREF="page1.htm"
Item.Title="The Red Page"
Item.Abstract="This is the abstract description for the red page."
Item.LogoRefs.Add "Red"
' Green item
Set Item = Project.Channel.AddItem()
Item.HREF="page2.htm"
Item.Title="The Green Page"
Item.Abstract="This is the abstract description for the green page."
Item.LogoRefs.Add "Green"
' Blue item
Set Item = Project.Channel.AddItem()
Item.HREF="page3.htm"
Item.Title="The Blue Page"
Item.Abstract="This is the abstract description for the blue page."
Item.LogoRefs.Add "Blue"
' Screensaver item
Set Item = Project.Channel.AddItem()
Item.HREF="scrnsave.htm"
Item.AddUsage "ScreenSaver"
' Save the project (very important!)
Call Project.Save "ColorChannels"
' write the CDF file to disk
Call Project.WriteCDFFile("c:\channels\color\color.cdf")
This example, although not very interesting, does illustrate the core features of the = Active Channel Server Objects. A more interesting use of these objects is in an Active Channel Agent script that performs a routine refresh cycle, searching the system for content that meets certain conditions for inclusion and when found, automatically updates the project with the information.