Пример #1
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);
            }
        }
Пример #2
0
 private void handleDeletedSourcesNotification(Core.Identity.ClientIdentity clientIdentity, Core.Identity.UserIdentity userIdentity, IEnumerable <Backend.Domain.Source.SourceId> sourceIds)
 {
     Backend.Infrastructure.IBackend backend = this.LookForBackend(userIdentity, clientIdentity);
     backend.deleteSources(sourceIds);
 }