Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            CARPaths paths = new LocalCARPaths();
            string sourceFolder = (args.Length > 0) ? args[0] : paths.CUTEWISE_ABSOLUTE_FOLDER;
            string targetFolder = (args.Length > 1) ? args[1] : paths.CUTEWISE_INCOMING_ABSOLUTE_FOLDER;

            new DirectoryInfo(sourceFolder)
                .GetAllCutewiseTerminationFiles()
                .Where(file => WP30Utils.HasEOF(file.FullName))
                .Apply(file => file.MoveTo(Path.Combine(targetFolder, file.Name)));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List<string> truncatedIIFs = new List<string>();
            List<string> truncatedRIFs = new List<string>();

            CARPaths paths = new LocalCARPaths();
            paths.ARCHIVED_REJECTED_FILES_FOLDER.GetSubDirectoryInfo(@"Y2012", @"2012_07").ListTruncatedFiles(CommonExtensions.ALL_ISSUE_FILES_PATTERN, truncatedIIFs, 1);
            paths.ARCHIVED_REJECTED_FILES_FOLDER.GetSubDirectoryInfo(@"Y2012", @"2012_07").ListTruncatedFiles(CommonExtensions.ALL_RETURN_FILES_PATTERN, truncatedRIFs, 1);

            DateTime DATE_LIMIT = new DateTime(2012, 7, 1);
            paths.ARCHIVED_PROCESSED_ISSUE_FILES_FOLDER.ListTruncatedFiles(CommonExtensions.ALL_ISSUE_FILES_PATTERN, truncatedIIFs, file => file.LastWriteTime > DATE_LIMIT);
            paths.ARCHIVED_PROCESSED_RETURN_FILES_FOLDER.ListTruncatedFiles(CommonExtensions.ALL_RETURN_FILES_PATTERN, truncatedRIFs, file => file.LastWriteTime > DATE_LIMIT);

            truncatedIIFs.SaveToTextFile(paths.ARCHIVE_FOLDER.GetFileInfo(@"truncatediifs.txt"));
            truncatedRIFs.SaveToTextFile(paths.ARCHIVE_FOLDER.GetFileInfo(@"truncatedrifs.txt"));
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                CARPaths paths = new LocalCARPaths();

                new FileInfo(@"lostrussianfiles.txt").ProcessLines(fileName =>
                    {
                        if (!String.IsNullOrWhiteSpace(fileName))
                        {
                            string actualName = fileName.Trim();

                            FileInfo file = paths.ARCHIVED_REJECTED_FILES_FOLDER.GetWP30DaySubDirectories().GetFileInfo(actualName);
                            if (file.Exists)
                            {
                                Console.Write("{0} found.", actualName);
                                if (file.CopyTo(paths.TEMP_FOLDER.GetSubDirectoryInfo("missingRussian").EnsureExists()).Exists)
                                {
                                    Console.WriteLine(" Copied.");
                                }
                                else
                                {
                                    Console.WriteLine(" Could not copy.");
                                }
                            }
                            else
                            {
                                Console.WriteLine("{0} not found.", file.FullName);
                            }
                        }
                    });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            CARPaths paths = new LocalCARPaths();

            Console.Out.WriteLine("Loading list of CXF files.");
            IEnumerable<string> allFiles = DBUtils.WithProdSqlReader(
                "CLI_Logger_DB",
                @"select RIGHT(The_message, 40) from CLI_Logger_DB.dbo.MSG_LOGGED ml where ml.The_Message like 'File % Created - Name:S:\DISPATCH_FOLDERS\OUT_PROC\%' and ml.Server_DateTime_Stamp > '20120701' order by RecordSequence",
                reader =>
                {
                    List<string> files = new List<string>();
                    using (var writer = File.CreateText(@"c:\temp\alljuly2012cxfs.txt"))
                    {
                        while (reader.Read())
                        {
                            string file = reader.GetString(0);
                            writer.WriteLine(file);
                            files.Add(file);
                        }
                    }
                    return files;
                });
            Console.Out.WriteLine("Found {0} files.", allFiles.Count());
            List<string> foundFiles = new List<string>();
            List<string> missingFiles = new List<string>();

            Console.Out.WriteLine("Finding processed files.");
            Dictionary<DirectoryInfo, IEnumerable<string>> processedFiles = new Dictionary<DirectoryInfo, IEnumerable<string>>();
            processedFiles.Add(paths.TODAY_ARCHIVE_FOLDER, paths.TODAY_ARCHIVE_FOLDER.GetAllCutewiseTerminationFiles().Select(file => file.Name));
            processedFiles.Add(paths.ARCHIVED_PROCESSED_CUTEWISE_FILES_FOLDER, paths.ARCHIVED_PROCESSED_CUTEWISE_FILES_FOLDER.GetAllCutewiseTerminationFiles().Select(file => file.Name));
            foreach (var day in RangeUtils.Enumerate(1, 31))
            {
                DirectoryInfo dir = new DirectoryInfo(Path.Combine(paths.ARCHIVED_PROCESSED_CUTEWISE_FILES_FOLDER.FullName, String.Format("2012\\2012-07\\2012-07-{0:00}", day)));
                processedFiles.Add(dir, dir.GetAllCutewiseTerminationFiles().Select(file => file.Name));
            }
            int totalProcessedFiles = processedFiles.Aggregate(0, (currentTotal, directoryInfo) => currentTotal + directoryInfo.Value.Count());
            Console.Out.WriteLine("Found {0} files.", totalProcessedFiles);

            Console.Out.WriteLine("Cross-checking.");
            foreach (var file in allFiles)
            {
                DirectoryInfo dir = processedFiles.Where(directoryInfo => directoryInfo.Value.Contains(file)).Select(directoryInfo => directoryInfo.Key).FirstOrDefault();
                if (dir == null)
                {
                    missingFiles.Add(file);
                }
                else
                {
                    foundFiles.Add(Path.Combine(dir.FullName, file));
                }
            }
            Console.Out.WriteLine("Missing files: {0}", missingFiles.Count());

            Console.Out.WriteLine("Filtering and saving.");
            missingFiles.SaveToTextFile(@"c:\temp\missingjuly2012cxfs.txt");
            IEnumerable<string> emptyFiles = foundFiles.Where(file => new FileInfo(file).Length == 0);
            Console.Out.WriteLine("Empty files: {0}", emptyFiles.Count());
            emptyFiles.SaveToTextFile(@"c:\temp\emptyjuly2012cxfs.txt");
            IEnumerable<string> nonEmptyFiles = foundFiles.Except(emptyFiles);
            IEnumerable<string> truncatedFiles = nonEmptyFiles.Where(file => !WP30Utils.HasEOF(file));
            Console.Out.WriteLine("Truncated files: {0}", truncatedFiles.Count());
            truncatedFiles.SaveToTextFile(@"c:\temp\truncatedjuly2012cxfs.txt");
            IEnumerable<string> goodFiles = nonEmptyFiles.Except(truncatedFiles);
            Console.Out.WriteLine("Good files: {0}", goodFiles.Count());
            goodFiles.SaveToTextFile(@"c:\temp\goodjuly2012cxfs.txt");
            Console.Out.WriteLine("Done.");
            Console.In.ReadLine();
        }