/// <summary> /// Submit the document to the government gateway. /// Returns the Xml from the GatewayServer, or an empty /// string if nothing to submit. /// </summary> public string Submit(string Class, bool UsesTestGateway, string DocumentXml) { if (DocumentXml != null && DocumentXml != "") { GatewayDocument submission = new GatewayDocument(); // The Posting settings must be applied first. // Assign posting settings. submission.Url = _submissionUrl; //... and fill in the fields ... submission.DocumentType = Class; submission.UsesTestGateway = UsesTestGateway; // Stuff the XML into the document submission.GatewayDoc = DocumentXml; // Submit the document XmlDocument returnDoc = GatewayServer.Submit(submission); // return the generated Xml return(returnDoc.OuterXml); } else { // Nothing to do return(""); } }
private void PostThread() { Trace.WriteLine("Got into Processing Thread " + Thread.CurrentThread.ManagedThreadId); List <GatewayDocument> gatewayDocList = gatewayDB.GetDocumentsWithStatus(DocumentStatus.NOSTATUS); while (gatewayDocList.Count > 0) { Trace.WriteLine("Documents in Posting Queue"); foreach (GatewayDocument gDoc in gatewayDocList) { Trace.WriteLine("About to send Document " + gDoc.SubmissionID); gatewayDB.SetStatus(gDoc.SubmissionID, DocumentStatus.SUBMITTING); XmlDocument gtwResponse = GatewayServer.Submit(gDoc); if (gtwResponse != null) { if (gDoc.InsertXmlUpdate(gtwResponse)) { Trace.WriteLine("XML Response from Gateway for document " + gDoc.SubmissionID + " was imported sucessfully into GatewayDocument. Writing to Database"); gatewayDB.UpdateDocument(gDoc); gatewayDB.SetStatus(gDoc.SubmissionID, DocumentStatus.POLLING); } else { Trace.WriteLine("GatewayDocument " + gDoc.SubmissionID + " could not be saved to the database"); } } else { gatewayDB.SetStatus(gDoc.SubmissionID, DocumentStatus.UNKNOWN); break; } } gatewayDocList = gatewayDB.GetDocumentsWithStatus(DocumentStatus.NOSTATUS); } Trace.WriteLine("Posting Queue is empty. Exiting Posting Thread"); }