Some tips for using FTP Rush Scripts.

Any issues, suggestions, and bug reports about new FTP Rush v3

Some tips for using FTP Rush Scripts.

Postby FTP » Sat Sep 26, 2020 5:01 am

Scripting language support is an important feature of FTP Rush V3, I'm sorry we don't have detailed help documentation yet, but here are some tips for using scripts.
1 Use "Log.Status(string msg)" function to Add one status line log to the log window. "Log.Error" to add error message.
Image



2 If you want to print a message to the Terminal window, you can use "Print" or "Println".
Image



3 You can use "Site.Add" to add a new server to the Site Manager and use "Site.Connect" to connect the server.
Site.Add( new Server{ Name = "demo", Host="demo.wftpserver.com", UserName="demo", Password="demo", Port = 21, Protocol= ServerProtocol.FTP});

Site.Connect("demo");
Image



4. Use Local.ChangeDir and Remote.ChangeDir to change working directory. Use Local.UploadFile and Remote.DownloadFile to transfer files.
Image


5. API reference

enum ServerProtocol
{
FTP,
SFTP,
WingWeb,
DropBox,
GoogleDrive,
OneDrive,
AmazonS3
}
enum FTPEnryptMode
{
PlainText,
Implicit,
Explicit
}

enum TaskType
{
DownloadFile,
UploadFile,
CreateLocalEmptyDir,
CreateRemoteEmptyDir,
DownloadDir,
UploadDir
}

enum TaskState
{
Queue,
Running,
Waiting,
TryAgain,
Cancel,
Failed,
Skipped,
Succeed
}

enum TaskExist
{
None,
Overwrite,
Resume,
Rename,
Skip,
Ask
}

class Server
{
string Name;
string Host;
int Port,
string UserName,
string Password,
ServerProtocol Protocol,
string Notes,
string DefaultLocalPath,
string DefaultRemotePath,
bool ByPassProxy,
FTPEnryptMode FTPEnryptMode,
bool UseHTTPS
}

class TransferItem
{

TaskType TaskType;
TaskState TaskState;
TaskExist TaskExist;
Server Server;
string LocalName;
string RemoteName;
long Size;
long Transfered;
}

class OptionSetting
{
Proxy Proxy;
string Lang;
int ConnectionTimeOut;
int ConnectionRetryNum;
int ConnectionDelay;
int TransferMaxNum;
int TransferDownSpeedLimit;
int TransferUpSpeedLimit;
bool UseListCache;
List<Server> LastConnectServers;
Dictionary<string, string> ShortcutPath;
SizeType SizeType;
string DefaultLocalFolder;
bool ByPassLocalAddress;
bool ShowDetailLog;
bool ShowTimeLog;
bool LogToFile;
bool LimitLogFile;
long LimitLogFileSize;
string LogFileName;
}

static class Site
{
void Load(string jsonfile=null)
//Load the sites list from the jsonfile, if jsonfile is null, load the default "site.json" in the application's folder.

void Save(string jsonfile=null)
//Save the sites list to the jsonfile, if jsonfile is null, save to the default "site.json".

void Add(Server server)
//Add a server to the sites list.

List<Server> GetServerList()
//Get the sites list.

void Clear()
//Clear the sites list.

void Remove(Server server)
//Remove the specific server from the sites list.

void Remove(string name)
//Remove server by name.

Server GetServer(string name)
//Get the server by name.

void Connect(Server server)
//Connect the specific server.

void Connect(string name)
//Connect the server by name, the server must exists in sites list.
}

static class Local
{
string CurrentDir()
//Get current working dir

ObservableCollection<RushFileInfo> FileList()
//Get file/dir list in the current local dir

Task ChangeDir(string dir)
//Change local directory

Task DeleteFile(string filename)
//Delete local file

Task DeleteDir(string dirname)
//Delete local directory

Task RenameFile(string oldname, string newname)
//Rename the file from the oldname to newname

Task RenameDir(string oldname, string newname)
//Rename the directory from oldname to newname

Task CreateDir(string dirname)
//Create local directory

void Open(string filename)
//Open the local filename

UploadFile(string local, string remote = null)
//Upload the "local" file to the "remote" path, if "remote" is null, then to the current remote directory.

void QueueUploadFile(string local, string remote = null)
//Queue the "local" file to the "remote" path, if "remote" is null, then to the current remote directory.

Task UploadDir(string local, string remote = null)
//Upload the "local" directory to the "remote" path, if "remote" is null, then to the current remote directory.

Task QueueUploadDir(string local, string remote = null)
//Queue the "local" directory to the "remote" path, if "remote" is null, then to the current remote directory.

}


static class Remote
{
string CurrentDir()
//Get current remote directory.

ObservableCollection<RushFileInfo> FileList()
//Get file/dir list in the current remote dir

Server Server()
//Get current connected server

Task ChangeDir(string dir)
//Change remote directory

Task CreateDir(string dir)
//Create remote directory

Task DeleteFile(string filename)
//Delete remote file

Task DeleteDir(string filename)
//Delete remote directory

Task RenameFile(string oldname, string newname)
// Rename remote file from oldname to newname

Task RenameDir(string oldname, string newname)
//Rename remote directory from oldname to newname

void DownloadFile(string remote, string local = null)
//Download the "remote" file to the "local" path, if "local" is null, then to the current local directory.

void QueueDownloadFile(string remote, string local = null)
//Queue the "remote" file to the "local" path, if "local" is null, then to the current local directory.

void DownloadDir(string remote, string local = null)
//Download the "remote" directory to the "local" path, if "local" is null, then to the current local directory.

Task QueueDownloadDir(string remote, string local = null)
//Queue the "remote" directory to the "local" path, if "local" is null, then to the current local directory.

}


static class Main
{
Task Refresh()
//Refresh current local and remote file view.

Task Disconnect()
//Disconnect the current server.

void Cancel()
//Cancel current operation.

void CloseTab(int index = -1)
//Close the tab, if index is -1, then close the current active tab.

void NewTab()
//New tab.

void SwitchTab(int index)
//Set active tab

int GetActiveTabIndex()
//Get current active tab index

int GetTabCount()
//Get tab count
}

static class Option
{
OptionSetting Settings
void Load(string settingFile = null)
void Save(string settingFile = null)
}


static class Transfer
{
void Add(TransferItem transferItem)
void Start()
void Stop()
void Remove(TransferItem transferItem)
void Remove(int index)
void RemoveAll()
ObservableCollection<TransferItem> GetQueueItems()
void Load(string queueFile = null)
void Save(string queueFile = null)
void DownloadFile(Server server, string remoteFile,string localFile)
void QueueDownloadFile(Server server, string remoteFile, string localFile)
void DownloadDir(Server server, string remoteDir, string localDir)
void QueueDownloadDir(Server server, string remoteDir, string localDir)
void UploadFile(Server server, string localFile, string remoteFile)
void QueueUploadFile(Server server, string localFile, string remoteFile)
void UploadDir(Server server, string localDir, string remoteDir)
void QueueUploadDir(Server server, string localDir, string remoteDir)

}

static class Log
{
public static void Status(string format, params object[] args)

public static void Status(string message)

public static void Error(string format, params object[] args)

public static void Error(string message)

public static void Command(string format, params object[] args)

public static void Command(string message)

public static void Response(string format, params object[] args)

public static void Response(string message)

}
FTP
Site Admin
 
1758
 
Tue Sep 29, 2009 6:09 am

Return to FTP Rush v3

Who is online

Users browsing this forum: No registered users and 1 guest