Exemplo n.º 1
0
        public bool LoadPersonsFromFile(String filename, FileHandler.FileType fileType)
        {
            FileHandler inputFileHandler = FileHandlerFactory.GetFileHandler(fileType);

            Persons = inputFileHandler.Load(filename);
            return(Persons != null);
        }
Exemplo n.º 2
0
        private void RunMatcher_OnClick(object sender, EventArgs e)
        {
            MatchResultsListBox.Items.Clear();
            LogPrintListBox.Items.Clear();

            if (InputFilenameTextBox.Text.Length > 0)
            {
                List <MatchResult> matchList = new List <MatchResult>();
                RunMatcherButton.Enabled = false;
                Logger.Info("Starting matching process...");

                FileHandler.FileType fileType = FileHandler.FileType.JSON;
                if (XmlRadioButton.Checked)
                {
                    fileType = FileHandler.FileType.XML;
                }

                if (PersonMatcher.LoadPersonsFromFile(InputFilenameTextBox.Text, fileType))
                {
                    matchList = PersonMatcher.FindAllMatches();
                }

                Logger.Info("Matching process completed.");
            }
            else
            {
                Logger.Warn("Please select a file");
            }

            RunMatcherButton.Enabled = true;
        }
Exemplo n.º 3
0
        private void SaveToFile_Clicked(object sender, EventArgs e)
        {
            FileHandler.FileType type = FileHandler.FileType.JSON;
            if (XmlOuput.Checked)
            {
                type = FileHandler.FileType.XML;
            }

            PersonMatcher.SaveMatchesToFile(OutputFilename.Text, type);
        }
Exemplo n.º 4
0
        public List <MatchResult> FindMatchesFromFile(String filename, FileHandler.FileType fileType)
        {
            FileHandler inputFileHandler = FileHandlerFactory.GetFileHandler(fileType);

            Persons = inputFileHandler.Load(filename);
            if (Persons != null)
            {
                Matches = FindAllMatches();
            }
            Logger.Info($"Found {Matches.Count} matches");
            return(Matches);
        }
Exemplo n.º 5
0
        public bool SaveMatchesToFile(String filename, FileHandler.FileType fileType)
        {
            FileHandler outputFileHandler = FileHandlerFactory.GetFileHandler(fileType);

            if (Matches.Count > 0)
            {
                return(outputFileHandler.Save(filename, Matches));
            }
            else
            {
                Logger.Warn("No matches available to export");
                return(false);
            }
        }
        public static FileHandler GetFileHandler(FileHandler.FileType fileType)
        {
            FileHandler newHandler = null;

            if (RegisteredHandlers.ContainsKey(fileType))
            {
                newHandler = Activator.CreateInstance(RegisteredHandlers[fileType]) as FileHandler;
            }
            else
            {
                Logger.Error("Unable to determine file parser type");
            }

            return(newHandler);
        }
 public static void RegisterFileHandler(FileHandler.FileType fileTypeDef, Type matcherType)
 {
     RegisteredHandlers[fileTypeDef] = matcherType;
 }