예제 #1
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string name = patternNavigator.SelectSingleNode("@Name").Value;

                string fileName =
                    Resources.Create +
                    name +
                    Resources.ExtensionSQLFile;

                string filePath = VulcanPackage.AddFileToProject(fileName);

                TableHelper th = new TableHelper(name, VulcanPackage.VulcanConfig, patternNavigator.SelectSingleNode("rc:Table", VulcanPackage.VulcanConfig.NamespaceManager));
                th.TraceHelper();


                th.TraceHelper();

                TableEmitterEx tex = new TableEmitterEx(th, VulcanPackage);

                tex.Emit(filePath, false);
                Connection connection = Connection.GetExistingConnection(VulcanPackage, patternNavigator);
                SQLTask    sqlTask    = new SQLTask(VulcanPackage,
                                                    Resources.Create + name,
                                                    Resources.Create + name,
                                                    ParentContainer,
                                                    connection
                                                    );

                sqlTask.TransmuteToFileTask(fileName);
                this.FirstExecutableGeneratedByPattern = sqlTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern  = this.FirstExecutableGeneratedByPattern;
            }
        }
예제 #2
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            string containerName       = patternNavigator.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;
            string helperTableTaskName = "Set Up Helper Table Group " + containerName;

            string helperTableFile     = containerName + Resources.ExtensionSQLFile;
            string helperTableFilePath = VulcanPackage.AddFileToProject(helperTableFile);

            File.Delete(helperTableFilePath);

            Connection c = Connection.GetExistingConnection(VulcanPackage, patternNavigator);

            foreach (XPathNavigator nav in patternNavigator.Select("rc:HelperTable", VulcanPackage.VulcanConfig.NamespaceManager))
            {
                string         tableName      = nav.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;
                XPathNavigator tableNavigator = nav.SelectSingleNode("rc:Table", VulcanPackage.VulcanConfig.NamespaceManager);
                Message.Trace(Severity.Debug, "Adding Helper table " + tableName);

                TableHelper    th = new TableHelper(tableName, VulcanPackage.VulcanConfig, tableNavigator);
                TableEmitterEx te = new TableEmitterEx(th, VulcanPackage);
                te.Emit(VulcanPackage.QualifiedProjectPath + helperTableFile, true);
            }

            SQLTask setupSQLTask = new SQLTask(VulcanPackage, helperTableTaskName, helperTableTaskName, ParentContainer, c);

            setupSQLTask.TransmuteToFileTask(helperTableFile);

            this.ExecuteDuringDesignTime(patternNavigator, setupSQLTask.SQLTaskHost);

            this.FirstExecutableGeneratedByPattern = setupSQLTask.SQLTaskHost;
            this.LastExecutableGeneratedByPattern  = this.FirstExecutableGeneratedByPattern;
        }
예제 #3
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string name = patternNavigator.SelectSingleNode("@Name").Value;
                string body = patternNavigator.SelectSingleNode("rc:Body", VulcanPackage.VulcanConfig.NamespaceManager).Value;

                string fileName =
                    Resources.Create +
                    name +
                    Resources.ExtensionSQLFile;

                string filePath = VulcanPackage.AddFileToProject(fileName);

                StoredProcEmitter spe = new StoredProcEmitter(name, body, VulcanPackage);
                foreach (XPathNavigator columnNav in patternNavigator.Select("rc:Columns/rc:Column", VulcanPackage.VulcanConfig.NamespaceManager))
                {
                    bool isOutput = columnNav.SelectSingleNode("@IsOutput").ValueAsBoolean;

                    spe.AddColumn(
                        columnNav.SelectSingleNode("@Name").Value,
                        columnNav.SelectSingleNode("@Default").Value,
                        columnNav.SelectSingleNode("@Type").Value,
                        isOutput);
                }
                spe.Emit(filePath, false);

                Connection c       = Connection.GetExistingConnection(VulcanPackage, patternNavigator);
                SQLTask    sqlTask = new SQLTask(VulcanPackage,
                                                 Resources.Create + name,
                                                 Resources.Create + name,
                                                 ParentContainer,
                                                 c
                                                 );

                sqlTask.TransmuteToFileTask(fileName);

                this.ExecuteDuringDesignTime(patternNavigator, sqlTask.SQLTaskHost);

                this.FirstExecutableGeneratedByPattern = sqlTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern  = this.FirstExecutableGeneratedByPattern;
            }
        }
예제 #4
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string createTableFile = VulcanPackage.AddFileToProject(
                    Resources.Create + Resources.Schema + Resources.Seperator +
                    VulcanPackage.Name +
                    Resources.ExtensionSQLFile
                    );

                File.Delete(createTableFile);
                string insertSPFile          = null;
                string checkAndinsertSPFile  = null;
                string insertAndUpdateSPFile = null;
                bool   hasCheckAndInsert     = false;
                bool   hasInsertAndUpdate    = false;

                foreach (XPathNavigator nav in patternNavigator.Select("rc:Dimension", VulcanPackage.VulcanConfig.NamespaceManager))
                {
                    string dimensionName = nav.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;

                    Message.Trace(Severity.Debug, "Emitting Create Statement for " + dimensionName);

                    TableHelper    th = new TableHelper(dimensionName, VulcanPackage.VulcanConfig, nav.SelectSingleNode("rc:Table", VulcanPackage.VulcanConfig.NamespaceManager));
                    TableEmitterEx te = new TableEmitterEx(th, VulcanPackage);
                    te.Emit(createTableFile, true);

                    if (String.IsNullOrEmpty(insertSPFile))
                    {
                        insertSPFile = VulcanPackage.AddFileToProject(
                            Resources.SPPrefix + Resources.Seperator +
                            Resources.Insert +
                            VulcanPackage.Name +
                            Resources.ExtensionSQLFile
                            );
                        File.Delete(insertSPFile);
                    }

                    InsertSPEmitter spe = new InsertSPEmitter(dimensionName, nav.SelectSingleNode("rc:Table", VulcanPackage.VulcanConfig.NamespaceManager), th, VulcanPackage);
                    spe.Emit(insertSPFile, true);

                    if (nav.Select("rc:Table/rc:CheckAndInsertUniqueColumn", VulcanPackage.VulcanConfig.NamespaceManager).Count > 0)
                    {
                        hasCheckAndInsert = true;


                        if (String.IsNullOrEmpty(checkAndinsertSPFile))
                        {
                            checkAndinsertSPFile = VulcanPackage.AddFileToProject(
                                Resources.SPPrefix + Resources.Seperator +
                                Resources.CheckAndInsert +
                                VulcanPackage.Name +
                                Resources.ExtensionSQLFile
                                );

                            File.Delete(checkAndinsertSPFile);
                        }

                        CheckAndInsertSPEmitter cispe = new CheckAndInsertSPEmitter(dimensionName, nav.SelectSingleNode("rc:Table", VulcanPackage.VulcanConfig.NamespaceManager), th, VulcanPackage);
                        cispe.Emit(checkAndinsertSPFile, true);
                    }

                    if (nav.Select("rc:Table/rc:InsertOrUpdateUniqueColumn", VulcanPackage.VulcanConfig.NamespaceManager).Count > 0)
                    {
                        hasInsertAndUpdate = true;

                        if (String.IsNullOrEmpty(insertAndUpdateSPFile))
                        {
                            insertAndUpdateSPFile = VulcanPackage.AddFileToProject(
                                Resources.SPPrefix + Resources.Seperator +
                                Resources.CheckAndInsert +
                                Resources.Update +
                                VulcanPackage.Name +
                                Resources.ExtensionSQLFile
                                );

                            File.Delete(insertAndUpdateSPFile);
                        }
                        InsertAndUpdateSPEmitter iuspe = new InsertAndUpdateSPEmitter(dimensionName, nav.SelectSingleNode("rc:Table", VulcanPackage.VulcanConfig.NamespaceManager), th, VulcanPackage);
                        iuspe.Emit(insertAndUpdateSPFile, true);
                    }
                }

                Dictionary <string, object> properties = new Dictionary <string, object>();
                properties["Name"] = Resources.Create + Resources.Schema + Resources.Seperator + VulcanPackage.Name;

                //TODO: This is a hardcoded bug, should be removed when Dimensions are rewritten!
                Connection dimensionConnection = Connection.GetExistingConnection(VulcanPackage, patternNavigator);

                SQLTask createTableTask =
                    new SQLTask(
                        VulcanPackage,
                        properties["Name"].ToString(),
                        properties["Name"].ToString(),
                        ParentContainer,
                        dimensionConnection,
                        properties
                        );

                createTableTask.TransmuteToFileTask(properties["Name"] + Resources.ExtensionSQLFile);

                properties["Name"] = Resources.SPPrefix + Resources.Seperator +
                                     Resources.Insert +
                                     VulcanPackage.Name;

                this.FirstExecutableGeneratedByPattern = createTableTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern  = this.FirstExecutableGeneratedByPattern;


                SQLTask createInsertSPTask =
                    new SQLTask(
                        VulcanPackage,
                        properties["Name"].ToString(),
                        properties["Name"].ToString(),
                        ParentContainer,
                        dimensionConnection,
                        properties
                        );
                createInsertSPTask.TransmuteToFileTask(properties["Name"] + Resources.ExtensionSQLFile);


                properties["Name"] = Resources.SPPrefix + Resources.Seperator +
                                     Resources.CheckAndInsert +
                                     VulcanPackage.Name;

                properties["Description"] = properties["Name"];

                VulcanPackage.AddPrecedenceConstraint(LastExecutableGeneratedByPattern, createInsertSPTask.SQLTaskHost, ParentContainer);
                this.LastExecutableGeneratedByPattern = createInsertSPTask.SQLTaskHost;

                if (hasCheckAndInsert)
                {
                    SQLTask createCheckInsertSPTask =
                        new SQLTask(
                            VulcanPackage,
                            properties["Name"].ToString(),
                            properties["Name"].ToString(),
                            ParentContainer,
                            dimensionConnection,
                            properties
                            );
                    createCheckInsertSPTask.TransmuteToFileTask(properties["Name"] + Resources.ExtensionSQLFile);

                    properties["Name"] = Resources.SPPrefix + Resources.Seperator +
                                         Resources.Insert + Resources.Defaults +
                                         VulcanPackage.Name;

                    properties["Description"] = properties["Name"];

                    VulcanPackage.AddPrecedenceConstraint(createInsertSPTask.SQLTaskHost, createCheckInsertSPTask.SQLTaskHost, ParentContainer);
                    this.LastExecutableGeneratedByPattern = createCheckInsertSPTask.SQLTaskHost;
                } // hasCheckAndInsert

                if (hasInsertAndUpdate)
                {
                    properties["Name"] = properties["Name"] = Resources.SPPrefix + Resources.Seperator +
                                                              Resources.CheckAndInsert + Resources.Update +
                                                              VulcanPackage.Name;
                    properties["Description"] = properties["Name"];

                    SQLTask createInsertUpdateTask =
                        new SQLTask(
                            VulcanPackage,
                            properties["Name"].ToString(),
                            properties["Name"].ToString(),
                            ParentContainer,
                            dimensionConnection,
                            properties
                            );
                    createInsertUpdateTask.TransmuteToFileTask(properties["Name"] + Resources.ExtensionSQLFile);

                    VulcanPackage.AddPrecedenceConstraint(LastExecutableGeneratedByPattern, createInsertUpdateTask.SQLTaskHost, ParentContainer);
                    this.LastExecutableGeneratedByPattern = createInsertUpdateTask.SQLTaskHost;
                } // hasInsertAndUpdate
            }
        }
예제 #5
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string name = patternNavigator.SelectSingleNode("@Name").Value;
                string body = patternNavigator.SelectSingleNode("rc:Body", VulcanPackage.VulcanConfig.NamespaceManager).Value.Trim();
                string type = patternNavigator.SelectSingleNode("@Type").Value;
                string resultSet = patternNavigator.SelectSingleNode("@ResultSet").Value;
                //   Message.Trace("\n\n{0}\n\n", patternNavigator.SelectSingleNode("@Name").);

                Connection c = Connection.GetExistingConnection(VulcanPackage, patternNavigator);

                if (c != null)
                {
                    SQLTask sqlTask = new SQLTask(VulcanPackage,
                       Resources.Create + name,
                       Resources.Create + name,
                        ParentContainer,
                        c
                        );

                    switch (type.ToUpperInvariant())
                    {
                        case "FILE":
                            string fileName = Resources.Create + name + Resources.ExtensionSQLFile;
                            string filePath = VulcanPackage.AddFileToProject(fileName);

                            TemplateEmitter te = new TemplateEmitter(new Template("temp", "temp", body));
                            te.SetParameters("");
                            te.Emit(filePath, false);

                            sqlTask.TransmuteToFileTask(fileName);
                            break;
                        case "EXPRESSION":
                            sqlTask.TransmuteToExpressionTask(body);
                            break;
                        default:
                            break;
                    }

                    switch (resultSet.ToUpperInvariant())
                    {
                        case "NONE":
                            sqlTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_None;
                            break;
                        case "SINGLEROW":
                            sqlTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_SingleRow;
                            break;
                        case "FULL":
                            sqlTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_Rowset;
                            break;
                        case "XML":
                            sqlTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_XML;
                            break;
                        default:
                            sqlTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_None;
                            break;
                    }

                    foreach (XPathNavigator resultNavigator in patternNavigator.Select("rc:Result", VulcanPackage.VulcanConfig.NamespaceManager))
                    {
                        sqlTask.BindResult(resultNavigator.SelectSingleNode("@Name").Value, resultNavigator.SelectSingleNode("@VariableName").Value);
                    }
                    this.FirstExecutableGeneratedByPattern = sqlTask.SQLTaskHost;
                    this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;

                    this.ExecuteDuringDesignTime(patternNavigator,sqlTask.SQLTaskHost);
                } // if c != null
                else
                {
                    Message.Trace(Severity.Error, "{0}: Connection {1} does not exist.", name, patternNavigator.SelectSingleNode("rc:Connection", VulcanPackage.VulcanConfig.NamespaceManager).OuterXml);
                }
            }
        }