protected Pattern(Vulcan.Packages.VulcanPackage vulcanPackage, DTS.IDTSSequence parentContainer) { _vulcanPackage = vulcanPackage; _parentContainer = parentContainer; _firstExecutableGeneratedByPattern = null; _lastExecutableGeneratedByPattern = null; }
public override void Emit(XPathNavigator patternNavigator) { string name = patternNavigator.SelectSingleNode("@Name").Value; string constraintMode = patternNavigator.SelectSingleNode("@ConstraintMode").Value; DTS.Sequence newParentContainer = VulcanPackage.AddSequenceContainer(name, ParentContainer); DTS.Executable previousExec = null; Pattern p = null; foreach (XPathNavigator nav in patternNavigator.SelectChildren(XPathNodeType.Element)) { p = PatternFactory.ProcessPattern(VulcanPackage, newParentContainer, nav, p); switch (constraintMode) { case "Linear": VulcanPackage.AddPrecedenceConstraint(previousExec, p.FirstExecutableGeneratedByPattern, newParentContainer); break; case "Parallel": break; default: Message.Trace(Severity.Error, "Unknown ConstraintMode {0}", constraintMode); break; } previousExec = p.LastExecutableGeneratedByPattern; } this.FirstExecutableGeneratedByPattern = newParentContainer; this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern; }
protected Pattern(Vulcan.Packages.VulcanPackage vulcanPackage,DTS.IDTSSequence parentContainer) { _vulcanPackage = vulcanPackage; _parentContainer = parentContainer; _firstExecutableGeneratedByPattern = null; _lastExecutableGeneratedByPattern = null; }
protected void ExecuteDuringDesignTime(XPathNavigator patternNavigator, DTS.Executable task) { bool executeNow = patternNavigator.SelectSingleNode("@ExecuteDuringDesignTime").ValueAsBoolean; if (executeNow) { Message.Trace(Severity.Alert, "Executing DTS Package {0}", VulcanPackage.ExtractNameFromDTSExecutable(task)); this.SafeExecute(task); } }
public DTS.Executable AppendExecutable(string moniker) { DTS.Executable executable = _dtsSequence.Executables.Add(moniker); if (_constraintMode == "Linear") { if (_lastExecutable != null) { _dtsSequence.PrecedenceConstraints.Add(_lastExecutable, executable); } _lastExecutable = executable; } return executable; }
public string ExtractNameFromDTSExecutable(DTS.Executable exec) { PropertyInfo namePropertyInfo = exec.GetType().GetProperty("Name"); if (namePropertyInfo != null) { return((string)namePropertyInfo.GetValue(exec, null)); } else { return(""); } }
public DTS.Executable AppendExecutable(string moniker) { DTS.Executable executable = _dtsSequence.Executables.Add(moniker); if (_constraintMode == "Linear") { if (_lastExecutable != null) { _dtsSequence.PrecedenceConstraints.Add(_lastExecutable, executable); } _lastExecutable = executable; } return(executable); }
public void AddPrecedenceConstraint(DTS.Executable from, DTS.Executable to, DTS.IDTSSequence parentContainer) { if (from != null && to != null && parentContainer != null) { if ( parentContainer.Executables.Contains(this.ExtractNameFromDTSExecutable(from)) && parentContainer.Executables.Contains(this.ExtractNameFromDTSExecutable(to)) ) { DTS.PrecedenceConstraint pc = parentContainer.PrecedenceConstraints.Add(from, to); pc.Name = ExtractNameFromDTSExecutable(from) + "_" + ExtractNameFromDTSExecutable(to); } } }
protected void ConfigurePatterns() { Pattern p = null; foreach (XPathNavigator patternNavigator in _packageNavigator.Select("rc:Patterns", _vulcanConfig.NamespaceManager)) { DTS.Executable previousExec = null; foreach (XPathNavigator nav in patternNavigator.SelectChildren(XPathNodeType.Element)) { p = PatternFactory.ProcessPattern(this, this.DTSPackage, nav, null); if (p != null) { AddPrecedenceConstraint(previousExec, p.FirstExecutableGeneratedByPattern, this.DTSPackage); previousExec = p.LastExecutableGeneratedByPattern; } } } }
protected void SafeExecute(DTS.Executable executable) { Vulcan.Common.ErrorEvents errorHandler = new Vulcan.Common.ErrorEvents(); DTS.DTSExecResult execResult = executable.Execute(null, null, errorHandler, null, null); if (execResult == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success && errorHandler.ValidationErrorCount == 0) { Message.Trace( Severity.Notification, "Success executing Task {0}", VulcanPackage.ExtractNameFromDTSExecutable(executable) ); } else { Message.Trace( Severity.Error, "Error executing Task {0}: Result = {1} (BugBug: SSIS always returns success) but ErrorCount = {2}", VulcanPackage.ExtractNameFromDTSExecutable(executable), execResult, errorHandler.ValidationErrorCount ); } }
public SsisExecutable(DTS.Executable executable) { _executable = executable; }
public void ProcessTaskBinding(Executable executable) { if (executable.BindingList != null && executable.BindingList.Count > 0) { foreach (var binding in executable.BindingList) { var parentExecutable = DtsSequence.Executables[((AST.AstNamedNode)binding.AstTaskflowInput.OutputPath.ParentItem).Name]; if (parentExecutable == null) { throw new InvalidOperationException("Could not find " + binding.AstTaskflowInput.OutputPath.Name); } var constraint = DtsSequence.PrecedenceConstraints.Add(parentExecutable, executable.DtsExecutable); constraint.Name = GetPrecedenceConstraintEmissionName(binding.AstTaskflowPrecedenceConstraints, binding.AstTaskflowInput); switch (binding.AstTaskflowInput.EvaluationOperation) { case TaskEvaluationOperationType.Constraint: constraint.EvalOp = Microsoft.SqlServer.Dts.Runtime.DTSPrecedenceEvalOp.Constraint; break; case TaskEvaluationOperationType.Expression: constraint.EvalOp = Microsoft.SqlServer.Dts.Runtime.DTSPrecedenceEvalOp.Expression; constraint.Expression = binding.AstTaskflowInput.Expression; break; case TaskEvaluationOperationType.ExpressionAndConstraint: constraint.EvalOp = Microsoft.SqlServer.Dts.Runtime.DTSPrecedenceEvalOp.ExpressionAndConstraint; constraint.Expression = binding.AstTaskflowInput.Expression; break; case TaskEvaluationOperationType.ExpressionOrConstraint: constraint.EvalOp = Microsoft.SqlServer.Dts.Runtime.DTSPrecedenceEvalOp.ExpressionOrConstraint; constraint.Expression = binding.AstTaskflowInput.Expression; break; default: throw new NotImplementedException(String.Format(CultureInfo.InvariantCulture, "TaskEvaluationOperationType {0} is not supported.", binding.AstTaskflowInput.EvaluationOperation)); } switch (binding.AstTaskflowInput.EvaluationValue) { case TaskEvaluationOperationValue.Completion: constraint.Value = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Completion; break; case TaskEvaluationOperationValue.Failure: constraint.Value = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure; break; case TaskEvaluationOperationValue.Success: constraint.Value = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success; break; default: throw new NotImplementedException(String.Format(CultureInfo.InvariantCulture, "EvaluationValue {0} is not supported.", binding.AstTaskflowInput.EvaluationValue)); } switch (binding.AstTaskflowPrecedenceConstraints.LogicalType) { case LogicalOperationType.And: constraint.LogicalAnd = true; break; case LogicalOperationType.Or: constraint.LogicalAnd = false; break; default: break; } } } else { if (ConstraintMode == ContainerConstraintMode.Linear) { if (_lastExecutable != null) { var constraint = DtsSequence.PrecedenceConstraints.Add(_lastExecutable, executable.DtsExecutable); constraint.Name = String.Format(CultureInfo.InvariantCulture, "__DefaultLinear_Sink_{0}", executable.Name); } if (DtsSequence.Executables.Count > 0) { _lastExecutable = executable.DtsExecutable; } } } }
public static Pattern ProcessPattern(Packages.VulcanPackage vulcanPackage, DTS.IDTSSequence parentContainer, XPathNavigator patternNavigator, Pattern previousPattern) { DTS.Executable lastExecutableInPattern = null; if (previousPattern != null) { lastExecutableInPattern = previousPattern.FirstExecutableGeneratedByPattern; } Pattern p = null; Message.Trace(Severity.Debug, "Emitting Pattern {0}", patternNavigator.Name); try { switch (patternNavigator.Name) { case "HelperTables": p = new HelperTablePattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "ETL": p = new ETLPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "StoredProc": p = new StoredProcPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "Dimensions": p = new DimensionsPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "Logtainer": p = new LogtainerPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "LogUpdate": p = new LogUpdatePattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "Container": p = new ContainerPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "FileSystemTask": p = new FileSystemTaskPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "ExecuteSQL": p = new ExecuteSQLPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "FactTable": p = new FactTablePattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "ExecutePackage": p = new ExecutePackagePattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; case "FTPTask": p = new FTPTaskPattern(vulcanPackage, parentContainer); p.Emit(patternNavigator); break; default: break; } } catch (System.Runtime.InteropServices.COMException ce) { Message.Trace(Severity.Error, ce, "Exception in Pattern {0}\n {1}\n", patternNavigator.Name, ce.Message); } catch (Exception e) { Message.Trace(Severity.Error, e, "Exception in Pattern {0}\n {1}\n", patternNavigator.Name, e.Message); } return(p); }
public DTS.Executable AppendExecutable(string moniker) { DTS.Executable executable = DtsSequence.Executables.Add(moniker); return(executable); }
public override void Emit(XPathNavigator patternNavigator) { if (patternNavigator != null) { string taskName = patternNavigator.SelectSingleNode("@Name").Value; string connectionName = patternNavigator.SelectSingleNode("@Connection").Value; string varPrefix = patternNavigator.SelectSingleNode("@PreviousLogEntryVariablePrefix").Value; string sourceColumn = patternNavigator.SelectSingleNode("@SourceColumn") == null ? null : patternNavigator.SelectSingleNode("@SourceColumn").Value; string destinationColumn = patternNavigator.SelectSingleNode("@DestinationColumn") == null ? null : patternNavigator.SelectSingleNode("@DestinationColumn").Value; string table = patternNavigator.SelectSingleNode("@Table") == null ? null : patternNavigator.SelectSingleNode("@Table").Value; string tableConnectionName = patternNavigator.SelectSingleNode("@TableConnection") == null ? null : patternNavigator.SelectSingleNode("@TableConnection").Value; if (varPrefix.ToUpperInvariant() == "varLog") { Message.Trace(Severity.Error, "Name: {0}: Error in PreviousLogEntryVariablePrefix: varLog is a reserved variable name.", taskName); return; } Connection connection = Connection.GetExistingConnection(VulcanPackage, connectionName); LogtainerLog ll = new LogtainerLog( VulcanPackage, Resources.LogVariablePrefix + VulcanPackage.Name + taskName, sourceColumn, destinationColumn, table, tableConnectionName ); string execSqlTaskName = Resources.Log + Resources.Seperator + VulcanPackage.Name + Resources.Seperator + taskName + Resources.Seperator; SQLTask logStartTask = new SQLTask(VulcanPackage, execSqlTaskName + Resources.Start, execSqlTaskName + Resources.Start, ParentContainer, connection); TemplateEmitter te = new TemplateEmitter(VulcanPackage.TemplateManager["LogStart"]); te.SetNamedParameter("ETLName", VulcanPackage.Name); te.SetNamedParameter("TaskName", taskName); if (_logStack.Count > 0) { te.SetNamedParameter("ParentLogID", "?"); // Yes you have to hard code the data type as there is no lookup or cross-reference source, and the intger is dependent on the connection you create... bugbug! logStartTask.BindParameter(CurrentLog.LogVariable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Input, 3); } else { te.SetNamedParameter("ParentLogID", "NULL"); } logStartTask.BindParameter(ll.LogVariable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, 3); logStartTask.BindParameter(ll.LastRecordLogVariable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, 3); logStartTask.BindParameter(ll.IsAnotherInstanceCurrentlyRunningLogVariable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, 3); string sqlExpression; te.Emit(out sqlExpression); logStartTask.TransmuteToExpressionTask(sqlExpression); te = new TemplateEmitter(VulcanPackage.TemplateManager["LogGetValue"]); te.SetNamedParameter("LogID", ll.LastRecordLogVariable.QualifiedName); this.FirstExecutableGeneratedByPattern = logStartTask.SQLTaskHost; // Push the current log variable onto the stack! _logStack.Push(ll); //Add a new SQL Task to read the previous log te = new TemplateEmitter("LogGetValue", VulcanPackage, ll.LastRecordLogVariable.QualifiedName); string readPreviousLogValuesQuery; te.Emit(out readPreviousLogValuesQuery); SQLTask readPreviousLogValues = new SQLTask(VulcanPackage, Resources.Log + Resources.LoadInto + varPrefix, Resources.Log + Resources.LoadInto + varPrefix, ParentContainer, connection); readPreviousLogValues.TransmuteToExpressionTask(readPreviousLogValuesQuery); VulcanPackage.AddPrecedenceConstraint(this.FirstExecutableGeneratedByPattern, readPreviousLogValues.SQLTaskHost, ParentContainer); //Bind and create variables for the SQL Task that reads the previous log. This is kinda hacky readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "StartTime", new DateTime(1980, 1, 1)), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.DBTimeStamp, 255); readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "EndTime", new DateTime(1980, 1, 1)), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.DBTimeStamp, 255); readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "FirstSourceRecord", String.Empty), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.WChar, 255); readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "FirstDestinationRecord", String.Empty), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.WChar, 255); readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "LastSourceRecord", String.Empty), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.WChar, 255); readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "LastDestinationRecord", String.Empty), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.WChar, 255); readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "Status", String.Empty), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.WChar, 255); readPreviousLogValues.BindParameter( VulcanPackage.AddVariable(varPrefix + "Notes", String.Empty), Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, (int)System.Data.OleDb.OleDbType.WChar, 255); // Handle the sub-tasks just like the Container pattern DTS.Executable previousExec = readPreviousLogValues.SQLTaskHost; Pattern p = null; foreach (XPathNavigator nav in patternNavigator.SelectChildren(XPathNodeType.Element)) { p = PatternFactory.ProcessPattern(VulcanPackage, ParentContainer, nav, p); VulcanPackage.AddPrecedenceConstraint(previousExec, p.FirstExecutableGeneratedByPattern, ParentContainer); previousExec = p.LastExecutableGeneratedByPattern; } this.LastExecutableGeneratedByPattern = previousExec; // Pop the current log variable off of the stack and end the log. ll = _logStack.Pop(); te = new TemplateEmitter(VulcanPackage.TemplateManager["LogSetValue"]); te.SetNamedParameter("LogID", ll.LogVariable.QualifiedName); StringBuilder writeValuesToLogQuery = new StringBuilder(); foreach (string column in ll.LogColumnDictionary.Keys) { string temp; te.SetNamedParameter("Column", column); te.SetNamedParameter("Value", ll.LogColumnDictionary[column].QualifiedName); te.Emit(out temp); writeValuesToLogQuery.Append(temp); writeValuesToLogQuery.AppendFormat(" + \n"); } te = new TemplateEmitter(VulcanPackage.TemplateManager["LogEnd"]); te.Emit(out sqlExpression); writeValuesToLogQuery.Append(sqlExpression); SQLTask logEndTask = new SQLTask(VulcanPackage, execSqlTaskName + Resources.Stop, execSqlTaskName + Resources.Stop, ParentContainer, connection); logEndTask.TransmuteToExpressionTask(writeValuesToLogQuery.ToString()); logEndTask.BindParameter(ll.LogVariable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Input, 3); if (previousExec != null) { VulcanPackage.AddPrecedenceConstraint(previousExec, logEndTask.SQLTaskHost, ParentContainer); } this.LastExecutableGeneratedByPattern = logEndTask.SQLTaskHost; } }
protected virtual void AddComponent(ISequence sequence, string ExecutableID) { sequence.AddTask(this); Executable = sequence.Executables.Add(ExecutableID); }