public override void Emit(XPathNavigator patternNavigator) { if (patternNavigator != null) { string firstOrLast = patternNavigator.SelectSingleNode("@FirstOrLast").Value; string status = patternNavigator.SelectSingleNode("@Status").Value; string notes = patternNavigator.SelectSingleNode("@Notes").Value; Connection tableConnection = Connection.GetExistingConnection(VulcanPackage, LogtainerPattern.CurrentLog.TableConnectionName); string execSqlTaskName = LogtainerPattern.CurrentLog.LogName + Resources.Seperator + firstOrLast + Guid.NewGuid(); TemplateEmitter te = new TemplateEmitter(VulcanPackage.TemplateManager["LogSelectQuery"]); if ( LogtainerPattern.CurrentLog.SourceColumn == null || LogtainerPattern.CurrentLog.DestinationColumn == null || LogtainerPattern.CurrentLog.TableConnectionName == null || LogtainerPattern.CurrentLog.Table == null) { Message.Trace(Severity.Error, "Could not perform LogUpdate (On Log: {0}), Parent Logtainer does not contain all of the necessary information. Needs SourceColumn, DestinationColumn, TableConnectionName, and Table attributes.", LogtainerPattern.CurrentLog.LogName); return; } te.SetNamedParameter("Source", LogtainerPattern.CurrentLog.SourceColumn); te.SetNamedParameter("Destination", LogtainerPattern.CurrentLog.DestinationColumn); te.SetNamedParameter("Table", LogtainerPattern.CurrentLog.Table); te.SetNamedParameter("Status", status); te.SetNamedParameter("Notes", notes); te.SetNamedParameter("SourceConvertStyle", "21"); te.SetNamedParameter("DestinationConvertStyle", "21"); string query; te.Emit(out query); SQLTask readForLogTask = new SQLTask(VulcanPackage, execSqlTaskName, execSqlTaskName, ParentContainer, tableConnection); readForLogTask.TransmuteToExpressionTask(String.Format("\"{0}\"", query)); readForLogTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_SingleRow; DTS.Variable sourceVar = LogtainerPattern.CurrentLog[firstOrLast + "SourceRecord"]; DTS.Variable destVar = LogtainerPattern.CurrentLog[firstOrLast + "DestinationRecord"]; DTS.Variable statusVar = LogtainerPattern.CurrentLog["Status"]; DTS.Variable notesVar = LogtainerPattern.CurrentLog["Notes"]; readForLogTask.BindResult("0", sourceVar.QualifiedName); readForLogTask.BindResult("1", destVar.QualifiedName); readForLogTask.BindResult("2", statusVar.QualifiedName); readForLogTask.BindResult("3", notesVar.QualifiedName); this.FirstExecutableGeneratedByPattern = readForLogTask.SQLTaskHost; this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern; } }
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); } } }