Esempio n. 1
0
        public SmartDetectorConfigurationControlViewModel(
            IExtendedAzureResourceManagerClient azureResourceManagerClient,
            IObservableTracer 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);
        }
Esempio n. 2
0
 public EmulationStatusControlViewModel(IEmulationSmartDetectorRunner smartDetectorRunner, IObservableTracer tracer, NotificationService notificationService)
 {
     this.SmartDetectorRunner = smartDetectorRunner;
     this.Tracer = tracer;
     this.notificationService = notificationService;
 }