예제 #1
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper()
        {
            if (RemoveOnly)
            {
                IntegrationManager.RemoveAccessPointCategories(IntegrationManager.AppList[InterfaceUri], _removeCategories.ToArray());
                return(ExitCode.OK);
            }
            else
            {
                CheckInstallBase();

                var appEntry = GetAppEntry(IntegrationManager, ref InterfaceUri);
                var feed     = FeedManager[InterfaceUri];

                if (NoSpecifiedIntegrations)
                {
                    var state = new IntegrationState(IntegrationManager, appEntry, feed);
Retry:
                    Handler.ShowIntegrateApp(state);
                    try
                    {
                        state.ApplyChanges();
                    }
                    #region Error handling
                    catch (ConflictException ex)
                    {
                        if (Handler.Ask(
                                Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                                defaultAnswer: false, alternateMessage: ex.Message))
                        {
                            goto Retry;
                        }
                    }
                    catch (InvalidDataException ex)
                    {
                        if (Handler.Ask(
                                Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                                defaultAnswer: false, alternateMessage: ex.Message))
                        {
                            goto Retry;
                        }
                    }
                    #endregion

                    return(ExitCode.OK);
                }
                else
                {
                    if (_removeCategories.Any())
                    {
                        IntegrationManager.RemoveAccessPointCategories(appEntry, _removeCategories.ToArray());
                    }
                    if (_addCategories.Any())
                    {
                        IntegrationManager.AddAccessPointCategories(appEntry, feed, _addCategories.ToArray());
                    }
                    return(ExitCode.OK);
                }
            }
        }
예제 #2
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (interfaceUri == null)
            {
                throw new ArgumentNullException(nameof(interfaceUri));
            }
            if (integrationManager == null)
            {
                throw new ArgumentNullException(nameof(integrationManager));
            }
            #endregion

            if (RemoveOnly())
            {
                RemoveOnly(integrationManager, interfaceUri);
                return(ExitCode.OK);
            }

            CheckInstallBase();

            var appEntry = GetAppEntry(integrationManager, ref interfaceUri);
            var feed     = FeedManager[interfaceUri];

            if (NoSpecifiedIntegrations())
            {
                var state = new IntegrationState(integrationManager, appEntry, feed);
Retry:
                Handler.ShowIntegrateApp(state);
                try
                {
                    state.ApplyChanges();
                }
                #region Error handling
                catch (ConflictException ex)
                {
                    if (Handler.Ask(
                            Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                            defaultAnswer: false, alternateMessage: ex.Message))
                    {
                        goto Retry;
                    }
                }
                catch (InvalidDataException ex)
                {
                    if (Handler.Ask(
                            Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                            defaultAnswer: false, alternateMessage: ex.Message))
                    {
                        goto Retry;
                    }
                }
                #endregion

                return(ExitCode.OK);
            }

            RemoveAndAdd(integrationManager, feed, appEntry);
            return(ExitCode.OK);
        }