private void ProcessSequence(DtsContainer container, IDTSSequence sequence, string path) { foreach (Executable executable in sequence.Executables) { ProcessObject(executable, path); } }
public ExecutableNodeFactory(Executable executable,Executables collection) { _collection = collection; _executable = (DtsContainer)executable; _host = _executable as TaskHost; _seq = _executable as Sequence; _foreachloop = _executable as ForEachLoop; _forloop = _executable as ForLoop; _psExecutable = PSObject.AsPSObject(_executable); if (null != _host) { _psExecutable.Properties.Add( new PSNoteProperty( "IsTaskHost", true )); _mainPipe = _host.InnerObject as MainPipe; } if (null != _mainPipe) { _psExecutable.Properties.Add(new PSNoteProperty("IsDataFlow", true)); } if (null != _seq) { _psExecutable.Properties.Add(new PSNoteProperty("IsSequence", true)); } if (null != _foreachloop) { _psExecutable.Properties.Add(new PSNoteProperty("IsForEachLoop", true)); } if (null != _forloop) { _psExecutable.Properties.Add(new PSNoteProperty("IsForLoop", true)); } }
public static void SetStandardErrorLoggingOptions(this DtsContainer package) { //assume we have one and only one log file package.LoggingOptions.EventFilterKind = DTSEventFilterKind.Inclusion; package.LoggingOptions.EventFilter = new [] { SsisConstants.LoggingEventOnError, SsisConstants.LoggingEventOnTaskFailed, SsisConstants.LoggingEventOnWarning }; package.LoggingMode = DTSLoggingMode.Enabled; }
// Called to get the value to set on the underlying object public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo info, object value) { var s = value as string; if (s != null) { if (s == string.Empty) { return(null); } if (IsGuid(s)) { return(value); } // If we made it this far, it's not a GUID - it's a task name try { Test test = (Test)context.Instance; Package pkg = Helper.LoadPackage(test.TestSuite, test.PackageLocation, test.StoredPassword); DtsContainer con = Helper.FindExecutable(pkg, value.ToString()); return(con.ID); } catch { throw new ArgumentException("Can not convert '" + s + "' to GUID"); } } return(base.ConvertFrom(context, info, value)); }
private void RecurseComponentsAndBuildPerformanceObjects(IDTSSequence container, DtsObjectPerformance performance, int indent) { foreach (Executable exe in container.Executables) { if (exe is DtsContainer) { DtsContainer child = (DtsContainer)exe; DtsObjectPerformance childPerformance; if (exe is TaskHost) { TaskHost task = (TaskHost)exe; MainPipe pipeline = task.InnerObject as MainPipe; if (pipeline != null) { childPerformance = new DtsPipelinePerformance(child.ID, child.Name, pipeline, indent + 1); } else { childPerformance = new DtsObjectPerformance(child.ID, child.Name, child.GetType(), indent + 1); } listComponentsPerformanceLookup.Add(child.ID, childPerformance); } else { childPerformance = new DtsObjectPerformance(child.ID, child.Name, child.GetType(), indent + 1); listComponentsPerformanceLookup.Add(child.ID, childPerformance); } performance.Children.Add(childPerformance); if (exe is IDTSSequence) { RecurseComponentsAndBuildPerformanceObjects((IDTSSequence)exe, childPerformance, indent + 1); } } } }
/// <summary> /// Gets the unique container key, based on the creation name. /// </summary> /// <param name="container">The container.</param> /// <returns>The container key</returns> public static string GetContainerKey(DtsContainer container) { string containerKey = container.CreationName; if (container is Package) { containerKey = PackageHelper.PackageCreationName; } else if (container is DtsEventHandler) { containerKey = PackageHelper.EventHandlerCreationName; } else if (container is Sequence) { containerKey = PackageHelper.SequenceCreationName; } else if (container is ForLoop) { containerKey = PackageHelper.ForLoopCreationName; } else if (container is ForEachLoop) { containerKey = PackageHelper.ForEachLoopCreationName; } return(containerKey); }
public static List <TaskHost> GetControlFlowObjects <T>(DtsContainer container) { List <TaskHost> returnItems = new List <TaskHost>(); if (container is EventsProvider) { EventsProvider ep = (EventsProvider)container; foreach (DtsEventHandler eh in ep.EventHandlers) { returnItems.AddRange(GetControlFlowObjects <T>(eh)); } } IDTSSequence sequence = (IDTSSequence)container; foreach (Executable exec in sequence.Executables) { if (exec is IDTSSequence) { returnItems.AddRange(GetControlFlowObjects <T>((DtsContainer)exec)); } else if (exec is TaskHost) { TaskHost th = (TaskHost)exec; if (th.InnerObject is T) { returnItems.Add(th); } } } return(returnItems); }
public ExecutableNodeFactory(Executable executable, Executables collection) { _collection = collection; _executable = (DtsContainer)executable; _host = _executable as TaskHost; _seq = _executable as Sequence; _foreachloop = _executable as ForEachLoop; _forloop = _executable as ForLoop; _psExecutable = PSObject.AsPSObject(_executable); if (null != _host) { _psExecutable.Properties.Add(new PSNoteProperty("IsTaskHost", true)); _mainPipe = _host.InnerObject as MainPipe; } if (null != _mainPipe) { _psExecutable.Properties.Add(new PSNoteProperty("IsDataFlow", true)); } if (null != _seq) { _psExecutable.Properties.Add(new PSNoteProperty("IsSequence", true)); } if (null != _foreachloop) { _psExecutable.Properties.Add(new PSNoteProperty("IsForEachLoop", true)); } if (null != _forloop) { _psExecutable.Properties.Add(new PSNoteProperty("IsForLoop", true)); } }
public override object Execute(Package package, DtsContainer container) { string remainingPath; var taskHost = Helper.FindExecutable(package, Properties[PropOutput].Value, out remainingPath) as TaskHost; if (taskHost == null) { throw new ArgumentException("Output property did not match a valid component output.", "package"); } var mainPipe = taskHost.InnerObject as MainPipe; if (mainPipe == null) { throw new ArgumentException("Output property did not match a valid component output.", "package"); } IDTSOutput output = Helper.FindComponentOutput(mainPipe, remainingPath); if (output == null) { throw new ArgumentException("Output property did not match a valid component output.", "package"); } throw new NotImplementedException(); // return true; }
private void EditExpressionButtonClick(int selectedRow, int selectedCol) { try { Package package = GetCurrentPackage(); if (package == null) { return; } if (selectedRow < 0) { return; } Variable variable = GetVariableForRow(selectedRow); if (variable == null) { return; } DtsContainer sourceContainer = FindObjectForVariablePackagePath(package, variable.GetPackagePath()); Variables variables = sourceContainer.Variables; VariableDispenser variableDispenser = sourceContainer.VariableDispenser; Konesans.Dts.ExpressionEditor.ExpressionEditorPublic editor = new Konesans.Dts.ExpressionEditor.ExpressionEditorPublic(variables, variableDispenser, variable); if (editor.ShowDialog() == DialogResult.OK) { string expression = editor.Expression; if (string.IsNullOrEmpty(expression) || string.IsNullOrEmpty(expression.Trim())) { expression = null; variable.EvaluateAsExpression = false; } else { variable.EvaluateAsExpression = true; } variable.Expression = expression; changesvc.OnComponentChanging(sourceContainer, null); changesvc.OnComponentChanged(sourceContainer, null, null, null); //marks the package designer as dirty SSISHelpers.MarkPackageDirty(package); TypeDescriptor.Refresh(variable); System.Windows.Forms.Application.DoEvents(); // Refresh the grid variablesToolWindowControl.GetType().InvokeMember("FillGrid", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, variablesToolWindowControl, new object[] { }); SetButtonEnabled(); RefreshHighlights(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace, DefaultMessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private Package GetPackageFromContainer(DtsContainer container) { while (!(container is Package)) { container = container.Parent; } return((Package)container); }
private void processPackage_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { System.ComponentModel.BackgroundWorker worker = (System.ComponentModel.BackgroundWorker)sender; DtsContainer container = (DtsContainer)e.Argument; ProcessObject(container, worker, string.Empty); }
public static Variable AddVariable(this DtsContainer package, string name, object value, bool readOnly, bool evaluateAsExpression) { var variable = package.Variables.Add(name, readOnly, SsisConstants.PackageVarUserNamespace, null); variable.Value = string.Empty; variable.EvaluateAsExpression = evaluateAsExpression; variable.Expression = value.ToString(); return(variable); }
private static Package GetPackage(DtsContainer executable) { while (executable.GetType() != typeof(Package)) { executable = executable.Parent; } return((Package)executable); }
private DtsContainer FindObjectForVariablePackagePath(DtsContainer parent, string PackagePath) { if (PackagePath.StartsWith(((IDTSPackagePath)parent).GetPackagePath() + ".Variables[")) { return((DtsContainer)parent); } IDTSSequence seq = parent as IDTSSequence; if (seq != null) { foreach (Executable e in seq.Executables) { if (e is IDTSPackagePath) { if (PackagePath.StartsWith(((IDTSPackagePath)e).GetPackagePath() + ".Variables[")) { return((DtsContainer)e); } } if (e is DtsContainer) { DtsContainer ret = FindObjectForVariablePackagePath((DtsContainer)e, PackagePath); if (ret != null) { return(ret); } } } } EventsProvider prov = parent as EventsProvider; if (prov != null) { foreach (DtsEventHandler eh in prov.EventHandlers) { if (eh is IDTSPackagePath) { if (PackagePath.StartsWith(((IDTSPackagePath)eh).GetPackagePath() + ".Variables[")) { return((DtsContainer)eh); } } if (eh is IDTSSequence) { DtsContainer ret = FindObjectForVariablePackagePath((DtsContainer)eh, PackagePath); if (ret != null) { return(ret); } } } } return(null); }
public void FindExecutableByNameTest() { var ssisApp = new Application(); Package packageToTest = ssisApp.LoadPackage(UnpackToFile(TestPackageResource), null); DtsContainer result = SsisUnit.Helper.FindExecutable(packageToTest, "SELECT COUNT"); Assert.AreEqual("SELECT COUNT", result.Name); }
private void ProcessAsserts(object loadedProject, Package packageToTest, DtsContainer taskHost, bool preExecuteAsserts, Log assertLog) { // TODO: Log asserts foreach (SsisAssert assert in Asserts.Values) { if (assert.TestBefore == preExecuteAsserts) { assert.Execute(loadedProject, packageToTest, taskHost, assertLog); } } }
public void RunVariableCommandGetTest() { var ts = new SsisTestSuite(); var target = new VariableCommand(ts, VariableCommand.VariableOperation.Get, "VariableTest", "0"); var ssisApp = new Application(); Package package = ssisApp.LoadPackage(_dtsxFilePath, null); DtsContainer container = package; string actual = target.Execute(package, container).ToString(); Assert.AreEqual("55", actual); }
private void ProcessSequence(DtsContainer container, IDTSSequence sequence, System.ComponentModel.BackgroundWorker worker, string path) { if (worker.CancellationPending) { return; } foreach (Executable executable in sequence.Executables) { ProcessObject(executable, worker, path); } }
internal static Variable FindVariable(DtsContainer container, string objectID) { if (container != null) { if (container.Variables.Contains(objectID)) { return(container.Variables[objectID]); } } return(null); }
public void FindExecutableByIdTest() { var ssisApp = new Application(); Package packageToTest = ssisApp.LoadPackage(UnpackToFile(TestPackageResource), null); DtsContainer result = SsisUnit.Helper.FindExecutable(packageToTest, "{B439F9C9-2B1D-47E4-B328-7603126875FF}"); Assert.AreEqual("INSERT ROW", result.Name); result = SsisUnit.Helper.FindExecutable(packageToTest, "{D2D9295A-45D0-4681-B021-F5077CB2EC22}"); Assert.AreEqual("UT Basic Scenario", result.Name); }
public override object Execute(Package package, DtsContainer container) { if (ConnectionReference == null) { throw new ApplicationException(string.Format(CultureInfo.CurrentCulture, "The connectionRef attribute is {0}, which does not reference a valid connection.", Properties[PropConnection].Value)); } object result; DbCommand dbCommand = null; CommandParentType commandParentType = GetCommandParentType(); try { OnCommandStarted(new CommandStartedEventArgs(DateTime.Now, CommandName, null, null, commandParentType)); dbCommand = GetCommand(ConnectionReference, SQLStatement); dbCommand.Connection.Open(); if (ReturnsValue) { result = dbCommand.ExecuteScalar(); } else { dbCommand.ExecuteNonQuery(); result = null; } OnCommandCompleted(new CommandCompletedEventArgs(DateTime.Now, CommandName, null, null, string.Format(CultureInfo.CurrentCulture, "The {0} command has completed.", CommandName), commandParentType)); } catch (Exception ex) { OnCommandFailed(new CommandFailedEventArgs(DateTime.Now, CommandName, null, null, ex.Message, commandParentType)); throw; } finally { if (dbCommand != null) { dbCommand.Connection.Close(); dbCommand.Dispose(); } } return(result); }
private void CheckConnectionManagers(Package package, BackgroundWorker worker, string path) { if (worker.CancellationPending) { return; } foreach (ConnectionManager cm in package.Connections) { DtsContainer container = (DtsContainer)package; // TODO; Fix - Cheat and hard code creation name as icon routines cannot get the correct connection icon ScanProperties(worker, path + ".Connections[" + cm.Name + "].", typeof(ConnectionManager), cm.GetType().Name, package.ID, cm.ID, cm.Name, (IDTSPropertiesProvider)cm, PackageHelper.ConnectionCreationName); } }
void MoveCopyButtonClick() { try { List <Variable> variables = GetSelectedVariables(); if (variables.Count > 0) { System.Collections.ArrayList variableDesigners = GetSelectedVariableDesigners(); #if DENALI || SQL2014 packageDesigner = (ComponentDesigner)variablesToolWindowControl.GetType().GetProperty("PackageDesigner", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance).GetValue(variablesToolWindowControl, null); #else packageDesigner = (ComponentDesigner)variablesToolWindowControl.GetType().InvokeMember("PackageDesigner", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, variablesToolWindowControl, null); #endif Package package = packageDesigner.Component as Package; DtsContainer oCurrentScope = FindObjectForVariablePackagePath(package, variables[0].GetPackagePath()); BIDSHelper.SSIS.VariablesMove form = new BIDSHelper.SSIS.VariablesMove(package, oCurrentScope.ID, variables.Count); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { DtsContainer targetContainer = form.TargetContainer; bool move = form.IsMove; try { CopyVariables(variables, move, targetContainer, package, variableDesigners); } finally { //refresh the grid after the changes we've made variablesToolWindowControl.GetType().InvokeMember("FillGrid", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, variablesToolWindowControl, new object[] { }); SetButtonEnabled(); RefreshHighlights(); } } } else { MessageBox.Show("Highlight one or more variables before clicking this button.", "BIDS Helper - Variable Scope Change", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (VariableCopyException ex) { MessageBox.Show(ex.Message, "BIDS Helper", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace, "BIDS Helper", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void SetupTest() { var target = new SsisTestSuite(Helper.CreateUnitTestStream(TestXmlFilename)); var ssisApp = new Application(); target.ConnectionList["AdventureWorks"].ConnectionString = "Provider=SQLNCLI11;Data Source=localhost;Integrated Security=SSPI;Initial Catalog=tempdb"; Package packageToTest = ssisApp.LoadPackage(UnpackToFile(TestPackageResource), null); string remainingPath; DtsContainer task = SsisUnit.Helper.FindExecutable(packageToTest, "SELECT COUNT", out remainingPath); int result = target.SetupCommands.Execute(null, packageToTest, task); Assert.AreEqual(4, result); }
public void RunPropertyCommandGetTest() { var ts = new SsisTestSuite(Helper.CreateUnitTestStream(TestXmlFilename)); var target = (PropertyCommand)ts.SetupCommands.Commands[0]; var ssisApp = new Application(); var packageFile = UnpackToFile("UTssisUnit.TestPackages.PropertyTest.dtsx"); ts.PackageList["PropertyTest"].PackagePath = packageFile; Package package = ssisApp.LoadPackage(ts.PackageList["PropertyTest"].PackagePath, null); DtsContainer container = package; object actual = target.Execute(package, container); Assert.AreEqual("TestValue", actual); }
public void FindExecutableDoesNotExistTest() { var ssisApp = new Application(); Package packageToTest = ssisApp.LoadPackage(UnpackToFile(TestPackageResource), null); DtsContainer result = SsisUnit.Helper.FindExecutable(packageToTest, "Does Not Exist"); Assert.IsNull(result); result = SsisUnit.Helper.FindExecutable(packageToTest, @"Package\Test\Does Not Exist"); Assert.IsNull(result); result = SsisUnit.Helper.FindExecutable(packageToTest, "{6CABA47A-AF51-49DB-8B9B-14FEB71B1EB2}"); Assert.IsNull(result); }
// Called to get the display value for the property grid public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) { if (destType == typeof(string) && value is string) { if (!IsGuid(value)) { return(value); } Test test = (Test)context.Instance; Package pkg = Helper.LoadPackage(test.TestSuite, test.PackageLocation, test.StoredPassword); DtsContainer con = Helper.FindExecutable(pkg, value.ToString()); return(con.Name); } return(base.ConvertTo(context, culture, value, destType)); }
private string[] ScanDtsObjectVariablesForErrors(DtsContainer o) { List <string> listOtherErrors = new List <string>(); foreach (Variable v in o.Variables) { if (!v.SystemVariable && v.GetPackagePath().StartsWith(((IDTSPackagePath)o).GetPackagePath() + ".Variables[")) //only variables in this scope { object val; try { val = v.Value; //look at each value to see if each variable expression works } catch (Exception ex) { listOtherErrors.Add(ex.Message); continue; } //if we haven't already gotten an error, try to validate the expression IDTSInfoEventsWrapper events = new IDTSInfoEventsWrapper(); try { if (!string.IsNullOrEmpty(v.Expression)) { Microsoft.SqlServer.Dts.Runtime.Wrapper.ExpressionEvaluatorClass eval = new Microsoft.SqlServer.Dts.Runtime.Wrapper.ExpressionEvaluatorClass(); eval.Expression = v.Expression; eval.Events = events; #if KATMAI || DENALI || SQL2014 eval.Evaluate(DtsConvert.GetExtendedInterface(o.VariableDispenser), out val, false); #else eval.Evaluate(DtsConvert.ToVariableDispenser90(o.VariableDispenser), out val, false); #endif } } catch { if (events.Errors.Length > 0) { listOtherErrors.Add("Error in expression for variable " + v.QualifiedName + ": " + events.Errors[0]); } continue; } } } return(listOtherErrors.ToArray()); }
private void ProcessObject(object component, System.ComponentModel.BackgroundWorker worker, string path) { if (worker.CancellationPending) { return; } DtsContainer container = component as DtsContainer; // Should only get package as we call GetPackage up front. Could make scope like, but need UI indicator that this is happening Package package = component as Package; if (package != null) { path = "\\Package"; CheckConnectionManagers(package, worker, path); } else if (!(component is DtsEventHandler)) { path = path + "\\" + container.Name; } IDTSPropertiesProvider propertiesProvider = component as IDTSPropertiesProvider; if (propertiesProvider != null) { CheckProperties(propertiesProvider, worker, path); } EventsProvider eventsProvider = component as EventsProvider; if (eventsProvider != null) { foreach (DtsEventHandler eventhandler in eventsProvider.EventHandlers) { ProcessObject(eventhandler, worker, path + ".EventHandlers[" + eventhandler.Name + "]"); } } IDTSSequence sequence = component as IDTSSequence; if (sequence != null) { ProcessSequence(container, sequence, worker, path); ScanPrecedenceConstraints(worker, path, container.ID, sequence.PrecedenceConstraints); } }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node == null) { return; } DtsContainer container = e.Node.Tag as DtsContainer; if (container == null) { return; } // Enable or disable OK button, when a valid move or copy target has been selected this.btnOK.Enabled = !(this.selectedContainerId == container.ID); }
internal static PrecedenceConstraint FindConstraint(DtsContainer container, string objectID) { IDTSSequence sequence = container as IDTSSequence; if (sequence == null) { System.Diagnostics.Debug.Assert(false, "sequence cannot be found"); return(null); } if (sequence.PrecedenceConstraints.Contains(objectID)) { return(sequence.PrecedenceConstraints[objectID]); } return(null); }
private DtsContainer FindObjectForVariablePackagePath(DtsContainer parent, string PackagePath) { if (PackagePath.StartsWith(((IDTSPackagePath)parent).GetPackagePath() + ".Variables[")) { return ((DtsContainer)parent); } IDTSSequence seq = parent as IDTSSequence; if (seq != null) { foreach (Executable e in seq.Executables) { if (e is IDTSPackagePath) { if (PackagePath.StartsWith(((IDTSPackagePath)e).GetPackagePath() + ".Variables[")) { return ((DtsContainer)e); } } if (e is DtsContainer) { DtsContainer ret = FindObjectForVariablePackagePath((DtsContainer)e, PackagePath); if (ret != null) return ret; } } } EventsProvider prov = parent as EventsProvider; if (prov != null) { foreach (DtsEventHandler eh in prov.EventHandlers) { if (eh is IDTSPackagePath) { if (PackagePath.StartsWith(((IDTSPackagePath)eh).GetPackagePath() + ".Variables[")) { return ((DtsContainer)eh); } } if (eh is IDTSSequence) { DtsContainer ret = FindObjectForVariablePackagePath((DtsContainer)eh, PackagePath); if (ret != null) return ret; } } } return null; }
public void OnVariableValueChanged(DtsContainer DtsContainer, Variable variable, ref bool fireAgain) { }
private void CopyVariables(List<Variable> variables, bool move, DtsContainer targetContainer, Package package, System.Collections.ArrayList sourceVariableDesigners) { foreach (Variable sourceVar in variables) { if (targetContainer is IDTSPackagePath && sourceVar.GetPackagePath().StartsWith(((IDTSPackagePath)targetContainer).GetPackagePath() + ".Variables[")) { throw new VariableCopyException("You are attempting to copy the variable '" + sourceVar.QualifiedName + "' to the same scope it is already in.", null); } else if (sourceVar.SystemVariable) { throw new VariableCopyException(sourceVar.QualifiedName + " is a system variable and cannot be copied or moved.", null); } } foreach (Variable sourceVar in variables) { //Variable targetVar = targetContainer.Variables.Add(sourceVar.Name, sourceVar.ReadOnly, sourceVar.Namespace, sourceVar.Value); //this is the standard way to add a variable, but it doesn't interact well with the variables tool window Variable targetVar = (Variable)packageDesigner.GetType().InvokeMember("CreateVariable", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, packageDesigner, new object[] { targetContainer, sourceVar.Name, sourceVar.ReadOnly, sourceVar.Namespace, sourceVar.Value }); try { targetVar.Name = sourceVar.Name; } catch (Exception ex) { serviceProvider.DestroyComponent(targetVar); throw new VariableCopyException("Could not copy " + sourceVar.QualifiedName + " to scope \"" + targetContainer.Name + "\" because another variable with that name already exists.", ex); } //targetVar.DataType is read only targetVar.Description = sourceVar.Description; targetVar.EvaluateAsExpression = sourceVar.EvaluateAsExpression; targetVar.Expression = sourceVar.Expression; targetVar.RaiseChangedEvent = sourceVar.RaiseChangedEvent; if (move) { DtsContainer sourceContainer = FindObjectForVariablePackagePath(package, sourceVar.GetPackagePath()); changesvc.OnComponentChanging(sourceContainer, null); changesvc.OnComponentChanged(sourceContainer, null, null, null); //marks the package designer as dirty } } if (move) { #if DENALI //terrible workaround to get the exact right parameter type for the DeleteVariables method in Denali. Guess calling InvokeMember against a function with a parameter of a generic type is tricky System.Collections.IList listParam = ((System.Collections.IList)System.Type.GetType("System.Collections.Generic.List`1[[" + ExpressionHighlighterPlugin.GetPrivateType(variablesToolWindowControl.GetType(), "Microsoft.DataTransformationServices.Design.VariableDesigner").AssemblyQualifiedName + "]]").GetConstructor(new Type[] { }).Invoke(new object[] { })); foreach (object o in sourceVariableDesigners) { listParam.Add(o); } variablesToolWindowControl.GetType().GetMethod("DeleteVariables", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance).Invoke(variablesToolWindowControl, new object[] { listParam }); #else variablesToolWindowControl.GetType().InvokeMember("DeleteVariables", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, variablesToolWindowControl, new object[] { sourceVariableDesigners }); #endif } changesvc.OnComponentChanging(targetContainer, null); changesvc.OnComponentChanged(targetContainer, null, null, null); //marks the package designer as dirty SSISHelpers.MarkPackageDirty(package); ValidatePackage(package); }
private string[] ScanDtsObjectVariablesForErrors(DtsContainer o) { List<string> listOtherErrors = new List<string>(); foreach (Variable v in o.Variables) { if (!v.SystemVariable && v.GetPackagePath().StartsWith(((IDTSPackagePath)o).GetPackagePath() + ".Variables[")) //only variables in this scope { object val; try { val = v.Value; //look at each value to see if each variable expression works } catch (Exception ex) { listOtherErrors.Add(ex.Message); continue; } //if we haven't already gotten an error, try to validate the expression IDTSInfoEventsWrapper events = new IDTSInfoEventsWrapper(); try { if (!string.IsNullOrEmpty(v.Expression)) { Microsoft.SqlServer.Dts.Runtime.Wrapper.ExpressionEvaluatorClass eval = new Microsoft.SqlServer.Dts.Runtime.Wrapper.ExpressionEvaluatorClass(); eval.Expression = v.Expression; eval.Events = events; #if KATMAI || DENALI eval.Evaluate(DtsConvert.GetExtendedInterface(o.VariableDispenser), out val, false); #else eval.Evaluate(DtsConvert.ToVariableDispenser90(o.VariableDispenser), out val, false); #endif } } catch { if (events.Errors.Length > 0) listOtherErrors.Add("Error in expression for variable " + v.QualifiedName + ": " + events.Errors[0]); continue; } } } return listOtherErrors.ToArray(); }
private void IterateContainers(DtsContainer parent, TreeNodeCollection nodes, string selectedContainerId) { TreeNode node = new TreeNode(); node.Name = parent.Name; node.Text = parent.Name; node.Tag = parent; SetNodeIcon(parent, node); nodes.Add(node); if (parent.ID == selectedContainerId) { node.TreeView.SelectedNode = node; } IDTSSequence seq = parent as IDTSSequence; if (seq != null) { foreach (Executable e in seq.Executables) { if (e is IDTSSequence || e is EventsProvider) { IterateContainers((DtsContainer)e, node.Nodes, selectedContainerId); } else { DtsContainer task = (DtsContainer)e; TreeNode childNode = new TreeNode(); childNode.Name = task.Name; childNode.Text = task.Name; childNode.Tag = task; SetNodeIcon(task, childNode); node.Nodes.Add(childNode); if (task.ID == selectedContainerId) { node.TreeView.SelectedNode = childNode; } } } } EventsProvider prov = parent as EventsProvider; if (prov != null) { foreach (DtsEventHandler p in prov.EventHandlers) { DtsContainer task = (DtsContainer)p; TreeNode childNode = new TreeNode(); childNode.Name = string.Format(CultureInfo.InvariantCulture, "{0} Event", p.Name); childNode.Text = string.Format(CultureInfo.InvariantCulture, "{0} Event", p.Name); childNode.Tag = task; SetNodeIcon(task, childNode); node.Nodes.Add(childNode); if (task.ID == selectedContainerId) { node.TreeView.SelectedNode = childNode; } } } return; }
private void SetNodeIcon(DtsContainer container, TreeNode childNode) { string key = PackageHelper.GetContainerKey(container); if (!this.imageList.Images.ContainsKey(key)) { if (PackageHelper.ControlFlowInfos.ContainsKey(key)) { this.imageList.Images.Add(key, PackageHelper.ControlFlowInfos[key].Icon); } else { MessageBox.Show(container.Name); } } childNode.ImageKey = key; childNode.SelectedImageKey = key; }
private PrecedenceConstraint FindConstraint(DtsContainer container, string objectID) { IDTSSequence sequence = container as IDTSSequence; if (sequence == null) { System.Diagnostics.Debug.Assert(false, "sequence cannot be found"); return null; } if (sequence.PrecedenceConstraints.Contains(objectID)) { return sequence.PrecedenceConstraints[objectID]; } return null; }
private DtsContainer FindContainer(DtsContainer component, string objectId) { //DtsContainer container = component as DtsContainer; if (component == null) { return null; } else if (component.ID == objectId) { return component; } EventsProvider eventsProvider = component as EventsProvider; if (eventsProvider != null) { foreach (DtsEventHandler eventhandler in eventsProvider.EventHandlers) { DtsContainer container = FindContainer(eventhandler, objectId); if (container != null) { return container; } } } IDTSSequence sequence = component as IDTSSequence; if (sequence != null) { foreach (Executable executable in sequence.Executables) { DtsContainer container = FindContainer((DtsContainer)executable, objectId); if (container != null) { return container; } } } return null; }
private Package GetPackageFromContainer(DtsContainer container) { while (!(container is Package)) { container = container.Parent; } return (Package)container; }
private Variable FindVariable(DtsContainer container, string objectID) { if (container != null) { if (container.Variables.Contains(objectID)) { return container.Variables[objectID]; } } return null; }