by Klaus Graefensteiner
8. September 2010 22:41
Hello IronRuby
I am currently reading the Pickaxe book to get up to speed with Ruby 1.9. Ruby doesn’t have a convincing Microsoft .NET integration story, but fortunately there is a Ruby language implementation in .NET called IronRuby. In this blog post I demonstrate how to integrate IronRuby with the VantagePoint EMI .NET API.
IronRuby = Ruby + .NET (DLR).
This is a very powerful combination. IronRuby runs on Silverlight and on the Windows 7 phone OS!
Querying Model Items of a certain ItemType with IronRuby
Figure 1: Getting all item instances of type Core.Template.Report
Of course all techniques described in this blog post still apply. Use .NET Reflector to discover and experiment with the VantagePoint API. One of the .NET types that provides most of the item specific attributes is the ItemInfo object.
Figure 2: ItemInfo object
IronRuby Script
Here is the IronRuby script that queries Report Template items and prints them out.
load_assembly "Dataworks.MI.Core"
load_assembly "Dataworks.MI.Core.Client"
DataWorks::MI::Core.class
DataWorks::MI::Core::Client::Globals.Version
DataWorks::MI::Core::Client::Globals.Initialize
itemsQuery = DataWorks::MI::Core::Query::ItemsQuery.new
itemType = DataWorks::MI::Core::TypeRepository.Instance.ItemTypes["Core.Template.Report"]
itemTypeFilter = DataWorks::MI::Core::Query::ItemTypeFilter.new(itemType)
itemsQuery.ItemTypeFilter = itemTypeFilter
reportItems = DataWorks::MI::Core::Query::QueryProvider.Instance.QueryItems(itemsQuery)
reportItems.each { |reportItem| puts "#{reportItem.name}" }
reportItems.each { |reportItem| puts "#{reportItem.FullyQualifiedName}" }
Helpful tip for loading the right assemblies
IronRuby provides the ability to load strongly typed assemblies from the Global Assembly Cache (GAC). To get these strongly typed names you can use the gacutil /l to list the assemblies in the GAC and copy and past the strong names of the assemblies that you are trying to load with IronRuby.
Download
The IronRuby script can be downloaded here: QueryReportTemplateItemsToCreatePageWithReportLinks.zip
Ausblick
IronRuby is still in the early stages, but it will be my favorite Ruby implementation on the Windows Platform. No doubt about it!