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); }
/// <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); } }
/// <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); } }
/// <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; } }
/// <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()); }
/// <summary> /// Loads and Exports the MetadataTypeInstallerContract using the specified MetadataType name. /// </summary> /// <param name="metadataTypeName">The MetadataType name.</param> /// <param name="filePath">The file path.</param> public void Export(string metadataTypeName, string filePath) { Load(metadataTypeName); File.WriteAllText(filePath, LegacySerializer.SerializeDataContract(this).ToString()); }
protected virtual string GetExecutionPlan(ResourceMetadataDetail detail) { return(LegacySerializer.SerializeDataContract((WorkerExecutionPlan)detail.Plan).ToString()); }
/// <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(); foreach (UserGroup item in editorGroups_CheckedListBox.CheckedItems.Cast <UserGroup>()) { if (!_scenario.UserGroups.Any(x => x.GroupName.Equals(item.GroupName))) { var group = Context.UserGroups.FirstOrDefault(x => x.GroupName.Equals(item.GroupName)); if (group != null) { _scenario.UserGroups.Add(group); } } } Collection <UserGroup> removeList = new Collection <UserGroup>(); foreach (UserGroup item in _scenario.UserGroups) { if (!editorGroups_CheckedListBox.CheckedItems.Cast <UserGroup>().Any(x => x.GroupName.Equals(item.GroupName))) { removeList.Add(item); } } foreach (var group in removeList) { _scenario.UserGroups.Remove(group); } if (string.IsNullOrEmpty(_scenario.ScenarioSettings)) { _settings = new ScenarioSettings(); } if (_modified) { //Grab data from combo boxes, create settings, serialize _settings.EstimatedRunTime = (int)runtime_NumericUpDown.Value; _settings.TargetCycle = sessionCycle_ComboBox.Text; _settings.NotificationSettings.CollectDartLogs = dartLog_CheckBox.Checked; _settings.NotificationSettings.Emails = email_textBox.Text; _settings.NotificationSettings.FailureCount = (int)threshold_comboBox.SelectedValue; _settings.NotificationSettings.TriggerList = triggerList_TextBox.Lines; _settings.NotificationSettings.FailureTime = (TimeSpan)failureTime_comboBox.SelectedValue; _settings.LogLocation = logLocation_TextBox.Text; _settings.CollectEventLogs = eventLog_CheckBox.Checked; _settings.ScenarioCustomDictionary = _scenarioCustomDictionary; _scenario.ScenarioSettings = LegacySerializer.SerializeDataContract(_settings).ToString(); } //_scenarioProducts = scenarioProductBindingSource.DataSource as IEnumerable<ScenarioProduct>; using (EnterpriseTestContext context = new EnterpriseTestContext()) { for (int i = 0; i < associatedProducts_DataGrid.Rows.Count; i++) { ScenarioProduct prod = associatedProducts_DataGrid.Rows[i].DataBoundItem as ScenarioProduct; prod.Update(context); } //foreach (var product in _scenarioProducts) //{ // product.Update(context); //} } //_associateProductHandler.SaveData(_scenario.EnterpriseScenarioId, this.associatedProducts_DataGrid); }
protected override string GetExecutionPlan(ResourceMetadataDetail detail) { return(LegacySerializer.SerializeDataContract((LoadTesterExecutionPlan)detail.Plan).ToString()); }