Ejemplo n.º 1
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // Create instances of helper classes.
                var configurationHelper = ConfigurationHelper.Instance;
                var fileOrganizerHelper = FileOrganizerHelper.Instance;

                // Get source and destination file paths
                var sourcePath      = configurationHelper.GetSourceFilePath();
                var destinationPath = configurationHelper.GetDestinationFilePath();
                var reportDecorator = new ReportDecorator(fileOrganizerHelper);

                // Organize the files
                try
                {
                    reportDecorator.OrganizeFiles(sourcePath, destinationPath);
                    reportDecorator.UpdateSuccessCount();
                }
                catch (Exception ex)
                {
                    reportDecorator.UpdateFailureCount();
                }
                finally {
                    reportDecorator.SaveReportCount();
                }

                Console.WriteLine($"Organized files successfully from \"{sourcePath}\" to \"{destinationPath}\"!! Please check \"{destinationPath}\" for output.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occurred. Please make sure you have set correct source and destination file names in config. Please check below error for more details!");
                Console.WriteLine();
                logger.Error("An exception occurred while organizing files! Please check stacktrace for more details.", ex);
            }
            finally
            {
                Console.WriteLine();
                Console.WriteLine("Press any key to exit!");
                Console.ReadKey();
            }
        }
Ejemplo n.º 2
0
 public ReportController()
 {
     reportDecorator = new ReportDecorator();
 }