예제 #1
0
 private void SettingsOnPropertyChanged(object sender, EventArgs args)
 {
     _eventAggregator.GetEvent <MainWindowClosedEvent>().Unsubscribe(OnWindowClosedAction);
     _baseProvider.Settings.PropertyChanged            -= SettingsOnPropertyChanged;
     _currentSettingsProvider.Settings.PropertyChanged -= SettingsOnPropertyChanged;
     IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
 }
예제 #2
0
        private void DeleteAccountCallback(MessageInteraction interaction)
        {
            if (interaction.Response != MessageResponse.Yes)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            if (_accountsProvider.Settings.DropboxAccounts.Contains(_currentAccount))
            {
                _accountsProvider.Settings.DropboxAccounts.Remove(_currentAccount);
            }

            foreach (var profile in _usedInProfilesList)
            {
                profile.DropboxSettings.AccountId = "";
                profile.DropboxSettings.Enabled   = false;
                profile.ActionOrder.Remove(nameof(DropboxSettings));
            }

            try
            {
                _dropboxService.RevokeToken(_currentAccount.AccessToken);
            }
            catch (Exception)
            {
                // ignored
            }

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
        private void DeleteFilesCallback(MessageInteraction interaction)
        {
            if (interaction.Response != MessageResponse.Yes)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            var notDeletedFiles = new List <HistoricFile>();

            foreach (var historicFile in _historicFiles)
            {
                try
                {
                    if (_file.Exists(historicFile.Path))
                    {
                        _file.Delete(historicFile.Path);
                    }
                }
                catch
                {
                    notDeletedFiles.Add(historicFile);
                }
            }

            if (notDeletedFiles.Count > 0)
            {
                NotfiyUserAboutNotDeletedFiles(notDeletedFiles);
            }

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #4
0
        public override void Execute(object obj)
        {
            var currentRegion = _regionHelper.CurrentRegionName;
            MessageInteraction interaction = null;

            if (currentRegion == MainRegionViewNames.SettingsView)
            {
                var currentSettings = _currentSettingsProvider.Settings;
                var result          = _appSettingsChecker.CheckDefaultViewers(currentSettings.ApplicationSettings);
                var resultDict      = new ActionResultDict();
                resultDict.Add(Translation.DefaultViewer, result);
                interaction = DetermineInteraction(resultDict, settingsChanged: false);
            }
            else if (currentRegion == MainRegionViewNames.ProfilesView)
            {
                var currentSettings = _currentSettingsProvider.Settings;
                var resultDict      = _profileChecker.CheckProfileList(currentSettings.ConversionProfiles, currentSettings.ApplicationSettings.Accounts);
                var settingsChanged = _settingsChanged.HaveChanged();
                interaction = DetermineInteraction(resultDict, settingsChanged);
            }

            if (interaction != null)
            {
                _interactionRequest.Raise(interaction, ResolveInteractionResult);
            }
            else
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
            }
        }
 private void StartConsuming()
 {
     while (!_queue.IsCompleted)
     {
         try
         {
             if (_queue == null) // || _queue.Count==0
             {
                 return;
             }
             _queue.TryTake(out T data);
             if (data != null)
             {
                 Debug.WriteLine($"item {_queue.Count+1} in queue will be processed");
                 _action(data);
             }
         }
         catch (InvalidOperationException ex)
         {
             Debug.WriteLine(string.Format("Work queue on thread {0} has been closed.", Thread.CurrentThread.ManagedThreadId));
         }
     }
     IsDone?.Invoke(this, new EventArgs());
     Dispose();
 }
예제 #6
0
        private void MessageInteractionCompleted(ProfileProblemsInteraction messageInteraction)
        {
            var responseStatus = messageInteraction.IgnoreProblems
                ? ResponseStatus.Success
                : ResponseStatus.Cancel;

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(responseStatus));
        }
 public void Execute(object parameter)
 {
     _historicFiles = parameter as IList <HistoricFile>;
     if (_historicFiles == null)
     {
         IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Error));
         return;
     }
     DeleteFilesWithQuery();
 }
예제 #8
0
        private void AddSmtpAccountCallback(SmtpAccountInteraction interaction)
        {
            if (!interaction.Success)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }
            _smtpAccounts.Add(interaction.SmtpAccount);

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
        private void UpdateSmtpAccountsCallback(SmtpAccountInteraction interactionBase)
        {
            if (!interactionBase.Success)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            interactionBase.SmtpAccount.CopyTo(_currentAccount);
            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #10
0
        public override async Task ExecuteAsync(object parameter)
        {
            this.Execution = new NotifyTaskCompletion <MacroCommandIsDoneEventArgs>(this._command(parameter));
            this.RaisePropertyChanged("Execution");
            this.RaisePropertyChanged("IsExecuting");
            this.RaiseCanExecuteChanged();
            var macroCommandIsDoneEventArgs = await this.Execution.Task;

            IsDone?.Invoke(this, macroCommandIsDoneEventArgs);
            this.RaiseCanExecuteChanged();
            this.RaisePropertyChanged("IsExecuting");
        }
 public override void Execute(object parameter)
 {
     if (!_settingsProvider.Settings.Equals(_mainSettingsProvider.Settings))
     {
         var interaction = new ValidateContinueWithSavingInteraction(Translation.Description, Translation.Title);
         _interactionRequest.Raise(interaction, ResolveInteractionResult);
     }
     else
     {
         IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
     }
 }
예제 #12
0
 private void UpdateTimeServerAccountsCallback(TimeServerAccountInteraction interaction)
 {
     if (interaction.Success)
     {
         interaction.TimeServerAccount.CopyTo(_currentAccount);
         IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
     }
     else
     {
         IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
     }
 }
예제 #13
0
        private void AddFtpAccountCallback(FtpAccountInteraction interaction)
        {
            if (!interaction.Success)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            _accountsProvider.Settings.FtpAccounts.Add(interaction.FtpAccount);

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #14
0
        private void AddTimeServerAccountCallback(TimeServerAccountInteraction interaction)
        {
            if (!interaction.Success)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            var timeServerAccounts = _currentSettingsProvider?.Settings?.ApplicationSettings?.Accounts?.TimeServerAccounts;

            timeServerAccounts?.Add(interaction.TimeServerAccount);

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #15
0
        public void Execute(object parameter)
        {
            var profileCheckResult = _profileChecker.ProfileCheckDict(_currentSettingsProvider.Profiles, _currentSettingsProvider.Settings.ApplicationSettings.Accounts);

            if (!profileCheckResult)
            {
                var interaction = new ProfileProblemsInteraction(profileCheckResult);
                _interactionRequest.Raise(interaction, MessageInteractionCompleted);
            }
            else
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
            }
        }
예제 #16
0
        private void AddHttpAccountCallback(HttpAccountInteraction interaction)
        {
            if (!interaction.Success)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            var httpAccounts = _accountsProvider.Settings.HttpAccounts;

            httpAccounts.Add(interaction.HttpAccount);

            var collectionView = CollectionViewSource.GetDefaultView(httpAccounts);

            collectionView.MoveCurrentTo(interaction.HttpAccount);

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #17
0
        private void DeleteAccountCallback(MessageInteraction interaction)
        {
            if (interaction.Response != MessageResponse.Yes)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }
            if (HttpAccounts.Contains(_currentAccount))
            {
                HttpAccounts.Remove(_currentAccount);
            }

            foreach (var profile in _usedInProfilesList)
            {
                profile.HttpSettings.AccountId = "";
                profile.HttpSettings.Enabled   = false;
            }

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #18
0
        public override void Execute(object parameter)
        {
            var interaction = new DropboxAccountInteraction();

            interaction.Result = DropboxAccountInteractionResult.UserCanceled; //required as default for [X]-Button
            _interactionInvoker.Invoke(interaction);

            switch (interaction.Result)
            {
            case DropboxAccountInteractionResult.Success:
                break;

            case DropboxAccountInteractionResult.AccesTokenParsingError:
                var parseErrorMessageInteraction = new MessageInteraction(Translation.DropboxAccountSeverResponseErrorMessage, Translation.AddDropboxAccount, MessageOptions.OK, MessageIcon.Warning);
                _interactionRequest.Raise(parseErrorMessageInteraction, IsDoneWithErrorCallback);
                return;

            case DropboxAccountInteractionResult.Error:
                var errorMessageInteraction = new MessageInteraction(Translation.DropboxAccountCreationErrorMessage, Translation.AddDropboxAccount, MessageOptions.OK, MessageIcon.Warning);
                _interactionRequest.Raise(errorMessageInteraction, IsDoneWithErrorCallback);
                return;

            case DropboxAccountInteractionResult.UserCanceled:
            default:
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            var newAccount = interaction.DropboxAccount;

            var accountWithSameID = _droboxAccounts.FirstOrDefault(a => a.AccountId == newAccount.AccountId);

            if (accountWithSameID != null)
            {
                _droboxAccounts.Remove(accountWithSameID);
            }

            _droboxAccounts.Add(newAccount);

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #19
0
        private void ResolveInteractionResult(MessageInteraction interactionResult)
        {
            var macroResult = ResponseStatus.Success;

            switch (interactionResult.Response)
            {
            case MessageResponse.Yes:
                macroResult = ResponseStatus.Success;
                break;

            case MessageResponse.No:
                _currentSettingsProvider.Reset();
                macroResult = ResponseStatus.Skip;
                break;

            case MessageResponse.Cancel:
                macroResult = ResponseStatus.Cancel;
                break;
            }
            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(macroResult));
        }
예제 #20
0
        public void Execute(object parameter)
        {
            var target = parameter as string;

            if (target == null || !_regionManager.Regions.Any(r => r.Name == MainRegionName))
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
                return;
            }

            var region = _regionManager.Regions[MainRegionName];
            var activeViewInMainRegion = region.ActiveViews.FirstOrDefault();

            if (activeViewInMainRegion?.GetType().Name == target)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
        private void DeleteAccountCallback(MessageInteraction interaction)
        {
            if (interaction.Response != MessageResponse.Yes)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }

            if (_accountsProvider?.Settings?.FtpAccounts != null && _accountsProvider.Settings.FtpAccounts.Contains(_currentAccount))
            {
                _accountsProvider?.Settings?.FtpAccounts.Remove(_currentAccount);
            }

            foreach (var profile in _usedInProfilesList)
            {
                profile.Ftp.AccountId = "";
                profile.Ftp.Enabled   = false;
                profile.ActionOrder.Remove(nameof(Ftp));
            }

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #22
0
        public override async void Execute(object parameter)
        {
            var settingsCheckResult = _tabSwitchSettingsCheck.CheckAllSettings();

            if (settingsCheckResult.SettingsHaveChanged)
            {
                var title = Translation.Settings;
                var text  = Translation.UnsavedChanges
                            + Environment.NewLine
                            + Translation.WantToSave;

                var messageInteraction = new MessageInteraction(text, title, MessageOptions.YesCancel, MessageIcon.Question);

                await _interactionRequest.RaiseAsync(messageInteraction);

                if (messageInteraction.Response != MessageResponse.Yes)
                {
                    IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                }
            }
            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #23
0
        public void Execute(object parameter)
        {
            IsDone += OnIsDone;

            if (_waitForSetEvent)
            {
                Task.Run(() =>
                {
                    var wasSet = DelayExecutionResetEvent.Wait(1000);
                    if (!wasSet)
                    {
                        throw new Exception("The event DelayExecutionResetEvent was not set within 1000ms");
                    }

                    IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ExecutionResponse));
                });
            }
            else
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ExecutionResponse));
            }
        }
        public override async void Execute(object parameter)
        {
            var newAccount = new DropboxAccount();

            try
            {
                var userInfo = await _dropboxUserInfoManager.GetDropboxUserInfo();

                if (userInfo.AccessToken != null)
                {
                    newAccount.AccountId   = userInfo.AccountId;
                    newAccount.AccessToken = userInfo.AccessToken;
                    newAccount.AccountInfo = userInfo.AccountInfo;
                }
            }
            catch (DropboxAccessDeniedException)
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
                return;
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "An error occured trying to add Dropbox account.");
                var errorMessageInteraction = new MessageInteraction(Translation.DropboxAccountCreationErrorMessage, Translation.AddDropboxAccount, MessageOptions.OK, MessageIcon.Warning);
                _interactionRequest.Raise(errorMessageInteraction, IsDoneWithErrorCallback);
                return;
            }

            var accountWithSameId = _accountsProvider.Settings.DropboxAccounts.FirstOrDefault(a => a.AccountId == newAccount.AccountId);

            if (accountWithSameId != null)
            {
                _accountsProvider.Settings.DropboxAccounts.Remove(accountWithSameId);
            }

            _accountsProvider.Settings.DropboxAccounts.Add(newAccount);

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
        }
예제 #25
0
        private void AddProfileCallback(InputInteraction interaction)
        {
            if (interaction.Success)
            {
                var name = interaction.InputText;

                var newProfile = CurrentSettingsProvider.SelectedProfile.Copy();
                newProfile.Guid = Guid.NewGuid().ToString();
                newProfile.Name = name;
                newProfile.Properties.Deletable = true;
                newProfile.Properties.Renamable = true;
                newProfile.Properties.IsShared  = false;

                _profilesProvider.Settings.Add(newProfile);
                CurrentSettingsProvider.SelectedProfile = newProfile;
            }

            var result = interaction.Success
                ? ResponseStatus.Success
                : ResponseStatus.Cancel;

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(result));
        }
예제 #26
0
 protected void RaiseIsDone(ResponseStatus responseStatus)
 {
     IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(responseStatus));
 }
        private void ResolveInteractionResult(ValidateContinueWithSavingInteraction interactionResult)
        {
            var responseStatus = interactionResult.Response == MessageResponse.Yes ? ResponseStatus.Success : ResponseStatus.Cancel;

            IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(responseStatus));
        }
 private void IsDoneWithErrorCallback(MessageInteraction interaction)
 {
     IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Error));
 }
예제 #29
0
 private void OnWindowClosedAction()
 {
     _eventAggregator.GetEvent <EditSettingsFinishedEvent>().Unsubscribe(OnWindowClosedAction);
     _eventAggregator.GetEvent <MainWindowClosedEvent>().Unsubscribe(OnWindowClosedAction);
     IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
 }