internal GetFileAttachmentDataResponse GetFileData(RNObject rnObject, long fileID, bool disableMTOM) { var result = new List <RNObject>(); bool mustRetry = false; // used to determine if we should retry a failed job int retryTimes = 0; // we don't want to endlessly retry, so we only will retry 3 times do { try { ID idObj = new ID { id = fileID, idSpecified = true }; byte[] fileData = _client.GetFileData(_clientInfoHeader, rnObject, idObj, disableMTOM); return(new GetFileAttachmentDataResponse { FileData = fileData, Successful = true, SuccessfulSet = true }); } catch (Exception ex) { GlobalContext.Log(string.Format("Failed GetFileData: Retry {0}: {1}", retryTimes, ex.Message), true); GlobalContext.Log(string.Format("Failed GetFileData: Retry {0}: {1}{2}{3}", retryTimes, ex.Message, Environment.NewLine, ex.StackTrace), false); if (retryTimes < 3) { // if we haven't retried 3 times then we retry the load again mustRetry = true; retryTimes++; } else { // don't retry for 3rd retry return(new GetFileAttachmentDataResponse { FileData = null, Successful = false, SuccessfulSet = true, Details = ex.Message }); } } GlobalContext.Log(string.Format("GetFileData Must Retry {0}", mustRetry), false); } while (mustRetry); GlobalContext.Log("GetFileData End: This code should never be hit.", false); return(null); // this code should never be hit }
/// <summary> /// Returns the contents of the given incident attachment. /// </summary> /// <param name="incidentId"></param> /// <param name="fileId"></param> /// <returns></returns> public byte[] getFileData(int incidentId, int fileId) { Incident incident = new Incident(); incident.ID = new ID(); // incident id incident.ID.id = incidentId; incident.ID.idSpecified = true; FileAttachmentCommon file = new FileAttachmentCommon(); file.ID = new ID(); // file id file.ID.id = fileId; file.ID.idSpecified = true; return(_rnowClient.GetFileData(_rnowClientInfoHeader, incident, file.ID, false)); }