public string ProcessCard(IOcrProcess ocr, string backPageDataPath, string frontPageDataPath = null)
        {
            if (frontPageDataPath != null)
            {
                IDCard.CardData.FrontSide = IdentityCardHelper.processCardImage(frontPageDataPath);
            }

            IDCard.CardData.BackSide = IdentityCardHelper.processCardImage(backPageDataPath);

            return(ocr.Process(backPageDataPath));
        }
        private void parseSecondLine(string line)
        {
            string cardCode = "";
            string validationNumberForCardCode = "";
            string cardOrigin  = "";
            string dateOfBirth = "";
            string validationNumberDateOfBirth = "";
            string gender       = "";
            string dateOfExpiry = "";
            string validationNumberDateOfExpiry = "";

            var blocks = line.Split("<");

            for (int j = 0; j < blocks.Length; j++)
            {
                var block = blocks[j];
                if (block != "")
                {
                    if (j == 0)
                    {
                        cardCode = block;
                    }

                    if (j == 1)
                    {
                        validationNumberForCardCode = block.Substring(0, 1);
                        cardOrigin  = block.Substring(1, 3);
                        dateOfBirth = block.Substring(4, 6);
                        validationNumberDateOfBirth = block.Substring(10, 1);
                        gender       = block.Substring(11, 1);
                        dateOfExpiry = block.Substring(12, 6);
                        validationNumberDateOfExpiry = block.Substring(18, 1);
                        if (block.Length != 19)
                        {
                            IDCard.PersonalData.PersonalNumber = block.Substring(19, 10);
                        }
                    }
                }
            }

            if (validationNumberForCardCode != "" && cardCode != "")
            {
                if (IdentityCardHelper.validate(cardCode, Int32.Parse(validationNumberForCardCode)))
                {
                    IDCard.CardData.CardCode = cardCode;
                }
                else
                {
                    throw new WrongDataFormatException("The data was not load properly");
                }
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load card code");
            }

            if (IdentityCardHelper.countries.ContainsKey(cardOrigin))
            {
                IDCard.CardData.CardOrigin = IdentityCardHelper.countries[cardOrigin];
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load card origin");
            }

            if (IdentityCardHelper.validate(dateOfBirth, Int32.Parse(validationNumberDateOfBirth)))
            {
                IDCard.PersonalData.DateOfBirth = IdentityCardHelper.parseDateTimeFormat(dateOfBirth);
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load date of birth");
            }

            if (IdentityCardHelper.validate(dateOfExpiry, Int32.Parse(validationNumberDateOfExpiry)))
            {
                IDCard.PersonalData.DateOfBirth = IdentityCardHelper.parseDateTimeFormat(dateOfExpiry);
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load date of birth");
            }

            if (IdentityCardHelper.genders.ContainsKey(gender))
            {
                IDCard.PersonalData.Sex = IdentityCardHelper.genders[gender];
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load gender");
            }
        }
        private void parseFirstLine(string line)
        {
            Boolean cardCodeExist             = true;
            Boolean identificationNumberExist = true;

            var country              = "";
            var cardSubType          = "";
            var cardCode             = "";
            var identificationNumber = "";

            int?validationNumber = null;
            var blocks           = line.Split("<");

            for (int j = 0; j < blocks.Length; j++)
            {
                var block = blocks[j];
                if (block != "")
                {
                    if (j == 0)
                    {
                        country     = block.Substring(2, 3);
                        cardSubType = block.Substring(1, 1);
                        cardCode    = block.Substring(5);
                    }

                    if (j == 1)
                    {
                        identificationNumber = block.Substring(1);
                        validationNumber     = block[0] - '0';
                    }
                }
            }

            IDCard.CardData.CardType = CardType.IdentityCard;

            if (true)
            {
                IDCard.CardData.CardSubType = (CardSubType)cardSubType[0];
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load card sub type");
            }

            if (IdentityCardHelper.countries.ContainsKey(country))
            {
                IDCard.CardData.CardOrigin = IdentityCardHelper.countries[country];
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load card origin");
            }

            if (cardCodeExist)
            {
                if (validationNumber != null)
                {
                    if (IdentityCardHelper.validate(cardCode, validationNumber))
                    {
                        IDCard.CardData.CardCode = cardCode;
                    }
                    else
                    {
                        throw new WrongDataFormatException("The data was not load properly");
                    }
                }
                else
                {
                    IDCard.CardData.CardCode = cardCode;
                }
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load card code");
            }

            if (identificationNumberExist)
            {
                IDCard.PersonalData.PersonalNumber = identificationNumber;
            }
        }
        private void parseSecondLine(string line)
        {
            string dateOFBirth  = "";
            string dateOfExpiry = "";
            string country      = "";
            string gender       = "";

            int?validationValueForDateOfBirth  = null;
            int?validaitonValueForDateOfExpiry = null;
            int?generalValidationValue         = line[line.Length - 1];

            var blocks = line.Split("<");

            for (int j = 0; j < blocks.Length; j++)
            {
                var block = blocks[j];
                if (block != "")
                {
                    if (j == 0)
                    {
                        dateOFBirth  = block.Substring(0, 6);
                        dateOfExpiry = block.Substring(8, 6);
                        gender       = block.Substring(7, 1);
                        country      = block.Substring(15, 3);
                        validationValueForDateOfBirth  = block[6] - '0';
                        validaitonValueForDateOfExpiry = block[14] - '0';
                    }
                }
            }

            if (IdentityCardHelper.validate(dateOfExpiry, validaitonValueForDateOfExpiry))
            {
                IDCard.CardData.DateOfExpiry = IdentityCardHelper.parseDateTimeFormat(dateOfExpiry);
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load date of expiration");
            }

            if (IdentityCardHelper.validate(dateOFBirth, validationValueForDateOfBirth))
            {
                IDCard.PersonalData.DateOfBirth = IdentityCardHelper.parseDateTimeFormat(dateOFBirth);
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load date of birth");
            }

            if (IdentityCardHelper.nations.ContainsKey(country))
            {
                IDCard.PersonalData.Nationality = IdentityCardHelper.nations[country];
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load nationality");
            }

            if (IdentityCardHelper.genders.ContainsKey(gender))
            {
                IDCard.PersonalData.Sex = IdentityCardHelper.genders[gender];
            }
            else
            {
                throw new WrongDataFormatException("We couldn't load gender");
            }
        }