コード例 #1
0
    public void XMLLoad(string path)
    {
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.LoadXml(path == string.Empty ? EditorPrefs.GetString("lastXML_format1") : File.ReadAllText(path));

        int index  = 0;
        int answer = 0;

        foreach (XmlNode xmlNode in xmlDoc.DocumentElement)
        {
            Format1 format = new Format1();
            // get all parent nodes
            foreach (XmlNode questionsNode in xmlNode)
            {
                if (questionsNode.Name == "Question")
                {
                    format.Question = questionsNode.InnerText;
                }
                if (questionsNode.Name == "Image")
                {
                    format.Image = questionsNode.InnerText;
                }
                if (questionsNode.Name == "Answers")
                {
                    foreach (XmlNode answersNode in questionsNode)
                    {
                        if (answersNode.Name == "Choices")
                        {
                            if (answer == 0)
                            {
                                format.CorrectAnswer = answersNode.InnerText;
                            }
                            else if (answer == 1)
                            {
                                format.WrongAnswerA = answersNode.InnerText;
                            }
                            else if (answer == 2)
                            {
                                format.WrongAnswerB = answersNode.InnerText;
                            }
                            else if (answer == 3)
                            {
                                format.WrongAnswerC = answersNode.InnerText;
                            }
                            answer++;
                        }
                    }
                }
                answer = 0;
                index++;
            }
            this.FormatList.Add(format);
        }
    }
コード例 #2
0
    static void Main(string[] args)
    {
        Format1 f1 = new Format1("5.10");

        f1.Data.Dic1.Add("Greet", "Hello World");
        f1.Data.Dic2.Add("RepeatGreet", 10);
        f1.Write("f1");
        Console.WriteLine("-------------------------------------------------------");
        Format2 f2 = new Format2("2.1", "general", f1.Data);

        f2.Data.Dic1.Add("Goodbye", "See you later, Alligator");
        f2.Data.Dic2.Add("RepeatBye", 1);
        f1.Write("f1");
        f2.Write("f2");
        Console.ReadKey();
    }
コード例 #3
0
    public override void OnDrawColumns()
    {
        this.Scroll = GUILayout.BeginScrollView(this.Scroll);
        {
            for (int i = 0; i < this.FormatList.Count; i++)
            {
                GUILayout.Space(5);

                Format1 format = this.FormatList[i];
                GUILayout.BeginVertical();
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUI.skin.textField.wordWrap = true;
                        // question
                        format.Question = EditorGUILayout.TextField(format.Question, GUILayout.Width(this.QuestionWidth), GUILayout.Height(FieldHeight));
                        GUILayout.Space(5);
                        // image
                        format.Image = EditorGUILayout.TextField(format.Image, GUILayout.Width(this.ImageWidth), GUILayout.Height(FieldHeight));
                        GUILayout.Space(5);
                        // correct answer
                        format.CorrectAnswer = EditorGUILayout.TextField(format.CorrectAnswer, GUILayout.Width(this.CorrectAnswerWidth), GUILayout.Height(FieldHeight));
                        GUILayout.Space(5);
                        // wrong answer
                        format.WrongAnswerA = EditorGUILayout.TextField(format.WrongAnswerA, GUILayout.Width(this.WrongAnswerAWidth), GUILayout.Height(FieldHeight));
                        GUILayout.Space(5);
                        // wrong answer
                        format.WrongAnswerB = EditorGUILayout.TextField(format.WrongAnswerB, GUILayout.Width(this.WrongAnswerBWidth), GUILayout.Height(FieldHeight));
                        GUILayout.Space(5);
                        // wrong answer
                        format.WrongAnswerC = EditorGUILayout.TextField(format.WrongAnswerC, GUILayout.Width(this.WrongAnswerCWidth), GUILayout.Height(FieldHeight));
                        GUILayout.Space(5);
                        // delete entry
                        if (GUILayout.Button("X", EditorStyles.toolbarButton, GUILayout.Width(20), GUILayout.Height(FieldHeight)))
                        {
                            this.FormatList.RemoveAt(i);
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
        }
        GUILayout.EndScrollView();
    }
コード例 #4
0
ファイル: DBHelper.cs プロジェクト: talhaabacus/IMRCrawler
        public int AddUpdateFormat1Detail(int tID, Format1 det)
        {
            IMRDataContext context    = new IMRDataContext();
            PDFDetail      pdfDetails = null;
            bool           addNew     = false;

            if (context.PDFDetails.Where(fdet => fdet.TreatmentID == tID).Any())
            {
                pdfDetails = context.PDFDetails.Single(fdet => fdet.TreatmentID == tID);
            }

            if (pdfDetails == null)
            {
                addNew     = true;
                pdfDetails = new PDFDetail();
            }

            pdfDetails.Age                 = det.Age;
            pdfDetails.Certifications      = det.Certifications;
            pdfDetails.ClinicalCaseSummary = det.ClinicalCaseSummary;
            pdfDetails.DateAssigned        = det.DateAssigned;
            pdfDetails.Diagnosis           = det.Diagnosis;
            pdfDetails.Gender              = det.Gender;
            pdfDetails.HowIMRDetermination = det.HowIMRDetermination;
            pdfDetails.IMRIssuesRationales = det.IMRIssuesRationales;
            pdfDetails.StateofLicensure    = det.StateOfLincesure;
            pdfDetails.URDenialDate        = det.URDenialDate;
            pdfDetails.TreatmentID         = tID;
            if (addNew)
            {
                context.PDFDetails.InsertOnSubmit(pdfDetails);
            }
            context.SubmitChanges();
            context.Connection.Close();
            context.Dispose();
            context = null;
            return(0);
        }
コード例 #5
0
    static void Main(string[] args)
    {
        var engine = new FileHelperEngine(typeof(Format1));

        // read in the data
        object[] importedObjects = engine.ReadString(@"""Date"",""Description"",""Original Description"",""Amount"",""Type"",""Category"",""Name"",""Labels"",""Notes""
    ""2/02/2012"",""ac"",""ac"",""515.00"",""a"",""b"","""",""javascript://""
    ""2/02/2012"",""test"",""test"",""40.00"",""a"",""d"",""c"","""","" """);
        // check that 2 records were imported
        Assert.AreEqual(2, importedObjects.Length);

        // check the values for the first record
        Format1 customer1 = (Format1)importedObjects[0];

        Assert.AreEqual(DateTime.Parse("2/02/2012"), customer1.Date);
        Assert.AreEqual("ac", customer1.Description);
        Assert.AreEqual("ac", customer1.OriginalDescription);
        Assert.AreEqual(515.00, customer1.Amount);
        Assert.AreEqual("a", customer1.Type);
        Assert.AreEqual("b", customer1.Category);
        Assert.AreEqual("", customer1.Name);
        Assert.AreEqual("javascript://", customer1.Labels);
        Assert.AreEqual("", customer1.Notes);
        // check the values for the second record
        Format1 customer2 = (Format1)importedObjects[1];

        Assert.AreEqual(DateTime.Parse("2/02/2012"), customer2.Date);
        Assert.AreEqual("test", customer2.Description);
        Assert.AreEqual("test", customer2.OriginalDescription);
        Assert.AreEqual(40.00, customer2.Amount);
        Assert.AreEqual("a", customer2.Type);
        Assert.AreEqual("d", customer2.Category);
        Assert.AreEqual("c", customer2.Name);
        Assert.AreEqual("", customer2.Labels);
        Assert.AreEqual(" ", customer2.Notes);
    }
コード例 #6
0
    public string XMLSave(string path)
    {
        using (XmlWriter xmlWriter = XmlWriter.Create(path))
        {
            xmlWriter.WriteStartDocument();

            xmlWriter.WriteStartElement("QuestionDatabase");

            for (int i = 0; i < this.FormatList.Count; i++)
            {
                Format1 format = this.FormatList[i];
                xmlWriter.WriteStartElement("Questions");

                xmlWriter.WriteStartElement("Question");
                xmlWriter.WriteString(format.Question);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Image");
                xmlWriter.WriteString(format.Image);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Answers");

                xmlWriter.WriteStartElement("Choices");
                xmlWriter.WriteAttributeString("correct", "true");
                xmlWriter.WriteString(format.CorrectAnswer);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Choices");
                xmlWriter.WriteAttributeString("correct", "false");
                xmlWriter.WriteString(format.WrongAnswerA);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Choices");
                xmlWriter.WriteAttributeString("correct", "false");
                xmlWriter.WriteString(format.WrongAnswerB);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Choices");
                xmlWriter.WriteAttributeString("correct", "false");
                xmlWriter.WriteString(format.WrongAnswerC);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndDocument();
            xmlWriter.Close();
        }

        string content = string.Empty;

        using (StreamReader read = new StreamReader(path))
        {
            content = read.ReadToEnd();
            content = UTF8ByteArrayToString(StringToUTF8ByteArray(content));
            read.Close();
        }
        return(content);
    }
コード例 #7
0
ファイル: PDFParser.cs プロジェクト: talhaabacus/IMRCrawler
        private void ParseFormat1Text()
        {
            try
            {
                Format1 f = new Format1();

                string dateAssigned = _text.Substring(_text.IndexOf("Date Assigned: ") + 15, 10);
                f.DateAssigned = DateTime.Parse(dateAssigned);

                string urDenial = "";
                urDenial       = _text.Substring(_text.IndexOf("UR Denial Date:  ") + 17, 10);
                f.URDenialDate = DateTime.Parse(urDenial);

                int imrindex   = _text.IndexOf("HOW THE IMR FINAL DETERMINATION WAS MADE");
                int caseindex  = _text.IndexOf("CLINICAL CASE SUMMARY");
                int issueindex = _text.IndexOf("IMR ISSUES, DECISIONS AND RATIONALES ");

                f.HowIMRDetermination = _text.Substring(imrindex + 40, caseindex - imrindex - 40);
                f.ClinicalCaseSummary = _text.Substring(caseindex + 21, issueindex - caseindex - 21);
                f.IMRIssuesRationales = _text.Substring(issueindex + 36);
                string diagnosisPart = "";
                if (_text.IndexOf(" year old") != -1)
                {
                    string text = _text.Substring(0, _text.IndexOf(" year old"));
                    string a    = text.Substring(text.LastIndexOf(' ')).Trim();
                    try
                    {
                        f.Age = Int32.Parse(a);
                    }
                    catch (Exception)
                    {
                        f.Age = 0;
                    }

                    text          = _text.Substring(_text.IndexOf(" year old") + 9).Trim();
                    diagnosisPart = text;
                    a             = text.Substring(0, text.IndexOf(' ')).Trim();
                    f.Gender      = a.Replace(',', ' ').Trim();

                    if ((f.Gender.ToLower() != "male") && (f.Gender.ToLower() != "female"))
                    {
                        if (_text.IndexOf(" female ") > 0)
                        {
                            f.Gender = "female";
                        }
                        else if (_text.IndexOf(" male ") > 0)
                        {
                            f.Gender = "male";
                        }
                    }
                }
                else if (_text.IndexOf("-year-old") != -1)
                {
                    string text = _text.Substring(0, _text.IndexOf("-year-old"));
                    string a    = text.Substring(text.LastIndexOf(' ')).Trim();
                    try
                    {
                        f.Age = Int32.Parse(a);
                    }
                    catch (Exception)
                    {
                        f.Age = 0;
                    }
                    text          = _text.Substring(_text.IndexOf("-year-old") + 9).Trim();
                    diagnosisPart = text;
                    a             = text.Substring(0, text.IndexOf(' ')).Trim();

                    f.Gender = a.Replace(',', ' ').Trim();
                    if ((f.Gender.ToLower() != "male") && (f.Gender.ToLower() != "female"))
                    {
                        if (_text.IndexOf(" female ") > 0)
                        {
                            f.Gender = "female";
                        }
                        else if (_text.IndexOf(" male ") > 0)
                        {
                            f.Gender = "male";
                        }
                    }
                }
                if (diagnosisPart.Length == 0)
                {
                    diagnosisPart = f.ClinicalCaseSummary;
                }
                diagnosisPart = diagnosisPart.Substring(diagnosisPart.IndexOf(".") + 1).Trim();

                if (diagnosisPart.ToLower().IndexOf("diagnosis") != -1)
                {
                    diagnosisPart = diagnosisPart.Substring(diagnosisPart.ToLower().IndexOf("diagnosis"));
                    f.Diagnosis   = diagnosisPart.Substring(0, diagnosisPart.IndexOf("."));
                }
                else if (diagnosisPart.ToLower().IndexOf("diagnosed") != -1)
                {
                    diagnosisPart = diagnosisPart.Substring(diagnosisPart.ToLower().IndexOf("diagnosed"));
                    f.Diagnosis   = diagnosisPart.Substring(0, diagnosisPart.IndexOf("."));
                }
                else if (diagnosisPart.ToLower().IndexOf("diagnoses") != -1)
                {
                    diagnosisPart = diagnosisPart.Substring(diagnosisPart.ToLower().IndexOf("diagnoses"));
                    f.Diagnosis   = diagnosisPart.Substring(0, diagnosisPart.IndexOf("."));
                }
                else if (diagnosisPart.ToLower().IndexOf("diagnosistic") != -1)
                {
                    diagnosisPart = diagnosisPart.Substring(diagnosisPart.ToLower().IndexOf("diagnosistic"));
                    f.Diagnosis   = diagnosisPart.Substring(0, diagnosisPart.IndexOf("."));
                }
                else
                {
                    f.Diagnosis = diagnosisPart.Substring(0, diagnosisPart.IndexOf("."));
                }
                int licenseIndex = _text.IndexOf("State(s) of Licensure:");
                if (licenseIndex != -1)
                {
                    licenseIndex = licenseIndex + 22;
                    string licensureText = _text.Substring(licenseIndex, _text.IndexOf("\r\n", licenseIndex) - licenseIndex);
                    f.StateOfLincesure = licensureText.Trim();
                }

                int certificationIndex = _text.IndexOf("Certification(s)/Specialty:");
                if (certificationIndex != -1)
                {
                    certificationIndex = certificationIndex + 27;
                    string certs = _text.Substring(certificationIndex, _text.IndexOf("\r\n", certificationIndex) - certificationIndex);
                    f.Certifications = certs.Trim();
                }

                DBHelper helper = new DBHelper();
                helper.AddUpdateFormat1Detail(_treatmentID, f);
            }
            catch (Exception e)
            {
                throw new Exception("Could not parse PDF ", e);
            }
        }