Example #1
0
        static void Main(string[] args)
        {
            // string[] args = {"-i", @"C:\Users\Juan Pelotas\AppData\Roaming\Cardiolizer\DCM_IN", "-o", @"\\172.100.1.201\Ambulatorio$", "-w", "-e" };

            if (args.Length == 0)
            {
                WriteUsage();
                return;
            }

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "-h" || args[i] == "--help")
                {
                    WriteUsage();
                    return;
                }

                //if (args[i] == "-i" || args[i] == "--input")
                //{
                //    if (!string.IsNullOrWhiteSpace(args[i + 1]))
                //    {
                //        Config.dataInPath = args[i + 1];
                //        i++;
                //    }
                //}


                //if (args[i] == "-o" || args[i] == "--output")
                //{
                //    if (!string.IsNullOrWhiteSpace(args[i + 1]))
                //    {
                //        Config.fileOutPath = args[i + 1];
                //        i++;
                //    }
                //}

                //if (args[i] == "-w" || args[i] == "--watch")
                //{
                //    Config.watch = true;
                //}

                //if (args[i] == "-e" || args[i] == "--erase")
                //{
                //    Config.erase = true;
                //}
            }

            Console.WriteLine("App Data Path: \"{0}\"", Config.appDataPath);
            Console.WriteLine("Data Path: \"{0}\"", Config.dataPath);
            Console.WriteLine("Data In dir: \"{0}\"", Config.dataInDir);
            Console.WriteLine("Template dir: \"{0}\"", Config.templateDir);
            // Console.WriteLine("Content File Path: \"{0}\"", Config.contentFilePath);
            Console.WriteLine("Temp: \"{0}\"", Config.tempDir);

            string[] folderPaths = new string[]
            {
                Config.dataInPath,
                Config.templatePath,
                Config.tempPath
            };

            Utilities.Folders.CheckIfNotExistAndCreate(folderPaths);

            // First check for files already in the input folder
            DirectoryInfo sourceDir = new DirectoryInfo(Config.dataInPath);

            foreach (FileInfo file in sourceDir.EnumerateFiles(Config.fileFilter))
            {
                MakeReport(file);
            }

            // Then start watching if applies
            if (Config.watch)
            {
                Watcher SRWatcher = new Watcher();
                SRWatcher.Watch(new DirectoryInfo(Config.dataInPath), Config.fileFilter, new DirectoryInfo(Config.fileOutPath));
                Console.WriteLine("Entering watch_mode. Press Q to quit.");
                while (Console.ReadKey().Key != ConsoleKey.Q)
                {
                    ;
                }
            }

            return;
        }