public AlertsControlViewModel(IEmulationSmartDetectorRunner smartDetectorRunner)
        {
            this.SmartDetectorRunner          = smartDetectorRunner;
            this.SelectedAlert                = null;
            this.AlertDetailsControlViewModel = null;

            this.AlertDetailsControlClosed += () =>
            {
                this.SelectedAlert = null;
            };
        }
Example #2
0
        public AlertsControlViewModel(IEmulationSmartDetectorRunner smartDetectorRunner, ISystemProcessClient systemProcessClient)
        {
            this.SmartDetectorRunner          = smartDetectorRunner;
            this.SelectedAlert                = null;
            this.AlertDetailsControlViewModel = null;
            this.systemProcessClient          = systemProcessClient;

            this.AlertDetailsControlClosed += () =>
            {
                this.SelectedAlert = null;
            };
        }
        public SmartDetectorConfigurationControlViewModel(
            IExtendedAzureResourceManagerClient azureResourceManagerClient,
            ITracer tracer,
            SmartDetectorManifest smartDetectorManifest,
            IEmulationSmartDetectorRunner smartDetectorRunner,
            UserSettings userSettings)
        {
            this.azureResourceManagerClient = azureResourceManagerClient;
            this.smartDetectorManifest      = smartDetectorManifest;
            this.tracer = tracer;
            this.smartDetectorManifest = smartDetectorManifest;
            this.userSettings          = userSettings;

            this.SmartDetectorRunner     = smartDetectorRunner;
            this.SmartDetectorName       = this.smartDetectorManifest.Name;
            this.ShouldShowStatusControl = false;

            // Create dummy resource identifier for initialization purposes
            this.dummyResourceIdentifier = new ResourceIdentifier(ResourceType.ApplicationInsights, "dummy-subscription-id", "dummy-resource-group-name", "dummy-resource-name");

            // Initialize cadences combo box
            IEnumerable <SmartDetectorCadence> cadences = this.smartDetectorManifest.SupportedCadencesInMinutes
                                                          .Select(cadence => new SmartDetectorCadence(TimeSpan.FromMinutes(cadence)));

            this.Cadences = new ObservableCollection <SmartDetectorCadence>(cadences);

            // Set selected cadence to be the first one. If non, pick 10 minutes cadence as default
            this.SelectedCadence = this.Cadences.Any() ?
                                   this.Cadences.First() :
                                   new SmartDetectorCadence(TimeSpan.FromMinutes(10));

            this.IterativeRunModeEnabled = false;
            this.IterativeStartTime      = DateTime.UtcNow;
            this.IterativeEndTime        = DateTime.UtcNow;

            // In case there is no subscription to select from user settings, skip the entire phase of re-loading resources from user settings
            if (this.userSettings.SelectedSubscription != null)
            {
                this.ShouldSelectResourcesAccordingToUserSettings = true;
            }

            this.SupportedResourceTypes = this.GetSupportedResourceTypes();

            this.ReadResourcesTask = new ObservableTask <List <ResourceIdentifier> >(
                Task.FromResult(new List <ResourceIdentifier>()),
                this.tracer);

            this.ReadSubscriptionsTask = new ObservableTask <ObservableCollection <HierarchicalResource> >(
                this.GetSubscriptionsAsync(),
                this.tracer,
                this.LoadPreviousSelectedSubscription);
        }
        public TracesControlViewModel(IEmulationSmartDetectorRunner smartDetectorRunner, IPageableLogArchive logArchive, ITracer tracer)
            : this()
        {
            this.tracer     = tracer;
            this.logArchive = logArchive;

            smartDetectorRunner.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(smartDetectorRunner.PageableLog))
                {
                    this.PageableLog = smartDetectorRunner.PageableLog;
                }
                else if (args.PropertyName == nameof(smartDetectorRunner.IsSmartDetectorRunning))
                {
                    this.IsSmartDetectorRunning = smartDetectorRunner.IsSmartDetectorRunning;
                }
            };
        }
Example #5
0
 public MainWindowViewModel(IAuthenticationServices authenticationServices, IEmulationSmartDetectorRunner smartDetectorRunner, NotificationService notificationService)
 {
     this.AuthenticationServices = authenticationServices;
     this.SmartDetectorRunner    = smartDetectorRunner;
     notificationService.TabSwitchedToAlertsControl += () => { this.SelectedTab = MainWindowTabItem.AlertsControl; };
 }
 public EmulationStatusControlViewModel(IEmulationSmartDetectorRunner smartDetectorRunner, NotificationService notificationService)
 {
     this.SmartDetectorRunner = smartDetectorRunner;
     this.notificationService = notificationService;
 }