예제 #1
0
        /// <summary>
        /// Creates resource detail and inserts it into the manifest.
        /// </summary>
        /// <param name="resources">The resources.</param>
        /// <param name="manifest">The manifest.</param>
        internal override void AddToManifest(Collection <VirtualResource> resources, SystemManifest manifest)
        {
            var resource = resources.First();

            MachineReservationDetail detail = manifest.Resources.GetResource <MachineReservationDetail>(resource.VirtualResourceId);

            if (detail == null)
            {
                detail = CreateDetail(resource);
                manifest.Resources.Add(detail);
            }

            // Add installers to the manifest that are specific to this instance of the Machine Reservation
            MachineReservationMetadata metadata = LegacySerializer.DeserializeXml <MachineReservationMetadata>(resource.VirtualResourceMetadataSet.First().Metadata);

            if (metadata.PackageId != Guid.Empty)
            {
                using (EnterpriseTestContext context = new EnterpriseTestContext())
                {
                    int i = 1;
                    foreach (var installer in SelectSoftwareInstallers(context, metadata.PackageId))
                    {
                        TraceFactory.Logger.Debug("Adding {0}".FormatWith(installer.Description));
                        manifest.SoftwareInstallers.Add(CreateSoftwareInstallerDetail(installer, i++));
                    }
                }
            }
        }
        /// <summary>
        /// Initialise using the saved data
        /// </summary>
        /// <param name="entity"></param>
        public override void Initialize(object entity)
        {
            _perfMonCollector = entity as PerfMonCollector;
            if (_perfMonCollector == null)
            {
                throw new ControlTypeMismatchException(entity, typeof(PerfMonCollector));
            }

            //Bind to the controls that make sense
            name_TextBox.DataBindings.Add("Text", _perfMonCollector, "Name");

            PopulateServerList();

            //browse throught the virtual resource metadata and add them to our listbox
            foreach (VirtualResourceMetadata vmdata in _perfMonCollector.VirtualResourceMetadataSet)
            {
                PerfMonCounterData tempCounter = LegacySerializer.DeserializeXml <PerfMonCounterData>(vmdata.Metadata);
                tempCounter.VirtualResourceMetadataId = vmdata.VirtualResourceMetadataId;
                _selectedCountersDataList.Add(tempCounter);
            }

            platform_ComboBox.SetPlatform(_perfMonCollector.Platform, VirtualResourceType.PerfMonCollector);

            LoadSystemSetting();

            selectedCounters_DataGridView.DataSource = _selectedCountersDataList;
        }
        /// <summary>
        /// Retrieves a collection of output monitor destinations of the specified type.
        /// </summary>
        /// <param name="monitorType">The type of output monitor destinations to retrieve.</param>
        /// <returns>A collection of output monitor destinations.</returns>
        public IEnumerable <string> GetOutputMonitorDestinations(string monitorType)
        {
            STFMonitorType      stfMonitorType = (STFMonitorType)Enum.Parse(typeof(STFMonitorType), monitorType);
            Collection <string> result         = new Collection <string>();

            using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
            {
                foreach (MonitorConfig monitorConfig in context.MonitorConfigs.Where(m => m.MonitorType == monitorType))
                {
                    if (monitorConfig.Configuration.StartsWith("<OutputMonitorConfig"))
                    {
                        OutputMonitorConfig outputConfig = LegacySerializer.DeserializeXml <OutputMonitorConfig>(monitorConfig.Configuration);

                        if (stfMonitorType.Equals(STFMonitorType.OutputEmail) || stfMonitorType.Equals(STFMonitorType.DigitalSendNotification))
                        {
                            result.Add(outputConfig.MonitorLocation);
                        }
                        else
                        {
                            result.Add($@"\\{monitorConfig.ServerHostName}\{outputConfig.MonitorLocation}");
                        }
                    }
                }
            }

            return(result);
        }
예제 #4
0
        private void LoadStoredCalculatedSeries()
        {
            // Pull the saved calculated series out of the user settings
            var allStoredSeries = LegacySerializer.DeserializeXml <Collection <StoredCalculatedSeries> >(Settings.Default.CalculatedSeries);
            StoredCalculatedSeries storedSeries = allStoredSeries.FirstOrDefault(n => n.SessionId == _sessionId && n.GraphName == this.GraphName);

            if (storedSeries != null)
            {
                _calculatedSeries.Clear();
                _calculatedSeries.AddRange(storedSeries.Series);
            }
        }
        /// <summary>
        /// Requests that the control finalize any edits that have been made by saving
        /// them from the UI controls to their backing objects.
        /// </summary>
        public override void FinalizeEdit()
        {
            // Change the focused control so that data bindings will update
            name_Label.Focus();

            var metadata = _reservation.VirtualResourceMetadataSet.First();

            if (_reservationData.PackageId != LegacySerializer.DeserializeXml <MachineReservationMetadata>(metadata.Metadata).PackageId)
            {
                metadata.Metadata = LegacySerializer.SerializeXml(_reservationData).ToString();
            }
        }
예제 #6
0
        /// <summary>
        /// reads the performance counters from the manifest
        /// </summary>
        /// <param name="perfResources"></param>
        private void ReadManifest(IEnumerable <ResourceDetailBase> perfResources)
        {
            _perfMonCounters = new ObservableCollection <PerfMonCounterData>();

            foreach (var perfResource in perfResources)
            {
                foreach (var data in perfResource.MetadataDetails)
                {
                    var tempCounterData = LegacySerializer.DeserializeXml <PerfMonCounterData>(data.Data);
                    _perfMonCounters.Add(tempCounterData);
                }
            }
        }
        /// <summary>
        /// Initializes this instance with the specified object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <exception cref="ControlTypeMismatchException">
        /// Thrown when an object of incorrect type is passed to this instance.
        ///   </exception>
        public override void Initialize(object entity)
        {
            _reservation = entity as VirtualResource;
            AddMetadataIfMissing(_reservation);

            if (_reservation == null)
            {
                throw new ControlTypeMismatchException(entity, typeof(VirtualResource));
            }

            platform_ComboBox.SetPlatform(_reservation.Platform, VirtualResourceType.MachineReservation);

            var metadata = _reservation.VirtualResourceMetadataSet.FirstOrDefault();

            if (metadata != null)
            {
                _reservationData = LegacySerializer.DeserializeXml <MachineReservationMetadata>(metadata.Metadata);
            }
            else
            {
                _reservationData = new MachineReservationMetadata();
            }

            var package = SoftwareInstallerPackage.CreateSoftwareInstallerPackage(Guid.Empty);

            package.Description = "None";

            package_ComboBox.Items.Add(package);
            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                List <SoftwareInstallerPackage> list = new List <SoftwareInstallerPackage>();
                list.Add(package);

                list.AddRange(context.SoftwareInstallerPackages.OrderBy(n => n.Description));
                package_ComboBox.DataSource    = list;
                package_ComboBox.DisplayMember = "Description";
                package_ComboBox.ValueMember   = "PackageId";

                package_ComboBox.SelectedItem = list.FirstOrDefault(e => e.PackageId == _reservationData.PackageId);
            }

            // Set up data bindings
            name_TextBox.DataBindings.Add("Text", _reservation, "Name");
            description_TextBox.DataBindings.Add("Text", _reservation, "Description");
            platform_ComboBox.DataBindings.Add("SelectedValue", _reservation, "Platform");
            instanceCount_NumericUpDown.DataBindings.Add("Text", _reservation, "InstanceCount");
            package_ComboBox.DataBindings.Add("SelectedValue", _reservationData, "PackageId");
        }
예제 #8
0
        private void LoadDateTimeSettings()
        {
            // Load the serialized settings list
            string serializedSettingsList = Properties.Settings.Default.DateFormats;
            var    settingsList           = LegacySerializer.DeserializeXml <Collection <GraphDateTimeSettings> >(serializedSettingsList);

            // Find the settings that apply to this graph
            GraphDateTimeSettings settings = settingsList.FirstOrDefault(n => n.GraphType == this.GetType().Name.ToString());

            if (settings == null)
            {
                settings = new GraphDateTimeSettings(this);
            }

            ApplyDateTimeSettings(settings);
        }
예제 #9
0
        private void StoreCalculatedSeries()
        {
            // Load the saved calculated series so we can update it
            var allStoredSeries = LegacySerializer.DeserializeXml <Collection <StoredCalculatedSeries> >(Settings.Default.CalculatedSeries);
            StoredCalculatedSeries storedSeries = allStoredSeries.FirstOrDefault(n => n.SessionId == _sessionId && n.GraphName == this.GraphName);

            if (storedSeries == null)
            {
                storedSeries = new StoredCalculatedSeries(_sessionId, this.GraphName);
                allStoredSeries.Add(storedSeries);
            }
            storedSeries.Series.Clear();
            _calculatedSeries.ForEach(n => storedSeries.Series.Add(n));
            Settings.Default.CalculatedSeries = LegacySerializer.SerializeXml(allStoredSeries).ToString();
            Settings.Default.Save();
        }
예제 #10
0
        /// <summary>
        /// Initializes this instance with the specified object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <exception cref="ControlTypeMismatchException">
        /// Thrown when an object of incorrect type is passed to this instance.
        ///   </exception>
        public override void Initialize(object entity)
        {
            _eventLogCollector = entity as EventLogCollector;
            if (_eventLogCollector == null)
            {
                throw new ControlTypeMismatchException(entity, typeof(EventLogCollector));
            }

            ServerInfo server = ConfigurationServices.AssetInventory.GetServers().FirstOrDefault(n => n.HostName == _eventLogCollector.HostName);

            if (server != null)
            {
                serverComboBox.Initialize(server, "EventLog");
            }
            else
            {
                serverComboBox.Initialize("EventLog");
            }

            platform_ComboBox.SetPlatform(_eventLogCollector.Platform, VirtualResourceType.EventLogCollector);

            // Set up data bindings
            name_TextBox.DataBindings.Add("Text", _eventLogCollector, "Name");
            description_TextBox.DataBindings.Add("Text", _eventLogCollector, "Description");
            platform_ComboBox.DataBindings.Add("SelectedValue", _eventLogCollector, "Platform");

            Binding intervalBinding = new Binding("Text", _eventLogCollector, "PollingInterval");

            intervalBinding.Format += new ConvertEventHandler(IntervalBinding_Format);
            intervalBinding.Parse  += new ConvertEventHandler(IntervalBinding_Parse);
            interval_TextBox.DataBindings.Add(intervalBinding);

            serverComboBox_SelectionChanged(serverComboBox, EventArgs.Empty);
            SelectedComponents = LegacySerializer.DeserializeXml <List <string> >(_eventLogCollector.ComponentsData);
            SelectedEntryTypes = LegacySerializer.DeserializeXml <List <string> >(_eventLogCollector.EntryTypesData);

            if (platform_ComboBox.SelectedIndex == -1) //Default to first item if platform isn't set
            {
                platform_ComboBox.SelectedIndex = 0;
            }

            serverComboBox.SelectionChanged += serverComboBox_SelectionChanged;
        }
예제 #11
0
        /// <summary>
        /// Opens the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        public Collection <QueueInstallationData> Open(string path)
        {
            SaveData saveData = null;

            try
            {
                saveData = LegacySerializer.DeserializeXml <SaveData>(File.ReadAllText(path));
            }
            catch (ArgumentException ex)
            {
                throw new QueueInstallException("Failed top open file", ex);
            }
            catch (IOException ex)
            {
                throw new QueueInstallException("Failed top open file", ex);
            }
            catch (UnauthorizedAccessException ex)
            {
                throw new QueueInstallException("Failed top open file", ex);
            }
            catch (NotSupportedException ex)
            {
                throw new QueueInstallException("Failed top open file", ex);
            }
            catch (SecurityException ex)
            {
                throw new QueueInstallException("Failed top open file", ex);
            }

            _printDrivers.Clear();
            foreach (string key in saveData.LoadedPackages.Keys)
            {
                _printDrivers.Add(key, saveData.LoadedPackages[key]);
            }

            UseConfigurationFile  = saveData.PreConfigure;
            AdditionalDescription = saveData.PreConfigureText;

            return(saveData.InstallData);
        }
예제 #12
0
        private void timeOptions_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Load the serialized settings list
            string serializedSettingsList = Properties.Settings.Default.DateFormats;
            var    settingsList           = LegacySerializer.DeserializeXml <Collection <GraphDateTimeSettings> >(serializedSettingsList);

            // Find the settings that apply to this graph
            GraphDateTimeSettings settings = settingsList.FirstOrDefault(n => n.GraphType == this.GetType().Name.ToString());

            if (settings == null)
            {
                settings = new GraphDateTimeSettings(this);
                settingsList.Add(settings);
            }

            settings.ShowDate  = showDate_ToolStripMenuItem.Checked;
            settings.Use24Hour = use24HourTime_ToolStripMenuItem.Checked;
            settings.ShowAMPM  = showAMPM_ToolStripMenuItem.Checked;

            ApplyDateTimeSettings(settings);
            Properties.Settings.Default.DateFormats = LegacySerializer.SerializeXml(settingsList).ToString();
            Properties.Settings.Default.Save();
        }
예제 #13
0
        public WorkerScheduledExecutionForm(string scheduleXml)
        {
            InitializeComponent();
            UserInterfaceStyler.Configure(this, FormStyle.FixedDialog);
            errorProvider.SetIconAlignment(hourMin_Label, ErrorIconAlignment.MiddleRight);

            if (!string.IsNullOrEmpty(scheduleXml))
            {
                try
                {
                    _bindingList.Clear();
                    _schedule    = LegacySerializer.DeserializeXml <ExecutionSchedule>(scheduleXml);
                    _bindingList = _schedule.BindingList;
                }
                catch (XmlException ex)
                {
                    TraceFactory.Logger.Error("Bad XML in Run Schedule", ex);
                    MessageBox.Show
                    (
                        "Unable to load existing schedule information.",
                        "Load Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                    );
                }
            }
            else
            {
                _schedule = new ExecutionSchedule();
            }

            dataGridViewCheckBoxColumn1.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridViewTextBoxColumn2.HeaderCell.Style.Alignment  = DataGridViewContentAlignment.MiddleCenter;
            dataGridViewTextBoxColumn3.HeaderCell.Style.Alignment  = DataGridViewContentAlignment.MiddleCenter;
            dataGridViewTextBoxColumn4.HeaderCell.Style.Alignment  = DataGridViewContentAlignment.MiddleCenter;
        }
예제 #14
0
        /// <summary>
        /// Requests that the control finalize any edits that have been made by saving
        /// them from the UI controls to their backing objects.
        /// </summary>
        public override void FinalizeEdit()
        {
            // Modify focus so that any data bindings will update
            name_Label.Focus();

            // Update the host name
            _eventLogCollector.HostName = serverComboBox.SelectedServer.HostName;

            // Only assign these properties if the selected values have changed.
            // This will avoid unnecessary "unsaved changes" prompts.
            List <string> originalComponents = LegacySerializer.DeserializeXml <List <string> >(_eventLogCollector.ComponentsData);

            if (!AreEqual(originalComponents, SelectedComponents))
            {
                _eventLogCollector.ComponentsData = LegacySerializer.SerializeXml(SelectedComponents).ToString();
            }

            List <string> originalEntryTypes = LegacySerializer.DeserializeXml <List <string> >(_eventLogCollector.EntryTypesData);

            if (!AreEqual(originalEntryTypes, SelectedEntryTypes))
            {
                _eventLogCollector.EntryTypesData = LegacySerializer.SerializeXml(SelectedEntryTypes).ToString();
            }
        }
예제 #15
0
 /// <summary>
 /// Refreshes monitor configuration for this instance.
 /// </summary>
 /// <param name="monitorConfig"></param>
 public override void RefreshConfig(MonitorConfig monitorConfig)
 {
     _config = LegacySerializer.DeserializeXml <DirectoryMonitorConfig>(monitorConfig.Configuration);
 }
예제 #16
0
 /// <summary>
 /// Refreshes monitor configuration for this instance.
 /// </summary>
 /// <param name="monitorConfig"></param>
 public override void RefreshConfig(MonitorConfig monitorConfig)
 {
     Configuration = LegacySerializer.DeserializeXml <StfMonitorConfig>(monitorConfig.Configuration);
 }
예제 #17
0
        /// <summary>
        /// Runs the Schedule of activities.
        /// </summary>
        public void Run(VirtualResourceInstanceStatusLogger logger)
        {
            var schedule = LegacySerializer.DeserializeXml <ExecutionSchedule>(_workerDetail.ExecutionSchedule);

            _virtualResourceStatusLogger = logger;


            if (schedule.SegmentCount > 0)
            {
                TraceFactory.Logger.Debug("Will process {0} segments in this scheduled execution.".FormatWith(schedule.SegmentCount));
            }
            else
            {
                TraceFactory.Logger.Debug("There are no scheduled items to execute, aborting...");
                Halt();
                return;
            }

            // Start the flow monitor to collect time on any pause events that will be used to adjust the total run time
            _flowControlMonitor.Start();

            // Set the base time in the scheduled execution object as the base time reference.
            schedule.BaseTime = _baseTime;
            TraceFactory.Logger.Debug("Base Time {0}".FormatWith(_baseTime));

            try
            {
                // Handle any startup delay that may occur because there is a staggered startup.
                var endTime = schedule.CalculateInitialEndTime();

                // Begin executing the schedule according to execution type (Repeat or Duration)
                int count = 0;
                if (schedule.UseDuration)
                {
                    TraceFactory.Logger.Debug("Duration execution starting...");

                    TimeSpan totalDuration = new TimeSpan(0, schedule.Duration, 0);

                    var scheduledExpiration = _baseTime.Add(totalDuration);
                    TraceFactory.Logger.Debug("Schedule Expiration at {0}".FormatWith(scheduledExpiration));

                    if (scheduledExpiration < endTime)
                    {
                        TraceFactory.Logger.Debug("Expiration earlier than initial end time, stopping at {0}".FormatWith(scheduledExpiration));

                        // The schedule expiration will hit before the first end time, so just delay
                        // for the expiration period and then return.  Adjust the expiration to account
                        // for any wall clock time lost from the base.
                        TimeSpan lostTime = DateTime.Now - _baseTime;
                        TimeSpan duration = totalDuration - lostTime;

                        _flowControlMonitor.Pause(() => !ExecutionHalted, duration, TimeSpan.FromSeconds(1));
                        return;
                    }
                    else if (endTime > _baseTime)
                    {
                        // Sleep for any startup time that is there because of a stagger setting
                        TimeSpan duration = endTime - DateTime.Now;

                        TraceFactory.Logger.Debug("Initial sleep until {0}".FormatWith(endTime));
                        _flowControlMonitor.Pause(() => !ExecutionHalted, duration, TimeSpan.FromSeconds(1));
                    }

                    // While the endtime is less than the schedule's expiration, execution the next
                    // schedule.  When endTime exceeds the schedules expiration, then we are done.
                    do
                    {
                        // Calculate a new end time based on the previous value and the current schedule iteration
                        TraceFactory.Logger.Debug("End Time {0}".FormatWith(endTime));
                        var scheduleSegment = schedule.CalculateNextEndTime(endTime, count++);

                        endTime = scheduleSegment.Item1;
                        var state = scheduleSegment.Item2;

                        TraceFactory.Logger.Debug("New End Time {0}, State {1}".FormatWith(endTime, state));

                        if (endTime > scheduledExpiration.Add(_flowControlMonitor.PauseTime))
                        {
                            endTime = scheduledExpiration.Add(_flowControlMonitor.PauseTime);
                            TraceFactory.Logger.Debug("End time later than Schedule Expiration");
                        }

                        RunSchedule(state, endTime);

                        // Include any pause time that has accumulated during the run to ensure the
                        // test runs the for the full duration.
                    } while (endTime < scheduledExpiration.Add(_flowControlMonitor.PauseTime));

                    TraceFactory.Logger.Debug("Duration execution complete");
                }
                else
                {
                    TraceFactory.Logger.Debug("Repeat Count execution starting...");

                    if (endTime > _baseTime)
                    {
                        // Sleep for any startup time that is there because of a stagger setting
                        TimeSpan duration = endTime - DateTime.Now;

                        TraceFactory.Logger.Debug("Initial sleep until {0}".FormatWith(endTime));
                        _flowControlMonitor.Pause(() => !ExecutionHalted, duration, TimeSpan.FromSeconds(1));
                    }

                    // Execute each segment until the total repeat count is met, which is the
                    // number of segments x repeat count.
                    do
                    {
                        endTime = endTime + _flowControlMonitor.PauseTime;

                        var scheduleSegment = schedule.CalculateNextEndTime(endTime, count++);
                        endTime = scheduleSegment.Item1;
                        var state = scheduleSegment.Item2;
                        TraceFactory.Logger.Debug("State: " + state + " , Endtime: " + endTime);
                        RunSchedule(state, endTime);
                        TraceFactory.Logger.Debug(count + " of " + schedule.TotalIterations);
                    } while (count < schedule.TotalIterations);

                    TraceFactory.Logger.Debug("Repeat Count execution complete");
                }
            }
            catch (WorkerHaltedException ex)
            {
                TraceFactory.Logger.Debug(ex.Message);
                return;
            }
        }