func init // adds using namespaces sys.add_use('System.Net') sys.add_use('FTP_client') // use external class sys.UseClass("FtpClient") // initialize instance sys.add_object(this.codename, 'FtpClient') // initialize properties sys.set_typed_field(104, 'KeepAlive') sys.set_typed_field(104, 'UseBinary') sys.set_typed_field(104, 'UsePassive') sys.set_typed_field(104, 'UseSSL') // makes implementation methods for properties sys._prop_init('StatusCode', 1, 0, 0) sys._prop_init('StatusDescription', 1, 0, 2) if(linked('onError')) this.setfield('ex', 'ex' + this.id) end end func doAppendFile(remote, local) if(linked('onError')) blk.println('if (!', this.codename, '.AppendFile(', d("remote"), ', ', d("local"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.AppendFile(', d("remote"), ', ', d("local"), ');') end end func doListDirectory(host, user, pass) blk.println(this.codename, '.Host = ', d("Host"), ';') .println(this.codename, '.UserName = ', d("User"), ';') .println(this.codename, '.Password = ', d("Password"), ';') linked("onError") ? blk.println('try {').inc() : '' blk.println('foreach (string item', this.id, ' in ', this.codename, '.ListDirectory(', d("remote"), ')) {').inc() event('onListDirectory', 'item' && this.id) blk.dec().println('}') if(linked("onError")) blk.dec().println('} catch(Exception ', this.ex, ') {').inc() event('onError', this.ex + '.Message') blk.dec().println('}') end end func doListDirectoryDetails(host, user, pass) blk.println(this.codename, '.Host = ', d("Host"), ';') .println(this.codename, '.UserName = ', d("User"), ';') .println(this.codename, '.Password = ', d("Password"), ';') linked("onError") ? blk.println('try {').inc() : '' blk.println('foreach (string item', this.id, ' in ', this.codename, '.ListDirectoryDetails(', d("remote"), ')) {').inc() event('onListDirectory', 'item' && this.id) blk.dec().println('}') if(linked("onError")) blk.dec().println('} catch(Exception ', this.ex, ') {').inc() event('onError', this.ex + '.Message') blk.dec().println('}') end end func doUploadFile(remote, local) if(linked('onError')) blk.println('if (!', this.codename, '.UploadFile(', d("remote"), ', ', d("local"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.UploadFile(', d("remote"), ', ', d("local"), ');') end end func doUploadFileWithUniqueName(remote, local) if(linked('onError')) blk.println('if (!', this.codename, '.UploadFileWithUniqueName(', d("remote"), ', ', d("local"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.UploadFileWithUniqueName(', d("remote"), ', ', d("local"), ');') end end func doDownloadFile(remote, local) if(linked('onError')) blk.println('if (!', this.codename, '.DownloadFile(', d("remote"), ', ', d("local"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.DownloadFile(', d("remote"), ', ', d("local"), ');') end end func doDeleteFile(remote) if(linked('onError')) blk.println('if (!', this.codename, '.DeleteFile(', d("remote"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.DeleteFile(', d("remote"), ');') end end func doGetFileSize(remote) linked("onError") ? blk.println('try {').inc() : '' event('onGetFileSize', this.codename + '.GetFileSize(' + d("remote") + ')') if(linked("onError")) blk.dec().println('} catch(Exception ', this.ex, ') {').inc() event('onError', this.ex + '.Message') blk.dec().println('}') end end func doGetDateTimestamp(remote) linked("onError") ? blk.println('try {').inc() : '' event('onGetDateTimestamp', this.codename + '.GetDateTimestamp(' + d("remote") + ')') if(linked("onError")) blk.dec().println('} catch(Exception ', this.ex, ') {').inc() event('onError', this.ex + '.Message') blk.dec().println('}') end end func doMakeDirectory(remote, newname) if(linked('onError')) blk.println('if (!', this.codename, '.MakeDirectory(', d("remote"), ', ', d("newname"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.MakeDirectory(', d("remote"), ', ', d("newname"), ');') end end func doRemoveDirectory(remote) if(linked('onError')) blk.println('if (!', this.codename, '.RemoveDirectory(', d("remote"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.RemoveDirectory(', d("remote"), ');') end end func doRename(remote, newname) if(linked('onError')) blk.println('if (!', this.codename, '.Rename(', d("remote"), ', ', d("newname"), ')) {').inc() event('onError', this.codename + '.Error') blk.dec().println('}') else blk.println(this.codename, '.Rename(', d("remote"), ', ', d("newname"), ');') end end func doPrintWorkingDirectory() linked("onError") ? blk.println('try {').inc() : '' event('onPrintWorkingDirectory', this.codename + '.PrintWorkingDirectory()') if(linked("onError")) blk.dec().println('} catch(Exception ', this.ex, ') {').inc() event('onError', this.ex + '.Message') blk.dec().println('}') end end