Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a code that check value of pages.. but now I want the sequence of roman numeral to check. Can some try to edit my code and to make it check the roman numeral pages.

C#
public void CheckPBSequence()
        {
            int pagenoInt;
            List<string> validpage = new List<string>(File.ReadAllLines(string.Concat(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["validpage"].ToString())));
            int prevPbNo = 0;
            bool isRoman = false;
            foreach (XElement pb in this._xdoc.Descendants("text").Descendants<XElement>("pb"))
            {
                try
                {
                    string pagenoStr = pb.Attribute("n").Value;
                    if (int.TryParse(pagenoStr, out pagenoInt))
                    {
                        if ((prevPbNo == 0 ? false : pagenoInt != prevPbNo + 1))
                        {
                            List<ErrorModel> errorlist = this.Errorlist;
                            ErrorModel errorModel = new ErrorModel()
                            {
                                LineNumber = ((IXmlLineInfo)pb).LineNumber,
                                ErrorMessage = "Incorrect page number",
                                Text = pagenoStr
                            };
                            errorlist.Add(errorModel);
                        }
                        if (isRoman)
                        {
                            prevPbNo = 0;
                        }
                        isRoman = false;
                        prevPbNo = pagenoInt;
                    }
                    else
                    {
                        if (RomanNumeralUtility.TryConvertToArabic(pagenoStr, out pagenoInt))
                        {
                            if (!isRoman)
                            {
                                prevPbNo = 0;
                            }
                            isRoman = true;
                        }
                        else if (!validpage.Contains(pagenoStr))
                        {
                            List<ErrorModel> errorModels = this.Errorlist;
                            ErrorModel errorModel1 = new ErrorModel()
                            {
                                LineNumber = ((IXmlLineInfo)pb).LineNumber,
                                ErrorMessage = "Incorrect page number",
                                Text = pagenoStr
                            };
                            errorModels.Add(errorModel1);
                        }
                        prevPbNo = 0;
                    }
                }
                catch (NullReferenceException nullReferenceException)
                {
                }
            }
        }
Posted
Comments
George Jonsson 6-Nov-15 4:14am    
How much do you pay for the coding?
Erwin Alcantara 26-Sep-19 12:47pm    
What????????
Richard MacCutchan 6-Nov-15 6:12am    
You first need to explain what the problem is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900