public SampleTemplate Get(string fileName, string accessPath, string downloadName = "NumberLookup") { var filePath = _getFullFilePath.Get(accessPath, fileName); if (!string.IsNullOrWhiteSpace(fileName)) { byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); var template = new SampleTemplate { content = fileBytes, TemplateType = new UploadDataType { Name = downloadName } }; return(template); } return(new SampleTemplate { content = new byte[4], TemplateType = new UploadDataType { Name = "Dummy" } }); }
public SampleTemplate Get(int typeId, string accessPath) { var fileName = _getFileName.Get(typeId); var filePath = _getFullFilePath.Get(accessPath, fileName); if (!string.IsNullOrWhiteSpace(fileName)) { byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); var template = new SampleTemplate { content = fileBytes, TemplateType = new UploadDataType { Id = typeId, Name = fileName } }; return(template); } return(new SampleTemplate { content = new byte[4], TemplateType = new UploadDataType { Name = "Dummy" } }); }
private void listBoxTemplate_SelectedIndexChanged(object sender, EventArgs e) { SampleTemplate msg = this.listBoxTemplate.SelectedItem as SampleTemplate; if (msg != null) { this.textBoxSendTemplate.Text = msg.GetTemplate(); } }
public static MessagePair GetMessagePair(string recieveMessage, List <SampleTemplate> templateList) { DateTime dtBegin = DateTime.Now; MessagePair p = new MessagePair(); p.IncomingMessageContent = recieveMessage; p.IncomingMessageType = HL7MessageParser.GetField(recieveMessage, "MSH", 9).Replace("^", "_"); SampleTemplate matchTemplate = null; SampleTemplate commonTemplate = null; foreach (SampleTemplate t in templateList) { string msgType = t.GetIncomingMessageType(); if (msgType == "ANY") { commonTemplate = t; } if (p.IncomingMessageType == msgType) { matchTemplate = t; break; } } if (matchTemplate == null) { matchTemplate = commonTemplate; } if (matchTemplate == null) { Program.Context.Log.Write(LogType.Error, string.Format("Cannot find match acknowledgment message template for message {0} \r\n{1}", p.IncomingMessageType, p.IncomingMessageContent)); p.OutgoingMessageType = "AE"; p.OutgoingMessageContent = HL7MessageParser.FormatResponseMessage (p.IncomingMessageContent, HL7MessageTemplates.ErrorResponse); } else { p.Template = matchTemplate; p.OutgoingMessageType = matchTemplate.GetOutgoingMessageType(); p.OutgoingMessageContent = HL7MessageParser.FormatResponseMessage (p.IncomingMessageContent, matchTemplate.GetTemplate()); } DateTime dtEnd = DateTime.Now; p.ProcessingTime = dtEnd.Subtract(dtBegin); return(p); }
private void LoadSampleTemplateList() { try { this.listBoxTemplate.Items.Clear(); string path = Path.Combine(Application.StartupPath, "SampleTemplates"); string[] flist = Directory.GetFiles(path); foreach (string fn in flist) { SampleTemplate t = new SampleTemplate(fn); this.listBoxTemplate.Items.Add(t); _templateList.Add(t); } if (this.listBoxTemplate.Items.Count > 0) { this.listBoxTemplate.SelectedIndex = 0; } } catch (Exception e) { Program.Context.Log.Write(e); } }