public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var luceneIndexStep = step as LuceneIndexDeploymentStep; if (luceneIndexStep == null) { return; } var indexSettings = await _luceneIndexSettingsService.GetSettingsAsync(); var data = new JArray(); var indicesToAdd = luceneIndexStep.IncludeAll ? indexSettings.Select(x => x.IndexName).ToArray() : luceneIndexStep.IndexNames; foreach (var index in indexSettings) { if (indicesToAdd.Contains(index.IndexName)) { var indexSettingsDict = new Dictionary <string, LuceneIndexSettings>(); indexSettingsDict.Add(index.IndexName, index); data.Add(JObject.FromObject(indexSettingsDict)); } } // Adding Lucene settings result.Steps.Add(new JObject( new JProperty("name", "lucene-index"), new JProperty("Indices", data) )); }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { if (!(step is ContentDefinitionDeploymentStep contentDefinitionStep)) { return; } var contentTypeDefinitionRecord = await _contentDefinitionStore.LoadContentDefinitionAsync(); var contentTypes = contentDefinitionStep.IncludeAll ? contentTypeDefinitionRecord.ContentTypeDefinitionRecords : contentTypeDefinitionRecord.ContentTypeDefinitionRecords .Where(x => contentDefinitionStep.ContentTypes.Contains(x.Name)); var contentParts = contentDefinitionStep.IncludeAll ? contentTypeDefinitionRecord.ContentPartDefinitionRecords : contentTypeDefinitionRecord.ContentPartDefinitionRecords .Where(x => contentDefinitionStep.ContentParts.Contains(x.Name)); result.Steps.Add(new JObject( new JProperty("name", "ContentDefinition"), new JProperty("ContentTypes", JArray.FromObject(contentTypes)), new JProperty("ContentParts", JArray.FromObject(contentParts)) )); return; }
public Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var settingsStep = step as SettingsDeploymentStep; if (settingsStep == null || (!settingsStep.IncludeAzureHubSettings && !settingsStep.IncludeSignalHubSettings)) { return(Task.CompletedTask); } if (settingsStep.IncludeAzureHubSettings) { var options = new AzureHubSettings(); _azureHubOptions.Configure(options); var data = new JArray(); result.Steps.Add(new JObject( new JProperty("name", nameof(AzureHubSettings)), new JProperty("settings", JObject.FromObject(options)) )); } if (settingsStep.IncludeSignalHubSettings) { var options = new SignalHubSettings(); _signalHubOptions.Configure(options); var data = new JArray(); result.Steps.Add(new JObject( new JProperty("name", nameof(SignalHubSettings)), new JProperty("settings", JObject.FromObject(options)) )); } return(Task.CompletedTask); }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { // TODO: Batch and create separate content files in the result var contentState = step as ContentTypeDeploymentStep; if (contentState == null) { return; } var data = new JArray(); foreach (var contentItem in await _session.QueryAsync <ContentItem, ContentItemIndex>(x => x.Published && x.ContentType.IsIn(contentState.ContentTypes)).List()) { data.Add(JObject.FromObject(contentItem)); } if (data.HasValues) { var jobj = new JObject(); jobj["name"] = "content"; jobj["data"] = data; result.Steps.Add(jobj); } return; }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var allContentState = step as AllContentDeploymentStep; if (allContentState == null) { return; } var data = new JArray(); result.Steps.Add(new JObject( new JProperty("name", "Content"), new JProperty("data", data) )); foreach (var contentItem in await _session.Query <ContentItem, ContentItemIndex>(x => x.Published).ListAsync()) { var objectData = JObject.FromObject(contentItem); // Don't serialize the Id as it could be interpreted as an updated object when added back to YesSql objectData.Remove(nameof(ContentItem.Id)); data.Add(objectData); } return; }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var settingsStep = step as SiteSettingsPropertyDeploymentStep <TModel>; if (settingsStep == null) { return; } var siteSettings = await _siteService.GetSiteSettingsAsync(); var settingJProperty = new JProperty(typeof(TModel).Name, JObject.FromObject(siteSettings.As <TModel>())); var settingsStepJObject = result.Steps.FirstOrDefault(s => s["name"]?.ToString() == "Settings"); if (settingsStepJObject != null) { settingsStepJObject.Add(settingJProperty); } else { result.Steps.Add(new JObject( new JProperty("name", "Settings"), new JProperty(settingJProperty) )); } }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var allRolesState = step as AllRolesDeploymentStep; if (allRolesState == null) { return; } // Get all roles var allRoleNames = await _roleService.GetRoleNamesAsync(); var permissions = new JArray(); var tasks = new List <Task>(); foreach (var roleName in allRoleNames) { var role = (Role)await _roleManager.FindByNameAsync(_roleManager.NormalizeKey(roleName)); if (role != null) { permissions.Add(JObject.FromObject( new RolesStepRoleModel { Name = role.NormalizedRoleName, Permissions = role.RoleClaims.Where(x => x.ClaimType == Permission.ClaimType).Select(x => x.ClaimValue).ToArray() })); } } result.Steps.Add(new JObject( new JProperty("name", "Roles"), new JProperty("Roles", permissions) )); }
public async Task <dynamic> BuildStepEditorAsync(DeploymentStep step, IUpdateModel updater) { dynamic deploymentStepShape = CreateContentShape("DeploymentStep_Edit"); deploymentStepShape.DeploymentStep = step; var context = new BuildEditorContext( deploymentStepShape, "", "", _shapeFactory, _layoutAccessor.GetLayout(), updater ); await BindPlacementAsync(context); await _drivers.InvokeAsync(async driver => { var result = await driver.BuildEditorAsync(step, context); if (result != null) { result.Apply(context); } }, Logger); return(deploymentStepShape); }
public override bool Matches(ObjectIdentifier name, ModelTypeClass type, DeploymentStep step = null) { bool matches = true; for (int i = 0; i < name.Parts.Count && i < _matchParts.Length; i++) { // Match names right-to-left, since specificity of a SQL identifier is right-to-left, // and so this behaves identically to NamedObjectFilterRule if the requested match // contains only one argument. var part = name.Parts[name.Parts.Count - 1 - i]; var match = _matchParts[_matchParts.Length - 1 - i]; if (!match.IsMatch(part)) { matches = false; break; } } if (matches && MatchType == MatchType.DoesMatch) { return(true); } return(!matches && MatchType == MatchType.DoesNotMatch); }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var adminMenuStep = step as AdminMenuDeploymentStep; if (adminMenuStep == null) { return; } var data = new JArray(); result.Steps.Add(new JObject( new JProperty("name", "AdminMenu"), new JProperty("data", data) )); // For each AdminNode, store info about its concrete type: linkAdminNode, contentTypesAdminNode etc... var serializer = new JsonSerializer() { TypeNameHandling = TypeNameHandling.Auto }; foreach (var adminMenu in (await _adminMenuService.GetAdminMenuListAsync()).AdminMenu) { var objectData = JObject.FromObject(adminMenu, serializer); data.Add(objectData); } return; }
public ActionResult DeleteStep(int id, int deploymentStepId) { this.CheckPermission(UserRoleAction.DeploymentChangeSteps); DeploymentStep deploymentStep = this.Entities.DeploymentStep .Include("Properties") .Include("MachineRoles") .Include("BundleVersion") .First(ds => ds.BundleVersionId == id && ds.Id == deploymentStepId); switch (deploymentStep.Type) { case DeploymentStepType.DeployWebSite: case DeploymentStepType.DeployDacpac: case DeploymentStepType.CopyFiles: this.UpdateProjectReference(new ProjectRelatedDeploymentStepModel { BundleVersionId = deploymentStep.BundleVersionId, DeploymentStepId = deploymentStep.Id, ProjectId = 0 }); break; } deploymentStep.MachineRoles.Clear(); this.Entities.DeploymentStep.Remove(deploymentStep); this.Entities.SaveChanges(); return(this.RedirectToAction("VersionDeployment", "Bundles", new { id = deploymentStep.BundleVersionId })); }
public override bool Matches(ObjectIdentifier name, ModelTypeClass type, DeploymentStep step = null) { bool result = (Schema == null || Schema.Equals(name.GetSchemaName(type))) && Matches(type.Name); return(result); }
public async Task ProcessDeploymentStepAsync(DeploymentStep deploymentStep, DeploymentPlanResult result) { if (!(deploymentStep is DeploymentPlanDeploymentStep deploymentPlanStep)) { return; } if (!await _deploymentPlanService.DoesUserHavePermissionsAsync()) { return; } var deploymentPlans = deploymentPlanStep.IncludeAll ? (await _deploymentPlanService.GetAllDeploymentPlansAsync()).ToArray() : (await _deploymentPlanService.GetDeploymentPlansAsync(deploymentPlanStep.DeploymentPlanNames)).ToArray(); var plans = (from plan in deploymentPlans select new { plan.Name, Steps = (from step in plan.DeploymentSteps select new { Type = step.GetType().Name, Step = step }).ToArray() }).ToArray(); // Adding deployment plans result.Steps.Add(new JObject( new JProperty("name", "deployment"), new JProperty("Plans", JArray.FromObject(plans)) )); }
private void ChangeNewDatabaseLocation(DeploymentPlanContributorContext context, string databasePath, string logPath) { DeploymentStep nextStep = context.PlanHandle.Head; // Loop through all steps in the deployment plan bool finished = false; while (nextStep != null && !finished) { // Increment the step pointer, saving both the current and next steps DeploymentStep currentStep = nextStep; // Only interrogate up to BeginPreDeploymentScriptStep - setvars must be done before that if (currentStep is BeginPreDeploymentScriptStep) { finished = true; break; } SqlCreateDatabaseStep createDbStep = currentStep as SqlCreateDatabaseStep; if (createDbStep != null) { TSqlFragment fragment = createDbStep.Script; CreateDatabaseStatementVisitor visitor = new CreateDatabaseStatementVisitor(databasePath, logPath); fragment.Accept(visitor); finished = true; } nextStep = currentStep.Next; } }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var allContentStep = step as AllWorkflowTypeDeploymentStep; if (allContentStep == null) { return; } var data = new JArray(); result.Steps.Add(new JObject( new JProperty("name", "WorkflowType"), new JProperty("data", data) )); foreach (var workflow in await _workflowTypeStore.ListAsync()) { var objectData = JObject.FromObject(workflow); // Don't serialize the Id as it could be interpreted as an updated object when added back to YesSql objectData.Remove(nameof(workflow.Id)); data.Add(objectData); } return; }
public void ProcessDeploymentStep(DeploymentStep deploymentStep) { switch (deploymentStep.Type) { case DeploymentStepType.DeployWebSite: this.ProcessWebSiteDeploymentStep(deploymentStep); break; case DeploymentStepType.Configuration: this.ProcessConfigurationStep(deploymentStep); break; case DeploymentStepType.CopyFiles: this.ProcessCopyFilesStep(deploymentStep); break; case DeploymentStepType.UpdateHostsFile: this.ProcessHostsStep(deploymentStep); break; case DeploymentStepType.RunSQLScript: this.ProcessSQLStep(deploymentStep); break; case DeploymentStepType.DeployDacpac: this.ProcessDacpacStep(deploymentStep); break; default: throw new AspNetDeployException("Deployment step type is not supported: " + deploymentStep.Type); } }
internal static void AssertAreDeploymentStepsEqual(DeploymentStep expectedDeploymentStep, dynamic actualDeploymentStep) { Assert.AreEqual(expectedDeploymentStep.ActivityDisplayName, actualDeploymentStep.name, "Unexpected name for deploymentstep"); Assert.AreEqual(expectedDeploymentStep.DateEnded, actualDeploymentStep.dateEnded, "Unexpected DateEnded for deploymentStep with name {0}", expectedDeploymentStep.ActivityDisplayName); Assert.AreEqual(expectedDeploymentStep.DateStarted, actualDeploymentStep.dateStarted, "Unexpected DateStarted for deploymentStep with name {0}", expectedDeploymentStep.ActivityDisplayName); Assert.AreEqual(expectedDeploymentStep.Status, actualDeploymentStep.status, "Unexpected Status for deploymentStep with name {0}", expectedDeploymentStep.ActivityDisplayName); }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { // TODO: Batch and create separate content files in the result. var contentState = step as ContentDeploymentStep; if (contentState == null) { return; } var data = new JArray(); foreach (var contentItem in await _session.Query <ContentItem, ContentItemIndex>(x => x.Published && x.ContentType.IsIn(contentState.ContentTypes)).ListAsync()) { var objectData = JObject.FromObject(contentItem); // Don't serialize the Id as it could be interpreted as an updated object when added back to YesSql. objectData.Remove(nameof(ContentItem.Id)); data.Add(objectData); } if (data.HasValues) { var jobj = new JObject { ["name"] = "content", ["data"] = data }; result.Steps.Add(jobj); } }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var customSettingsStep = step as CustomSettingsDeploymentStep; if (customSettingsStep == null) { return; } var settingsList = new List <JProperty> { new JProperty("name", "custom-settings") }; var settingsTypes = customSettingsStep.IncludeAll ? _customSettingsService.GetAllSettingsTypes().ToArray() : _customSettingsService.GetSettingsTypes(customSettingsStep.SettingsTypeNames).ToArray(); foreach (var settingsType in settingsTypes) { if (!await _customSettingsService.CanUserCreateSettingsAsync(settingsType)) { return; } } foreach (var settingsType in settingsTypes) { var settings = await _customSettingsService.GetSettingsAsync(settingsType); settingsList.Add(new JProperty(settings.ContentType, JObject.FromObject(settings))); } // Adding custom settings result.Steps.Add(new JObject(settingsList.ToArray())); }
public DeploymentStepModel Create(DeploymentStep deploymentStep) { WebSiteDeploymentStepModel model = new WebSiteDeploymentStepModel(); model.OrderIndex = deploymentStep.OrderIndex; return(model); }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var openIdServerStep = step as OpenIdServerDeploymentStep; if (openIdServerStep == null) { return; } var settings = await _openIdServerService .GetSettingsAsync(); var settingsModel = new OpenIdServerSettingsStepModel { AccessTokenFormat = settings.AccessTokenFormat, Authority = settings.Authority?.AbsoluteUri, EncryptionCertificateStoreLocation = settings.EncryptionCertificateStoreLocation, EncryptionCertificateStoreName = settings.EncryptionCertificateStoreName, EncryptionCertificateThumbprint = settings.EncryptionCertificateThumbprint, SigningCertificateStoreLocation = settings.SigningCertificateStoreLocation, SigningCertificateStoreName = settings.SigningCertificateStoreName, SigningCertificateThumbprint = settings.SigningCertificateThumbprint, // The recipe step only reads these flags, and uses constants for the paths. // Conversely, we export true for endpoints with a path, false for those without. EnableAuthorizationEndpoint = !string.IsNullOrWhiteSpace(settings.AuthorizationEndpointPath), EnableLogoutEndpoint = !string.IsNullOrWhiteSpace(settings.LogoutEndpointPath), EnableTokenEndpoint = !string.IsNullOrWhiteSpace(settings.TokenEndpointPath), EnableUserInfoEndpoint = !string.IsNullOrWhiteSpace(settings.UserinfoEndpointPath), EnableIntrospectionEndpoint = !string.IsNullOrWhiteSpace(settings.IntrospectionEndpointPath), EnableRevocationEndpoint = !string.IsNullOrWhiteSpace(settings.RevocationEndpointPath), AllowAuthorizationCodeFlow = settings.AllowAuthorizationCodeFlow, AllowClientCredentialsFlow = settings.AllowClientCredentialsFlow, AllowHybridFlow = settings.AllowHybridFlow, AllowImplicitFlow = settings.AllowImplicitFlow, AllowPasswordFlow = settings.AllowPasswordFlow, AllowRefreshTokenFlow = settings.AllowRefreshTokenFlow, DisableAccessTokenEncryption = settings.DisableAccessTokenEncryption, DisableRollingRefreshTokens = settings.DisableRollingRefreshTokens, UseReferenceAccessTokens = settings.UseReferenceAccessTokens, RequireProofKeyForCodeExchange = settings.RequireProofKeyForCodeExchange, }; // Use nameof(OpenIdServerSettings) as name, // to match the recipe step. var obj = new JObject( new JProperty( "name", nameof(OpenIdServerSettings))); obj.Merge(JObject.FromObject(settingsModel)); result.Steps.Add(obj); }
private void ChangeCreateIndexOperationalProps(DeploymentPlanContributorContext context, IList <IndexOption> options) { DeploymentStep nextStep = context.PlanHandle.Head; // Loop through all steps in the deployment plan bool foundMainSection = false; while (nextStep != null) { DeploymentStep currentStep = nextStep; nextStep = currentStep.Next; // We only want to analyze the main part of the deployment script - we'll skip // any steps until we pass the end of the predeployment section, and stop once // we hit the start of the postdeployment section if (currentStep is EndPreDeploymentScriptStep) { foundMainSection = true; continue; } if (!foundMainSection) { // Haven't gotten past predeployment yet continue; } if (currentStep is BeginPostDeploymentScriptStep) { break; } // We need to care about CreateElementSteps and AlterElementSteps for Indexes. DeploymentScriptDomStep domStep = currentStep as DeploymentScriptDomStep; TSqlObject elementObject = null; if (domStep is CreateElementStep) { elementObject = ((CreateElementStep)domStep).SourceElement; } else if (domStep is AlterElementStep) { elementObject = ((AlterElementStep)domStep).SourceElement; } if (elementObject != null) { if (Index.TypeClass.Equals(elementObject.ObjectType) && !(View.TypeClass.Equals(elementObject.GetParent().ObjectType))) { TSqlFragment fragment = domStep.Script; IndexStatementVisitor visitor = new IndexStatementVisitor(options); fragment.Accept(visitor); } } } }
private void FindAndRenameUnnamedDefaultConstraints(DeploymentPlanContributorContext context) { DeploymentStep nextStep = context.PlanHandle.Head; // Loop through all steps in the deployment plan bool foundMainSection = false; while (nextStep != null) { DeploymentStep currentStep = nextStep; nextStep = currentStep.Next; // We only want to analyze the main part of the deployment script - we'll skip // any steps until we pass the end of the predeployment section, and stop once // we hit the start of the postdeployment section if (currentStep is EndPreDeploymentScriptStep) { foundMainSection = true; continue; } if (!foundMainSection) { // Haven't gotten past predeployment yet continue; } if (currentStep is BeginPostDeploymentScriptStep) { break; } // We need to care about CreateElementSteps and AlterElementSteps for default constraints. DeploymentScriptDomStep domStep = currentStep as DeploymentScriptDomStep; TSqlObject elementObject = null; // most of the default constraints in the deployment plan seem to be deployed as Alter Table statements, but // just in case the default constraint was deployed as part of a Create Table (don't see how it is possible, but just being safe) if (domStep is CreateElementStep) { elementObject = ((CreateElementStep)domStep).SourceElement; } else if (domStep is AlterElementStep) { elementObject = ((AlterElementStep)domStep).SourceElement; } if (elementObject != null) { TSqlFragment fragment = domStep.Script; // call the visitor, which in turn will auto-name these constraints var visitor = new DefaultConstraintDefinitionVisitor(); fragment.Accept(visitor); } } }
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { if (!(step is MediaDeploymentStep mediaStep)) { return; } List <string> paths; if (mediaStep.IncludeAll) { var fileStoreEntries = await _mediaFileStore.GetDirectoryContentAsync(null, true); paths = ( from fileStoreEntry in fileStoreEntries where !fileStoreEntry.IsDirectory select fileStoreEntry.Path ).ToList(); } else { paths = new List <string>(mediaStep.FilePaths ?? Array.Empty <string>()); foreach (var directoryPath in mediaStep.DirectoryPaths ?? Array.Empty <string>()) { var fileStoreEntries = await _mediaFileStore.GetDirectoryContentAsync(directoryPath, true); paths.AddRange( from fileStoreEntry in fileStoreEntries where !fileStoreEntry.IsDirectory select fileStoreEntry.Path); } paths.Sort(); } foreach (var path in paths) { var stream = await _mediaFileStore.GetFileStreamAsync(path); await result.FileBuilder.SetFileAsync(path, stream); } // Adding media files result.Steps.Add(new JObject( new JProperty("name", "media"), new JProperty("Files", JArray.FromObject( (from path in paths select new { SourcePath = path, TargetPath = path }).ToArray() )) )); }
private void ProcessConfigurationStep(DeploymentStep deploymentStep) { string configuration = JsonConvert.SerializeObject(new { file = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("File")), content = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("SetValues")) }); this.deploymentClient.ProcessConfigFile(configuration); }
private void ProcessSQLStep(DeploymentStep deploymentStep) { string configuration = JsonConvert.SerializeObject(new { connectionString = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("ConnectionString")), command = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("Command")), }); this.deploymentClient.RunSQLScript(configuration); }
private static DeploymentStepDecision RemoveCreateElement(DeploymentStep step, KeeperDecider decider) { var createStep = step as CreateElementStep; return(createStep == null ? null : new DeploymentStepDecision() { Remove = decider.ShouldRemoveFromPlan(createStep.SourceElement?.Name ?? new ObjectIdentifier(), createStep.SourceElement?.ObjectType, StepType.Create), StepType = StepType.Create, ObjectName = createStep.SourceElement?.Name?.ToString() ?? "" }); }
public Task ProcessDeploymentStepAsync(DeploymentStep deploymentStep, DeploymentPlanResult result) { if (!(deploymentStep is JsonRecipeDeploymentStep jsonRecipeStep)) { return(Task.CompletedTask); } result.Steps.Add(JObject.Parse(jsonRecipeStep.Json)); return(Task.CompletedTask); }
public Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) { var customFile = step as CustomFileDeploymentStep; if (customFile == null) { return(Task.CompletedTask); } return(result.FileBuilder.SetFileAsync(customFile.FileName, Encoding.UTF8.GetBytes(customFile.FileContent))); }
public IDeploymentStep Convert(DeploymentStep deploymentStep) { using (var convertedDeploymentStep = DomainLocator.GetDeploymentStep()) { convertedDeploymentStep.Object.Id = deploymentStep.Id; convertedDeploymentStep.Object.Description = deploymentStep.Description; convertedDeploymentStep.Object.StepState = (BO.DeploymentStepState)deploymentStep.StepState; convertedDeploymentStep.Object.Comment = deploymentStep.Comment; return(convertedDeploymentStep.Object); } }
public IndexModifierStep(DeploymentStep originalStep) { _originalStep = originalStep; }
public CreateIndexDecideAtBuildTime(DeploymentStep originalStep, SQLServerEdition edition) : base(originalStep) { _edition = edition; }
public CreateIndexDecideAtRuntime(DeploymentStep originalStep) : base(originalStep) { }
public BatchedSqlTableMigrationStep(DeploymentStep wrappedStep, int rowCount) { _wrappedStep = wrappedStep; _rowCount = rowCount; }