Пример #1
0
        private void StartbackgroundWorker()
        {
            rtbSampleOutput.Text = "";
            EDIInformation para = new EDIInformation(txtSampleFile.Text, rtbXslt.Text);

            backgroundWorker1.RunWorkerAsync(para);
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                EDIInformation par = e.Argument as EDIInformation;

                StreamReader sr          = new StreamReader(par.EDIFileName);
                string       fileContent = sr.ReadToEnd();
                sr.Close();
                sr.Dispose();

                XmlToDataTable xmlToDataTable = new XmlToDataTable(DataSource);
                e.Result = xmlToDataTable.Parse(par.Xslt, fileContent).ToString();
            }
            catch (Exception ex)
            {
                e.Result = "Error:" + ex.Message;
            }
        }
Пример #4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                EDIInformation par = e.Argument as EDIInformation;

                StreamReader sr          = new StreamReader(par.EDIFileName);
                string       fileContent = sr.ReadToEnd();
                sr.Close();
                sr.Dispose();

                EdiX12Parser ediTransformer = new EdiX12Parser(par.EDIFileName, fileContent);
                e.Result = ediTransformer.Parse(par.Xslt).ToString();
            }
            catch (Exception ex)
            {
                e.Result = "Error:" + ex.Message;
            }
        }
Пример #5
0
        private EDIInformation GetEmbeddedEDISample(string sample)
        {
            string fileName = Path.Combine("c:\\temp\\", "x.txt");

            string sampleContent = string.Empty;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(sample))
                using (StreamReader reader = new StreamReader(stream))
                {
                    sampleContent = reader.ReadToEnd();
                }

            string ediContent  = sampleContent.Substring(0, sampleContent.IndexOf("==EDIEND=="));
            string xsltContent = sampleContent.Substring(sampleContent.IndexOf("==EDIEND==") + 11);

            EDIInformation ediInfo = new EDIInformation(string.Empty, xsltContent);

            ediInfo.Edi = ediContent;

            return(ediInfo);
        }