Exemplo n.º 1
0
        /// <summary>
        /// Read the source file, the new File, get the records and write
        /// them to a destination file.  (record not in first file but in
        /// second will be written to the third)
        /// </summary>
        /// <param name="sourceFile">The file with the source records.</param>
        /// <param name="newFile">The file with the new records.</param>
        /// <param name="destFile">The destination file.</param>
        /// <returns>The new records on the new file.</returns>
        public T[] WriteNewRecords(string sourceFile, string newFile, string destFile)
        {
            FileHelperEngine <T> engine = CreateEngineAndClearErrors();

            T[] res = OnlyNewRecords(sourceFile, newFile);

            engine.WriteFile(destFile, res);
            ErrorManager.AddErrors(engine.ErrorManager);
            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the duplicated records in both files.
        /// </summary>
        /// <param name="file1">A file with records.</param>
        /// <param name="file2">A file with records.</param>
        /// <returns>The records that appear in both files.</returns>
        public T[] OnlyDuplicatedRecords(string file1, string file2)
        {
            FileHelperEngine <T> engine = CreateEngineAndClearErrors();

            T[] olds = engine.ReadFile(file1);
            ErrorManager.AddErrors(engine.ErrorManager);
            T[] currents = engine.ReadFile(file2);
            ErrorManager.AddErrors(engine.ErrorManager);

            var news = new List <T>();

            ApplyDiffInBoth(currents, olds, news);

            return(news.ToArray());
        }
Exemplo n.º 3
0
        /// <summary>Returns the records in newFile that not are in the sourceFile</summary>
        /// <param name="sourceFile">The file with the old records.</param>
        /// <param name="newFile">The file with the new records.</param>
        /// <returns>The records in newFile that not are in the sourceFile</returns>
        public T[] OnlyMissingRecords(string sourceFile, string newFile)
        {
            FileHelperEngine <T> engine = CreateEngineAndClearErrors();

            T[] olds = engine.ReadFile(sourceFile);
            ErrorManager.AddErrors(engine.ErrorManager);

            T[] currents = engine.ReadFile(newFile);
            ErrorManager.AddErrors(engine.ErrorManager);

            var news = new List <T>();

            ApplyDiffOnlyIn1(olds, currents, news);

            return(news.ToArray());
        }