Archived Boards > COM Automation and dotNet

RSS Feed Reader Sample Code

(1/2) > >>

Deana:

--- Code: Winbatch ---;***************************************************************************
;**   RSS Feed Reader
;**
;** Purpose: Read an RSS feed using dotNet. Displays full summary of the selected Rss Feed in a message
;** Inputs:  URL of RSS feed
;** Outputs: Results in a Reportview / Message
;** Reference:
;**       REQUIRES WinBatch 2013A or newer and dotNet 2.0 or newer
;**
;** Developer: Deana Falk 2013.06.13
;***************************************************************************
If Version( )< '2013A'
   Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
   Exit
EndIf
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Prompt for input
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rssfeed = 'http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
maxfeed = 128 ; Maximum nuber of syndication items to display

; Create an array to store the results
arrRssFeed = ArrDimension(maxfeed,2) ;Columns: Title,Summary
arrRssFeed[0,0] = 'Title'
arrRssFeed[0,1] = 'Summary'
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Load assemblies into the WinBatch process.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;ObjectClrOption( 'use', 'System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35');System.ServiceModel.Web v4.0_4.0.0.0__31bf3856ad364e35
ObjectClrOption( 'use', 'System.ServiceModel.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35')  
ObjectClrOption( 'use', 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Create a class implemented by a managed assembly.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;Create an instance of XmlReader class that reads XML data from a specified URL.
XmlReader = ObjectClrNew( 'System.Xml.XmlReader' )
XmlReader = XmlReader.Create( rssfeed )
; Create an instance of Rss20FeedFormatter class.
Rss20FeedFormatter = ObjectClrNew( 'System.ServiceModel.Syndication.Rss20FeedFormatter' )
; The ReadFrom() method of Rss20FeedFormatter class accepts an XmlReader and reads the XML data.
Rss20FeedFormatter.ReadFrom(XmlReader)
; The XmlReader is closed.
XmlReader.Close()
; The Feed property of Rss20FeedFormatter class is of type SyndicationFeed and represents the feed being read.
; The Title and Copyright properties of SyndicationFeed class return title and copyright mesage of the current feed respectively.
Title = Rss20FeedFormatter.Feed.Title.Text
Title = Title : ' [ ' : Rss20FeedFormatter.Feed.Copyright.Text : ' ]'
; The Items property of the SyndicationFeed class returns a collection of SyndicationItem objects representing feed items.  
SyndicationItems  = Rss20FeedFormatter.Feed.Items
row = 1
ForEach Item in SyndicationItems
   arrRssFeed[row,0] = Item.Title.Text   ; Title
   arrRssFeed[row,1] = StrSub( Item.Summary.Text, 1, 2048 )  ; Summary  
   row = row + 1
Next

MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`RSS Feed Reader Sample`
MyDialogX=002
MyDialogY=059
MyDialogWidth=766
MyDialogHeight=353
MyDialogNumControls=005
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`257,331,122,012,PUSHBUTTON,"PushButton_Display",DEFAULT,"Display Feed Summary",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`391,331,070,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`015,033,736,290,REPORTVIEW,"ReportView_1",arrRssFeed,DEFAULT,DEFAULT,30,11534336,DEFAULT,DEFAULT,"192|192|192"`
MyDialog004=`015,003,526,012,VARYTEXT,"FeedTitle_1",Title,DEFAULT,DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog005=`015,023,300,008,STATICTEXT,"StaticText_1",DEFAULT,"Select the feed item you would like to display.",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

;Display Full Summary of the selected Rss Feed in a message
feedtitle  = arrRssFeed[0,0]
feedsummary  = arrRssFeed[0,1]
Pause( feedtitle, feedsummary )
Exit
 
Reference:  http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/dotNet/System_ServiceModel+Read~RSS~Feed.txt

kdmoyers:
Deanna,
What do you suppose this error (attached photo) indicates?
Maybe bad dotnet version? if so, how to upgrade that?
-Kirby

stanl:
Kirby;
That key is for .NET 4.0/4.5 - I posted code on the old board to collect the base assemblies into a db table that exist on a PC. In fact these are placed in WB CLROption() code.  You probably have a version of the assembly that will work with Deana's code and just have to replace that line with the version you have.
[EDIT] here is what mine shows on my laptop

Deana:

--- Quote from: kdmoyers on June 14, 2013, 05:01:24 am ---Deanna,
What do you suppose this error (attached photo) indicates?
Maybe bad dotnet version? if so, how to upgrade that?
-Kirby

--- End quote ---

Kirby,
What version of dotNet do you have installed?

Try going to your start menu and typing 'System.ServiceModel.Web' in the 'search programs and files' field. if you see a folder appear. Right-click and select 'open folder location'. Open that folder and you may see a sub folder that looks something like this: v4.0_4.0.0.0__31bf3856ad364e35 this is the version information need by the ObjectClrOption function.

That code was written on Windows 7 with .NET 4.0 installed. This version of the framework can be downloaded from Microsoft. See: http://www.microsoft.com/en-us/download/details.aspx?id=17851

kdmoyers:

--- Quote from: stanl on June 14, 2013, 06:37:19 am ---You probably have a version of the assembly that will work with Deana's code and just have to replace that line with the version you have.
--- End quote ---
Thanks Stan!
I'll try tinkering with that line to see if I can get it to work.
-Kirby

Navigation

[0] Message Index

[#] Next page

Go to full version