示例#1
0
        /// <summary>
        /// Loads all data from the database required to build the manifests for this Scenario so that
        /// properties like Resources and Quantities can be evaluated before the actual building of the manifests.
        /// </summary>
        private void Initialize()
        {
            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                TraceFactory.Logger.Debug($"Loading all resources for scenarioId: {ScenarioId}");

                // Get the enabled VirtualResources but filter out any disabled items from the VirtualResourceMetadataSet
                var resources = EnterpriseScenario.SelectWithAllChildren(context, ScenarioId)?.VirtualResources.Where(e => e.Enabled);
                if (resources == null || !resources.Any())
                {
                    //No reason to continue if there are no resources
                    return;
                }

                foreach (var resource in resources)
                {
                    var temp = resource.VirtualResourceMetadataSet.Where(x => x.Enabled).ToList();
                    resource.VirtualResourceMetadataSet.Clear();
                    temp.ForEach(resource.VirtualResourceMetadataSet.Add);
                }
                Resources = resources;

                ManifestSet.ScenarioId   = ScenarioId;
                ManifestSet.ScenarioName = EnterpriseScenario.Select(context, ScenarioId).Name;

                Quantities = new SessionResourceQuantity(Resources);
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SystemManifestAgent" /> class.
 /// </summary>
 /// <param name="ticket">The session configuration.</param>
 /// <param name="scenarioId">The scenarioId from which to build the manifest(s).</param>
 public SystemManifestAgent(SessionTicket ticket, Guid scenarioId)
 {
     Ticket      = ticket;
     ScenarioId  = scenarioId;
     Assets      = new List <AssetDetail>();
     DataCache   = new DataModelCache();
     Quantities  = new SessionResourceQuantity();
     ManifestSet = new SystemManifestCollection();
     _agents     = new List <IManifestComponentAgent>()
     {
         new ManifestAssetAgent(ScenarioId),
         new ManifestDocumentAgent(ScenarioId),
         new ManifestServerAgent(ScenarioId),
         new ManifestPrintQueueAgent(ScenarioId),
         new ManifestRetrySettingsAgent(ScenarioId),
         new ManifestSettingsAgent(),
         new ManifestPluginAssembliesAgent()
     };
     Initialize();
 }
        /// <summary>
        /// Loads based on the specified user and Hold Id.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="role">The role.</param>
        public void Load(UserCredential user, string holdId)
        {
            SessionResourceQuantity quantity = GetQuantities(Scenario);

            using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
            {
                foreach (string platformId in quantity.MachineQuantity.Keys)
                {
                    FrameworkClientPlatform platform = context.FrameworkClientPlatforms.FirstOrDefault(x => x.FrameworkClientPlatformId.Equals(platformId));
                    int count = VirtualMachine.GetUsageCountByHold(platformId, holdId, user);

                    var usage = new ScenarioPlatformUsage()
                    {
                        PlatformId      = platformId,
                        Description     = platform.Name,
                        RequiredCount   = quantity.MachineQuantity[platformId],
                        AuthorizedCount = count
                    };

                    Add(usage);
                }
            }
        }
        /// <summary>
        /// Loads based on the specified user and Platform.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="role">The user role (User, Admin, etc.).</param>
        /// <param name="platform">The virtual machine platform.</param>
        public void Load(UserCredential user, FrameworkClientPlatform platform)
        {
            SessionResourceQuantity quantity = GetQuantities(Scenario);

            int requiredCount = 0;

            if (quantity.MachineQuantity.ContainsKey(platform.FrameworkClientPlatformId))
            {
                requiredCount = quantity.MachineQuantity[platform.FrameworkClientPlatformId];
            }

            int count = VirtualMachine.GetUsageCountByPlatform(platform.FrameworkClientPlatformId, user);

            var usage = new ScenarioPlatformUsage()
            {
                PlatformId      = platform.FrameworkClientPlatformId,
                Description     = platform.Name,
                RequiredCount   = requiredCount,
                AuthorizedCount = count
            };

            Add(usage);
        }