public static string GetConfidenLevelWithTotalCharacters(FCEngine.IEngine engine, FCEngine.IDocument document)
        {
            int    result  = 0;
            int    charAll = 0;
            int    charNeedsVerification = 0;
            IField root      = document as IField;
            var    fieldsAll = recursiveFindFieldLast(root);

            if (!object.ReferenceEquals(fieldsAll, null))
            {
                for (int i = 0; i < fieldsAll.Count; i++)
                {
                    var type = fieldsAll[i].Type;
                    if (type == FieldTypeEnum.FT_TextField || type == FieldTypeEnum.FT_DateTimeField ||
                        type == FieldTypeEnum.FT_CurrencyField || type == FieldTypeEnum.FT_NumberField)
                    {
                        if (!object.ReferenceEquals(fieldsAll[i].Value, null))
                        {
                            FCEngine.IText text = fieldsAll[i].Value.AsText;
                            for (int d = 0; d < text.Length; d++)
                            {
                                FCEngine.ICharParams charParams = engine.CreateCharParams();
                                text.GetCharParams(d, charParams);
                                if (charParams.NeedsVerification)
                                {
                                    charNeedsVerification += 1;
                                }
                            }
                            charAll += text.Length;
                        }
                        else if (!object.ReferenceEquals(fieldsAll[i].Instances, null))
                        {
                            var instances = fieldsAll[i].Instances;
                            for (int o = 0; o < instances.Count; o++)
                            {
                                if (!object.ReferenceEquals(instances[o].Value, null))
                                {
                                    FCEngine.IText text = instances[o].Value.AsText;
                                    for (int d = 0; d < text.Length; d++)
                                    {
                                        FCEngine.ICharParams charParams = engine.CreateCharParams();
                                        text.GetCharParams(d, charParams);
                                        if (charParams.NeedsVerification)
                                        {
                                            charNeedsVerification += 1;
                                        }
                                    }
                                    charAll += text.Length;
                                }
                            }
                        }
                    }
                    else if (type == FieldTypeEnum.FT_Table)
                    {
                        if (!object.ReferenceEquals(fieldsAll[i].Instances, null))
                        {
                            var instances = fieldsAll[i].Instances;
                            for (int o = 0; o < instances.Count; o++)
                            {
                                var row   = instances.Item(o);
                                var cells = row.Children;
                                if (!object.ReferenceEquals(cells, null))
                                {
                                    for (int j = 0; j < cells.Count; j++)
                                    {
                                        var cellField = cells.Item(j);
                                        var cellType  = cellField.Type;
                                        if (cellType == FieldTypeEnum.FT_TextField || cellType == FieldTypeEnum.FT_DateTimeField || cellType == FieldTypeEnum.FT_CurrencyField || cellType == FieldTypeEnum.FT_NumberField)
                                        {
                                            FCEngine.IText text = cellField.Value.AsText;
                                            for (int d = 0; d < text.Length; d++)
                                            {
                                                FCEngine.ICharParams charParams = engine.CreateCharParams();
                                                text.GetCharParams(d, charParams);
                                                if (charParams.NeedsVerification)
                                                {
                                                    charNeedsVerification += 1;
                                                }
                                            }
                                            charAll += text.Length;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (charAll != 0)
                {
                    result = 100 - ((charNeedsVerification * 100) / charAll);
                }
            }
            return(string.Format("{0} % ( {1} of {2} )", result, charAll - charNeedsVerification, charAll));
        }
        public static string GetAccurracyLevelHeaderMandatoryFieldWithTotalCharacters(FCEngine.IEngine engine, FCEngine.IDocument document, string[] mandatoryFields)
        {
            int    result  = 0;
            int    charAll = 0;
            int    charNeedsVerification = 0;
            IField root      = document as IField;
            var    fieldsAll = recursiveFindFieldLast(root);

            /*dataTable = new DataTable();
             *
             * //setup table
             * dataTable.Columns.Add("Field Name", typeof(string));
             * dataTable.Columns.Add("Original Value", typeof(string));
             * dataTable.Columns.Add("Idx Need to Verify", typeof(string));
             * dataTable.Columns.Add("Need to Verify", typeof(string));
             */

            if (!object.ReferenceEquals(fieldsAll, null))
            {
                for (int i = 0; i < fieldsAll.Count; i++)
                {
                    int      fcharAll = 0;
                    int      fcharNeedsVerification = 0;
                    var      type                = fieldsAll[i].Type;
                    var      fieldName           = fieldsAll[i].Name;
                    var      fieldValue          = "";
                    string[] fieldVerification   = null;
                    string   strNeedVerification = "";

                    //calculate only for Mandatory field
                    if (Array.IndexOf(mandatoryFields, fieldName) >= 0)
                    {
                        if (type == FieldTypeEnum.FT_TextField || type == FieldTypeEnum.FT_DateTimeField || type == FieldTypeEnum.FT_CurrencyField || type == FieldTypeEnum.FT_NumberField)
                        {
                            if (!object.ReferenceEquals(fieldsAll[i].Value, null))
                            {
                                FCEngine.IText text = fieldsAll[i].Value.AsText;
                                fieldValue = text.PlainText;
                                Console.WriteLine(string.Format("plain text: {0}", fieldValue));
                                fieldVerification = new string[fieldValue.Length];
                                for (int d = 0; d < text.Length; d++)
                                {
                                    FCEngine.ICharParams charParams = engine.CreateCharParams();
                                    text.GetCharParams(d, charParams);
                                    fieldVerification[d] = "";
                                    if (charParams.NeedsVerification)
                                    {
                                        charNeedsVerification  += 1;
                                        fcharNeedsVerification += 1;
                                        strNeedVerification     = strNeedVerification + fieldValue.ToCharArray(d, 1)[0].ToString();
                                    }
                                }
                                charAll  += text.Length;
                                fcharAll += text.Length;
                            }
                        }

                        Console.WriteLine(string.Format("field of {0} has total char {1} and value {2} then total char need to verify {3} and value {4})", fieldName, fcharAll, fieldValue, fcharNeedsVerification, strNeedVerification));
                    }
                }
                if (charAll != 0)
                {
                    result = 100 - ((charNeedsVerification * 100) / charAll);
                }
            }

            Console.WriteLine(string.Format("Confidence Header Level is {0} ", result.ToString()));
            return(string.Format("{0} % ( {1} of {2} )", result, charAll - charNeedsVerification, charAll));
        }
        public static string GetAccurracyLevelDetailMandatoryFieldWithTotalCharacter(FCEngine.IEngine engine, FCEngine.IDocument document, string[] mandatoryFields)
        {
            int    result  = 0;
            int    charAll = 0;
            int    charNeedsVerification = 0;
            IField root      = document as IField;
            var    fieldsAll = recursiveFindFieldLast(root);


            if (!object.ReferenceEquals(fieldsAll, null))
            {
                for (int i = 0; i < fieldsAll.Count; i++)
                {
                    var      type              = fieldsAll[i].Type;
                    var      fieldName         = fieldsAll[i].Name;
                    var      fieldValue        = "";
                    string[] fieldVerification = null;

                    //calculate only for Mandatory field
                    if (type == FieldTypeEnum.FT_Table)
                    {
                        if (!object.ReferenceEquals(fieldsAll[i].Instances, null))
                        {
                            var instances = fieldsAll[i].Instances;
                            for (int o = 0; o < instances.Count; o++)
                            {
                                var row   = instances.Item(o);
                                var cells = row.Children;
                                if (!object.ReferenceEquals(cells, null))
                                {
                                    for (int j = 0; j < cells.Count; j++)
                                    {
                                        var    cellField = cells.Item(j);
                                        var    cellType  = cellField.Type;
                                        var    cellName  = cellField.Name;
                                        int    fcharAll  = 0;
                                        int    fcharNeedsVerification = 0;
                                        string strNeedVerification    = "";
                                        if (Array.IndexOf(mandatoryFields, cellName) >= 0)
                                        {
                                            if (cellType == FieldTypeEnum.FT_TextField || cellType == FieldTypeEnum.FT_DateTimeField || cellType == FieldTypeEnum.FT_CurrencyField || cellType == FieldTypeEnum.FT_NumberField)
                                            {
                                                FCEngine.IText text = cellField.Value.AsText;
                                                fieldValue        = text.PlainText;
                                                fieldVerification = new string[fieldValue.Length];
                                                for (int d = 0; d < text.Length; d++)
                                                {
                                                    FCEngine.ICharParams charParams = engine.CreateCharParams();
                                                    text.GetCharParams(d, charParams);
                                                    if (charParams.NeedsVerification)
                                                    {
                                                        charNeedsVerification  += 1;
                                                        fcharNeedsVerification += 1;
                                                        strNeedVerification     = strNeedVerification + fieldValue.ToCharArray(d, 1)[0].ToString();
                                                    }
                                                }
                                                charAll  += text.Length;
                                                fcharAll += text.Length;
                                            }
                                            Console.WriteLine(string.Format("field of {0} has total char {1} and value {2} then total char need to verify {3} and value {4})", cellName, fcharAll, fieldValue, fcharNeedsVerification, strNeedVerification));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (charAll != 0)
                {
                    result = 100 - ((charNeedsVerification * 100) / charAll);
                }
            }

            Console.WriteLine(string.Format("Accuracy Detail Level is {0} ", result.ToString()));
            return(string.Format("{0} % ( {1} of {2} )", result, charAll - charNeedsVerification, charAll));
        }
        public static bool isValidEightItems(FCEngine.IEngine engine, FCEngine.IDocument document, string[] items)
        {
            IField root      = document as IField;
            var    fieldsAll = recursiveFindFieldLast(root);

            if (!object.ReferenceEquals(fieldsAll, null))
            {
                for (int i = 0; i < fieldsAll.Count; i++)
                {
                    var type      = fieldsAll[i].Type;
                    var fieldName = fieldsAll[i].Name;
                    if (Array.IndexOf(items, fieldName) >= 0)
                    {
                        if (type == FieldTypeEnum.FT_TextField || type == FieldTypeEnum.FT_DateTimeField || type == FieldTypeEnum.FT_CurrencyField || type == FieldTypeEnum.FT_NumberField)
                        {
                            if (!object.ReferenceEquals(fieldsAll[i].Value, null))
                            {
                                FCEngine.IText text = fieldsAll[i].Value.AsText;

                                Console.WriteLine("fieldName: " + fieldName + " and value: " + text);
                                if (!Object.ReferenceEquals(text, null))
                                {
                                    if (Object.ReferenceEquals(text.PlainText, "") || text.PlainText.Length == 0)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    else if (type == FieldTypeEnum.FT_Table)
                    {
                        if (!object.ReferenceEquals(fieldsAll[i].Instances, null))
                        {
                            var instances = fieldsAll[i].Instances;
                            for (int o = 0; o < instances.Count; o++)
                            {
                                var row   = instances.Item(o);
                                var cells = row.Children;
                                if (!object.ReferenceEquals(cells, null))
                                {
                                    for (int j = 0; j < cells.Count; j++)
                                    {
                                        var cellField = cells.Item(j);
                                        var cellType  = cellField.Type;
                                        var cellname  = cellField.Name;
                                        if (Array.IndexOf(items, cellname) >= 0)
                                        {
                                            if (cellType == FieldTypeEnum.FT_TextField || cellType == FieldTypeEnum.FT_DateTimeField || cellType == FieldTypeEnum.FT_CurrencyField || cellType == FieldTypeEnum.FT_NumberField)
                                            {
                                                FCEngine.IText text = cellField.Value.AsText;
                                                Console.WriteLine("cellName: " + cellname + " and value: " + text);
                                                if (!Object.ReferenceEquals(text, null))
                                                {
                                                    if (Object.ReferenceEquals(text.PlainText, "") || text.PlainText.Length == 0)
                                                    {
                                                        return(false);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }