如何绕过Windows Service中的执行 [英] How to bypass the execption in window service

查看:63
本文介绍了如何绕过Windows Service中的执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我对一种情况有一个查询,即

建筑:

我创建了一个WCF服务,其中包含用于从sharepoint上传,下载和删除文件的逻辑.现在,每30秒就会从Windows服务调用此WCF.这意味着该过程将每30秒运行一次,以将文件上传到Sharepoint和从Sharepoint删除文件.请不要因为我创建了三个单独的窗口服务而正在调用一个WCF服务.


问题:

1)在使用窗口服务上传文件的过程中,如果在上传一个文件时发生错误,则服务抛出异常,并且不会转到下一个文件进行上传.这是该服务的障碍,因为我希望该服务继续上载不会引起异常的其他文件.

问候,
Abhishek Pareek

Hi All,

I have one query regarding one scenario i.e.

Architecture:

I had created one WCF service which is containing the logic for uploading, downloading and deleting the files from sharepoint. Now, this WCF is being called from windows service for every 30 seconds. This means that the process will run for every 30 second to upload, download and delete the files to and from Sharepoint. Please not that I had created three separate window service which are calling one WCF service.


Issue:

1) During uploading the files using window service, if some error is occurring while uploading one file than service is throwing exception and it is not going to next file to upload it. This is a roadblock for this service as I want the service to continue the uploading of other files which are not causing exceptions.

Regards,
Abhishek Pareek

推荐答案

嗨Abhishek,

标记数据库或集合中文件的状态,例如转移,错误,就绪等.
如果使用FaultContract和try/catch块在一个文件句柄中发生任何错误,请 WCF错误处理和错误转换 [ ^ ].
再次开始传输处于就绪状态的文件.
Hi Abhishek,

Mark the state of file in db or in collection like tranfered, error ,ready etc.
If any error occur in one file handle using faultcontract and try/catch block WCF Error Handling and Fault Conversion[^].
Again start transfer those file which are in ready state.


Vivek,

我的问题是,在上载文件时出错时,我的窗口服务正在停止,并且它不会处理下一个文件.我想做这样的修改:如果窗口服务遇到与文件大小等相关的错误,则应该寻找下一个要上传的文件.

请注意,我已经使用此窗口和WCF服务来上载,下载和删除数千个文件.因此,如果我的窗口服务在第二个文件处停止,那么它将一直停留在第二个文件上,直到我解决了该问题.我想以某种方式修改功能,如果第二个文件出现错误,则应继续使用下一个文件.

问候,
Abhishek pareek
Hi Vivek,

My problem is that my window service is halting up when it is getting error during uploading of files and it is not going to process next file. I would like to do make amendments in such a way that if window service is experience some error like related to file size etc. than it should look for next file to upload.

Please note that I had made this window and WCF service for upload, download and delete thousands of files in a mintue. So if my window sevice halting at second file than it will be always stuck at second only until I resolved the issue. I would like to amend the functionality in such a ways that if error occurs at second file it should go for next file ownwards.

Regards,
Abhishek pareek


您可以捕获到您知道可以安全处理且不会抛出的异常,如下所示:


You could catch the exception which you know are safe to proceed with and not throw them, like below:


try
{
    //do stuff
}
catch (System.IO.FileNotFoundException)
{
    //log exception
}
catch (Exception ex)
{
    throw;
}


这篇关于如何绕过Windows Service中的执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆