public static void DownloadImageAsPDFMRC(ImageApi apiInstance, ImageSaveAsPDFMRCParameters saveImageParameters, int workerNumber, string inputFilePath, Stream destinationStream, OperationsManager.ProgressDelegate downloadOperationStartEventHandler) { Exception e = null; int pausems = 5000; for (int i = 0; i < FrameworkGlobals.MAX_RETRYING_REQUESTS; i++) { downloadOperationStartEventHandler.Invoke(workerNumber, inputFilePath, i); try { apiInstance.ImageSaveAsPDFMRCFile(saveImageParameters, destinationStream); return; } catch (Exception ex) { if (i < FrameworkGlobals.MAX_RETRYING_REQUESTS - 1) { Thread.Sleep(pausems); //marking a pause in case of cnx temporarily out and to avoid overhead. pausems += 2000; } else {//last iteration e = ex; } } } throw e; }
public static PdfGetInfoResponse SendGetInfoRequest(PDFApi apiInstance, PdfGetInfoParameters getInfoParameters, int workerNumber, string inputFilePath, OperationsManager.ProgressDelegate getInfoOperationStartEventHandler) { Exception e = null; int pausems = 5000; for (int i = 0; i < FrameworkGlobals.MAX_RETRYING_REQUESTS; i++) { getInfoOperationStartEventHandler.Invoke(workerNumber, inputFilePath, i); try { return(apiInstance.GetInfo(getInfoParameters)); } catch (Exception ex) { if (i < FrameworkGlobals.MAX_RETRYING_REQUESTS - 1) { Thread.Sleep(pausems); //marking a pause in case of cnx temporarily out and to avoid overhead. pausems += 2000; } else {//last iteration e = ex; } } } throw e; }
public static PdfLoadDocumentResponse SendLoadDocumentRequest(PDFApi apiInstance, int workerNumber, string inputFilePath, string fileName, PdfConformance conformance, string password, Stream fileStream, ContentEncoding contentEncoding, OperationsManager.ProgressDelegate uploadOperationStartEventHandler) { Exception e = null; int pausems = 5000; if (fileStream.Length > int.MaxValue) { throw new OutOfMemoryException(); } for (int i = 0; i < FrameworkGlobals.MAX_RETRYING_REQUESTS; i++) { uploadOperationStartEventHandler.Invoke(workerNumber, inputFilePath, i); try { fileStream.Seek(0, SeekOrigin.Begin); byte[] data = new byte[fileStream.Length]; fileStream.Read(data, 0, (int)fileStream.Length); PdfLoadDocumentFromByteArrayParameters pdfLoadDocumentFromByteArrayParameters = new PdfLoadDocumentFromByteArrayParameters(data) { FileName = fileName, Password = password, Conformance = conformance, ContentEncoding = contentEncoding }; PdfLoadDocumentResponse response = apiInstance.LoadDocumentAsPDF(pdfLoadDocumentFromByteArrayParameters); return(response); } catch (Exception ex) { if (i < FrameworkGlobals.MAX_RETRYING_REQUESTS - 1) { Thread.Sleep(pausems); //marking a pause in case of cnx temporarily out and to avoid overhead. pausems += 2000; } else {//last iteration e = ex; } } } throw e; }
public static PdfLoadDocumentResponse SendLoadPDFMultipartRequest(PDFApi apiInstance, int workerNumber, string inputFilePath, string fileName, PdfConformance conformance, string password, Stream fileStream, ContentEncoding contentEncoding, OperationsManager.ProgressDelegate uploadOperationStartEventHandler) { Exception e = null; int pausems = 5000; for (int i = 0; i < FrameworkGlobals.MAX_RETRYING_REQUESTS; i++) { uploadOperationStartEventHandler.Invoke(workerNumber, inputFilePath, i); try { fileStream.Seek(0, SeekOrigin.Begin); PdfLoadDocumentResponse response = apiInstance.LoadDocumentAsPDFMultipart(fileStream, new PdfLoadDocumentParameters() { ContentEncoding = contentEncoding, Conformance = conformance, Password = password, FileName = fileName }); return(response); } catch (Exception ex) { if (i < FrameworkGlobals.MAX_RETRYING_REQUESTS - 1) { Thread.Sleep(pausems); //marking a pause in case of cnx temporarily out and to avoid overhead. pausems += 2000; } else {//last iteration e = ex; } } } throw e; }