<?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>TechBlog &#187; Automations</title>
	<atom:link href="http://techblog.byllemos.com/category/navision/automations-navision/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.byllemos.com</link>
	<description>Accelerating into the Future with Wisdom about Technology! Ingrid Byllemos</description>
	<lastBuildDate>Tue, 05 Jan 2010 00:04:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Could Not Load Type Library &#8211; Application Handler</title>
		<link>http://techblog.byllemos.com/2009/05/could-not-load-type-library-application-handler/</link>
		<comments>http://techblog.byllemos.com/2009/05/could-not-load-type-library-application-handler/#comments</comments>
		<pubDate>Sun, 24 May 2009 21:09:31 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Automations]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=245</guid>
		<description><![CDATA[<p>Hi!</p>
<p>Lately I have been talking with some people, which have received the error “Could Not Load Type Library”. All these errors were caused by missing registration of the NSAppHandler.dll.</p>
<p>The NSAppHandler.dll can be registered in the following steps:<span id="more-245"></span>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Hi!</p>
<p>Lately I have been talking with some people, which have received the error “Could Not Load Type Library”. All these errors were caused by missing registration of the NSAppHandler.dll.</p>
<p>The NSAppHandler.dll can be registered in the following steps:<span id="more-245"></span></p>
<blockquote><p>
1) Open a command prompt &#8211; remember to do it as Administrator or else you dll won&#8217;t be registered</p>
<p>2) Change to your directory with the dll &#8211; for me it was C:\Program Files\Common Files\Microsoft Dynamics NAV\Application Handler</p>
<p>3) Register it manually with the help of regsvr32<br />
- Try first regsvr32 NSAppHandler.dll &#8211; if this fails, then try regsvr32 /i NSAppHandler.dll
</p></blockquote>
<p>Also notice, that the NSAppHandler.dll is not completely compliant with all Office versions &#8211; so you might need to install an older one, as the one that did come with your Navision version.</p>
<p>If you have installed a &#8220;wrong&#8221; version &#8211; then remember to unregister your NSAppHandler.dll before installing the new one – and of course close your NAV Client during the NSAppHandler.dll switch. (Unregister is done by using regsvr32 /u NSAppHandler.dll)</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2009/05/could-not-load-type-library-application-handler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Expanding the FTP automation</title>
		<link>http://techblog.byllemos.com/2009/03/expanding-the-ftp-automation/</link>
		<comments>http://techblog.byllemos.com/2009/03/expanding-the-ftp-automation/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 22:14:43 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Automations]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Navision]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=134</guid>
		<description><![CDATA[<p>In the previous post I have started the development of FTP automation. The first post did only include some basic functions such as download, upload and list. Now it’s time for some more functionality.</p>
<p>So now let us add the&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>In the previous post I have started the development of FTP automation. The first post did only include some basic functions such as download, upload and list. Now it’s time for some more functionality.</p>
<p>So now let us add the possibility to delete and rename files.</p>
<p>Deleting a file from the FTP server is actually pretty simple. All you have to know is the filename and where it is place. Once you have this information you can use the WebRequestMethods to delete the file.<br />
<span id="more-134"></span><br />
We will start with making a connection to the FTP Server:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow"><ol><li> string ConnectionString = &quot;ftp://&quot; + strFTPServer + ':' + intFTPPort + &quot;/&quot; + strFtpDirectory + @FileName;</li><li>&nbsp;</li><li>FtpWebRequest FtpRequest = <span class="br0">&#40;</span>FtpWebRequest<span class="br0">&#41;</span>FtpWebRequest.Create<span class="br0">&#40;</span>ConnectionString<span class="br0">&#41;</span>;</li><li>FtpRequest.Credentials = new NetworkCredential<span class="br0">&#40;</span>strUsername, strPassword<span class="br0">&#41;</span>;</li><li>FtpRequest.KeepAlive = false;</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now we are ready to delete the file:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow"><ol><li>FtpRequest.Method = WebRequestMethods.Ftp.DeleteFile;</li><li>FtpRequest.GetResponse<span class="br0">&#40;</span><span class="br0">&#41;</span>.Close<span class="br0">&#40;</span><span class="br0">&#41;</span>;</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>This is done by using WebRequestMethods to set the DeleteFile Method and then afterwards executing the deletion with GetResponse.</p>
<p>Remember to catch Execeptions, to see if the deletion went well.</p>
<p>So now you can delete files from the FTP server. </p>
<p>This was easy. So let us continue with the renaming.</p>
<p>Renaming a file is similar to the deletion of a file. Again all you need to know is the filename &#038; path and then you can use WebRequestMethods to rename the file.</p>
<p>As in the deletion of a file you will start with making the server connection:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow"><ol><li>string ConnectionString = &quot;ftp://&quot; + strFTPServer + ':' + intFTPPort + &quot;/&quot; + strFtpDirectory + @FileName;</li><li>&nbsp;</li><li>FtpWebRequest FtpRequest = <span class="br0">&#40;</span>FtpWebRequest<span class="br0">&#41;</span>FtpWebRequest.Create<span class="br0">&#40;</span>ConnectionString<span class="br0">&#41;</span>;</li><li>FtpRequest.Credentials = new NetworkCredential<span class="br0">&#40;</span>strUsername, strPassword<span class="br0">&#41;</span>;</li><li>FtpRequest.KeepAlive = false;</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now that the server connection is in place &#8211; you are ready to perform the renaming:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow"><ol><li></li><li>FtpRequest.Method = WebRequestMethods.Ftp.Rename;</li><li>FtpRequest.RenameTo = NewFileName;</li><li>FtpRequest.GetResponse<span class="br0">&#40;</span><span class="br0">&#41;</span>.Close<span class="br0">&#40;</span><span class="br0">&#41;</span>;</li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>As you can see, we are also here using WebRequestMethods to set Rename Method. First the Method is chosen; you set the new filename with FtpRequest.RenameTo and then afterwards execute the rename with GetResponse.</p>
<p>So the only difference to the deletion is the Method and the RenameTo command. </p>
<p>That’s all folks! Now you can delete and rename files on an Ftp.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2009/03/expanding-the-ftp-automation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a FTP automation</title>
		<link>http://techblog.byllemos.com/2008/12/writing-a-ftp-automation/</link>
		<comments>http://techblog.byllemos.com/2008/12/writing-a-ftp-automation/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 22:25:36 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Automations]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Navision]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=115</guid>
		<description><![CDATA[<p>Over some time I have been using a plain dos ftp from Navision. There is some advantages and some disadvantage combined with it. </p>
<p>A advantage is, that this use does not require any third part products; but a disadvantage&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Over some time I have been using a plain dos ftp from Navision. There is some advantages and some disadvantage combined with it. </p>
<p>A advantage is, that this use does not require any third part products; but a disadvantage is that you does not have the fully control over the file transfer, so you have to build your own kind of file log and parsing it to know if everything went well.</p>
<p>Therefor I decided to build my own automation for Navision in c#.<br />
<span id="more-115"></span><br />
My first version of the automation should only contain some basic functions.<br />
Which are:<br />
- Upload File<br />
- Download File<br />
- List</p>
<p>To upload a file we will be using FTPWebRequest, which is a part of System.Net and FileInfo,<br />
which is a part of System.IO.</p>
<p>We will start with making a connection to the FTP Server:</p>
<blockquote><p>string ConnectionString =<br />
<font class="blankspace">&#8230;&#8230;</font>&#8220;ftp://&#8221; + strFTPServer + &#8216;:&#8217; +intFTPPort + &#8220;/&#8221; +strFtpDirectory +FileName;</p>
<p>FtpWebRequest FtpRequest =<br />
<font class="blankspace">&#8230;&#8230;</font>(FtpWebRequest)FtpWebRequest.Create(new Uri(ConnectionString));</p>
<p>FtpRequest.Credentials = new NetworkCredential(strUsername, strPassword);
</p></blockquote>
<p>If the connection went well, we are ready for to upload the file. The upload is done by<br />
creating a File Stream and then writing the file byte by byte to the Ftp Server.</p>
<blockquote><p>
FtpRequest.Method = WebRequestMethods.Ftp.UploadFile;<br />
FtpRequest.ContentLength = FileInf.Length;</p>
<p>FileInfo FileInf = new FileInfo(FileName);</p>
<p>int BufferLength = 2048;<br />
byte[] Buffer = new byte[BufferLength];<br />
int ContentLength;</p>
<p>FileStream UpStream = FileInf.OpenRead();<br />
Stream FtpStream = FtpRequest.GetRequestStream();                   </p>
<p>ContentLength = UpStream.Read(Buffer, 0, BufferLength);<br />
while (ContentLength != 0)<br />
{<br />
<font class="blankspace">&#8230;&#8230;</font>FtpStream.Write(Buffer, 0, ContentLength);<br />
<font class="blankspace">&#8230;&#8230;</font>ContentLength = UpStream.Read(Buffer, 0, BufferLength);<br />
}</p>
<p>FtpStream.Close();<br />
FtpStream.Dispose();</p>
<p>UpStream.Close();<br />
UpStream.Dispose();
</p></blockquote>
<p>To download a file is pretty similar to upload a file.</p>
<p>First we start with making a connection to the Server:</p>
<blockquote><p>
FtpWebRequest FtpRequest =<br />
<font class="blankspace">&#8230;&#8230;</font>(FtpWebRequest)FtpWebRequest.Create(new Uri(ConnectionString));</p>
<p>FtpRequest.Credentials = new NetworkCredential(strUsername, strPassword);
</p></blockquote>
<p>and then we downloads the file by using a stream:</p>
<blockquote><p>
System.IO.Stream ResponseStream = null;<br />
System.IO.FileStream DownStream = null;</p>
<p>FtpRequest.Method = WebRequestMethods.Ftp.DownloadFile;<br />
FtpWebResponse WebResponse = (FtpWebResponse)FtpRequest.GetResponse();<br />
ResponseStream = WebResponse.GetResponseStream();<br />
DownStream = System.IO.File.Open(DownFileName + &#8220;.tmp&#8221;, System.IO.FileMode.Create);</p>
<p>while (((iWork = ResponseStream.Read(buf, 0, buf.Length)) > 0))<br />
<font class="blankspace">&#8230;&#8230;</font>DownStream.Write(buf, 0, iWork);</p>
<p>ResponseStream.Close();<br />
ResponseStream.Dispose();</p>
<p>DownStream.Flush();
</p></blockquote>
<p>If you want to check that the download went well &#8211; you can always check the return response<br />
from the FtpRequest:</p>
<blockquote><p>
FtpWebResponse ReturnResponse = ((FtpWebResponse)FtpRequest.GetResponse());<br />
if (StatusOk(ReturnResponse))<br />
{<br />
<font class="blankspace">&#8230;&#8230;</font>DownloadSucceeded = true;<br />
}
</p></blockquote>
<p>And then finally the List functionality. This function will be useful when downloading files.</p>
<p>Again we start with making a connection to the Server:</p>
<blockquote><p>
FtpWebRequest FtpRequest =<br />
<font class="blankspace">&#8230;&#8230;</font>(FtpWebRequest)FtpWebRequest.Create(new Uri(ConnectionString));</p>
<p>FtpRequest.Credentials = new NetworkCredential(strUsername, strPassword);
</p></blockquote>
<p>Then we use the ListDirectoryDetails funtion to find the files.</p>
<blockquote><p>
FtpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;<br />
FtpWebResponse Response = (FtpWebResponse)FtpRequest.GetResponse();
</p></blockquote>
<p>As you can see, where are again using the stream functionality.</p>
<blockquote><p>
StringBuilder Result = new StringBuilder();<br />
StreamReader Reader = new StreamReader(Response.GetResponseStream());<br />
string Line = Reader.ReadLine();<br />
string tmpLine;<br />
while (Line != null)<br />
{<br />
<font class="blankspace">&#8230;&#8230;</font>tmpLine = Line;</p>
<p><font class="blankspace">&#8230;&#8230;</font>//Lines starting with d is directories &#8211; everything else is file<br />
<font class="blankspace">&#8230;&#8230;</font>if (!tmpLine.StartsWith(&#8220;d&#8221;))<br />
<font class="blankspace">&#8230;&#8230;</font>{<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>tmpLine = Line.Substring(Line.LastIndexOf(&#8216; &#8216;) + 1);<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>Result.Append(tmpLine);<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>Result.Append(&#8220;\n&#8221;);<br />
<font class="blankspace">&#8230;&#8230;</font>}<br />
<font class="blankspace">&#8230;&#8230;</font>Line = Reader.ReadLine();<br />
}</p>
<p>Reader.Close();<br />
Response.Close();</p>
<p>string[] FileList<br />
FileList = Result.ToString().Split(&#8216;\n&#8217;);
</p></blockquote>
<p>Thats all – now you can upload, download and list files.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/12/writing-a-ftp-automation/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Writing an automation for Navision in C#</title>
		<link>http://techblog.byllemos.com/2008/10/writing-an-automation-for-navision-in-c/</link>
		<comments>http://techblog.byllemos.com/2008/10/writing-an-automation-for-navision-in-c/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 20:12:57 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ADO]]></category>
		<category><![CDATA[Automations]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Navision]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=74</guid>
		<description><![CDATA[<p>Writing a automation for Navision is pretty simple, when you first know how to do it <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>First of all, I assume that you already know about C#.</p>
<p>So here are the basic steps for&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Writing a automation for Navision is pretty simple, when you first know how to do it <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>First of all, I assume that you already know about C#.</p>
<p>So here are the basic steps for creating an automation:<br />
<span id="more-74"></span><br />
1. Create a new Class Library project.</p>
<ul>
<li>Chose File -&gt; New -&gt; Project and then chose Class Library and save it as myAutomation (or use you own name)</li>
</ul>
<p>2. Before making any changes &#8211; setup the Properties</p>
<ul>
<li>Chose Project -&gt; myAutomation Properties</li>
<li>Select tab Application and then the button Assembly Information
<ul>
<li>In the Assembly Information window, mark &#8220;Make assembly COM-Visible&#8221; and chose Ok</li>
</ul>
</li>
<li>Select tab Build
<ul>
<li>Mark &#8220;Register for COM interop&#8221;</li>
</ul>
</li>
<li>Select tab Signing
<ul>
<li>Mark &#8220;Sign the assembly&#8221; and create a key files (or chose an existing one)</li>
</ul>
</li>
</ul>
<p>Now everything is setup and you can close the property setup.</p>
<p>3. Add the namespace for InteropServices
<ul>
<li>This is done by adding using System.Runtime.InteropServices</li>
</ul>
<p>You should now have a code similar to the following:</p>
<blockquote><p>using System;<br />
using System.Text;<br />
using System.Runtime.InteropServices;</p>
<p>namespace myAutomation<br />
{<br />
<font class="blankspace">&#8230;&#8230;</font>public class myAutomation<br />
<font class="blankspace">&#8230;&#8230;</font>{<br />
<font class="blankspace">&#8230;&#8230;</font>}<br />
}</p></blockquote>
<p>4. Declare the interface</p>
<p>First you have to decide if the class should be visible or not. In this case we want it to be visible, so that we can use it with the automation.</p>
<blockquote><p>[ComVisible(true)]</p></blockquote>
<p>Next you can choose to set the Guid and ProgId.</p>
<blockquote><p>[Guid("41E646B3-F65C-4d8e-8539-499FA56C7076")]<br />
[ProgId("myAutomation")]
</p></blockquote>
<p>Then decide the Class Interface Type. You can choose between None and Autodual.</p>
<blockquote><p>
[ClassInterface(ClassInterfaceType.AutoDual)]
</p></blockquote>
<p>For now we will be using Autodual, because None requires the use of Interface and class&#8217;es &#8211; where as Autodual only uses class.</p>
<p>You should now have a code similar to the following:</p>
<blockquote><p>using System;<br />
using System.Text;<br />
using System.Runtime.InteropServices;</p>
<p>namespace myAutomation<br />
{<br />
<font class="blankspace">&#8230;&#8230;</font>[ComVisible(true)]<br />
<font class="blankspace">&#8230;&#8230;</font>[Guid("41E646B3-F65C-4d8e-8539-499FA56C7076")]<br />
<font class="blankspace">&#8230;&#8230;</font>[ClassInterface(ClassInterfaceType.AutoDual)]<br />
<font class="blankspace">&#8230;&#8230;</font>[ProgId("myAutomation")]<br />
<font class="blankspace">&#8230;&#8230;</font>public class myAutomation<br />
<font class="blankspace">&#8230;&#8230;</font>{<br />
<font class="blankspace">&#8230;&#8230;</font>}<br />
}</p></blockquote>
<p>Now you can add all the functions that you need.</p>
<p>Notice, you can hide functions and classes from the automation by using Private or [ComVisible(false)]</p>
<p>Here is a code example for an automation with visible and invisible methods.</p>
<blockquote><p>
using System;<br />
using System.Text;<br />
using System.Runtime.InteropServices;</p>
<p>namespace myAutomation<br />
{<br />
<font class="blankspace">&#8230;&#8230;</font>[ComVisible(true)]<br />
<font class="blankspace">&#8230;&#8230;</font>[Guid("41E646B3-F65C-4d8e-8539-499FA56C7076")]<br />
<font class="blankspace">&#8230;&#8230;</font>[ClassInterface(ClassInterfaceType.AutoDual)]<br />
<font class="blankspace">&#8230;&#8230;</font>[ProgId("myAutomation")]<br />
<font class="blankspace">&#8230;&#8230;</font>public class myAutomation<br />
<font class="blankspace">&#8230;&#8230;</font>{<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>public Int16 Add(Int16 X, Int16 Y)<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>{<br />
<font class="blankspace">&#8230;&#8230;&#8230;&#8230;&#8230;.</font>Int16 Result = (Int16)(X + Y);<br />
<font class="blankspace">&#8230;&#8230;&#8230;&#8230;&#8230;.</font>return Result;<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>}</p>
<p><font class="blankspace">&#8230;&#8230;&#8230;..</font>//Is hidden in the Automation because of Private<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>private Int16 PrivateAdd(Int16 X, Int16 Y)<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>{<br />
<font class="blankspace">&#8230;&#8230;&#8230;&#8230;&#8230;.</font>Int16 Result = (Int16)(X + Y);<br />
<font class="blankspace">&#8230;&#8230;&#8230;&#8230;&#8230;.</font>return Result;<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>}</p>
<p><font class="blankspace">&#8230;&#8230;&#8230;..</font>//Is hidden in the Automation because of ComVisible<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>[ComVisible(false)]<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>public Int16 InvisibleAdd(Int16 X, Int16 Y)<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>{<br />
<font class="blankspace">&#8230;&#8230;&#8230;&#8230;&#8230;.</font>Int16 Result = (Int16)(X + Y);<br />
<font class="blankspace">&#8230;&#8230;&#8230;&#8230;&#8230;.</font>return Result;<br />
<font class="blankspace">&#8230;&#8230;&#8230;..</font>}<br />
<font class="blankspace">&#8230;&#8230;</font>}<br />
}
</p></blockquote>
<p>Functions are in the automation presented as Methods, where as C# properties (public set; get;) are presented as properties.</p>
<p>Please note, that I am using Visual Studio C# 2008 (you can download the Express version from Microsoft <a href="http://www.microsoft.com/express/vcsharp/">here</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/10/writing-an-automation-for-navision-in-c/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Importing Image from a non Navision table to a Navision blob field</title>
		<link>http://techblog.byllemos.com/2008/05/importing-image-from-a-non-navision-table-to-blob-field/</link>
		<comments>http://techblog.byllemos.com/2008/05/importing-image-from-a-non-navision-table-to-blob-field/#comments</comments>
		<pubDate>Mon, 12 May 2008 19:33:33 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[ADO]]></category>
		<category><![CDATA[Automations]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=66</guid>
		<description><![CDATA[<p>In SQL it is possible to define tables with a column, which is of type image. This field type is not known by Navision or by ADO and can thereby not be extracted like other fields.<br /><br /></p>
<p>There exists 2 ways&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>In SQL it is possible to define tables with a column, which is of type image. This field type is not known by Navision or by ADO and can thereby not be extracted like other fields.<br/><br/></p>
<p>There exists 2 ways to get this fields value.<br/></p>
<p>1) One way is to stream the image to a file and then afterwards import it into the blob.<br/><br/><br />
<span id="more-66"></span><br />
In this example I assume you already have the ADO Connection and thereby already got the ADORecordSet.<br/><br/><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">ADOStream.Type := <span style="">1</span>; //1 = Binary
ADOStream.Open;
ADOStream.Write<span class="br0">&#40;</span>ADORecordSet.Fields.Item<span class="br0">&#40;</span>FieldName<span class="br0">&#41;</span>.Value<span class="br0">&#41;</span>;
ADOStream.SaveToFile<span class="br0">&#40;</span>'c:\tmp.bmp',2<span class="br0">&#41;</span>; //2 = SaveCreateOverWrite
ReturnTable.Picture.IMPORT<span class="br0">&#40;</span>'c:\tmp.bmp'<span class="br0">&#41;</span>;
ADOStream.Close;
CLEAR<span class="br0">&#40;</span>ADOStream<span class="br0">&#41;</span>;
&nbsp;
Where ADOStream is 'Microsoft ActiveX Data Objects <span style="">2.8</span> Library'.Stream
and ADORecordSet is 'Microsoft ActiveX Data Objects <span style="">2.8</span> Library'.Recordset
</div></pre><!--END_DEVFMTCODE--><br />
<br/><br />
This method works for compressed and uncompressed Blob fields.<br />
<br/><br/><br />
2) Another way is to move/insert the image into your table by using ADO RecordSet.<br />
<br/><br/><br />
Create 2 connections, one to your image table (ADOConn) and one to the table in Navision (NAVconn) where you want the picture to be inserted. Then &#8220;transfer&#8221; the Value from one RecordSet to another and add it.<br/><br/></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">FromRecSet := ADOConn.Execute<span class="br0">&#40;</span>'SELECT image FROM tableX','',0<span class="br0">&#41;</span>;
FromRecSet.MoveFirst;
&nbsp;
//The following query is used to get a &quot;blank&quot; recordset, just like a INIT in Navision
MyQuery := 'SELECT <span class="br0">&#91;</span>EntryNo<span class="br0">&#93;</span>, <span class="br0">&#91;</span>Picture<span class="br0">&#93;</span> FROM <span class="br0">&#91;</span>MyTable<span class="br0">&#93;</span> WHERE <span class="br0">&#91;</span>EntryNo<span class="br0">&#93;</span> = 0';
&nbsp;
NewRecSet.Open<span class="br0">&#40;</span>MyQuery,NAVconn,1,3,1<span class="br0">&#41;</span>;
NewRecSet.AddNew;
NewRecSet.Fields.Item<span class="br0">&#40;</span>'Picture'<span class="br0">&#41;</span>.Value := FromRecSet.Fields.Item<span class="br0">&#40;</span>'image'<span class="br0">&#41;</span>.Value;
NewRecSet.Update;
&nbsp;
</div></pre><!--END_DEVFMTCODE--><br />
<br/><br />
This method does not work for compressed Blob fields!<br />
<br/><br/><br />
If you need to know more about <a href="http://techblog.byllemos.com/?p=38">ADO Connection</a> or <a href="http://techblog.byllemos.com/?p=40">ADO RecordSet</a>, then please read my previous posts on <a title="ADO" href="http://techblog.byllemos.com/?s=ADO">ADO</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/05/importing-image-from-a-non-navision-table-to-blob-field/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML Scraping from Navision</title>
		<link>http://techblog.byllemos.com/2008/05/html-scraping-from-navision/</link>
		<comments>http://techblog.byllemos.com/2008/05/html-scraping-from-navision/#comments</comments>
		<pubDate>Thu, 08 May 2008 18:55:09 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Automations]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Microsoft HTML Object Library]]></category>
		<category><![CDATA[Microsoft Internet Controls]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[Scraping]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=65</guid>
		<description><![CDATA[<p>Some times you are in the need of showing a web page an afterwards using the results or data from the web page in Navision.</p>
<p>This can be done by using HTML Scraping. HTML Scraping is a technique which allows&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Some times you are in the need of showing a web page an afterwards using the results or data from the web page in Navision.</p>
<p>This can be done by using HTML Scraping. HTML Scraping is a technique which allows you to extract data from a web page.<br />
<span id="more-65"></span><br />
HTML Scraping contains of 3 elementary steps:</p>
<ul>
<li> First open a browser and find the page from where data should be extracted</li>
<li> Second extract the HTML page and find the tag which contains the data &#8211; and extract it</li>
<li> Third close the browser</li>
</ul>
<p>Let&#8217;s take a closer look on each of the mentioned steps.</p>
<p>To open a browser use the automation &#8216;Microsoft Internet Controls&#8217;.InternetExplorer<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">IF ISCLEAR<span class="br0">&#40;</span>iExplorer<span class="br0">&#41;</span> THEN
   CREATE<span class="br0">&#40;</span>iExplorer<span class="br0">&#41;</span>;
&nbsp;
iExplorer.Visible<span class="br0">&#40;</span>TRUE<span class="br0">&#41;</span>; //Show the browser window
&nbsp;
iExplorer.Navigate<span class="br0">&#40;</span>'http://www.byllemos.com'<span class="br0">&#41;</span>;
</div></pre><!--END_DEVFMTCODE--><br />
Where iExplorer is defined as &#8216;Microsoft Internet Controls&#8217;.InternetExplorer with the parameter WithEvent set to Yes.</p>
<p>If you do not want the browser window to be shown for the user, then set Visble to false.</p>
<p>Now its time for the HTML Scraping <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  To do this, we add code on the iExplorer::DocumentComplete trigger. This is done, because we only want to scrape complete pages.</p>
<p>First you have to load the document:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">//Load the document
HTMLdocument := iExplorer.Document<span class="br0">&#40;</span><span class="br0">&#41;</span>;
</div></pre><!--END_DEVFMTCODE--><br />
Where HTMLdocument is &#8216;Microsoft HTML Object Library&#8217;.HTMLDocument</p>
<p>Now you are able to parse the document and get data from it:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">//Get a specific tag
HTMLElementCollection := HTMLdocument.getElementsByTagName<span class="br0">&#40;</span>'Title'<span class="br0">&#41;</span>;
&nbsp;
//select a single element
HTMLElement := HTMLElementCollection.item;
&nbsp;
//get the value
returnvalue := HTMLElement.innerText;
</div></pre><!--END_DEVFMTCODE--><br />
Where HTMLElementCollection is &#8216;Microsoft HTML Object Library&#8217;.IHTMLElementCollection and HTMLElement is &#8216;Microsoft HTML Object Library&#8217;.HTMLHtmlElement</p>
<p>Now you have scraped the page and can close the browser:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">iExplorer.Quit;
&nbsp;
CLEAR<span class="br0">&#40;</span>iExplorer<span class="br0">&#41;</span>;</div></pre><!--END_DEVFMTCODE--></p>
<p>Before quitting the browser though &#8211; you must be sure, that the page loading is completed.<br />
One way to do this is by waiting for the browser not to be busy:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">WHILE iExplorer.Busy<span class="br0">&#40;</span><span class="br0">&#41;</span> DO BEGIN
END;</div></pre><!--END_DEVFMTCODE--><br />
While loading a web page &#8211; the browser will tell that it is busy.</p>
<p>If you are showing the web page for the user, you also have to wait for the user to close/quit the browser &#8211; or else you will run the risk for a too early end of your codeunit. This can be done by waiting for the visible property to change:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">WHILE iExplorer.Visible<span class="br0">&#40;</span><span class="br0">&#41;</span> DO BEGIN
END; </div></pre><!--END_DEVFMTCODE--><br />
That&#8217;s all &#8211; now you are able to perform HTML Scarping <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/05/html-scraping-from-navision/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

