protected internal virtual ISet <string> GetAllDeploymentIds(DeploymentBuilderImpl deploymentBuilder) { ISet <string> result = new HashSet <string>(); //var nameFromDeployment = deploymentBuilder.nameFromDeployment; string nameFromDeployment = deploymentBuilder.GetNameFromDeployment(); if (!string.IsNullOrEmpty(nameFromDeployment)) { result.Add(nameFromDeployment); } var deployments = deploymentBuilder.Deployments; result.AddAll(deployments); deployments = new HashSet <string>(deploymentBuilder.DeploymentResourcesById.Keys); result.AddAll(deployments); deployments = new HashSet <string>(deploymentBuilder.DeploymentResourcesByName.Keys); result.AddAll(deployments); return(result); }
/// <summary> /// 部署执行 /// </summary> /// <param name="commandContext"></param> /// <returns></returns> protected internal virtual IDeploymentWithDefinitions DoExecute(CommandContext commandContext) { IDeploymentManager deploymentManager = commandContext.DeploymentManager; var deploymentIds = GetAllDeploymentIds(deploymentBuilder); if (deploymentIds.Count > 0) { var deploymentIdArray = deploymentIds.ToArray(); IList <DeploymentEntity> deployments = deploymentManager.FindDeploymentsByIds(deploymentIdArray); EnsureDeploymentsWithIdsExists(deploymentIds, deployments); } CheckCreateAndReadDeployments(commandContext, deploymentIds); // set deployment name if it should retrieved from an existing deployment var nameFromDeployment = deploymentBuilder.GetNameFromDeployment(); SetDeploymentName(nameFromDeployment, deploymentBuilder, commandContext); //TODO 加载resources到上下文 // get resources to re-deploy var resources = GetResources(deploymentBuilder, commandContext); // .. and add them the builder AddResources(resources, deploymentBuilder); var resourceNames = deploymentBuilder.ResourceNames; if ((resourceNames == null) || (resourceNames.Count == 0)) { throw new NotValidException("No deployment resources contained to deploy."); } IDeploymentWithDefinitions dep = commandContext.RunWithoutAuthorization <IDeploymentWithDefinitions>(() => { AcquireExclusiveLock(commandContext); DeploymentEntity deployment = InitDeployment(); //准备部署的xml数据源 byte[] IDictionary <string, ResourceEntity> resourcesToDeploy = ResolveResourcesToDeploy(commandContext, deployment); //准备忽略的resource IDictionary <string, ResourceEntity> resourcesToIgnore = new Dictionary <string, ResourceEntity>(deployment.Resources); foreach (var key in resourcesToDeploy.Keys) { if (resourcesToIgnore.ContainsKey(key)) { resourcesToIgnore.Remove(key); } } if (resourcesToDeploy.Count > 0) { Log.DebugCreatingNewDeployment(); deployment.Resources = resourcesToDeploy; Deploy(deployment); } else { Log.UsingExistingDeployment(); deployment = GetExistingDeployment(commandContext, deployment.Name); } ScheduleProcessDefinitionActivation(commandContext, deployment); if (deploymentBuilder is IProcessApplicationDeploymentBuilder) { // for process application deployments, job executor registration is managed by // process application manager ISet <string> processesToRegisterFor = RetrieveProcessKeysFromResources(resourcesToIgnore); IProcessApplicationRegistration registration = RegisterProcessApplication(commandContext, deployment, processesToRegisterFor); return(new ProcessApplicationDeploymentImpl(deployment, registration)); } else { RegisterWithJobExecutor(commandContext, deployment); } return(deployment); }); CreateUserOperationLog(deploymentBuilder, dep, commandContext); return(dep); }