protected virtual void OnRaiseEditExpressionSelected(EditExpressionSelectedEventArgs e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. EventHandler <EditExpressionSelectedEventArgs> handler = EditExpressionSelected; // Event will be null if there are no subscribers if (handler != null) { handler(this, e); } }
protected virtual void OnRaiseEditExpressionSelected(EditExpressionSelectedEventArgs e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. EventHandler<EditExpressionSelectedEventArgs> handler = EditExpressionSelected; // Event will be null if there are no subscribers if (handler != null) { handler(this, e); } }
void expressionListWindow_EditExpressionSelected(object sender, EditExpressionSelectedEventArgs e) { try { Package package = null; DtsContainer container = null; if (win == null) { return; } try { package = GetCurrentPackage(); if (package == null) { return; } } catch (Exception ex) { System.Diagnostics.Debug.Assert(false, ex.ToString()); return; } // Parameters for Expression Editor Variables variables = null; VariableDispenser variableDispenser = null; string propertyName = string.Empty; Type propertyType = null; // Target objects IDTSPropertiesProvider propertiesProvider = null; Variable variable = null; PrecedenceConstraint constraint = null; // Get the container container = FindContainer(package, e.ContainerID); // Get the property details and variable objects for the editor if (e.Type == typeof(Variable)) { variable = FindVariable(container, e.ObjectID); propertyName = "Value"; propertyType = System.Type.GetType("System." + variable.DataType.ToString()); variables = container.Variables; variableDispenser = container.VariableDispenser; } else if (e.Type == typeof(PrecedenceConstraint)) { constraint = FindConstraint(container, e.ObjectID); propertyName = "Expression"; propertyType = typeof(bool); variables = container.Variables; variableDispenser = container.VariableDispenser; } else { if (e.Type == typeof(ConnectionManager)) { propertiesProvider = FindConnectionManager(package, e.ObjectID) as IDTSPropertiesProvider; } else if (e.Type == typeof(ForEachEnumerator)) { ForEachLoop forEachLoop = container as ForEachLoop; propertiesProvider = forEachLoop.ForEachEnumerator as IDTSPropertiesProvider; } else { propertiesProvider = container as IDTSPropertiesProvider; } if (propertiesProvider != null) { DtsProperty property = propertiesProvider.Properties[e.Property]; propertyName = property.Name; propertyType = PackageHelper.GetTypeFromTypeCode(property.Type); variables = container.Variables; variableDispenser = container.VariableDispenser; } else { throw new Exception(string.Format(CultureInfo.InvariantCulture, "Expression editing not supported on this object ({0}).", e.ObjectID)); } } // Show the editor Konesans.Dts.ExpressionEditor.ExpressionEditorPublic editor = new Konesans.Dts.ExpressionEditor.ExpressionEditorPublic(variables, variableDispenser, propertyType, propertyName, e.Expression); if (editor.ShowDialog() == DialogResult.OK) { // Get expression string expression = editor.Expression; if (expression == null || string.IsNullOrEmpty(expression.Trim())) { expression = null; } // Set the new expression on the target object object objectChanged = null; if (variable != null) { if (expression == null) { variable.EvaluateAsExpression = false; } variable.Expression = expression; objectChanged = variable; } else if (constraint != null) { if (expression == null) { constraint.EvalOp = DTSPrecedenceEvalOp.Constraint; } constraint.Expression = expression; objectChanged = constraint; } else if (propertiesProvider != null) { // TaskHost, Sequence, ForLoop, ForEachLoop and ConnectionManager propertiesProvider.SetExpression(e.Property, expression); objectChanged = propertiesProvider; } expressionListWindow_RefreshExpressions(null, null); // Finish displaying expressions list before you mark the package // as dirty (which runs the expression highlighter) System.Windows.Forms.Application.DoEvents(); SetPackageAsDirty(package, expression, objectChanged); } } catch (Exception ex) { throw ex; } }
void expressionListWindow_EditExpressionSelected(object sender, EditExpressionSelectedEventArgs e) { try { Package package = null; DtsContainer container = null; if (win == null) { return; } try { package = GetCurrentPackage(); if (package == null) { return; } } catch (Exception ex) { System.Diagnostics.Debug.Assert(false, ex.ToString()); return; } // Parameters for Expression Editor Variables variables = null; VariableDispenser variableDispenser = null; string propertyName = string.Empty; Type propertyType = null; // Target objects IDTSPropertiesProvider propertiesProvider = null; Variable variable = null; PrecedenceConstraint constraint = null; // Get the container container = SSISHelpers.FindContainer(package, e.ContainerID); // Get the property details and variable objects for the editor if (e.Type == typeof(Variable)) { variable = SSISHelpers.FindVariable(container, e.ObjectID); propertyName = "Value"; propertyType = System.Type.GetType("System." + variable.DataType.ToString()); variables = container.Variables; variableDispenser = container.VariableDispenser; } else if (e.Type == typeof(PrecedenceConstraint)) { constraint = SSISHelpers.FindConstraint(container, e.ObjectID); propertyName = "Expression"; propertyType = typeof(bool); variables = container.Variables; variableDispenser = container.VariableDispenser; } else { if (e.Type == typeof(ConnectionManager)) { propertiesProvider = SSISHelpers.FindConnectionManager(package, e.ObjectID) as IDTSPropertiesProvider; } else if (e.Type == typeof(ForEachEnumerator)) { ForEachLoop forEachLoop = container as ForEachLoop; propertiesProvider = forEachLoop.ForEachEnumerator as IDTSPropertiesProvider; } else { propertiesProvider = container as IDTSPropertiesProvider; } if (propertiesProvider != null) { DtsProperty property = propertiesProvider.Properties[e.Property]; propertyName = property.Name; propertyType = PackageHelper.GetTypeFromTypeCode(property.Type); variables = container.Variables; variableDispenser = container.VariableDispenser; } else { throw new Exception(string.Format(CultureInfo.InvariantCulture, "Expression editing not supported on this object ({0}).", e.ObjectID)); } } // Show the editor Konesans.Dts.ExpressionEditor.ExpressionEditorPublic editor = new Konesans.Dts.ExpressionEditor.ExpressionEditorPublic(variables, variableDispenser, propertyType, propertyName, e.Expression); editor.Editor.ExpressionFont = ExpressionFont; editor.Editor.ExpressionColor = ExpressionColor; editor.Editor.ResultFont = ResultFont; editor.Editor.ResultColor = ResultColor; if (editor.ShowDialog() == DialogResult.OK) { // Get expression string expression = editor.Expression; if (expression == null || string.IsNullOrEmpty(expression.Trim())) { expression = null; } // Set the new expression on the target object object objectChanged = null; if (variable != null) { if (expression == null) { variable.EvaluateAsExpression = false; } variable.Expression = expression; objectChanged = variable; } else if (constraint != null) { if (expression == null) { constraint.EvalOp = DTSPrecedenceEvalOp.Constraint; } constraint.Expression = expression; objectChanged = constraint; } else if (propertiesProvider != null) { // TaskHost, Sequence, ForLoop, ForEachLoop and ConnectionManager propertiesProvider.SetExpression(e.Property, expression); objectChanged = propertiesProvider; } expressionListWindow_RefreshExpressions(null, null); // Finish displaying expressions list before you mark the package // as dirty (which runs the expression highlighter) System.Windows.Forms.Application.DoEvents(); SetPackageAsDirty(package, expression, objectChanged); } } catch (Exception ex) { throw ex; } }