Multiple Servers
You can install the file service on multiple servers. This is used in organizations with offices at various locations, each with its own LAN or WAN. In such a scenario, you cannot access all files via UNC paths from a single central file service.
Routing
One challenge that arises if you run multiple file services is to direct a file request to the correct server.
The routing of file service requests is done the same way as for direct print jobs. Entries in the routing table tell the file services which jobs in the file request queue need to be processed. In the print solution, we have the printer name to determine the routing, and in the file service, we have a device name.
SetDevice
Before making a file service request, call the SetDevice function to specify which device you are sending the request to. Each device can then be mapped to a file service in the routing table.
procedure SetDevice(Device: Text)
It is entirely up to you how you name your devices. Just ensure there are no overlaps with direct printer names.
By default, the device name is blank. Any connected service can pick up the job and process it. If multiple services are running, this is usually not what you want for the file service.
Example
Here is an example showing how to direct two file requests to two file services.
First, we write a file to a device called DEVICE1, and then we write another to DEVICE2.
action(WriteTextTwoDevices)
{
ApplicationArea = All;
Caption = 'Write Text File to two devices';
ToolTip = 'Write the test text file to two devices.';
Image = Export;
trigger OnAction()
var
FileService: Codeunit "ForNAV File Service";
begin
FileService.SetDevice('DEVICE1');
FileService.WriteText('DEMOFILES:\device1.txt', 'Hello device 1!', "ForNAV Encoding"::"utf-8", true);
FileService.SetDevice('DEVICE2');
FileService.WriteText('DEMOFILES:\device2.txt', 'Hello device 2!', "ForNAV Encoding"::"utf-8", true);
end;
}
The next step is to specify which service should handle which devices. One service can handle multiple devices, but in this example, we will assign our two services one device each.
You will find a link to the routing page on the setup page for print and files.
In this example, we will direct all requests for DEVICE1 to a service running on a server named OFFICE. Requests for DEVICE2 are sent to a service named PRODUCTION.
When the code is run, you can find the two requests on the file queue with the device name listed in the entries.