Exemplo n.º 1
0
        protected virtual void AppendResultsXML(List <Artifact> Results)
        {
            if (ResultsXML == null)
            {
                ResultsXML = new XElement("lms-patterns-fetus", new XAttribute("fhr-sample-rate", "4"), new XAttribute("up-sample-rate", "1"));
            }

            foreach (var item in Results)
            {
                XElement toAdd = null;
                switch (item.ArtifactData.Category)
                {
                case "Baseline":
                    toAdd = XMLWriter.WriteBaselineXML(item, AbsoluteStart);
                    break;

                case "Contraction":
                    toAdd = XMLWriter.WriteContractionXML(item, AbsoluteStart);
                    break;

                case "Acceleration":
                    toAdd = XMLWriter.WriteAccelerationXML(item, AbsoluteStart);
                    break;

                case "Deceleration":
                    toAdd = XMLWriter.WriteDecelerationXML(item, AbsoluteStart);
                    break;

                default:
                    break;
                }

                ResultsXML.Add(toAdd);
            }
        }
Exemplo n.º 2
0
        void ResultsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Trace.WriteLine("Results received.");
            if (!ResultTimer.Enabled)
            {
                MessageBox.Show("Work complete");
                buttonRun.Text = "Run";
                if (checkBoxFlush.Checked)
                {
                    if (textBoxResult.Text.ToLower().IndexOf(".dat") > 0)
                    {
                        using (StreamWriter sw = new StreamWriter(textBoxResult.Text))
                        {
                            foreach (var item in ResultsDAT)
                            {
                                sw.WriteLine(item);
                            }
                        }
                    }
                    else
                    {
                        var xml = (from c in ResultsXML.Elements()
                                   select c);

                        var xmlArr = xml.ToArray();
                        ResultsXML.Elements().Remove();
                        ResultsXML.Add(xmlArr.Distinct());
                        XElement XML = XElement.Load(textBoxInPath.Text);
                        if (XML.Elements("fhr-sample").Count() > 0 && XML.Elements("up-sample").Count() > 0)
                        {
                            var FHRElems = from b in XML.Descendants("fhr-sample")
                                           select b;

                            var UPElems = from c in XML.Descendants("up-sample")
                                          select c;

                            ResultsXML.Add(FHRElems);
                            ResultsXML.Add(UPElems);
                        }
                        else if (XML.Elements("visit").Count() > 0)
                        {
                            List <byte> FHRList = new List <byte>();
                            List <byte> UPList  = new List <byte>();

                            XMLHelper.LoadRawTracings(UPList, FHRList, XML);
                            foreach (var item in UPList)
                            {
                                ResultsXML.Add(new XElement("up-sample", new XAttribute("value", item)));
                            }

                            foreach (var item in FHRList)
                            {
                                ResultsXML.Add(new XElement("fhr-sample", new XAttribute("value", item)));
                            }
                        }

                        ResultsXML.Save(textBoxResult.Text);
                    }

                    if (checkBoxArcive.Enabled && checkBoxArcive.Checked)
                    {
                        XMLWriter.FlushToArchiveFormat(textBoxInPath.Text, textBoxResult.Text, ResultsDAT, AbsoluteStart);
                    }
                }

                Running = false;
            }
        }