Example #1
0
        /// <summary>
        /// Loads the specified VirtualResourceDetail into the specified EnterpriseScenario.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="scenario">The <see cref="EnterpriseScenario"/></param>
        /// <param name="detail">The metadata detail</param>
        public void LoadDetail <T>(EnterpriseScenario scenario, T detail) where T : ResourceDetailBase
        {
            VirtualResourceId    = SequentialGuid.NewGuid();
            EnterpriseScenario   = scenario;
            EnterpriseScenarioId = scenario.EnterpriseScenarioId;
            ResourceType         = detail.ResourceType.ToString();
            Name          = detail.Name;
            Description   = detail.Description;
            InstanceCount = detail.InstanceCount;
            Platform      = detail.Platform;
            Enabled       = detail.Enabled;

            foreach (var metadataDetail in detail.MetadataDetails)
            {
                VirtualResourceMetadata metadata = new VirtualResourceMetadata(ResourceType, metadataDetail.MetadataType)
                {
                    VirtualResource           = this,
                    VirtualResourceId         = VirtualResourceId,
                    ExecutionPlan             = GetExecutionPlan(metadataDetail),
                    VirtualResourceMetadataId = metadataDetail.Id,
                    Name            = metadataDetail.Name,
                    Metadata        = metadataDetail.Data,
                    MetadataVersion = metadataDetail.MetadataVersion,
                    Enabled         = metadataDetail.Enabled
                };

                VirtualResourceMetadataSet.Add(metadata);
            }

            LoadChildDetail(detail);
        }
Example #2
0
        /// <summary>
        /// Creates a copy of this <see cref="VirtualResourceMetadata"/>.
        /// </summary>
        /// <returns></returns>
        public VirtualResourceMetadata Copy(bool includeRetrySettings)
        {
            VirtualResourceMetadata metadata = new VirtualResourceMetadata
            {
                VirtualResourceMetadataId = SequentialGuid.NewGuid(),
                Name            = Name,
                ResourceType    = ResourceType,
                MetadataType    = MetadataType,
                Metadata        = Metadata,
                MetadataVersion = MetadataVersion,
                Enabled         = Enabled,
                ExecutionPlan   = ExecutionPlan
            };

            if (this.AssetUsage != null)
            {
                metadata.AssetUsage = new VirtualResourceMetadataAssetUsage();
                metadata.AssetUsage.AssetSelectionData = this.AssetUsage.AssetSelectionData;
            }

            if (this.DocumentUsage != null)
            {
                metadata.DocumentUsage = new VirtualResourceMetadataDocumentUsage();
                metadata.DocumentUsage.DocumentSelectionData = this.DocumentUsage.DocumentSelectionData;
            }

            if (this.ServerUsage != null)
            {
                metadata.ServerUsage = new VirtualResourceMetadataServerUsage();
                metadata.ServerUsage.ServerSelectionData = this.ServerUsage.ServerSelectionData;
            }

            if (this.PrintQueueUsage != null)
            {
                metadata.PrintQueueUsage = new VirtualResourceMetadataPrintQueueUsage();
                metadata.PrintQueueUsage.PrintQueueSelectionData = this.PrintQueueUsage.PrintQueueSelectionData;
            }

            if (includeRetrySettings)
            {
                foreach (var retrySetting in this.VirtualResourceMetadataRetrySettings)
                {
                    VirtualResourceMetadataRetrySetting copiedSetting = new VirtualResourceMetadataRetrySetting
                    {
                        SettingId           = SequentialGuid.NewGuid(),
                        State               = retrySetting.State,
                        Action              = retrySetting.Action,
                        RetryLimit          = retrySetting.RetryLimit,
                        RetryDelay          = retrySetting.RetryDelay,
                        LimitExceededAction = retrySetting.LimitExceededAction
                    };
                    metadata.VirtualResourceMetadataRetrySettings.Add(copiedSetting);
                }
            }

            return(metadata);
        }
Example #3
0
        /// <summary>
        /// Creates a copy of this <see cref="VirtualResource"/>.
        /// </summary>
        /// <returns></returns>
        public VirtualResource Copy()
        {
            // Create a new resource of the same type as this one using reflection
            VirtualResource newResource = (VirtualResource)Activator.CreateInstance(this.GetType());

            newResource.CopyResourceProperties(this);

            // Copy over all metadata items
            foreach (VirtualResourceMetadata metadata in this.VirtualResourceMetadataSet)
            {
                VirtualResourceMetadata copiedMetadata = metadata.Copy(true);
                copiedMetadata.VirtualResourceId = newResource.VirtualResourceId;
                newResource.VirtualResourceMetadataSet.Add(copiedMetadata);
            }

            return(newResource);
        }