<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fi3ry &#187; .NET Development</title>
	<atom:link href="http://www.fi3ry.com/category/programming/net_development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fi3ry.com</link>
	<description>A conglomeration of non-sense and programming junk</description>
	<lastBuildDate>Thu, 09 Jul 2009 15:30:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>VB.NET Finding The Current Working Directory</title>
		<link>http://www.fi3ry.com/programming/net_development/vb-net-finding-the-current-working-directory/</link>
		<comments>http://www.fi3ry.com/programming/net_development/vb-net-finding-the-current-working-directory/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 15:30:58 +0000</pubDate>
		<dc:creator>Fi3ry</dc:creator>
				<category><![CDATA[.NET Development]]></category>

		<guid isPermaLink="false">http://www.fi3ry.com/?p=86</guid>
		<description><![CDATA[I&#8217;m sure there are plenty of different ways to find the current working directory using VB.NET.  I&#8217;m using Environment.CurrentDirectory.  Seems to work OK.
For testing purposes I used File.Exists() from System.IO

Imports System.IO
...
MsgBox(File.Exists(Environment.CurrentDirectory &#038; "\YourFileToInclude.rpt"))

]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure there are plenty of different ways to find the current working directory using VB.NET.  I&#8217;m using Environment.CurrentDirectory.  Seems to work OK.<br />
For testing purposes I used File.Exists() from System.IO<br />
<code><br />
Imports System.IO<br />
...<br />
MsgBox(File.Exists(Environment.CurrentDirectory &#038; "\YourFileToInclude.rpt"))<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fi3ry.com/programming/net_development/vb-net-finding-the-current-working-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the ArcGIS API for Microsoft Silverlight</title>
		<link>http://www.fi3ry.com/programming/net_development/using-the-arcgis-api-for-microsoft-silverlight/</link>
		<comments>http://www.fi3ry.com/programming/net_development/using-the-arcgis-api-for-microsoft-silverlight/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 02:08:19 +0000</pubDate>
		<dc:creator>Fi3ry</dc:creator>
				<category><![CDATA[.NET Development]]></category>

		<guid isPermaLink="false">http://www.fi3ry.com/?p=67</guid>
		<description><![CDATA[I just started to do some development using the ArcGIS API for Silverlight.  So far so good.  The layers provided by ESRI stream off the web pretty quick, and the examples are pretty easy to follow.  Like most things ESRI though the object documentation sucks.  As I figure things out I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>I just started to do some development using the <a href="http://resources.esri.com/arcgisserver/apis/silverlight/">ArcGIS API for Silverlight</a>.  So far so good.  The layers provided by ESRI stream off the web pretty quick, and the examples are pretty easy to follow.  Like most things ESRI though the object documentation sucks.  As I figure things out I&#8217;ll post em up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fi3ry.com/programming/net_development/using-the-arcgis-api-for-microsoft-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linq to XML:Using Distinct and Where Clauses</title>
		<link>http://www.fi3ry.com/programming/net_development/linq-to-xml_using-distinct-where/</link>
		<comments>http://www.fi3ry.com/programming/net_development/linq-to-xml_using-distinct-where/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 00:05:05 +0000</pubDate>
		<dc:creator>Fi3ry</dc:creator>
				<category><![CDATA[.NET Development]]></category>

		<guid isPermaLink="false">http://www.fi3ry.com/?p=37</guid>
		<description><![CDATA[I recently decided to use Linq (Language Integrated Query) available in .NET 3.5 SP1 to an XML stream I had to retrieve some information from.  So like every other copy and paste expert, I mean programmer I looked to my lady Googles.  Here are some basic references:
MSDN .NET Language-Integrated Query for XML Data
A [...]]]></description>
			<content:encoded><![CDATA[<p>I recently decided to use Linq (Language Integrated Query) available in .NET 3.5 SP1 to an XML stream I had to retrieve some information from.  So like every other copy and paste expert, I mean programmer I looked to my lady Googles.  Here are some basic references:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb308960.aspx" target="_blank">MSDN .NET Language-Integrated Query for XML Data</a><br />
<a href="http://blog.blocks4.net/post/2007/08/Querying-XML-documents-with-LINQ-to-XML.aspx" target="_blank">A quick intro at blocks4.</a></p>
<p>This is what the XML stream outputs looks like. [Obviously the names have been changed to protect the innocent.]</p>
<pre><code>
&lt;Report&gt;
&lt;ReportItems Count="5"&gt;
 &lt;ReportItem Asset="EV-9D9" Longitude="-115.0695" Latitude="36.2657" MessageTime="11/20/2008 9:56 AM" MessageTimeZone="PST" MessageTimeZoneGMTOffset="-480" SpeedUnit="Mph" Speed="14" Direction="North East"  Name="Normal Speed Resumed" /&gt;
  &lt;ReportItem Asset="EV-9D9" Longitude="-115.0739" Latitude="36.2629" MessageTime="11/20/2008 9:56 AM" MessageTimeZone="PST" MessageTimeZoneGMTOffset="-480" SpeedUnit="Mph" Speed="25" Direction="North East" Name="Maximum Speed Exceeded" /&gt;
  &lt;ReportItem Asset="EV-9D9" Longitude="-115.1464" Latitude="36.1747" MessageTime="11/20/2008 9:41 AM" MessageTimeZone="PST" MessageTimeZoneGMTOffset="-480" Speed="65" Name="Ignition On" /&gt;
  &lt;ReportItem Asset="EV-9D9" Longitude="-115.1464" Latitude="36.1748" MessageTime="11/20/2008 1:01 AM" MessageTimeZone="PST" MessageTimeZoneGMTOffset="-480" Speed="n/a" Address="Map Location" Name="Host Synchronization" Version="0" /&gt;
  &lt;ReportItem Asset="IG-88" MessageTime="11/19/2008 11:00 PM" MessageTimeZone="PST" MessageTimeZoneGMTOffset="-480" AccumulatedMileage="8" AccumulatedMileageUnit="mi" AccumulatedMileageState="Arizona" Name="Accumulated State Mileage" /&gt;
&lt;/ReportItems&gt;
&lt;/Report&gt;
</code></pre>
<p>I had to use <a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.parse.aspx" target="_blank">Parse</a> method in the <em>XDocument</em> object for the XML because the wrapper from the SOAP object returned a String of XML.  Next was to get a <em>Distinct</em> listing of <em>Assets</em> from the stream.</p>
<pre><code>
xdocs = XDocument.Parse(report) 'report is the string of xml
Dim query = From AssetReport In xdocs.Descendants("ReportItem") _
                    Select Asset = AssetReport .Attribute("Asset").Value _
                    Distinct
</code></pre>
<p>If the XML is coming from a file or from an RSS feed use the <em><a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.load.aspx" target="_blank">Load</a> </em>function.</p>
<p>You&#8217;ll notice I used <em>xdocs<a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.descendants.aspx" target="_blank">.Descendants</a>(&#8221;ReportItem&#8221;)</em> because I was only interested in the information in the <em>ReportItem</em> tags.</p>
<p>Also, for ease of use with the object returned in <em>query</em> I &#8220;mapped&#8221; <em>Asset</em> to equal the <em>value</em> of the <em>Attribute</em> named <em>Asset</em> in the XML stream.</p>
<p>Now that <em>query</em> contains a distinct listing of Assets, I&#8217;ll loop over each one pulling the information I want.</p>
<pre><code>
Dim AssetNum As String = String.Empty

For Each item In query

            AssetNum = item.ToString()

            Dim query2 = From DataReport In xdocs.Descendants("ReportItem") _
                    Where (DataReport.Attribute("Name").Value = "Ignition On" _
                    Or DataReport.Attribute("Name").Value = "Ignition Off" _
                    Or DataReport.Attribute("Name").Value = "Breadcrumb" _
                    Or DataReport.Attribute("Name").Value = "Host Synchronization" _
                    Or DataReport.Attribute("Name").Value = "Normal Speed Resumed" _
                    Or DataReport.Attribute("Name").Value = "Maximum Speed Exceeded") _
                    And DataReport.Attribute("Asset").Value = AssetNum _
                    Order By DataReport.Attribute("MessageTime").Value Ascending _
                    Select Asset = DataReport.Attribute("Asset").Value, _
                    Longitude = DataReport.Attribute("Longitude").Value, _
                    Latitude = DataReport.Attribute("Latitude").Value, _
                    MessageTime = DataReport.Attribute("MessageTime").Value, _
                    Speed = DataReport.Attribute("Speed").Value, _
                    Name = DataReport.Attribute("Name").Value, _
                    GMTOffset = DataReport.Attribute("MessageTimeZoneGMTOffset").Value

            For Each item2 In query2
                Try
                    Console.WriteLine("Asset Number: " &#038; item2.Asset &#038; _
                                             ", time: " &#038; item2.MessageTime &#038; _
                                             ", Lat: " &#038; item2.Latitude &#038; _
                                              ", Long: " &#038; item2.Longitude)
                Catch ex As Exception
                    Debug.WriteLine(ex.Message)
                End Try

            Next
            query2 = Nothing
        Next
</pre>
<p></code><br />
A variable <em>AssetNum</em> was declared to hold the asset number because you cannot use <em>item.ToString()</em> directly in <em>query2</em>.</p>
<p>For part of the <em>Where</em> clause I was only interested in retrieving the <em>ReportItems</em> with latitudes and longitudes in them.  Through some trial and error I found that the <em>ReportItems</em> with <em>Names</em> equaling <em>"Ignition On", "Ignition Off", "Breadcrumb", "Host Synchronization", "Normal Speed Resumed" and "Maximum Speed Exceeded"</em> fit the bill.</p>
<p>The final part of the <em>Where</em> clause is the <em>And</em> where the XML is filtered using the <em>AssetNum</em> variable that contains the current Asset identifier from the distinct list of Assets.</p>
<p>You'll notice the dot notation is used for the <em>Console</em> output.  This is because the attribute values are associated in the Linq query.  This was not necessary in the distinct query because there was only one <em>Select</em> item returned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fi3ry.com/programming/net_development/linq-to-xml_using-distinct-where/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
