<?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/tag/automations/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>C# and Dns.GetHostEntry</title>
		<link>http://techblog.byllemos.com/2008/10/c-and-dnsgethostentry/</link>
		<comments>http://techblog.byllemos.com/2008/10/c-and-dnsgethostentry/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 21:19:30 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Automations]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=73</guid>
		<description><![CDATA[<p>I am currently building a new FTP automation for Navision. </p>
<p>During this I discovered that Dns.GetHostEntry is not always stable.<br />
<span id="more-73"></span><br />
So I did some testing. Here are some of the results:</p>
<blockquote>
<table border="0">
<tbody>
<tr></tr></tbody></table></blockquote><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I am currently building a new FTP automation for Navision. </p>
<p>During this I discovered that Dns.GetHostEntry is not always stable.<br />
<span id="more-73"></span><br />
So I did some testing. Here are some of the results:</p>
<blockquote>
<table border="0">
<tbody>
<tr>
<td>Dns.GetHostEntry(localhost)</td>
<td>Ok</td>
</tr>
<tr>
<td>Dns.GetHostEntry(127.0.0.1)</td>
<td>Ok</td>
</tr>
<tr>
<td>Dns.GetHostEntry(192.168.1.147)</td>
<td>No Such   Host is Known</td>
</tr>
</tbody>
</table>
</blockquote>
<p>The funny side is that its all to the same ftp server.</p>
<p>It seams, that Dns.GetHostEntry often throws the exception (No Such Host is Known).</p>
<p>So, what to do? Well I have chosen to use the command Dns.GetHostAddresses instead of Dns.GetHostEntry.</p>
<p>The difference between GetHostEntry and GetHostAddresses is that GetHostEntry will attempt a DNS reverse resolve before giving you the IP address back, where as GetHostAddress just returns the IP address.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/10/c-and-dnsgethostentry/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Execution of batch jobs and other programs from Navision</title>
		<link>http://techblog.byllemos.com/2008/04/execution-of-batch-jobs-and-other-programs-from-navision/</link>
		<comments>http://techblog.byllemos.com/2008/04/execution-of-batch-jobs-and-other-programs-from-navision/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 20:55:41 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Automations]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[Run]]></category>
		<category><![CDATA[WshShell]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=63</guid>
		<description><![CDATA[<p>There are at least 2 ways of execution of external batch jobs and programs.<br />
One way is to use the SHELL command another way is to use WshShell.</p>
<p>Lets start with looking at SHELL.<br />
<span id="more-63"></span><br />
SHELL is&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>There are at least 2 ways of execution of external batch jobs and programs.<br />
One way is to use the SHELL command another way is to use WshShell.</p>
<p>Lets start with looking at SHELL.<br />
<span id="more-63"></span><br />
SHELL is a command that you can use directly in the C/AL code. It returns a &#8220;returncode&#8221; and takes name and &#8220;parameters&#8221; as parameter.</p>
<blockquote><p>ReturnCode := SHELL(&#8216;cmd.exe&#8217;,'/c&#8217;,'c:\mybatch.cmd&#8217;);</p>
<p>Where /c means execute my command and the close window (terminate).<br />
You can also use /k which will leave the execution window open.</p></blockquote>
<p>Be aware of, if you are using SHELL in Navision 4 (or higher) you will get a security message from Navision.</p>
<blockquote><p>You are about to run the following executable for the first time<br />
Executable: cmd.exe<br />
Parameter: /c mybatch.cmd</p>
<p>Please be aware that you may be running an executable that could potentially<br />
harm your computer</p>
<p>Do you trust this executable and its parameter?</p></blockquote>
<p>This message is ok in the situations where a user manually can accept the execution &#8211; but if you are running batchs jobs from a scheduler, this is not the ideal situation. Therefor in these cases I would recommend the use of WshShell &#8211; or you could always use WshShell, in that way you would never be shown the security warning <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>So how do we use WshShell? WshShell is an automation, which I have earlier mentioned in the articles about <a title="SendKeys" href="http://techblog.byllemos.com/?p=6" target="_blank">SendKeys</a>. You can execute a batch job by using the command Run.</p>
<blockquote><p>IF ISCLEAR(WshShell) THEN<br />
<blankspace>&#8230;.</blankspace>CREATE(WshShell);</p>
<p>WshMode := 1;<br />
WaitForEndOfCommand := TRUE;</p>
<p>ReturnCode := WshShell.Run(&#8216;cmd.exe /c c:\mybatch.cmd&#8217;,<br />
<blankspace>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</blankspace>WshMode,<br />
<blankspace>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</blankspace>WaitForEndOfCommand);</p>
<p>WshShell is defined as &#8216;Windows Script Host Object Model&#8217;.WshShell<br />
WshMode is an integer and is used to handle the Window Style (minimized, maximize etc.). Valid values can be found <a title="Windows Script Host - Run Method" href="http://msdn2.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx" target="_blank">here.</a></p></blockquote>
<p>WshShell requires a few more lines of codes than SHELL &#8211; but I think its worth the effort.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/04/execution-of-batch-jobs-and-other-programs-from-navision/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

