public SalesManagerService()
        {
            InitializeComponent();

            log4net.Config.XmlConfigurator.Configure();
            _logger = LogManager.GetLogger("Windows Service");

            ApplicationConfigValidator validator = new ApplicationConfigValidator();
            try
            {
                validator.Validate();

                _serverFolderPath = ConfigurationManager.AppSettings["ServerFolder"];
                _wrongFilesFolderPath = ConfigurationManager.AppSettings["NotAppropriateFilesFolder"];
                _processedFiles = ConfigurationManager.AppSettings["ProcessedFilesFolder"];

                _cancelationTokenSource = new CancellationTokenSource();

                var taskScheduler =
                    new LimitedTaskScheduler(Int32.Parse(ConfigurationManager.AppSettings["MaxDatabaseConnections"]));
                _taskFactory = new TaskFactory(taskScheduler);
                _fileHandler = new FileHandler();
            }
            catch (ConfigurationErrorsException ex)
            {
                _logger.Fatal("Eroor occurs with configuration. " + ex.Message);
                return;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                _logger.Fatal("Erorr occurs with max number of connections to database. " + ex.Message);
                return;
            }
        }
        static void Main(string[] args)
        {
            ApplicationConfigValidator validator = new ApplicationConfigValidator();

            log4net.Config.XmlConfigurator.Configure();
            _logger = LogManager.GetLogger("Console application");

            try
            {
                validator.Validate();

                _serverFolderPath = ConfigurationManager.AppSettings["ServerFolder"];
                _wrongFilesFolderPath = ConfigurationManager.AppSettings["NotAppropriateFilesFolder"];
                _processedFiles = ConfigurationManager.AppSettings["ProcessedFilesFolder"];

                var taskScheduler =
                    new LimitedTaskScheduler(Int32.Parse(ConfigurationManager.AppSettings["MaxDatabaseConnections"]));
                _taskFactory = new TaskFactory(taskScheduler);
                _fileHandler = new FileHandler();
            }
            catch (ConfigurationErrorsException ex)
            {
                _logger.Fatal("Eroor occurs with configuration. " + ex.Message);
                return;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                _logger.Fatal("Erorr occurs with max number of connections to database. " + ex.Message);
                return;
            }

            ScanServerFolder();

            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = _serverFolderPath;
            watcher.Filter = "*.csv";
            watcher.Created += new FileSystemEventHandler(OnChanged);

            watcher.EnableRaisingEvents = true;

            Console.Read();
        }