private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var payload = GeneratPayloadString();
            var dtoLog  = new DtoLog {
                CreateDateTime = DateTime.Now, Payload = payload, SearchPath = _userSettings.ServiceInfo.SearchPath, Source = "Scheduler"
            };

            _boLog.Save(dtoLog);
            _fileManager.LogDelegate = LogChanges;
            _windowsRegistryManager.GenerateNewRegistryKeys(_userSettings.SelectedFileExtensionList, ref dtoLog);
            _fileManager.RenameAllFilesWithNewExtension(_userSettings.SelectedFileExtensionList, _userSettings.ServiceInfo.SearchPath, ref dtoLog);
            _userSettings.ServiceInfo.NextServiceRunDateTime = DateTime.Now.AddHours(_userSettings.ServiceInfo.Interval);
            _serviceInfo.Save(_userSettings.ServiceInfo);
        }
Exemplo n.º 2
0
        private void SetWorkerThreads()
        {
            string searchPath;

            if (RadioBtnHdd.IsChecked.Value)
            {
                searchPath = "HD";
            }
            else if (!string.IsNullOrEmpty(_chosenSearchPath))
            {
                searchPath = _chosenSearchPath;
            }
            else
            {
                MessageBox.Show("Choose Search Path.");
                return;
            }
            BtnStart.IsEnabled = false;
            TxtLog.AppendText(DateTime.Now + "\tStarted.\r\n");
            GeneratPayloadString();
            var dtoLog = new DtoLog {
                CreateDateTime = DateTime.Now, Payload = _payLoad, SearchPath = searchPath, Source = "App"
            };

            new BoLog().Save(dtoLog);
            _dtoLog     = dtoLog;
            _searchPath = searchPath;
            var backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += (s, eventArgs) =>
            {
                userSettings.SearchPath = searchPath;
                _boUserSettings.Save(userSettings);
                _windowsRegistryManager.GenerateNewRegistryKeys(userSettings.SelectedFileExtensionList, ref dtoLog);
            };
            backgroundWorker.RunWorkerCompleted += WindowsRegistryManagerWorkCompleted;
            backgroundWorker.RunWorkerAsync();
        }