Показаны различия между двумя версиями страницы.
— |
axapta:какпослатьфайлпоftp [2018/04/13 22:43] (текущий) |
||
---|---|---|---|
Строка 1: | Строка 1: | ||
+ | Раздел: | ||
+ | ---- | ||
+ | Из DevelopmentAxapta (Dahlsgaard Jan) | ||
+ | |||
+ | В Класс/ | ||
+ | <code XPP> | ||
+ | DLLFunction _internetConnect; | ||
+ | DLLFunction _ftpGetFile; | ||
+ | DLLFunction _ftpPutFile; | ||
+ | </ | ||
+ | и вот это в new: | ||
+ | <code XPP> | ||
+ | _internetConnect = new DLLFunction(_winInet," | ||
+ | _internetConnect.returns(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | _internetConnect.arg(ExtTypes:: | ||
+ | |||
+ | _ftpGetFile | ||
+ | _ftpGetFile.returns(ExtTypes:: | ||
+ | _ftpGetFile.arg(ExtTypes:: | ||
+ | _ftpGetFile.arg(ExtTypes:: | ||
+ | _ftpGetFile.arg(ExtTypes:: | ||
+ | _ftpGetFile.arg(ExtTypes:: | ||
+ | _ftpGetFile.arg(ExtTypes:: | ||
+ | _ftpGetFile.arg(ExtTypes:: | ||
+ | _ftpGetFile.arg(ExtTypes:: | ||
+ | |||
+ | _ftpPutFile | ||
+ | _ftpPutFile.returns(ExtTypes:: | ||
+ | _ftpPutFile.arg(ExtTypes:: | ||
+ | _ftpPutFile.arg(ExtTypes:: | ||
+ | _ftpPutFile.arg(ExtTypes:: | ||
+ | _ftpPutFile.arg(ExtTypes:: | ||
+ | _ftpPutFile.arg(ExtTypes:: | ||
+ | </ | ||
+ | |||
+ | и следующие функции: | ||
+ | <code XPP> | ||
+ | int internetConnect(str 60 _server, str 99 _userName, str 99 _password ) | ||
+ | { | ||
+ | return | ||
+ | _internetConnect.call(_handle, | ||
+ | } | ||
+ | int FtpGetFile(int _hdl, str 255 _remoteFile, | ||
+ | { | ||
+ | return | ||
+ | _FtpGetFile.call(_hdl, | ||
+ | } | ||
+ | |||
+ | int FtpPutFile(int _hdl, str 255 _localFile, str 255 _remoteFile) | ||
+ | { | ||
+ | return | ||
+ | _FtpPutFile.call(_hdl, | ||
+ | } | ||
+ | |||
+ | boolean ftpSetCurrentDirectory(str _name) | ||
+ | { | ||
+ | DLLFunction setCurrentDirectory = new DLLFunction(winInetDLL, | ||
+ | ; | ||
+ | |||
+ | if (connectHandle == 0) | ||
+ | return false; | ||
+ | |||
+ | setCurrentDirectory.returns(ExtTypes:: | ||
+ | |||
+ | setCurrentDirectory.arg(ExtTypes:: | ||
+ | ExtTypes:: | ||
+ | |||
+ | return setCurrentDirectory.call(connectHandle, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Используйте internetconnect для соединения с ftp сервером, | ||
+ | |||
+ | XPO файл с добавленными функциями | ||
+ | < | ||
+ | Exportfile for AOT version 1.0 or later | ||
+ | Formatversion: | ||
+ | |||
+ | ***Element: CLS | ||
+ | |||
+ | ; Axapta Class: WinInet unloaded at Monday 1/9/2006 | ||
+ | ; -------------------------------------------------------------------------------- | ||
+ | CLSVERSION 1 | ||
+ | | ||
+ | CLASS #WinInet | ||
+ | PROPERTIES | ||
+ | Name #WinInet | ||
+ | Extends | ||
+ | RunOn # | ||
+ | ENDPROPERTIES | ||
+ | | ||
+ | METHODS | ||
+ | Version: 3 | ||
+ | SOURCE # | ||
+ | #final class WinInet | ||
+ | #{ | ||
+ | # DLL _winInet; | ||
+ | # DLLFunction _internetOpen; | ||
+ | # DLLFunction _internetCloseHandle; | ||
+ | # DLLFunction _internetOpenUrl; | ||
+ | # DLLFunction _internetReadFile; | ||
+ | # | ||
+ | # int _handle; | ||
+ | # int _result; | ||
+ | # | ||
+ | # DLLFunction _internetConnect; | ||
+ | # DLLFunction _ftpGetFile; | ||
+ | # DLLFunction _ftpPutFile; | ||
+ | # DLLFunction _ftpSetCurrentDirectory; | ||
+ | # DLLFunction _ftpCommand; | ||
+ | # DLLFunction _ftpFindFirstFile; | ||
+ | # DLLFunction _ftpDeleteFile; | ||
+ | # DLLFunction _ftpRenameFile; | ||
+ | # DLLFunction _ftpCreateDirectory; | ||
+ | # DLLFunction _ftpRemoveDirectory; | ||
+ | # DLLFunction _ftpGetCurrentDirectory; | ||
+ | # | ||
+ | # | ||
+ | # # | ||
+ | # # | ||
+ | # # | ||
+ | # | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE #finalize | ||
+ | #void finalize() | ||
+ | #{ | ||
+ | # this.internetCloseHandle(_handle); | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE #ftpCommand | ||
+ | #int ftpCommand(int _handler, boolean _expectResponseIn, | ||
+ | #{ | ||
+ | # int _handlerOut; | ||
+ | # int _expectResponse; | ||
+ | # ; | ||
+ | # | ||
+ | # if (_expectResponseIn) | ||
+ | # _expectResponse = 1; | ||
+ | # else | ||
+ | # _expectResponse = 0; | ||
+ | # | ||
+ | # if(_ftpCommand.call(_handler, | ||
+ | # return 0; | ||
+ | # else | ||
+ | # return _handlerOut; | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #boolean ftpCreateDirectory(int _hdl, str 255 _name) | ||
+ | #{ | ||
+ | # if (_ftpCreateDirectory.call(_hdl, | ||
+ | # return false; | ||
+ | # else | ||
+ | # return true; | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #boolean ftpDeleteFile(int _hdl, str 255 _file) | ||
+ | #{ | ||
+ | # if (_ftpDeleteFile.call(_hdl, | ||
+ | # return false; | ||
+ | # else | ||
+ | # return true; | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #int ftpGetCurrentDirectory(int _hdl, str 255 _remoteFile, | ||
+ | #{ | ||
+ | # return 0;// | ||
+ | #} | ||
+ | # | ||
+ | ENDSOURCE | ||
+ | SOURCE #FtpGetFile | ||
+ | #int ftpGetFile(int _hdl, str 255 _remoteFile, | ||
+ | #{ | ||
+ | # return _FtpGetFile.call(_hdl, | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE #FtpPutFile | ||
+ | #int ftpPutFile(int _hdl, str 255 _localFile, str 255 _remoteFile) | ||
+ | #{ | ||
+ | # return _FtpPutFile.call(_hdl, | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #boolean ftpRemoveDirectory(int _hdl, str 255 _name) | ||
+ | #{ | ||
+ | # if (_ftpRemoveDirectory.call(_hdl, | ||
+ | # return false; | ||
+ | # else | ||
+ | # return true; | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #boolean ftpRenameFile(int _hdl, str 255 _fileOld, str 255 _fileNew) | ||
+ | #{ | ||
+ | # if (_ftpRenameFile.call(_hdl, | ||
+ | # return false; | ||
+ | # else | ||
+ | # return true; | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #Boolean ftpSetCurrentDirectory(int _handler, str _name) | ||
+ | #{ | ||
+ | # ; | ||
+ | # | ||
+ | # if (_handler == 0) | ||
+ | # return false; | ||
+ | # | ||
+ | # if (_ftpSetCurrentDirectory.call(_handler, | ||
+ | # return false; | ||
+ | # else | ||
+ | # return true; | ||
+ | #} | ||
+ | # | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #boolean internetCloseHandle(int handle) | ||
+ | #{ | ||
+ | # return _internetCloseHandle.call(handle); | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #int internetConnect(str 60 _server, str 99 _userName, str 99 _password ) | ||
+ | #{ | ||
+ | # return _internetConnect.call(_handle, | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #int internetOpen(str 255 agent,int accessType, | ||
+ | #{ | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # return _internetOpen.call(agent, | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #int internetOpenUrl(str 500 url,int flags = 0,int context = 0) | ||
+ | #{ | ||
+ | # Binary _headers = new Binary(512); | ||
+ | # int hdl = _internetOpenUrl.call(_handle, | ||
+ | # return hdl; | ||
+ | # | ||
+ | # | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE # | ||
+ | #str internetReadFile(int hdl) | ||
+ | #{ | ||
+ | # Binary _buffer = new Binary(2048); | ||
+ | # Binary _bytesRead = new Binary(4); | ||
+ | # str result; | ||
+ | # boolean ret; | ||
+ | # int done = 0; | ||
+ | # | ||
+ | # while (! done) | ||
+ | # { | ||
+ | # ret = _internetReadFile.call(hdl, | ||
+ | # if ((! _bytesRead.dWord(0)) || (! ret)) | ||
+ | # done = 1; | ||
+ | # else | ||
+ | # { | ||
+ | # result += subStr(_buffer.string(0), | ||
+ | # } | ||
+ | # } | ||
+ | # return ret ? result : ""; | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE #new | ||
+ | #void new() | ||
+ | #{ | ||
+ | # try | ||
+ | # { | ||
+ | # _winInet = new DLL(" | ||
+ | # } | ||
+ | # catch(Exception:: | ||
+ | # { | ||
+ | # infolog.clear(); | ||
+ | # return; | ||
+ | # } | ||
+ | # | ||
+ | # _internetOpen = new DLLFunction(_winInet," | ||
+ | # _internetOpen.returns(ExtTypes:: | ||
+ | # _internetOpen.arg(ExtTypes:: | ||
+ | # _internetOpen.arg(ExtTypes:: | ||
+ | # _internetOpen.arg(ExtTypes:: | ||
+ | # _internetOpen.arg(ExtTypes:: | ||
+ | # _internetOpen.arg(ExtTypes:: | ||
+ | # | ||
+ | # _internetCloseHandle = new DLLFunction(_winInet," | ||
+ | # _internetCloseHandle.returns(ExtTypes:: | ||
+ | # _internetCloseHandle.arg(ExtTypes:: | ||
+ | # | ||
+ | # _internetOpenUrl = new DLLFunction(_winInet," | ||
+ | # _internetOpenUrl.returns(ExtTypes:: | ||
+ | # _internetOpenUrl.arg(ExtTypes:: | ||
+ | # _internetOpenUrl.arg(ExtTypes:: | ||
+ | # _internetOpenUrl.arg(ExtTypes:: | ||
+ | # _internetOpenUrl.arg(ExtTypes:: | ||
+ | # _internetOpenUrl.arg(ExtTypes:: | ||
+ | # _internetOpenUrl.arg(ExtTypes:: | ||
+ | # | ||
+ | # _internetReadFile = new DLLFunction(_winInet," | ||
+ | # _internetReadFile.returns(ExtTypes:: | ||
+ | # _internetReadFile.arg(ExtTypes:: | ||
+ | # _internetReadFile.arg(ExtTypes:: | ||
+ | # _internetReadFile.arg(ExtTypes:: | ||
+ | # _internetReadFile.arg(ExtTypes:: | ||
+ | # | ||
+ | # _handle = this.internetOpen(" | ||
+ | # | ||
+ | # _internetConnect = new DLLFunction(_winInet," | ||
+ | # _internetConnect.returns(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # _internetConnect.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpGetFile | ||
+ | # _ftpGetFile.returns(ExtTypes:: | ||
+ | # _ftpGetFile.arg(ExtTypes:: | ||
+ | # _ftpGetFile.arg(ExtTypes:: | ||
+ | # _ftpGetFile.arg(ExtTypes:: | ||
+ | # _ftpGetFile.arg(ExtTypes:: | ||
+ | # _ftpGetFile.arg(ExtTypes:: | ||
+ | # _ftpGetFile.arg(ExtTypes:: | ||
+ | # _ftpGetFile.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpPutFile | ||
+ | # _ftpPutFile.returns(ExtTypes:: | ||
+ | # _ftpPutFile.arg(ExtTypes:: | ||
+ | # _ftpPutFile.arg(ExtTypes:: | ||
+ | # _ftpPutFile.arg(ExtTypes:: | ||
+ | # _ftpPutFile.arg(ExtTypes:: | ||
+ | # _ftpPutFile.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpSetCurrentDirectory = new DLLFunction(_winInet, | ||
+ | # _ftpSetCurrentDirectory.returns(ExtTypes:: | ||
+ | # _ftpSetCurrentDirectory.arg(ExtTypes:: | ||
+ | # _ftpSetCurrentDirectory.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpCommand = new DLLFunction(_winInet, | ||
+ | # _ftpCommand.returns(ExtTypes:: | ||
+ | # _ftpCommand.arg(ExtTypes:: | ||
+ | # _ftpCommand.arg(ExtTypes:: | ||
+ | # _ftpCommand.arg(ExtTypes:: | ||
+ | # _ftpCommand.arg(ExtTypes:: | ||
+ | # _ftpCommand.arg(ExtTypes:: | ||
+ | # _ftpCommand.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpDeleteFile = new DLLFunction(_winInet, | ||
+ | # _ftpDeleteFile.returns(ExtTypes:: | ||
+ | # _ftpDeleteFile.arg(ExtTypes:: | ||
+ | # _ftpDeleteFile.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpRenameFile = new DLLFunction(_winInet, | ||
+ | # _ftpRenameFile.returns(ExtTypes:: | ||
+ | # _ftpRenameFile.arg(ExtTypes:: | ||
+ | # _ftpRenameFile.arg(ExtTypes:: | ||
+ | # _ftpRenameFile.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpCreateDirectory = new DLLFunction(_winInet, | ||
+ | # _ftpCreateDirectory.returns(ExtTypes:: | ||
+ | # _ftpCreateDirectory.arg(ExtTypes:: | ||
+ | # _ftpCreateDirectory.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpRemoveDirectory = new DLLFunction(_winInet, | ||
+ | # _ftpRemoveDirectory.returns(ExtTypes:: | ||
+ | # _ftpRemoveDirectory.arg(ExtTypes:: | ||
+ | # _ftpRemoveDirectory.arg(ExtTypes:: | ||
+ | # | ||
+ | # _ftpGetCurrentDirectory = new DLLFunction(_winInet, | ||
+ | # _ftpGetCurrentDirectory.returns(ExtTypes:: | ||
+ | # _ftpGetCurrentDirectory.arg(ExtTypes:: | ||
+ | # _ftpGetCurrentDirectory.arg(ExtTypes:: | ||
+ | # _ftpGetCurrentDirectory.arg(ExtTypes:: | ||
+ | # | ||
+ | # / | ||
+ | # _ftpFindFirstFile.returns(ExtTypes:: | ||
+ | # _ftpFindFirstFile.arg(ExtTypes:: | ||
+ | # _ftpFindFirstFile.arg(ExtTypes:: | ||
+ | # | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | SOURCE #ok | ||
+ | #boolean ok() | ||
+ | #{ | ||
+ | # if (_winInet) | ||
+ | # return TRUE; | ||
+ | # else | ||
+ | # return FALSE; | ||
+ | #} | ||
+ | ENDSOURCE | ||
+ | ENDMETHODS | ||
+ | ENDCLASS | ||
+ | |||
+ | ***Element: END | ||
+ | </ | ||
+ | |||
+ | [[http:// |