Exemplo n.º 1
0
        /// <summary>
        /// Creates a new integration state View-Model.
        /// </summary>
        /// <param name="integrationManager">The integration manager used to apply selected integration options.</param>
        /// <param name="appEntry">The application being integrated.</param>
        /// <param name="feed">The feed providing additional metadata, icons, etc. for the application.</param>
        public IntegrationState([NotNull] IIntegrationManager integrationManager, [NotNull] AppEntry appEntry, [NotNull] Feed feed)
        {
            #region Sanity checks
            if (integrationManager == null)
            {
                throw new ArgumentNullException("integrationManager");
            }
            if (appEntry == null)
            {
                throw new ArgumentNullException("appEntry");
            }
            if (feed == null)
            {
                throw new ArgumentNullException("feed");
            }
            #endregion

            _integrationManager = integrationManager;
            AppEntry            = appEntry;
            Feed = feed;

            CapabilitiyRegistration = (AppEntry.AccessPoints == null) || AppEntry.AccessPoints.Entries.OfType <AccessPoints.CapabilityRegistration>().Any();

            LoadCommandAccessPoints();
            LoadDefaultAccessPoints();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds an existing <see cref="AppEntry"/> or creates a new one for a specific interface URI.
        /// </summary>
        /// <param name="integrationManager">Manages desktop integration operations.</param>
        /// <param name="interfaceUri">The interface URI to create an <see cref="AppEntry"/> for. Will be updated if <see cref="Feed.ReplacedBy"/> is set and accepted by the user.</param>
        protected virtual AppEntry GetAppEntry([NotNull] IIntegrationManager integrationManager, [NotNull] ref FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null)
            {
                throw new ArgumentNullException(nameof(integrationManager));
            }
            if (interfaceUri == null)
            {
                throw new ArgumentNullException(nameof(interfaceUri));
            }
            #endregion

            try
            {
                // Try to find an existing AppEntry
                return(integrationManager.AppList[interfaceUri]);
            }
            catch (KeyNotFoundException)
            {
                try
                {
                    // Create a new AppEntry
                    return(CreateAppEntry(integrationManager, ref interfaceUri));
                }
                catch (InvalidOperationException ex)
                    // Only use exact exception type match
                    when(ex.GetType() == typeof(InvalidOperationException))
                    {
                        // Find the existing AppEntry after interface URI replacement
                        return(integrationManager.AppList[interfaceUri]);
                    }
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        protected override AppEntry GetAppEntry(IIntegrationManager integrationManager, ref FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null)
            {
                throw new ArgumentNullException(nameof(integrationManager));
            }
            if (interfaceUri == null)
            {
                throw new ArgumentNullException(nameof(interfaceUri));
            }
            #endregion

            var appEntry = base.GetAppEntry(integrationManager, ref interfaceUri);
            var feed     = FeedManager.GetFresh(interfaceUri);

            // Detect feed changes that may make an AppEntry update necessary
            if (!appEntry.CapabilityLists.UnsequencedEquals(feed.CapabilityLists))
            {
                string changedMessage = string.Format(Resources.CapabilitiesChanged, appEntry.Name);
                if (Handler.Ask(
                        changedMessage + " " + Resources.AskUpdateCapabilities,
                        defaultAnswer: false, alternateMessage: changedMessage))
                {
                    integrationManager.UpdateApp(appEntry, feed);
                }
            }

            return(appEntry);
        }
        private AppEntry ReplaceAppEntry(IIntegrationManager integrationManager, AppEntry entry, FeedTarget newTarget)
        {
            integrationManager.RemoveApp(entry);
            var newEntry = CreateAppEntry(integrationManager, newTarget);

            integrationManager.AddAccessPoints(newEntry, newTarget.Feed, entry.AccessPoints.Entries);
            return(newEntry);
        }
Exemplo n.º 5
0
 public UsersController(
     IIntegrationManager integrationManager,
     IUserStore userStore,
     IUserNotificationStore userNotificationStore,
     ISubscriptionStore subscriptionStore)
 {
     this.integrationManager    = integrationManager;
     this.userStore             = userStore;
     this.userNotificationStore = userNotificationStore;
     this.subscriptionStore     = subscriptionStore;
 }
        /// <summary>
        /// Creates a new integration state View-Model.
        /// </summary>
        /// <param name="integrationManager">The integration manager used to apply selected integration options.</param>
        /// <param name="appEntry">The application being integrated.</param>
        /// <param name="feed">The feed providing additional metadata, icons, etc. for the application.</param>
        public IntegrationState(IIntegrationManager integrationManager, AppEntry appEntry, Feed feed)
        {
            _integrationManager = integrationManager ?? throw new ArgumentNullException(nameof(integrationManager));
            AppEntry            = appEntry ?? throw new ArgumentNullException(nameof(appEntry));
            Feed = feed ?? throw new ArgumentNullException(nameof(feed));

            CapabilityRegistration = (AppEntry.AccessPoints == null) || AppEntry.AccessPoints.Entries.OfType <AccessPoints.CapabilityRegistration>().Any();

            LoadCommandAccessPoints();
            LoadDefaultAccessPoints();
        }
Exemplo n.º 7
0
 public WebhookChannel(IHttpClientFactory httpClientFactory, ILogStore logStore,
                       IIntegrationManager integrationManager,
                       IUserNotificationQueue userNotificationQueue,
                       IUserNotificationStore userNotificationStore)
 {
     this.httpClientFactory     = httpClientFactory;
     this.logStore              = logStore;
     this.integrationManager    = integrationManager;
     this.userNotificationQueue = userNotificationQueue;
     this.userNotificationStore = userNotificationStore;
 }
    private AppEntry CreateAppEntry(IIntegrationManager integrationManager, FeedTarget target)
    {
        BackgroundDownload(target.Uri);

        try
        {
            Log.Info("Creating app entry for " + target.Uri.ToStringRfc());
            return(integrationManager.AddApp(target));
        }
        catch (InvalidOperationException ex) when(ex.GetType() == typeof(InvalidOperationException))
        {
            Log.Warn("Attempting to handle race condition while creating app entry for " + target.Uri.ToStringRfc());
            return(integrationManager.AppList[target.Uri]);
        }
    }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a new integration state View-Model.
        /// </summary>
        /// <param name="integrationManager">The integration manager used to apply selected integration options.</param>
        /// <param name="appEntry">The application being integrated.</param>
        /// <param name="feed">The feed providing additional metadata, icons, etc. for the application.</param>
        public IntegrationState([NotNull] IIntegrationManager integrationManager, [NotNull] AppEntry appEntry, [NotNull] Feed feed)
        {
            #region Sanity checks
            if (integrationManager == null) throw new ArgumentNullException("integrationManager");
            if (appEntry == null) throw new ArgumentNullException("appEntry");
            if (feed == null) throw new ArgumentNullException("feed");
            #endregion

            _integrationManager = integrationManager;
            AppEntry = appEntry;
            Feed = feed;

            CapabilitiyRegistration = (AppEntry.AccessPoints == null) || AppEntry.AccessPoints.Entries.OfType<AccessPoints.CapabilityRegistration>().Any();

            LoadCommandAccessPoints();
            LoadDefaultAccessPoints();
        }
Exemplo n.º 10
0
 public MobilePushChannel(ILogger <MobilePushChannel> log, ILogStore logStore,
                          IAppStore appStore,
                          IIntegrationManager integrationManager,
                          IUserNotificationQueue userNotificationQueue,
                          IUserNotificationStore userNotificationStore,
                          IUserStore userStore,
                          IClock clock)
 {
     this.appStore              = appStore;
     this.log                   = log;
     this.logStore              = logStore;
     this.integrationManager    = integrationManager;
     this.userNotificationQueue = userNotificationQueue;
     this.userNotificationStore = userNotificationStore;
     this.userStore             = userStore;
     this.clock                 = clock;
 }
Exemplo n.º 11
0
 public MessagingChannel(ILogger <MessagingChannel> log, ILogStore logStore,
                         IAppStore appStore,
                         IIntegrationManager integrationManager,
                         IMessagingFormatter messagingFormatter,
                         IMessagingTemplateStore messagingTemplateStore,
                         IUserNotificationQueue userNotificationQueue,
                         IUserNotificationStore userNotificationStore)
 {
     this.appStore               = appStore;
     this.log                    = log;
     this.logStore               = logStore;
     this.integrationManager     = integrationManager;
     this.messagingFormatter     = messagingFormatter;
     this.messagingTemplateStore = messagingTemplateStore;
     this.userNotificationQueue  = userNotificationQueue;
     this.userNotificationStore  = userNotificationStore;
 }
Exemplo n.º 12
0
 public SmsChannel(ILogger <SmsChannel> log, ILogStore logStore,
                   IAppStore appStore,
                   IIntegrationManager integrationManager,
                   ISmsFormatter smsFormatter,
                   ISmsTemplateStore smsTemplateStore,
                   IUserNotificationQueue userNotificationQueue,
                   IUserNotificationStore userNotificationStore)
 {
     this.appStore           = appStore;
     this.integrationManager = integrationManager;
     this.log                   = log;
     this.logStore              = logStore;
     this.smsFormatter          = smsFormatter;
     this.smsTemplateStore      = smsTemplateStore;
     this.userNotificationQueue = userNotificationQueue;
     this.userNotificationStore = userNotificationStore;
 }
Exemplo n.º 13
0
 public EmailChannel(ILogger <EmailChannel> log, ILogStore logStore,
                     IAppStore appStore,
                     IIntegrationManager integrationManager,
                     IEmailFormatter emailFormatter,
                     IEmailTemplateStore emailTemplateStore,
                     IUserNotificationQueue userNotificationQueue,
                     IUserNotificationStore userNotificationStore,
                     IUserStore userStore)
 {
     this.appStore           = appStore;
     this.emailFormatter     = emailFormatter;
     this.emailTemplateStore = emailTemplateStore;
     this.log                   = log;
     this.logStore              = logStore;
     this.integrationManager    = integrationManager;
     this.userNotificationQueue = userNotificationQueue;
     this.userNotificationStore = userNotificationStore;
     this.userStore             = userStore;
 }
Exemplo n.º 14
0
    /// <summary>
    /// Finds an existing <see cref="AppEntry"/> or creates a new one for a specific interface URI.
    /// </summary>
    /// <param name="integrationManager">Manages desktop integration operations.</param>
    /// <param name="interfaceUri">The interface URI to create an <see cref="AppEntry"/> for. Will be updated if <see cref="Feed.ReplacedBy"/> is set and accepted by the user.</param>
    protected virtual AppEntry GetAppEntry(IIntegrationManager integrationManager, ref FeedUri interfaceUri)
    {
        #region Sanity checks
        if (integrationManager == null)
        {
            throw new ArgumentNullException(nameof(integrationManager));
        }
        if (interfaceUri == null)
        {
            throw new ArgumentNullException(nameof(interfaceUri));
        }
        #endregion

        var existingEntry = integrationManager.AppList.GetEntry(interfaceUri);

        var target = GetTarget(ref interfaceUri, out bool replaced);

        return(replaced && existingEntry != null
            ? ReplaceAppEntry(integrationManager, existingEntry, target)
            : existingEntry ?? CreateAppEntry(integrationManager, target));
    }
Exemplo n.º 15
0
        protected AppEntry CreateAppEntry([NotNull] IIntegrationManager integrationManager, [NotNull] ref FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null)
            {
                throw new ArgumentNullException(nameof(integrationManager));
            }
            if (interfaceUri == null)
            {
                throw new ArgumentNullException(nameof(interfaceUri));
            }
            #endregion

            var target = new FeedTarget(interfaceUri, FeedManager.GetFresh(interfaceUri));
            DetectReplacement(ref target);

            Log.Info("Creating app entry for " + target.Uri.ToStringRfc());
            var appEntry = integrationManager.AddApp(target);
            BackgroundDownload(target.Uri);
            return(appEntry);
        }
Exemplo n.º 16
0
        public static ConfiguredIntegrationsDto FromDomainObject(App source, IIntegrationManager integrationManager)
        {
            var result = new ConfiguredIntegrationsDto
            {
                Configured = new Dictionary <string, ConfiguredIntegrationDto>()
            };

            if (source.Integrations != null)
            {
                foreach (var(id, configured) in source.Integrations)
                {
                    result.Configured[id] = ConfiguredIntegrationDto.FromDomainObject(configured);
                }
            }

            result.Supported = new Dictionary <string, IntegrationDefinitionDto>();

            foreach (var definition in integrationManager.Definitions)
            {
                result.Supported[definition.Type] = IntegrationDefinitionDto.FromDomainObject(definition);
            }

            return(result);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="integrationManager"></param>
 public IntegrationController(IIntegrationManager integrationManager)
 {
     IntegrationManager = integrationManager;
 }
 public IntegrationsController(IIntegrationManager instanceManager, UserManager <AppUser> userManager, IAdminLogger logger) : base(userManager, logger)
 {
     _integrationManager = instanceManager;
 }
Exemplo n.º 19
0
        /// <summary>
        /// Finds an existing <see cref="AppEntry"/> or creates a new one for a specific interface URI and feed.
        /// </summary>
        /// <param name="integrationManager">Manages desktop integration operations.</param>
        /// <param name="interfaceUri">The interface URI to create an <see cref="AppEntry"/> for. Will be updated if <see cref="Feed.ReplacedBy"/> is set and accepted by the user.</param>
        protected override AppEntry GetAppEntry(IIntegrationManager integrationManager, ref FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null) throw new ArgumentNullException(nameof(integrationManager));
            if (interfaceUri == null) throw new ArgumentNullException(nameof(interfaceUri));
            #endregion

            var appEntry = base.GetAppEntry(integrationManager, ref interfaceUri);
            var feed = FeedManager.GetFresh(interfaceUri);

            // Detect feed changes that may make an AppEntry update necessary
            if (!appEntry.CapabilityLists.UnsequencedEquals(feed.CapabilityLists))
            {
                string changedMessage = string.Format(Resources.CapabilitiesChanged, appEntry.Name);
                if (Handler.Ask(
                    changedMessage + " " + Resources.AskUpdateCapabilities,
                    defaultAnswer: false, alternateMessage: changedMessage))
                    integrationManager.UpdateApp(appEntry, feed);
            }

            return appEntry;
        }
Exemplo n.º 20
0
 public AppsController(IAppStore appStore, IUserResolver userResolver, IIntegrationManager integrationManager)
 {
     this.appStore           = appStore;
     this.userResolver       = userResolver;
     this.integrationManager = integrationManager;
 }