public void DownloadJobData(WebRequestSession req) { StringBuilder errMessage = new StringBuilder(); String file = RemoteCall.RESTGetAsFile(req.ssl, req.host, req.port, req.url, errMessage, req.cts); if (!String.IsNullOrEmpty(file) && File.Exists(file)) { File.Delete(file); try { Thread.Sleep(req.delay); } catch (Exception e) { } Interlocked.Increment(ref FinishedFiles); } }
public static int TaskResult(WebRequestSession session, String taskID, StringBuilder taskError) { string relUrl = "/caxa/task_result?taskid=" + taskID; String msg = ""; try { Boolean bSSL = session.ssl; String host = session.host; int port = session.port; String url = relUrl.Replace("\\", "/"); StringBuilder errMessage = new StringBuilder(); String file = RemoteCall.RESTGetAsFile(bSSL, host, port, url, errMessage); if (!String.IsNullOrEmpty(file) && File.Exists(file)) { //if (file.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase)) { string LocalFullPath = Util.Util.GetTempFileName(""); String extractTo = LocalFullPath.Replace("/", "\\"); if (!extractTo.EndsWith("\\")) { extractTo += "\\"; } if (!Directory.Exists(extractTo)) { Directory.CreateDirectory(extractTo); } GZip.UnZip(file, extractTo); if (taskError != null) { taskError.Append(extractTo); } try { File.Delete(file); } catch (Exception e) { Debug.WriteLine(e.Message); } return(+1); } } else { msg = errMessage.ToString(); } } catch (Exception e) { msg = e.Message; } if (taskError != null) { taskError.Append(msg); } return(-1); }