private void btnShowXml_Click(object sender, EventArgs e) { StreamReader sr = new StreamReader(txtSampleFile.Text); string fileContent = sr.ReadToEnd(); sr.Close(); EdiX12Parser ediParser = new EdiX12Parser(txtSampleFile.Text, fileContent); string xmlFile = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(txtSampleFile.Text) + ".xml"); StreamWriter sw = new StreamWriter(xmlFile); sw.Write(ediParser.GenerateXml()); sw.Close(); Process.Start(xmlFile); }
private void lvwSamples_SelectedIndexChanged(object sender, EventArgs e) { if (lvwSamples.SelectedItems.Count > 0) { btnSelect.Enabled = true; btnExport1.Enabled = true; btnExport2.Enabled = true; btnExport3.Enabled = true; btnExport4.Enabled = true; btnExportAll.Enabled = true; this.Cursor = Cursors.WaitCursor; EDIInformation ediInfo = lvwSamples.SelectedItems[0].Tag as EDIInformation; rtbEDI.Text = ediInfo.Edi; XsltFile = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(lvwSamples.SelectedItems[0].Text) + ".xslt"); StreamWriter sw = new StreamWriter(XsltFile); sw.Write(ediInfo.Xslt); sw.Close(); EdiX12Parser ediParser = new EdiX12Parser(lvwSamples.SelectedItems[0].Text, rtbEDI.Text); XmlFile = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(lvwSamples.SelectedItems[0].Text) + ".xml"); sw = new StreamWriter(XmlFile); sw.Write(ediParser.GenerateXml()); sw.Close(); webBrowser1.Url = new Uri(XmlFile); webBrowser2.Url = new Uri(XsltFile); rtbFlatFile.Text = ediParser.Parse(ediInfo.Xslt).ToString(); this.Cursor = Cursors.Default; } else { btnSelect.Enabled = false; btnExport1.Enabled = false; btnExport2.Enabled = false; btnExport3.Enabled = false; btnExport4.Enabled = false; btnExportAll.Enabled = false; } }