File Download via HTTP and FTP

I have been working on a solution for file download.  I am now able to download both binary and text files both via http and ftp and both with Classic Client and Role Tailored Client.

Attached is a codeunit that can download a text file via http, a zip file via http and a text file via ftp.  I use dotnet object for the Role Tailored Client to handle files on the client side.

FileDownload

When the Database Name has non-english character

At a client I was trying to start the NAV 2009 R2 Service Tier.  The client has a non-english character in the database name and the service tier complained and would not start.  This is an issue that Microsoft fixed recently and after I installed a newer version of the service tier everything works fine.

I also had to make sure that the CustomSettings.config file was saved with UTF-8 encoding.  This can be done by running Notepad in administrative mode, open the file and select the UFT-8 encoding in save-as dialog.

FindPrinter function in Codeunit 1

There is sometime a mixup in printer names between Netbios Names and DNS Names.  Also, you might want to have certain reports printed to certain printers only.  I installed a code after
[code htmlscript=”false”]IF NOT PrinterSelection.GET(USERID,ReportID) THEN
IF NOT PrinterSelection.GET(”,ReportID) THEN
IF NOT PrinterSelection.GET(USERID,0) THEN
IF PrinterSelection.GET(”,0) THEN;[/code]
to search for printers using both Netbios Names and DNS Names.
[code htmlscript=”false”]IF (PrinterSelection."Printer Name" <> ”) AND
NOT Printer.GET(PrinterSelection."Printer Name") AND
(COPYSTR(PrinterSelection."Printer Name",1,2) = ‘\\’) THEN BEGIN
IF UPPERCASE(COPYSTR(PrinterSelection."Printer Name",1,26)) =
‘\\PRINTSERVER.DYNAMICS.IS\’ THEN BEGIN
LookupPrinterName :=
‘\\PRINTSERVER\’ + COPYSTR(PrinterSelection."Printer Name",27);
PrinterFound := Printer.GET(LookupPrinterName);
END
ELSE
IF UPPERCASE(COPYSTR(PrinterSelection."Printer Name",1,14)) =
‘\\PRINTSERVER\’ THEN BEGIN
LookupPrinterName :=
‘\\PRINTSERVER.DYNAMICS.IS\’ +
COPYSTR(PrinterSelection."Printer Name",15);
PrinterFound := Printer.GET(LookupPrinterName);
END;
IF PrinterFound THEN
PrinterSelection."Printer Name" := Printer.Name
ELSE BEGIN
IF ISCLEAR(SystemNetwork) THEN
CREATE(SystemNetwork,TRUE,TRUE);
SystemNetwork.AddWindowsPrinterConnection(
PrinterSelection."Printer Name");
IF NOT Printer.GET(PrinterSelection."Printer Name") THEN
ERROR(Text50000,PrinterSelection."Printer Name");
END;
END;[/code]
Where
[code htmlscript=”false”]Text50000 =
"Printer for this report is not found: %1, restart NAV and try again.
If still unsuccesful please contact IT department."[/code]
and

Name DataType Subtype Length
PrinterSelection Record Printer Selection
Printer Record Printer
SystemNetwork Automation ‘Windows Script Host Object Model’.WshNetwork
LookupPrinterName Text 250
PrinterFound Boolean

The line SystemNetwork.AddWindowsPrinterConnection connects the computer to the network printer if so a restart of the NAV client should be enough to get things working.