Esempio n. 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;
            }
        }
Esempio n. 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;
        }
Esempio n. 3
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
            }
        }