Ejemplo n.º 1
0
        protected override void OnExecute(DeploymentPlanContributorContext context)
        {
            InitializeFilter(context.Arguments);
            DeploymentStep next = context.PlanHandle.Head;

            while (next != null)
            {
                DeploymentStep current = next;
                next = current.Next;

                CreateElementStep createStep = current as CreateElementStep;
                if (createStep != null && ShouldFilter(createStep))
                {
                    base.Remove(context.PlanHandle, createStep);
                }
            }
        }
        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 only care about CreateElementSteps for Indexes.
                CreateElementStep createElementStep = currentStep as CreateElementStep;
                if (createElementStep != null &&
                    createElementStep.SourceElement != null &&
                    Index.TypeClass.Equals(createElementStep.SourceElement.ObjectType))
                {
                    TSqlFragment fragment = createElementStep.Script;

                    CreateIndexStatementVisitor visitor = new CreateIndexStatementVisitor(options);
                    fragment.Accept(visitor);
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnExecute(DeploymentPlanContributorContext context)
        {
            // Use target model's collation since that is where we are deploying to, and hence how the
            // deployment should be comparing collation types
            InitializeFilter(context.Target, context.Arguments);
            DeploymentStep next = context.PlanHandle.Head;

            while (next != null)
            {
                DeploymentStep current = next;
                next = current.Next;

                CreateElementStep createStep = current as CreateElementStep;
                if (createStep != null && ShouldFilter(createStep))
                {
                    base.Remove(context.PlanHandle, createStep);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// We should filter the step if the source element for the step
        /// doesn't pass the filter
        /// </summary>
        private bool ShouldFilter(CreateElementStep createStep)
        {
            TSqlObject createdObject = createStep.SourceElement;

            return(!_filter.Filter(new[] { createdObject }).Any());
        }
            /// <summary>
            /// Writes details for the various operation types
            /// that could be contained in the deployment plan.
            /// Optionally writes script bodies, depending on
            /// the value of the IncludeScripts property.
            /// </summary>
            private void ReportPlanOperations(XmlWriter xmlw)
            {// write the node to indicate the start
                // of the list of operations.
                xmlw.WriteStartElement("Operations");

                // Loop through the steps in the plan,
                // starting at the beginning.
                DeploymentStep currentStep = _planHead;

                while (currentStep != null)
                {
                    // Report the type of step
                    xmlw.WriteStartElement(currentStep.GetType().Name);

                    // based on the type of step, report
                    // the relevant information.
                    // Note that this procedure only handles
                    // a subset of all step types.
                    if (currentStep is SqlRenameStep)
                    {
                        SqlRenameStep renameStep = (SqlRenameStep)currentStep;
                        xmlw.WriteAttributeString("OriginalName", renameStep.OldName);
                        xmlw.WriteAttributeString("NewName", renameStep.NewName);
                        xmlw.WriteAttributeString("Category", GetElementCategory(renameStep.RenamedElement));
                    }
                    else if (currentStep is SqlMoveSchemaStep)
                    {
                        SqlMoveSchemaStep moveStep = (SqlMoveSchemaStep)currentStep;
                        xmlw.WriteAttributeString("OrignalName", moveStep.PreviousName);
                        xmlw.WriteAttributeString("NewSchema", moveStep.NewSchema);
                        xmlw.WriteAttributeString("Category", GetElementCategory(moveStep.MovedElement));
                    }
                    else if (currentStep is SqlTableMigrationStep)
                    {
                        SqlTableMigrationStep dmStep = (SqlTableMigrationStep)currentStep;
                        xmlw.WriteAttributeString("Name", GetElementName(dmStep.SourceTable));
                        xmlw.WriteAttributeString("Category", GetElementCategory(dmStep.SourceElement));
                    }
                    else if (currentStep is CreateElementStep)
                    {
                        CreateElementStep createStep = (CreateElementStep)currentStep;
                        xmlw.WriteAttributeString("Name", GetElementName(createStep.SourceElement));
                        xmlw.WriteAttributeString("Category", GetElementCategory(createStep.SourceElement));
                    }
                    else if (currentStep is AlterElementStep)
                    {
                        AlterElementStep alterStep = (AlterElementStep)currentStep;
                        xmlw.WriteAttributeString("Name", GetElementName(alterStep.SourceElement));
                        xmlw.WriteAttributeString("Category", GetElementCategory(alterStep.SourceElement));
                    }
                    else if (currentStep is DropElementStep)
                    {
                        DropElementStep dropStep = (DropElementStep)currentStep;
                        xmlw.WriteAttributeString("Name", GetElementName(dropStep.TargetElement));
                        xmlw.WriteAttributeString("Category", GetElementCategory(dropStep.TargetElement));
                    }

                    // If the script bodies are to be included,
                    // add them to the report.
                    if (this.IncludeScripts)
                    {
                        using (StringWriter sw = new StringWriter())
                        {
                            currentStep.GenerateBatchScript(sw);
                            string tsqlBody = sw.ToString();
                            if (string.IsNullOrEmpty(tsqlBody) == false)
                            {
                                xmlw.WriteCData(tsqlBody);
                            }
                        }
                    }

                    // close off the current step
                    xmlw.WriteEndElement();
                    currentStep = currentStep.Next;
                }
                xmlw.WriteEndElement();
            }
Ejemplo n.º 6
0
 /// <summary>
 /// We should filter the step if the source element for the step
 /// doesn't pass the filter
 /// </summary>
 private bool ShouldFilter(CreateElementStep createStep)
 {
     TSqlObject createdObject = createStep.SourceElement;
     return !_filter.Filter(new[] {createdObject}).Any();
 }