/// <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);
        }
        /// <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;
        }
Ejemplo n.º 3
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++));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Dumps the subscribers list to a data file.
        /// </summary>
        public void SaveSubscriberData()
        {
            try
            {
                if (File.Exists(_dumpFile))
                {
                    File.Delete(_dumpFile);
                    TraceFactory.Logger.Debug("Deleted {0}".FormatWith(_dumpFile));
                }

                lock (_lock)
                {
                    if (_subscribers.Count > 0)
                    {
                        File.WriteAllText(_dumpFile, LegacySerializer.SerializeDataContract(_subscribers).ToString());
                        TraceFactory.Logger.Debug("Wrote out data for {0} subscribers".FormatWith(_subscribers.Count));
                    }
                    else
                    {
                        TraceFactory.Logger.Debug("Nothing to save...");
                    }
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Unable to dump subscribers", ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Saves the session data to a local cache.
        /// </summary>
        public void SessionDataSave()
        {
            TraceFactory.Logger.Debug("Saving proxy references and subscribers");
            EventPublisher.SaveSubscriberData();

            // Attempt to dump a cache file of the currently active sessions
            try
            {
                if (File.Exists(_backupFile))
                {
                    File.Delete(_backupFile);
                    TraceFactory.Logger.Debug("deleted {0}".FormatWith(_backupFile));
                }

                if (_proxyControllers.SessionIds.Count() > 0)
                {
                    File.WriteAllText(_backupFile, LegacySerializer.SerializeDataContract(_proxyControllers).ToString());
                    TraceFactory.Logger.Debug("Wrote out {0} proxy entries".FormatWith(_proxyControllers.SessionIds.Count()));
                }
                else
                {
                    TraceFactory.Logger.Debug("Nothing to save...");
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Failed to write cache file", ex);
            }
        }
Ejemplo n.º 6
0
        private VirtualResource CreateExpandedResource(Collection <ExpandedResourceMetadata> expandedData, int index)
        {
            // First clone this Load Tester resource, then clear it's metadata set.
            VirtualResource resource = this.Clone <LoadTester>();

            resource.VirtualResourceMetadataSet.Clear();

            resource.Name = "{0} [{1}]".FormatWith(resource.Name, index);

            // For each entry in the expanded set, get the metadata item from "this" by the id
            // in the expanded set item, clone it, then update the thread count to the value
            // in the expanded set item, then add the new metadata item to the resource.  Do
            // this for all items in the expanded data.  Then return the resource.
            foreach (var item in expandedData)
            {
                var metadata = VirtualResourceMetadataSet.First(x => x.VirtualResourceMetadataId == item.Id).Clone();

                // Update the execution plan with the correct number of threads and update it with
                // the property thread ramp up information.
                var plan = LegacySerializer.DeserializeDataContract <LoadTesterExecutionPlan>(metadata.ExecutionPlan);
                plan.ThreadCount = item.ThreadCount;

                plan.RampUpSettings = new Collection <RampUpSetting>();
                foreach (var setting in item.RampUpSettings)
                {
                    plan.RampUpSettings.Add(setting);
                }
                metadata.ExecutionPlan = LegacySerializer.SerializeDataContract(plan).ToString();
                resource.VirtualResourceMetadataSet.Add(metadata);
            }

            return(resource);
        }
 private static void AddMetadataIfMissing(VirtualResource reservation)
 {
     if (reservation.VirtualResourceMetadataSet.Count == 0)
     {
         var resourceType = VirtualResourceType.MachineReservation.ToString();
         var metadata     = new VirtualResourceMetadata(resourceType, resourceType);
         metadata.Metadata = LegacySerializer.SerializeXml(new MachineReservationMetadata()).ToString();
         reservation.VirtualResourceMetadataSet.Add(metadata);
     }
 }
        private void addCounter_ToolStripButton_Click(object sender, EventArgs e)
        {
            if (ValidateSelection())
            {
                PerfMonCounterData tempCounterData = new PerfMonCounterData();

                if (_loadFromMachine)
                {
                    PerformanceCounter selectedCounter = SelectedCounter as PerformanceCounter;
                    tempCounterData.Category     = selectedCounter.CategoryName;
                    tempCounterData.Counter      = selectedCounter.CounterName;
                    tempCounterData.InstanceName = selectedCounter.InstanceName;
                }
                else
                {
                    string selectedInstance = SelectedInstance;
                    tempCounterData.Category = SelectedCategory.ToString();
                    tempCounterData.Counter  = ((ResourceWindowsCategory)SelectedCounter).Name;
                    /// Don't insert "N/A" into the counter data, use empty string instead.
                    tempCounterData.InstanceName = (selectedInstance == PerfMonController.InstanceDoesNotApply) ? string.Empty : selectedInstance;
                }

                tempCounterData.TargetHost = _selectedServer.HostName;

                //if the user has entered the username and password then use it
                if (!string.IsNullOrEmpty(userName_textBox.Text) || !string.IsNullOrEmpty(password_textBox.Text))
                {
                    tempCounterData.Credentials = new PerfMonCounterCredential(userName_textBox.Text, password_textBox.Text, string.IsNullOrEmpty(domain_textBox.Text) ? "." : domain_textBox.Text);
                }
                else
                {
                    tempCounterData.Credentials = new PerfMonCounterCredential();
                }

                tempCounterData.Interval = interval_TimeSpanControl.Value.TotalMilliseconds;

                VirtualResourceMetadata tempMetaData = new VirtualResourceMetadata(VirtualResourceType.PerfMonCollector.ToString(), "PerfMonCounter");

                //associate the GUID of the tempMetaData to the perfmoncounterdata item
                tempCounterData.VirtualResourceMetadataId = tempMetaData.VirtualResourceMetadataId;

                tempMetaData.VirtualResourceId = _perfMonCollector.VirtualResourceId;
                tempMetaData.Name = tempCounterData.TargetHost + "-" + tempCounterData.Category + "/" + tempCounterData.InstanceName + "/" + tempCounterData.Counter;
                string metadataxml = LegacySerializer.SerializeXml(tempCounterData).ToString();
                tempMetaData.Metadata = metadataxml;

                //we are not currently connected to DB or using the existing data, so add this to the virtual resource metadata collection
                _perfMonCollector.VirtualResourceMetadataSet.Add(tempMetaData);
                _perfMonCollector.Platform = (string)platform_ComboBox.SelectedValue;

                //populate the listview in the newly added item
                _selectedCountersDataList.Add(tempCounterData);
            }
        }
Ejemplo n.º 9
0
 public ScenarioSelectionItem(EnterpriseScenario scenario)
 {
     ScenarioId       = scenario.EnterpriseScenarioId;
     Name             = scenario.Name;
     EstimatedRunTime = scenario.EstimatedRuntime;
     // ScenarioSettings override the default
     if (!string.IsNullOrEmpty(scenario.ScenarioSettings))
     {
         ScenarioSettings settings = LegacySerializer.DeserializeDataContract <ScenarioSettings>(scenario.ScenarioSettings);
         EstimatedRunTime = settings.EstimatedRunTime;
     }
 }
Ejemplo n.º 10
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();
            }
        }
Ejemplo n.º 12
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);
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Loads the session data from a local cache
        /// </summary>
        public void SessionDataLoad()
        {
            TraceFactory.Logger.Debug("Loading proxy references and subscribers");
            EventPublisher.LoadSubscriberData();

            // If there is a proxy entries cache file, load it and process it.
            if (File.Exists(_backupFile))
            {
                TraceFactory.Logger.Debug("Cache file exists, loading");
                var proxies = LegacySerializer.DeserializeDataContract <SessionProxyControllerSet>(File.ReadAllText(_backupFile));

                // If the number of entries is greater than the max, then we need to adjust
                // the max to account for all entries.
                if (proxies.Count > _proxyControllers.Maximum)
                {
                    _proxyControllers = new SessionProxyControllerSet(proxies.Count);
                }

                // Create a new entry in the proxie entries and then tell the proxy
                // entry to refresh all subscribers.
                foreach (var proxy in proxies.Values)
                {
                    try
                    {
                        proxy.Channel.Ping();
                        _proxyControllers.Add(proxy);
                        TraceFactory.Logger.Debug("Endpoint reloaded for {0}".FormatWith(proxy.SessionId));
                    }
                    catch (EndpointNotFoundException ex)
                    {
                        TraceFactory.Logger.Debug("Endpoint skipped for {0}:{1}".FormatWith(proxy.SessionId, ex.Message));
                    }
                }

                try
                {
                    File.Delete(_backupFile);
                    TraceFactory.Logger.Debug("deleted {0}".FormatWith(_backupFile));
                }
                catch (Exception ex)
                {
                    TraceFactory.Logger.Error("Error deleting saved proxies file", ex);
                }
            }
            else
            {
                TraceFactory.Logger.Debug("Nothing to load...");
            }
        }
        /// <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");
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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();
        }
Ejemplo n.º 17
0
        protected void CreateMetadataDetail(VirtualResource resource, ResourceDetailBase detail)
        {
            Dictionary <int, OfficeWorkerMetadataDetail> orderedDetails = new Dictionary <int, OfficeWorkerMetadataDetail>();

            foreach (var data in resource.VirtualResourceMetadataSet)
            {
                OfficeWorkerMetadataDetail metadata = new OfficeWorkerMetadataDetail()
                {
                    MetadataType = data.MetadataType,
                    Data         = data.Metadata,

                    Plan = data.ExecutionPlan != null
                        ? LegacySerializer.DeserializeDataContract <WorkerExecutionPlan>(data.ExecutionPlan)
                        : new WorkerExecutionPlan(),

                    Id              = data.VirtualResourceMetadataId,
                    Name            = data.Name,
                    MetadataVersion = data.MetadataVersion,
                    Enabled         = data.Enabled,
                };

                // Offset the key by 100, this is a bunch but it will guarantee (or should) that
                // if for some reason the same order number exists in two plans that they
                // won't conflict.  While the ordered list contains the key, it will keep
                // adding one until it's found an open spot.  Using 100 means we could have up
                // to 100 entries with the same order number and still resolve them.  Of course this
                // doesn't guarantee any ultimate order to the metadata, but in most cases when
                // the order value is unique, this will just ensure the items are added in numerical
                // order so that the serialized XML shows them in order as well.
                int key = metadata.Plan.Order * 100;

                while (orderedDetails.ContainsKey(key))
                {
                    key++;
                }
                orderedDetails.Add(key, metadata);
            }

            // Add the metadata to the manifest in order so that the XML shows them in order.
            foreach (int key in orderedDetails.Keys.OrderBy(x => x))
            {
                detail.MetadataDetails.Add(orderedDetails[key]);
            }
        }
Ejemplo n.º 18
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;
        }
Ejemplo n.º 19
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_TextBox.Focus();

            // Push the configuration data into the ExecutionPlan property of the metadata
            foreach (var item in _loadTester.VirtualResourceMetadataSet)
            {
                if (string.IsNullOrEmpty(item.ExecutionPlan))
                {
                    var configItem = _configurations.FirstOrDefault(e => e.Metadata.VirtualResourceMetadataId == item.VirtualResourceMetadataId);
                    if (configItem != null)
                    {
                        item.ExecutionPlan = LegacySerializer.SerializeDataContract(configItem.ExecutionPlan).ToString();
                    }
                }
                else
                {
                    // Entity Framework handles all situations where no fields have changed, except serialized XML.
                    // So to ensure this form doesn't think something has changed when it hasn't, only update
                    // the serialized XML if there is actually a change.
                    XDocument oldPlan = XDocument.Parse(item.ExecutionPlan);

                    var configItem = _configurations.FirstOrDefault(e => e.Metadata.VirtualResourceMetadataId == item.VirtualResourceMetadataId);
                    if (configItem != null)
                    {
                        string    serializedPlan = LegacySerializer.SerializeDataContract(configItem.ExecutionPlan).ToString();
                        XDocument newPlan        = XDocument.Parse(serializedPlan);

                        if (!XmlUtil.AreEqual(oldPlan, newPlan, orderInvariant: true))
                        {
                            item.ExecutionPlan = serializedPlan;
                        }
                    }
                }
            }

            if (GlobalSettings.IsDistributedSystem)
            {
                // Need to grab the platform directly from the combobox
                _loadTester.Platform = ((FrameworkClientPlatform)virtualMachinePlatform_ComboBox.SelectedItem).FrameworkClientPlatformId;
            }
        }
Ejemplo n.º 20
0
        private void CreateMetadataDetail(VirtualResource resource, ResourceDetailBase detail)
        {
            foreach (var data in resource.VirtualResourceMetadataSet.Where(m => m.Enabled))
            {
                LoadTesterMetadataDetail metadata = new LoadTesterMetadataDetail()
                {
                    MetadataType = data.MetadataType,
                    Data         = data.Metadata,

                    Plan = data.ExecutionPlan != null
                        ? LegacySerializer.DeserializeDataContract <LoadTesterExecutionPlan>(data.ExecutionPlan)
                        : new LoadTesterExecutionPlan(),

                    Id              = data.VirtualResourceMetadataId,
                    Name            = data.Name,
                    MetadataVersion = data.MetadataVersion,
                    Enabled         = data.Enabled,
                };
                detail.MetadataDetails.Add(metadata);
            }
        }
Ejemplo n.º 21
0
        private void importToolStripButton_Click(object sender, EventArgs e)
        {
            using (var dialog = new ExportOpenFileDialog(_directory, "Open STB Device Export File", ImportExportType.Printer))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var file = dialog.Base.FileName;
                    _directory = Path.GetDirectoryName(file);

                    using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
                    {
                        var contracts = LegacySerializer.DeserializeDataContract <AssetContractCollection <PrinterContract> >(File.ReadAllText(file));
                        foreach (var contract in contracts)
                        {
                            var printer = ContractFactory.Create(contract, context);
                            AddPrinter(printer);
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
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)
        {
            _adminWorker = entity as AdminWorker;
            if (_adminWorker == null)
            {
                throw new ControlTypeMismatchException(entity, typeof(AdminWorker));
            }

            // Load the configurations into the helper class
            foreach (var item in _adminWorker.VirtualResourceMetadataSet)
            {
                WorkerExecutionPlan plan = null;
                if (item.ExecutionPlan == null)
                {
                    plan = new WorkerExecutionPlan();
                }
                else
                {
                    plan = LegacySerializer.DeserializeDataContract <WorkerExecutionPlan>(item.ExecutionPlan);
                }

                _mainConfigurations.Add(new WorkerActivityConfiguration(item, plan));
            }

            // Load the activities into the binding list
            activity_TabControl.SelectTab(main_TabPage);
            _selectedPhase = ResourceExecutionPhase.Main;
            activity_GridView.BestFitColumns();

            // Set up data bindings
            name_TextBox.DataBindings.Add("Text", _adminWorker, "Name");
            description_TextBox.DataBindings.Add("Text", _adminWorker, "Description");

            platform_ComboBox.SetPlatform(_adminWorker.Platform, VirtualResourceType.AdminWorker);
            testcaseid_numericUpDown.Value = _adminWorker.TestCaseId;
            ConfigureEnableAllButton();
            CreateActivityDropDownMenu();

            RefreshGrid();
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
0
        private void importToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                using (var dialog = new ExportOpenFileDialog(_directory, "Open Test Document Export File", ImportExportType.Document))
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        var file = dialog.Base.FileName;
                        _directory = Path.GetDirectoryName(file);

                        var contracts = LegacySerializer.DeserializeDataContract <DocumentContractCollection>(File.ReadAllText(file));

                        foreach (var contract in contracts)
                        {
                            if (!_context.TestDocuments.Any(x => x.FileName.Equals(contract.FileName, StringComparison.OrdinalIgnoreCase)))
                            {
                                var document = ContractFactory.Create(_context, contract);
                                _importedDocumentData.Add(document.TestDocumentId, contract.Data);
                                AddDocument(document);
                            }
                            else
                            {
                                // Log an error for the current file, but keep going
                                TraceFactory.Logger.Debug("Document already exists: {0}".FormatWith(contract.FileName));
                            }
                        }

                        MessageBox.Show("Documents have been imported", "Import Documents", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error(ex);
                MessageBox.Show("Error importing document: {0}. Check log file for more details.".FormatWith(ex.Message));
            }
        }
Ejemplo n.º 25
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();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Loads the subscribers list from a data file.
        /// </summary>
        public void LoadSubscriberData()
        {
            if (!File.Exists(_dumpFile))
            {
                TraceFactory.Logger.Debug("Nothing to load...");
                return;
            }

            lock (_lock)
            {
                _subscribers = LegacySerializer.DeserializeDataContract <Collection <Uri> >(File.ReadAllText(_dumpFile));
            }

            TraceFactory.Logger.Debug("Loaded {0} subscribers".FormatWith(_subscribers.Count));
            try
            {
                File.Delete(_dumpFile);
                TraceFactory.Logger.Debug("Deleted {0}".FormatWith(_dumpFile));
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Error deleting saved subscriber file", ex);
            }
        }
Ejemplo n.º 27
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;
        }
Ejemplo n.º 28
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();
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Exports the AssetContractCollection to a file with the specified file name.
 /// </summary>
 /// <param name="fileName"></param>
 public void Export(string fileName)
 {
     File.WriteAllText(fileName, LegacySerializer.SerializeDataContract(this).ToString());
 }
        private void LoadComboBoxes(EnterpriseTestContext context)
        {
            sessionName_ComboBox.DataSource    = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionName.ToString());
            sessionName_ComboBox.SelectedIndex = -1;
            sessionType_ComboBox.DataSource    = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionType.ToString());
            sessionType_ComboBox.SelectedIndex = -1;
            sessionCycle_ComboBox.DataSource   = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionCycle.ToString());


            retention_ComboBox.DataSource    = SessionLogRetentionHelper.ExpirationList;
            retention_ComboBox.SelectedIndex = retention_ComboBox.FindString(EnumUtil.GetDescription(WizardPageManager.GetDefaultLogRetention()));

            Dictionary <string, int> failureItems = new Dictionary <string, int>();
            List <TimeSpan>          failTimes    = new List <TimeSpan>();

            using (AssetInventoryContext assetContext = DbConnect.AssetInventoryContext())
            {
                string powerState   = EnumUtil.GetDescription(VMPowerState.PoweredOff);
                var    availableVMs = assetContext.FrameworkClients.Where(n => n.PowerState == powerState);

                platform_ComboBox.DataSource = null;
                platform_ComboBox.Items.Clear();
                platform_ComboBox.DisplayMember = "Name";
                platform_ComboBox.ValueMember   = "FrameworkClientPlatformId";
                platform_ComboBox.DataSource    = assetContext.FrameworkClientPlatforms.Where(n => n.Active).OrderBy(n => n.FrameworkClientPlatformId).ToList();

                holdId_ComboBox.DataSource = null;
                holdId_ComboBox.Items.Clear();
                holdId_ComboBox.DataSource = availableVMs.Select(n => n.HoldId).Distinct().Where(n => n != null).ToList();
            }
            failureItems.Add("1 Failure", 1);
            failureItems.Add("2 Failures", 2);
            failureItems.Add("5 Failures", 5);
            failureItems.Add("10 Failures", 10);
            failureItems.Add("15 Failures", 15);
            failureItems.Add("20 Failures", 20);

            threshold_comboBox.DataSource    = new BindingSource(failureItems, null);
            threshold_comboBox.DisplayMember = "Key";
            threshold_comboBox.ValueMember   = "Value";

            failTimes.Add(TimeSpan.FromMinutes(15));
            failTimes.Add(TimeSpan.FromMinutes(30));
            failTimes.Add(TimeSpan.FromHours(1));
            failTimes.Add(TimeSpan.FromHours(2));
            failTimes.Add(TimeSpan.FromHours(6));
            failTimes.Add(TimeSpan.FromHours(12));
            failureTime_comboBox.DataSource = new BindingSource(failTimes, null);


            if (Ticket.SessionId != null && _scenario != null)
            {
                if (!string.IsNullOrEmpty(_scenario.ScenarioSettings))
                {
                    var scenarioSettings = LegacySerializer.DeserializeDataContract <ScenarioSettings>(_scenario.ScenarioSettings);
                    //Populate boxes from selected settings
                    dartLog_CheckBox.Checked           = scenarioSettings.NotificationSettings.CollectDartLogs;
                    email_textBox.Text                 = scenarioSettings.NotificationSettings.Emails;
                    failureTime_comboBox.SelectedIndex = failTimes.FindIndex(x => x == scenarioSettings.NotificationSettings.FailureTime);
                    threshold_comboBox.SelectedIndex   = failureItems.ToList().FindIndex(x => x.Value == scenarioSettings.NotificationSettings.FailureCount);
                    triggerList_TextBox.Lines          = scenarioSettings.NotificationSettings.TriggerList;
                    runtime_NumericUpDown.Value        = Math.Min(scenarioSettings.EstimatedRunTime, runtime_NumericUpDown.Maximum); // scenarioSettings.EstimatedRunTime;
                    logLocation_TextBox.Text           = scenarioSettings.LogLocation;
                    eventLog_CheckBox.Checked          = scenarioSettings.CollectEventLogs;
                }

                sessionName_ComboBox.Text = string.IsNullOrEmpty(Ticket.SessionName) ? _scenario.Name : Ticket.SessionName;
            }

            //TraceFactory.Logger.Debug($"initial:{_initial}");
            if (!_initial)
            {
                sessionType_ComboBox.SelectedText   = Ticket.SessionType;
                sessionCycle_ComboBox.SelectedIndex = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionCycle.ToString()).Select(x => x.Name).ToList().IndexOf(Ticket.SessionCycle);


                //TraceFactory.Logger.Debug($"email:{_ticket.EmailAddresses}");
                if (!string.IsNullOrEmpty(Ticket.EmailAddresses))
                {
                    dartLog_CheckBox.Checked           = Ticket.CollectDARTLogs;
                    email_textBox.Text                 = Ticket.EmailAddresses;
                    failureTime_comboBox.SelectedIndex = failTimes.FindIndex(x => x == Ticket.FailureTime);
                    threshold_comboBox.SelectedIndex   = failureItems.ToList().FindIndex(x => x.Value == Ticket.FailureCount);
                    triggerList_TextBox.Lines          = Ticket.TriggerList;
                    runtime_NumericUpDown.Value        = Math.Min(Ticket.DurationHours, runtime_NumericUpDown.Maximum);
                    eventLog_CheckBox.Checked          = Ticket.CollectEventLogs;
                    email_textBox.Text                 = Ticket.EmailAddresses;
                }
                if (Ticket.FailureTime != TimeSpan.MaxValue)
                {
                    failureTime_comboBox.SelectedIndex = failTimes.FindIndex(x => x == Ticket.FailureTime);
                }
                if (Ticket.FailureCount != -1)
                {
                    threshold_comboBox.SelectedIndex = failureItems.ToList().FindIndex(x => x.Value == Ticket.FailureCount);
                }
                if (!string.IsNullOrEmpty(Ticket.LogLocation))
                {
                    logLocation_TextBox.Text = Ticket.LogLocation;
                }
                if (Ticket.TriggerList != null)
                {
                    triggerList_TextBox.Lines = Ticket.TriggerList;
                }
                dartLog_CheckBox.Checked    = Ticket.CollectDARTLogs;
                eventLog_CheckBox.Checked   = Ticket.CollectEventLogs;
                runtime_NumericUpDown.Value = Math.Min(Ticket.DurationHours, runtime_NumericUpDown.Maximum);
            }
        }