private Byte[] GetPdfRendition(string customerCode, string siteCode, int formHistoryTransactionUid) { Byte[] data = null; bool bSuccess = false; for (int iFailureCnt = 0; !bSuccess && iFailureCnt < RETRIES; iFailureCnt++) { PdfRenditionDownloader downloader = null; try { downloader = new PdfRenditionDownloader(); downloader.Url = m_strDownloadURL; data = downloader.GetPdfRendition(customerCode, siteCode, formHistoryTransactionUid); bSuccess = true; } catch (Exception ex) { string error = string.Format("Get pdf failed for customer code {0}, site code {1}, formHistoryTransactionUid {2}. Retrying...\n", customerCode, siteCode, formHistoryTransactionUid); m_Utils.WriteEventLogEntry(error + ex.Message, EventLogEntryType.Error, EVENT_LOG_SOURCE); } finally { if (downloader != null) { downloader.Dispose(); } } } if (!bSuccess) { string error = string.Format("Get pdf rendition failed after {0} retries.", RETRIES); throw new Exception(error); } return(data); }
private bool SetPdfRenditionManifestDownloaded(string customerCode, string siteCode, int manifestNumber) { bool bSuccess = false; for (int iFailureCnt = 0; !bSuccess && iFailureCnt < RETRIES; iFailureCnt++) { PdfRenditionDownloader pdfRenditionDownloader = null; try { pdfRenditionDownloader = new PdfRenditionDownloader(); pdfRenditionDownloader.Url = m_strDownloadURL; pdfRenditionDownloader.SetManifestDownloaded(customerCode, siteCode, manifestNumber); bSuccess = true; } catch (Exception ex) { string error = string.Format("Set pdf rendition manifest downloaded failed for customer code {0}, site code {1}, manifest number {2}. Retrying...\n", customerCode, siteCode, manifestNumber); m_Utils.WriteEventLogEntry(error + ex.Message, EventLogEntryType.Error, EVENT_LOG_SOURCE); } finally { if (pdfRenditionDownloader != null) { pdfRenditionDownloader.Dispose(); } } } if (!bSuccess) { //Note: Don't throw here, because we need to purge the downloaded files. string error = string.Format("Set pdf rendition manifest downloaded failed after {0} retries. Download must be run again.", RETRIES); m_Utils.WriteEventLogEntry(error, EventLogEntryType.Error, EVENT_LOG_SOURCE); } return(bSuccess); }