コード例 #1
0
 public ManagerImageReference(CMConfigurationSection config)
 {
     TemplateFields = new DispatchedObservableCollection<ManagerTemplateField>();
     Config = config;
     IndexOffset = 0;
     ImageVariants = new List<ImageVariant>();
 }
コード例 #2
0
        public ManagerContext()
        {
            _config = (CMConfigurationSection)ConfigurationManager.GetSection("CMConfiguration");

            Carts = new DispatchedObservableCollection<ManagerCart>();
            CartItemsView = CollectionViewSource.GetDefaultView(Carts);
            CartItemsView.Filter = CartDislpayFilter;

            DataBase = new DispatchedObservableCollection<DataMessage>();
            //RunningEvents = new DispatchedObservableCollection<EventFlow>();
            DataFlowItems = new DispatchedObservableCollection<DataFlowItem>();
            ImageFlowItems = new DispatchedObservableCollection<DataFlowItem>();

            DataFlowItemsView = CollectionViewSource.GetDefaultView(DataFlowItems);
            DataFlowItemsView.Filter = DataFlowNameFilter;
            var sortData = new SortDescription { Direction = ListSortDirection.Descending, PropertyName = "Timestamp" };
            DataFlowItemsView.SortDescriptions.Add(sortData);

            ImageFlowItemsView = CollectionViewSource.GetDefaultView(ImageFlowItems);
            ImageFlowItemsView.Filter = ImageFlowNameFilter;
            var sortImage = new SortDescription { Direction = ListSortDirection.Descending, PropertyName = "Timestamp" };
            ImageFlowItemsView.SortDescriptions.Add(sortImage);

            #region INPUTS
            // Open Connection to INBOUND MQ
            foreach (InputConfiguration input in _config.InputConfigurations)
            {
                switch (input.Type.ToUpper())
                {
                    case "MQ":
                        {
                            var amquri = input.MQUri;
                            var amqinexchange = input.MQExchange;
                            var dataInConnection = new AMQConsumer(amquri, amqinexchange, this);
                            dataInConnection.Connect();
                            // TODO Catch hand handle connection exceptions and reconnect

                            _disposables.Add(dataInConnection);
                        }
                        break;
                    case "HTTP":
                        {
                            var httpBindIp = input.BindIp;
                            var httpBindPort = input.BindPort;
                            var dataInHttpServer = new CMHttpServer(httpBindIp, httpBindPort, this);
                            dataInHttpServer.Start();

                            _disposables.Add(dataInHttpServer);
                        }
                        break;
                        // TODO Handle and log default
                }
            }

            #endregion INPUTS

            #region OUTPUTS
            // Open Connection to OUTBOUND MQ
            if (_config.OutputConfiguration.EnableDataDispatchMQ)
            {
                var amquri = _config.OutputConfiguration.DispatchMQConfiguration.MQUri;
                var amqoutexchange = _config.OutputConfiguration.DispatchMQConfiguration.MQExchange;
                var dataOutConnection = new AMQQueuePublisher(amquri, amqoutexchange);
                dataOutConnection.Connect();
                _publishers.Add(dataOutConnection);
                // TODO Catch hand handle connection exceptions and reconnect

                _disposables.Add(dataOutConnection);
            }
            #endregion OUTPUTS

            if (!ResetFomrFile())
            {
                LoadCarts(true, false);
                LoadInitialImages();
                LoadReceivedImages();
            }
        }