Show/Hide Toolbars

Inventu Viewer+ Server Macros

Navigation: Implementing the ServerMacro Class > ServerMacro Members > Client Interaction Methods

GetClientFile - used to request the client to upload a file to the server

Scroll Prev Top Next More

GetClientFile can be used to request the client to upload a file to the server, to be then available to the macro code.

 

bool GetClientFile(string fileName, string message, string title 
[, bool exactMatch]  [, int timeOut])

 

Parameters

 

fileName

Required. The file name that forms a basis for the server-side handling of the file.  For the client, this name's extension is used to determine the type of file to upload.  If parameter exactMatch is set true, then the file selected at the client must have a name that matches this parameter.

 

message

 Required. The message that is displayed to the client describing which file is to be uploaded.

 

title

 Required. The title displayed at the top of the File Upload request at the client.

 

exactMatch

Optional. When true, the fileName will be compared to the file selected at the client and must be an exact match or the user will be requested to select a different file.

timeout

 Optional. Number of milliseconds to wait for client response.  -1 means no timeout (indefinite wait).  Default value is -1 (indefinite wait)

 

Remarks

If the user uploads a file, GetClientFile will return true.  Two ServerMacro properties contain important information following a successful upload.  These are:

 

Property

Type

Description

xferReceiveFile

String

Full path to the file as it is available on the server.  This generally will be in the C:\ProgramData\[Inventu|Flynet]\DataXFer\XfersTo folder, but this can be changed in the Inventu Viewer+ Emulation server's registry setting XferRootFolder.  The file name will have the session ID pre-pended to ensure unique names across sessions.

xferReceiveName

String

The simple file name as selected by the client

 

Example

This example shows a file upload being requested, then some verification logic and appending a timestamp line to the file.

 

public override MacroRunResult run()

{

 bool ok = this.GetClientFile(fileName, "Please upload the Text File""Text Input Upload"false);

 if (ok)

 {

         this.ClientMessageBox("File \"" + this.xferReceiveFile + "\" was uploaded OK!!!""File " 

                 this.xferReceiveName + " Upload Complete"MacroMessageType.info, MacroButtons.ok);

         using (StreamWriter sw=new StreamWriter(this.xferReceiveFile,true))

         {

                 sw.WriteLine("New Line " + DateTime.Now.ToLongDateString() 

                                 +"-"DateTime.Now.ToLongTimeString());

         }

         MacroDialogRC rc = this.PutClientFile(this.xferReceiveFile, 

                         "The File has been sent back to you--did you download it OK?""File Updated and Returned",

                         MacroMessageType.question, MacroButtons.yes | MacroButtons.no);

         if (rc == MacroDialogRC.yes)

                 this.ClientMessageBox("That's great, thanks for trusting the file appending service!",

                          "Good News"MacroMessageType.info, MacroButtons.ok);

         else

                 this.ClientMessageBox("Sorry you were unable to trust the file appending service!"

                                 "BAD News"MacroMessageType.info, MacroButtons.ok);

         }

 }

 else

         this.ClientMessageBox("File upload failed or was cancelled!!!"

                 "File " + fileName + " Upload Failed"MacroMessageType.error, MacroButtons.ok);

 return MacroRunResult.ok;

}