private static void SaveNaesbQuickResponseFile(NaesbQuickResponse qr, string fileName) { //serialize with out the namespace because GENTRAN can't handle it XmlDocument xmlFile = XmlTransformer.XmlSerialize(qr, true); xmlFile.Save(Properties.Settings.Default.NaesbOutboundUnc + fileName); }
//public int Invoke(DateTime processStart, DateTime gasDay, string cycle, string fileName, NaesbQuickResponse nqr) //{ ////serialize Naesb NaesbRequestForConfirmation //XmlDocument naesbXml = XmlTransformer.XmlSerialize(nqr, true); ////create naesb event process //int eventProcessId = _naesbEventProcessCreateService.Invoke( // new NaesbEventProcess // { // Type = "QR", // GasDay = gasDay, // Cycle = cycle, // Pipeline = _naesbPipelineGetService.Invoke(nqr.PartyIndentificaton.ConfirmingPartyDuns).Pipeline, // Utility = _naesbUtilityGetService.Invoke(nqr.PartyIndentificaton.UtilityDunsNumber).Utility, // ProcessStart = processStart, // EdiFileName = fileName, // EdiData = naesbXml.InnerXml, // DomainData = null, // UserId = _settings.UserId // } //); ////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; //} public int Invoke(DateTime processStart, string fileName, Domain.ConfirmationResponse.ConfirmationResponse cr) { //transform ConfirmationResponse NaesbQuickResponse nqr = _naesbQuickResponseGetService.Invoke(cr); //serialize Naesb NaesbRequestForConfirmation XmlDocument naesbXml = XmlTransformer.XmlSerialize(nqr, true); //create naesb event process int eventProcessId = _naesbEventProcessCreateService.Invoke( new NaesbEventProcess { Type = "QR", GasDay = cr.GasDay, Cycle = cr.Cycle, Pipeline = cr.PartyIndentificaton.PipelineEntity, Utility = cr.PartyIndentificaton.UtilityEntity, ProcessStart = processStart, EdiFileName = fileName, EdiData = naesbXml.InnerXml, DomainData = null, // there is no business QuickResponse UserId = _settings.UserId } ); //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); }
private static void SendQuickResponse(FileInfo file) { // check if the naesb event flag is on for this event/pipeline/utility/cycle var naesbEvent = GetQrNaesbEvent(file); if (naesbEvent != null && naesbEvent.On == true) { //transform file to ConfirmationResponse var cr = Container.Resolve <IConfirmationResponseEventGet>().Invoke(file); //format naseb file name string fileName = FormatNaesbQuickResponseFileName(cr); //transform ConfirmationResponse to NaesbQuickResponse NaesbQuickResponse naesbQuickResponse = Container.Resolve <INaesbQuickResponseGet>().Invoke(cr); //create naesb quick response naesb event process int naesbEventProcessId = Container.Resolve <INaesbQuickResponseCreate>().Invoke(DateTime.Now, fileName, cr); Console.WriteLine("==Processing: 3. Created quick response naesb event process: [Id: " + naesbEventProcessId + "] [Cycle: " + naesbEvent.Cycle + "] [Utility: " + naesbEvent.Utility + "] [Pipeline: " + naesbEvent.Pipeline + "]"); //save quick response to disk SaveNaesbQuickResponseFile(naesbQuickResponse, fileName); Console.WriteLine("==Processing: 4. Created naesb quick response: [File: " + Properties.Settings.Default.NaesbOutboundUnc + fileName + "]"); //update naesb event DateTime now = DateTime.Now; Container.Resolve <INaesbEventUpdate>().Invoke(naesbEvent.Id, now); Console.WriteLine("==Processing: 5. Updated the quick response naesb event process 'ProcessedTime': [" + now + "]"); } }
public NaesbQuickResponse Invoke(Domain.ConfirmationResponse.ConfirmationResponse confirmationResponse) { NaesbQuickResponse nqr = new NaesbQuickResponse(); nqr.Header = _naesbQuickResponseHeaderGetService.Invoke(confirmationResponse); nqr.PurchaseOrderNumber = confirmationResponse.PurchaseOrderNumber; nqr.PurposeCode = "27"; nqr.PartyIndentificaton = new PartyIndentificaton(); nqr.PartyIndentificaton.ConfirmingPartyDuns = _naesbPipelineGetByPipelineService.Invoke(confirmationResponse.PartyIndentificaton.PipelineEntity)?.PipelineEntityId; nqr.PartyIndentificaton.UtilityDunsNumber = _naesbUtilityGetByUtilityService.Invoke(confirmationResponse.PartyIndentificaton.UtilityEntity)?.UtilityEntityId; return(nqr); }