public DeploymentOperation(DeploymentContext deploymentContext, IInfrastructure infrastructure, Resource resource = null)
        {
            this.GroupType      = deploymentContext.GroupType;
            this.GroupId        = deploymentContext.GroupId;
            this.HierarchyId    = deploymentContext.HierarchyId;
            this.RootId         = deploymentContext.RootId;
            this.DeploymentId   = deploymentContext.DeploymentId;
            this.CorrelationId  = deploymentContext.CorrelationId;
            this.CreateByUserId = deploymentContext.CreateByUserId;
            if (string.IsNullOrEmpty(deploymentContext.LastRunUserId))
            {
                this.LastRunUserId = this.CreateByUserId;
            }
            else
            {
                this.LastRunUserId = deploymentContext.LastRunUserId;
            }
            if (resource == null)
            {
                if (!string.IsNullOrEmpty(deploymentContext.SubscriptionId))
                {
                    this.SubscriptionId = deploymentContext.SubscriptionId;
                    this.ResourceId     = $"/{infrastructure.BuiltinPathSegment.Subscription}/{deploymentContext.SubscriptionId}";
                }
                if (!string.IsNullOrEmpty(deploymentContext.ManagementGroupId))
                {
                    this.ManagementGroupId = deploymentContext.ManagementGroupId;
                    this.ResourceId        = $"/{infrastructure.BuiltinPathSegment.ManagementGroup}/{deploymentContext.ManagementGroupId}";
                }
                if (!string.IsNullOrEmpty(deploymentContext.ResourceGroup))
                {
                    this.ResourceId += $"/{infrastructure.BuiltinPathSegment.ResourceGroup}/{deploymentContext.ResourceGroup}";
                }
                this.ResourceId += $"/{infrastructure.BuiltinPathSegment.Provider}/{infrastructure.BuiltinServiceTypes.Deployments}/{deploymentContext.DeploymentName}";

                this.Type              = infrastructure.BuiltinServiceTypes.Deployments;
                this.Name              = deploymentContext.DeploymentName;
                this.ParentResourceId  = deploymentContext.ParentId;
                this.SubscriptionId    = deploymentContext.SubscriptionId;
                this.ManagementGroupId = deploymentContext.ManagementGroupId;
            }
            else
            {
                this.ResourceId        = resource.ResourceId;
                this.Name              = resource.FullName;
                this.Type              = resource.FullType;
                this.ParentResourceId  = string.IsNullOrEmpty(resource.CopyId) ? deploymentContext.GetResourceId(infrastructure) : resource.CopyId;
                this.SubscriptionId    = resource.SubscriptionId;
                this.ManagementGroupId = resource.ManagementGroupId;
            }
        }