Exemplo n.º 1
0
        public static IValidator CreateValidator(ValidationRequest request)
        {
            IValidator validator;

            switch (Path.GetExtension(request.FileName).ToLower())
            {
            case ".zip":
                validator = new ZipValidator(request);
                break;

            case ".pdf":
                validator = new PdfValidator(request);
                break;

            case ".xml":
                validator = new XmlValidator(request);
                break;

            case ".doc":
            case ".docx":
                validator = new WordValidator(request);
                break;

            case ".json":
                validator = new JsonValidator(request);
                break;

            case ".txt":
                validator = new TextValidator(request);
                break;

            case ".csv":
                validator = new CsvValidator(request);
                break;

            case ".html":
            case ".htm":
                validator = new HtmlValidator(request);
                break;

            default:
                validator = new UnknownValidator(request);
                break;
            }

            return(validator);
        }
Exemplo n.º 2
0
        public static void Search(string Item, out string Result)
        {
            GetCathegory(Item.ToUpper(), out string Cathegory, out string ItemForSearch);

            if (Cathegory == "System Board")
            {
                Result = JconPath.Search(ItemForSearch);
            }
            else if (Cathegory == "Jcon Path")
            {
                Result = DisplaySystemBoardSearch(ItemForSearch);
            }
            else
            {
                Result = null;
            }

            // Local Methods

            void GetCathegory(string userObject, out string cathegory, out string itemForSearch)
            {
                UnknownModel unknown = new UnknownModel();

                unknown.obj = userObject;
                UnknownValidator userValidator = new UnknownValidator();
                ValidationResult result        = userValidator.Validate(unknown);

                if (result.IsValid == false)
                {
                    foreach (ValidationFailure failure in result.Errors)
                    {
                        DataCollection.Logs.Add(failure.ErrorMessage);
                    }
                    cathegory     = "Error";
                    itemForSearch = "Error";
                }
                else
                {
                    if (unknown.obj.Contains("_"))
                    {
                        cathegory = "System Board";
                    }
                    else if (unknown.obj.Substring(0, 1) == "J")
                    {
                        cathegory = "Jcon Path";
                    }
                    else
                    {
                        cathegory = "Unknown";
                    }

                    itemForSearch = unknown.obj;
                }
            }

            string DisplaySystemBoardSearch(string item)
            {
                JconPathModel jconpath = new JconPathModel();

                jconpath.TableName = item.Substring(0, 4);
                jconpath.Column    = Convert.ToChar(item.Substring(5, 1));
                jconpath.Row       = Convert.ToByte(item.Substring(7, item.Length - 7));

                JconPathValidator pathValidator = new JconPathValidator();
                ValidationResult  pathresult    = pathValidator.Validate(jconpath);

                if (pathresult.IsValid == false)
                {
                    foreach (ValidationFailure failure in pathresult.Errors)
                    {
                        DataCollection.Logs.Add(failure.ErrorMessage);
                    }
                    return("");
                }
                else
                {
                    return(SystemBoard.Search(jconpath.TableName, jconpath.Column, jconpath.Row));
                }
            }
        }