/// <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.º 2
0
 public MigrationStepBatcher(SqlTableMigrationStep step, int rowCount)
 {
     _step     = step;
     _rowCount = rowCount;
 }
Ejemplo n.º 3
0
 public MigrationStepBatcher(SqlTableMigrationStep step, int rowCount)
 {
     _step = step;
     _rowCount = rowCount;
 }