Esempio n. 1
0
        /// <summary>
        /// The main constructor for MuiViewModel that takes an instance of Active Requests Service
        /// </summary>
        /// <param name="service"></param>
        public RequestsViewModel(IComponentContext container, IActiveRequestsService service, IEventAggregator aggregator, ILoggerFactory loggerFactory)
        {
            this.ea                   = aggregator;
            this.loggerFac            = loggerFactory;
            this.logger               = loggerFactory.Create <RequestsViewModel>();
            this.container            = container;
            this.service              = service;
            this.ActiveRequests       = new ObservableCollection <RequestObject>();
            this.ParameterList        = new ObservableCollection <Pair <string, object> >();
            this.ActiveRequests       = service.GetRequests();
            this.Pipe                 = null;
            this.MakeRequestCommand   = new DelegateCommand(MakeRequest);
            this.Timer                = new Timer();
            Timer.Elapsed            += new ElapsedEventHandler(OnTimedEvent);
            Timer.Interval            = 500;
            Timer.Enabled             = true;
            this.CanStartPipeline     = true;
            this.CanStopPipeline      = false;
            this.StartPipelineCommand = new DelegateCommand(StartPipeline);
            this.StopPipelineCommand  = new DelegateCommand(StopPipeline);

            this.ea.GetEvent <SelectionChangedEvent>().Subscribe((item) => {
                if (item != null && item.ParameterList != null)
                {
                    this.ParameterList = item.ParameterList;
                }
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor that takes an instance of AvailableRequestsService
        /// </summary>
        /// <param name="service"></param>
        public DataGridViewModel(IComponentContext container, IAvailableRequestsService service, IActiveRequestsService activeReqService, IEventAggregator aggregator, ILoggerFactory logFactory)
        {
            this.logger = logFactory.Create <DataGridViewModel>();
            logger.Debug("Initialized " + typeof(DataGridViewModel));

            this.ea        = aggregator;
            this.container = container;
            this.Requests  = new ObservableCollection <MenuItem>();
            this.Requests.AddRange(CreateMenuItems());

            this.ActiveRequests = new ObservableCollection <RequestObject>();
            this.ActiveRequests = activeReqService.GetRequests();
            this.AddSelectedItemToActiveCommand      = new DelegateCommand(AddSelectedItemToActive);
            this.RemoveSelectedItemFromActiveCommand = new DelegateCommand(RemoveSelectedItemFromActive);
            this.SelectedRequestItem                = new RequestObject();
            this.SelectedActiveRequestItem          = new RequestObject();
            this.ParameterList                      = new ObservableCollection <Pair <string, object> >();
            this.SelectedActiveRequestParameterList = new ObservableCollection <Pair <string, object> >();
            this.EditParametersCommand              = new DelegateCommand(EditParameters);
            this.SaveParametersCommand              = new DelegateCommand(SaveParameters);

            this.ea.GetEvent <SelectedMenuItemChangedEvent>().Subscribe((item) =>
            {
                //once clicked parse out the appropriate menu item properties (api name & request name)
                Enum.TryParse(item.Title, out RequestTypes result);
                this.SelectedRequestItem.ApiName     = result;
                this.SelectedRequestItem.RequestName = item.Title;

                //remove any previous parameters
                this.SelectedRequestItem.ParameterList.Clear();

                //add the menu items parameter list to the selected request items parameter list
                this.SelectedRequestItem.ParameterList.AddRange(item.ParameterList);
            });
        }
Esempio n. 3
0
 public InputDiagViewModel(IActiveRequestsService service)
 {
     this.service        = service;
     this.DataCollection = service.GetRequests();
 }