/// <summary> /// Resumes an unfinished request based on the correlation ID /// </summary> /// <param name="correlationId"></param> public static void ResumePendingRequest(string correlationId, string PollMsgFileName, string PollMsgResults) { try { //createPollMessage GovTalkGateway PollingService = new GovTalkGateway(); GovTalkMessage PollMessage = PollingService.CreatePollMessage(correlationId); //send Poll Message log.Info("Sending poll msg ..."); string PollURI = CRCOStringFunctions.SetURI(_env, "Poll"); XmlDocument XmlResponse = new XmlDocument(); if (_diskPolling) { GiftAidSubmissionProcessController.SerializeObjectToFile(PollMessage, PollMsgFileName); XmlResponse = GiftAidSubmissionProcessController.DespatchToGateway(PollMsgFileName, PollURI); } else { XmlDocument PollDoc = GiftAidSubmissionProcessController.SerializeInMemory(PollMessage); XmlResponse = GiftAidSubmissionProcessController.DespatchToGateway(PollDoc, PollURI); } //readPollAcknowledgement log.Info("Reading poll reply msg ..."); GiftAidSubmissionProcessController.ReadResponse(XmlResponse); //write results to file System.IO.File.WriteAllText(PollMsgResults + correlationId + ".xml", XmlResponse.InnerXml); } catch (Exception ex) { log.Error(ex.ToString()); } }
/// <summary> /// Creates and sends messages to the poll URI /// </summary> public static void PollService() { try { string PollTime = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss", CultureInfo.InvariantCulture); string PollMsgFileName = ConfigurationManager.AppSettings["TempFolder"].ToString() + @"\TestPollMessage" + PollTime + ".xml"; string PollMsgResults = ConfigurationManager.AppSettings["TempFolder"].ToString() + @"\PollMessageResults" + PollTime + ".xml"; //createPollMessage GovTalkGateway PollingService = new GovTalkGateway(); GovTalkMessage PollMessage = PollingService.CreatePollMessage(_correlationId); //send Poll Message log.Info("Sending poll msg ..."); string PollURI = String.IsNullOrEmpty(_pollURI) ? CRCOStringFunctions.SetURI(_env, "Poll"): _pollURI; XmlDocument XmlResponse = new XmlDocument(); if (_diskPolling) { GiftAidSubmissionProcessController.SerializeObjectToFile(PollMessage, PollMsgFileName); log.Debug("Poll URI Is " + PollURI); XmlResponse = GiftAidSubmissionProcessController.DespatchToGateway(PollMsgFileName, PollURI); } else { XmlDocument PollDoc = GiftAidSubmissionProcessController.SerializeInMemory(PollMessage); log.Debug("Poll URI Is " + PollURI); XmlResponse = GiftAidSubmissionProcessController.DespatchToGateway(PollDoc, PollURI); } //readPollAcknowledgement log.Info("Reading poll reply msg ..."); GiftAidSubmissionProcessController.ReadResponse(XmlResponse); _counter++; log.Info("Counter is now: " + _counter.ToString()); if (_resp == "response" && !Object.ReferenceEquals(null,_timer)) { _timer.Stop(); _timer.Dispose(); _returnValue = _correlationId + "_" + _env + "_" + _resp; System.IO.File.WriteAllText(_resultFileFirstPart + _returnValue + ".xml", XmlResponse.InnerXml); return; } if (_resp == "error" && !Object.ReferenceEquals(null, _timer)) { _timer.Stop(); _timer.Dispose(); _returnValue = _correlationId + "_" + _env + "_" + _resp; System.IO.File.WriteAllText(_resultFileFirstPart + _returnValue + ".xml", XmlResponse.InnerXml); return; } System.IO.File.WriteAllText(PollMsgResults + _returnValue + ".xml", XmlResponse.InnerXml); } catch (Exception ex) { log.Error(ex.ToString()); } }