Esempio n. 1
0
        public List <clsTolkappiyam> LoadTolkappiyamDetails()
        {
            string                appDataPath    = Path.Combine(Application.StartupPath, "Data");
            string                xmlTolkappiyam = Path.Combine(appDataPath, "Tolkappiyam.xml");
            List <string>         lstDetails     = new List <string>();
            List <clsTolkappiyam> lstcomdetails  = new List <clsTolkappiyam>();
            XmlTextReader         reader         = null;

            try
            {
                reader = new XmlTextReader(xmlTolkappiyam);

                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        if (!reader.IsEmptyElement)
                        {
                            string ss = reader.Name;

                            reader.Read(); // Read the start tag.

                            if (ss == "Verse")
                            {
                                do
                                {
                                    reader.Read();
                                    if (reader.IsStartElement())
                                    {
                                        if (!reader.IsEmptyElement)
                                        {
                                            lstDetails.Add(reader.ReadString());
                                        }
                                    }
                                } while (!reader.Name.Equals("Verse"));

                                clsTolkappiyam objresult = new clsTolkappiyam();
                                objresult.Text     = lstDetails[0].ToString();
                                objresult.Original = lstDetails[1].ToString();
                                objresult.Division = objresult.stringToEnum(lstDetails[2].ToString());
                                objresult.Chapter  = lstDetails[3].ToString();
                                objresult.Verse    = lstDetails[6].ToString();
                                objresult.Line     = lstDetails[7].ToString();

                                lstcomdetails.Add(objresult);
                                lstDetails.Clear();
                            }
                        }
                    }
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(lstcomdetails);
        }
        private void SearchingSingleWord()
        {
            string                WordTobeSerached = comboBox1.SelectedItem.ToString();
            List <string>         lstcomdetails    = new List <string>();
            List <clsTolkappiyam> lstFinalResult   = new List <clsTolkappiyam>();
            XmlTextReader         reader           = null;
            string                dummystr         = string.Empty;
            bool stringFormat;

            if (string.IsNullOrEmpty(WordTobeSerached))
            {
                MessageBox.Show("Please enter the word");
            }
            else
            {
                try
                {
                    reader = new XmlTextReader(xmlTolkappiyam);

                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            string ss = reader.Name;


                            if (!reader.IsEmptyElement)
                            {
                                reader.Read(); // Read the start tag.

                                if (ss == "Text")
                                {
                                    dummystr = reader.Value;
                                }

                                if (IsParsed)
                                {
                                    stringFormat = (ss.Equals("Text")) && reader.Value.Split(' ').Contains(WordTobeSerached);
                                }
                                else
                                {
                                    stringFormat = (ss.Equals("OriginalText")) && reader.Value.Split(' ').Contains(WordTobeSerached);
                                }


                                if (stringFormat)
                                {
                                    if (!IsParsed)
                                    {
                                        lstcomdetails.Add(dummystr);
                                    }

                                    lstcomdetails.Add(reader.Value);
                                    do
                                    {
                                        reader.Read();
                                        if (reader.IsStartElement())
                                        {
                                            if (!reader.IsEmptyElement)
                                            {
                                                lstcomdetails.Add(reader.ReadString());
                                            }
                                            else
                                            {
                                                lstcomdetails.Add("");
                                            }
                                        }
                                    } while (!reader.Name.Equals("Verse"));
                                    clsTolkappiyam objresult = new clsTolkappiyam();
                                    objresult.Text     = lstcomdetails[0].ToString();
                                    objresult.Original = lstcomdetails[1].ToString();
                                    objresult.Division = objresult.stringToEnum(lstcomdetails[2].ToString());
                                    objresult.Chapter  = lstcomdetails[3].ToString();
                                    objresult.Verse    = lstcomdetails[6].ToString();
                                    objresult.Line     = lstcomdetails[7].ToString();

                                    lstFinalResult.Add(objresult);
                                    lstcomdetails.Clear();
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }

                Display(lstFinalResult, DisplayType.Word);
            }
        }