Ejemplo n.º 1
0
        protected Backend.Infrastructure.IBackend LookForBackend(Core.Identity.UserIdentity userIdentity, Core.Identity.ClientIdentity clientIdentity)
        {
            Core.Identity.DomainIdentity domainIdentity = DomainIdentity.Create(userIdentity, clientIdentity);

            Backend.Infrastructure.IBackend backend = null;

            if (this.state != KernelState.initialized)
            {
                throw new Core.Exceptions.CoreNotInitializedException();
            }

            this.backends.TryGetValue(domainIdentity, out backend);

            return(backend);
        }
Ejemplo n.º 2
0
        private void BindBackendFor(Core.Identity.UserIdentity userIdentity, Core.Identity.ClientIdentity clientIdentity)
        {
            if (userIdentity == null)
            {
                throw new ArgumentException("userIdentity must be provided", "userIdentity");
            }

            if (clientIdentity == null)
            {
                throw new ArgumentException("clientIdentity must be provided", "clientIdentity");
            }

            Core.Identity.DomainIdentity domainIdentity = DomainIdentity.Create(userIdentity, clientIdentity);

            Backend.Infrastructure.IBackend backend = new Backend.Implementations.Lest.LESTBackend(
                new Backend.Infrastructure.Identity.UserIdentity(userIdentity.UserId, userIdentity.Name, userIdentity.Password),
                new Backend.Infrastructure.Identity.ClientIdentity(clientIdentity.ClientId, clientIdentity.Name)
                );

            this.backends.Add(domainIdentity, backend);
        }
Ejemplo n.º 3
0
        internal virtual void AddUser(Core.Identity.UserIdentity userIdentity)
        {
            IEnumerable <Extensibility.IProducerPlugin> producers = this.ActivateProducers(userIdentity);

            foreach (Extensibility.IProducerPlugin producer in producers)
            {
                //producer.notifyNewDigitalInputs += handleNewDigitalInputsNotification;
                Observable.FromEventPattern <Core.Extensibility.Events.NotifyNewDigitalInputsEventHandler, Core.Extensibility.Events.NewDigitalInputsEventArgs>(
                    h => producer.notifyNewDigitalInputs += h,
                    h => producer.notifyNewDigitalInputs -= h
                    )
                .Subscribe(
                    evt =>
                {
                    Backend.Infrastructure.IBackend backend = this.LookForBackend(evt.EventArgs.UserIdentity, evt.EventArgs.ClientIdentity);
                    backend.saveDigitalInputs(evt.EventArgs.DigitalInputs);
                }
                    );

                //producer.notifyDeletedSources += handleDeletedSourcesNotification;
                Observable.FromEventPattern <Core.Extensibility.Events.NotifyRemovedSourcesEventHandler, Core.Extensibility.Events.RemovedDigitalInputsEventArgs>(
                    h => producer.notifyRemovedSources += h,
                    h => producer.notifyRemovedSources -= h
                    )
                .Subscribe(
                    evt =>
                {
                    Backend.Infrastructure.IBackend backend = this.LookForBackend(evt.EventArgs.UserIdentity, evt.EventArgs.ClientIdentity);
                    backend.deleteSources(evt.EventArgs.Sources);
                }
                    );

                this.BindBackendFor(userIdentity, producer.ProducerInfo.Identity);// userIdentity.BackendKey);

                log4net.LogManager.GetLogger("").Info(string.Format("Configuring (prod: {0} - user: {1})", producer.ProducerInfo.Name, userIdentity.UserId));

                producer.Initialize();
                this.producers.Add(producer);
            }
        }
Ejemplo n.º 4
0
 internal virtual void RemoveUser(Core.Identity.UserIdentity userIdentity)
 {
 }
Ejemplo n.º 5
0
        internal virtual IEnumerable <Extensibility.IProducerPlugin> ActivateProducers(Core.Identity.UserIdentity userIdentity)
        {
            List <Extensibility.IProducerPlugin> activatedProducers = new List <Extensibility.IProducerPlugin>();

            foreach (Type producerType in this.configuration.ProducerTypes)
            {
                activatedProducers.Add((Extensibility.IProducerPlugin)Activator.CreateInstance(producerType, userIdentity));
            }

            return(activatedProducers);
        }