Exemple #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="ManifestServerAgent"/> class.
        /// </summary>
        /// <param name="scenarioId"></param>
        public ManifestServerAgent(Guid scenarioId)
        {
            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                // Retrieve server usage data for all enabled activities in the specified session
                var activities = (from serverusage in context.VirtualResourceMetadataServerUsages
                                  let data = serverusage.ServerSelectionData
                                             let metadata = serverusage.VirtualResourceMetadata
                                                            let resource = metadata.VirtualResource
                                                                           where resource.EnterpriseScenarioId == scenarioId &&
                                                                           resource.Enabled == true &&
                                                                           metadata.Enabled == true &&
                                                                           data != null
                                                                           select new { Id = metadata.VirtualResourceMetadataId, Servers = data }).ToList();

                foreach (var activity in activities)
                {
                    ServerSelectionData serverSelectionData = GetSelectionData(activity.Servers);
                    _activityServers.Add(activity.Id, GetServerIds(serverSelectionData));
                }
            }

            var serverIds = _activityServers.Values.SelectMany(n => n).Distinct().ToList();

            using (AssetInventoryContext assetContext = DbConnect.AssetInventoryContext())
            {
                _servers.AddRange(assetContext.FrameworkServers.Where(n => serverIds.Contains(n.FrameworkServerId)).ToServerInfoCollection());
            }
        }
        private void ApplyButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (MetadataTreeView.SelectedItem == null || (string.IsNullOrEmpty(MetadataMemberTextBox.Text) && MetadataMemberCombobox.SelectedIndex == -1))
            {
                return;
            }

            var selectedTreeNode = MetadataTreeView.SelectedItem as TreeNode;

            if (selectedTreeNode == null)
            {
                return;
            }

            //if the user has selected the class item, just skip and go back
            if (selectedTreeNode.IsClass)
            {
                return;
            }

            if (selectedTreeNode.EnumValueCollection.Count == 0)
            {
                if (!ValidateInput(MetadataMemberTextBox.Text, selectedTreeNode.PropertyType))
                {
                    MessageBox.Show($"Entered data does not match required type. Please enter the data of format {selectedTreeNode.PropertyType}", ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            selectedTreeNode.Text     = selectedTreeNode.EnumValueCollection.Count > 0 ? MetadataMemberCombobox.SelectedItem.ToString() : MetadataMemberTextBox.Text;
            selectedTreeNode.Modified = true;

            Dictionary <string, string> pluginChangeDictionary;

            _pluginChangesDictionary.TryGetValue(PluginComboBox.Text, out pluginChangeDictionary);

            if (pluginChangeDictionary == null || pluginChangeDictionary.Count == 0)
            {
                pluginChangeDictionary =
                    new Dictionary <string, string> {
                    { selectedTreeNode.Name, selectedTreeNode.Text }
                };
            }
            else
            {
                pluginChangeDictionary[selectedTreeNode.Name] = selectedTreeNode.Text;
            }

            if (_stfServerComboBox.HasSelection)
            {
                var serverSelection = new ServerSelectionData(_stfServerComboBox.SelectedServer);
                pluginChangeDictionary["FrameworkServer"] = Serializer.Serialize(serverSelection).ToString();
            }

            _pluginChangesDictionary[PluginComboBox.Text] = pluginChangeDictionary;
        }
            private static string GetServerDisplayString(PluginConfigurationData configurationData)
            {
                ServerSelectionData servers = configurationData.Servers;

                if (servers?.SelectedServers?.Count > 0)
                {
                    return($"Servers: {servers.SelectedServers.Count} selected");
                }
                else
                {
                    return(null);
                }
            }
Exemple #4
0
        /// <summary>
        /// Transforms <see cref="ServerSelectionData" /> from a <see cref="PluginConfigurationData" /> object into the corresponding
        /// <see cref="ServerInfoCollection" /> using data from the specified <see cref="IAssetInventory" />.
        /// </summary>
        /// <param name="configurationData">The <see cref="PluginConfigurationData" />.</param>
        /// <param name="assetInventory">The <see cref="IAssetInventory" />.</param>
        /// <returns>A <see cref="ServerInfoCollection" /> object.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="configurationData" /> is null.
        /// <para>or</para>
        /// <paramref name="assetInventory" /> is null.
        /// </exception>
        public static ServerInfoCollection GetExecutionServers(PluginConfigurationData configurationData, IAssetInventory assetInventory)
        {
            if (configurationData == null)
            {
                throw new ArgumentNullException(nameof(configurationData));
            }

            if (assetInventory == null)
            {
                throw new ArgumentNullException(nameof(assetInventory));
            }

            ServerSelectionData serverSelectionData = configurationData.Servers ?? new ServerSelectionData();
            var selectedServers = assetInventory.GetServers().Where(n => serverSelectionData.SelectedServers.Contains(n.ServerId));

            return(new ServerInfoCollection(selectedServers.ToList()));
        }
Exemple #5
0
 private static ServerIdCollection GetServerIds(ServerSelectionData selectionData)
 {
     return(new ServerIdCollection(selectionData.SelectedServers));
 }