private static void SaveNaesbRequestForConfirmationFile(NaesbRequestForConfirmation nrfc, string ediFileName) { //serialize with out the namespace because GENTRAN can't handle it XmlDocument xmlFile = XmlTransformer.XmlSerialize(nrfc, true); xmlFile.Save(Properties.Settings.Default.NaesbOutboundUnc + ediFileName); }
public IHttpActionResult Get(int id) { NaesbRequestForConfirmation obj = _container.Resolve <INaesbRequestForConfirmationGet>().Invoke(id); if (obj != null) { return(Ok(obj)); } return(NotFound()); }
private static void ProcessRequestForConfirmation(RequestForConfirmation rfc, DateTime processStart) { string naesbFileName = string.Empty; int id = 0; try { if (rfc != null) { Console.WriteLine("==Processing: 1. Retrieved rfc from the repository for Gas Day: " + rfc.GasDay.ToShortDateString()); //create an Naesb file name naesbFileName = FormatNaesbRequestForConfirmationFileName(rfc); //create request for confirmation id = Container.Resolve <INaesbRequestForConfirmationCreate>().Invoke(processStart, naesbFileName, rfc); Console.WriteLine("==Processing: 2. Created request for confirmation naesb event process: [Id: " + id + "] [Cycle: " + rfc.Cycle + "] [Utility: " + rfc.PartyIndentificaton.UtilityEntity + "] [Pipeline: " + rfc.PartyIndentificaton.PipelineEntity + "]"); //map domain rfc model to the Naesb rfc model. NaesbRequestForConfirmation nrfc = Container.Resolve <INaesbRequestForConfirmationGet>().Invoke(rfc); //get the newly created naesb event process that was processed NaesbEventProcess obj = Container.Resolve <INaesbEventProcessGet>().Invoke(id); if (obj != null) { //save rfc mxl file to BizConnect SaveNaesbRequestForConfirmationFile(nrfc, naesbFileName); Console.WriteLine("==Processing: 3. Created rfc naesb file: [" + Properties.Settings.Default.NaesbOutboundUnc + naesbFileName + "]"); } else { Console.WriteLine("==Processing: The request for confirmation was NOT created"); } } else { Console.WriteLine("==Processing: No rfc to process"); } } catch (Exception ex) { Console.WriteLine("==Processing Error:"); Console.WriteLine(ex); if (id > 0) //if the id == 0 it failed before the naesbEventProcess row was created { string stacktrace = Stacktrace(ex); Container.Resolve <INaesbEventProcessError>().Invoke(id, "RFC", stacktrace); } CreateIncident(ex, null); } }
public int Invoke(DateTime processStart, string fileName, Domain.RequestForConfirmation.RequestForConfirmation obj) { //map domain rfc model to the Naesb rfc model. NaesbRequestForConfirmation nrfc = _naesbRequestForConfirmationGetService.Invoke(obj); //serialize to xml XmlDocument domainXml = XmlTransformer.XmlSerialize(obj, true); //serialize Naesb NaesbRequestForConfirmation XmlDocument naesbXml = XmlTransformer.XmlSerialize(nrfc, true); //create naesb event process int eventProcessId = _naesbEventProcessCreateService.Invoke( new NaesbEventProcess { Type = "RFC", GasDay = obj.GasDay, Cycle = obj.Cycle, Pipeline = obj.PartyIndentificaton.PipelineEntity, Utility = obj.PartyIndentificaton.UtilityEntity, ProcessStart = processStart, EdiFileName = fileName, EdiData = naesbXml.InnerXml, DomainData = domainXml.InnerXml, UserId = _settings.UserId } ); //get the naesb event var naesbEvent = _naesbEventGetService.Invoke("RFC", obj.PartyIndentificaton.PipelineEntity, obj.PartyIndentificaton.UtilityEntity, obj.Cycle); if (naesbEvent != null && naesbEvent.On == true) //if null then the pipeline/utility/cycle doesn't exist in Pegasys { //save the domain rfc to the repository _requestForConfirmationEventCreateService.Invoke(obj); //TODO: maybe make this use its own class instead of generic -> NaesbEventProcessCompletion //update ProcessEnd timestamp _naesbEventProcessUpdateService.Invoke(eventProcessId, new KeyValuePair <string, DateTime>("ProcessEnd", DateTime.Now)); return(eventProcessId); } throw new NaesbError { ReasonCode = "101", Value = "Pipeline/Utility/Cycle naesb event not found." }; }
public IHttpActionResult Post(RequestForConfirmation value) { string naesbFileName = FormatNaesbRequestForConfirmationFileName(value); int id = _container.Resolve <INaesbRequestForConfirmationCreate>().Invoke(DateTime.Now, naesbFileName, value); //map domain rfc model to the Naesb rfc model. NaesbRequestForConfirmation nrfc = _container.Resolve <INaesbRequestForConfirmationGet>().Invoke(id); SaveNaesbRequestForConfirmationFile(nrfc, naesbFileName); if (id > 0) { string location = Request.RequestUri + "/" + id; return(Created(location, id)); } return(BadRequest()); }