sách gpt4 ai đã đi

axapta - FTPWebRequest hàng loạt

In lại 作者:行者123 更新时间:2023-12-02 03:47:08 28 4
mua khóa gpt4 Nike

我制作了一个批处理类来检查 FTP 上的文件、下载它们并在 FTP 上删除它们。

当我手动运行它(不是批量运行)时,它运行完美,下载 FTP 中的所有文件并在下载完成后删除它们。

当我尝试批量运行时,问题开始了,我尝试了服务器端和客户端批处理。

两者都报超时错误:

System.Reflection.TargetInvocationException:调用目标抛出异常。 ---> System.Net.WebException: 操作超时。

在 System.Net.FtpWebRequest.CheckError()

在 System.Net.FtpWebRequest.GetResponse()

---内部异常堆栈跟踪结束---

有没有人有从FTP批量下载文件的经验?

我试过将超时时间设置得更高。我还测试了执行批处理作业的服务器上的连接,我可以访问 FTP。所以这不是防火墙问题。我认为它一定是 AX 中的东西,但我真的想不出任何东西。

这是代码(注意:downloadfile 和 deletefile 是用不同的 set_method() 建立连接的相同代码:

permissionSet = new Set(Types::Class);
files = new List(types::String);
permissionset.add(new InteropPermission(InteropKind::DllInterop));
permissionset.add(new InteropPermission(InteropKind::ClrInterop));
CodeAccessPermission::assertMultiple(permissionset);
ftpo = System.Net.WebRequest::Create();
request = ftpo;
request.set_KeepAlive(false);
request.set_UsePassive(false);
request.set_UseBinary(true);
request.set_Method("NLST");
credential = new System.Net.NetworkCredential(,);
request.set_Credentials(credential);
thử
{
//first get the filelist from FTP
response = request.GetResponse();
reader = new System.IO.StreamReader(response.GetResponseStream());
while(!reader.get_EndOfStream())
{
text = reader.ReadLine();
files.addStart(text);
}
reader.Close();
response.Close();
CodeAccessPermission::revertAssert();
if(files.elements() >0)
{
it = New ListIterator(files);
while(it.more())
{
filename = it.value();
downloadfile(filename);
deleteFile(filename);
it.next();
}
}
}

这是完整的异常:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.WebException: The operation has timed out.
at System.Net.FtpWebRequest.CheckError()
at System.Net.FtpWebRequest.GetResponse()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at ClrBridgeImpl.InvokeClrInstanceMethod(ClrBridgeImpl* , ObjectWrapper* objectWrapper, Char* pszMethodName, Int32 argsLength, ObjectWrapper** arguments, Boolean* argsAreByRef, Boolean* isException)

1 Câu trả lời

根据我的经验,文件操作在批量运行时并不可靠。如果您尝试在客户端上运行它,但它仍然超时,那么您可能遇到了另一个问题。根据我的经验,您可能需要打开 FTP 服务器的属性(很可能在 IIS 中)并增加超时限制。我必须对我们用来产生销售税的网络服务做类似的事情。如果我们有一个超过 100 行的销售订单,它会产生同样的错误。当我们增加超时时,错误消失了。

关于axapta - 批量 FTPWebRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16147752/

28 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com