Beispiel #1
0
        private static bool HasExpression(ConnectionManager connectionManager, List <string> listConfigPaths, out bool HasConfiguration)
        {
            IDTSPropertiesProvider dtsObject = (IDTSPropertiesProvider)connectionManager;
            bool returnValue = false;

            HasConfiguration = false;

#if !DENALI && !SQL2014 //connection managers already have built-in expression highlighting in Denali, so don't run this code in Denali
            foreach (DtsProperty p in dtsObject.Properties)
            {
                try
                {
                    if (!string.IsNullOrEmpty(dtsObject.GetExpression(p.Name)))
                    {
                        returnValue = true;
                        break;
                    }
                }
                catch { }
            }
#endif

            //check for package configurations separately so you can break out of the expensive expressions search as soon as you find one
            foreach (DtsProperty p in dtsObject.Properties)
            {
                string sPackagePath = p.GetPackagePath(dtsObject);
                if (listConfigPaths.Contains(sPackagePath))
                {
                    HasConfiguration = true;
                    break;
                }
            }
            return(returnValue);
        }
Beispiel #2
0
        private void ScanProperties(IDTSPropertiesProvider provider, TreeNode parent)
        {
            if (this.CancellationPending)
            {
                return;
            }

            TreeNode properties  = AddFolder("Properties", parent);
            TreeNode expressions = AddFolder("PropertyExpressions", parent);

            // New 2012 + interface implemented by Package, Sequence, DtsEventHandler, ForLoop, ForEachLoop
            // There are other objects that implement IDTSPropertiesProvider, and therefore support expressions, e.g. ConnectionManager, Variable
            // However we can use it to skip objects that have no expressions set, by using HasExpressions property
            bool hasExpressions = true;
            IDTSPropertiesProviderEx providerEx = provider as IDTSPropertiesProviderEx;

            if (providerEx != null)
            {
                hasExpressions = providerEx.HasExpressions;
            }

            foreach (DtsProperty property in provider.Properties)
            {
                TypeCode propertyType = property.Type;
                string   propertyName = property.Name;

                #region Check property value
                string match;
                if (property.Type == TypeCode.String && property.Get)
                {
                    string value = property.GetValue(provider) as string;
                    if (!string.IsNullOrEmpty(value))
                    {
                        PropertyMatch(properties, new DisplayProperty(property, value), propertyName, value);
                    }
                }
                #endregion

                #region Check property expression
                string expression = provider.GetExpression(property.Name);
                if (expression == null)
                {
                    continue;
                }

                // Check this for a while, before we trust it, simce it is undocumented.
                System.Diagnostics.Debug.Assert(hasExpressions, "HasExpressions was false, but we have an expression.");

                if (ExpressionMatch(expression, out match))
                {
                    VariableFoundEventArgs foundArgument = new VariableFoundEventArgs();
                    foundArgument.Match = match;
                    OnRaiseVariableFound(foundArgument);
                    AddNode(expressions, propertyName, GetImageIndex(IconKeyVariableExpression), new PropertyExpression(propertyName, expression, PackageHelper.GetTypeFromTypeCode(property.Type)), true);
                }
                #endregion
            }
        }
        private void ScanProperties(BackgroundWorker worker, string objectPath, Type objectType, string objectTypeName, string containerID, string objectID, string objectName, IDTSPropertiesProvider provider, string containerKey)
        {
            if (worker.CancellationPending)
            {
                return;
            }

            foreach (DtsProperty property in provider.Properties)
            {
                try
                {
                    string expression = provider.GetExpression(property.Name);
                    if (expression == null)
                    {
                        continue;
                    }

                    System.Diagnostics.Debug.Assert(PackageHelper.ControlFlowInfos.ContainsKey(containerKey));

                    ExpressionInfo info = new ExpressionInfo();
                    info.ContainerID = containerID;
                    info.ObjectID    = objectID;
                    info.Type        = objectType;
                    info.ObjectName  = objectName;

                    if (property.Name.StartsWith("["))
                    {
                        info.ObjectPath = objectPath + ".Properties" + property.Name + "";
                    }
                    else
                    {
                        info.ObjectPath = objectPath + ".Properties[" + property.Name + "]";
                    }

                    info.ObjectType    = objectTypeName;
                    info.PropertyName  = property.Name;
                    info.Expression    = expression;
                    info.HasExpression = (info.Expression != null);
                    info.Icon          = PackageHelper.ControlFlowInfos[containerKey].Icon;
                    worker.ReportProgress(0, info);
                }
                catch { }
            }
        }
Beispiel #4
0
        private bool HasExpression(TaskHost taskHost, string transformName, List <string> listConfigPaths, out bool HasConfiguration)
        {
            IDTSPropertiesProvider dtsObject = (IDTSPropertiesProvider)taskHost;
            bool returnValue = false;

            HasConfiguration = false;
            transformName    = "[" + transformName + "]";

            foreach (DtsProperty p in dtsObject.Properties)
            {
                if (p.Name.StartsWith(transformName))
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(dtsObject.GetExpression(p.Name)))
                        {
                            returnValue = true;
                            break;
                        }
                    }
                    catch { }
                }
            }

            //check for package configurations separately so you can break out of the expensive expressions search as soon as you find one
            foreach (DtsProperty p in dtsObject.Properties)
            {
                if (p.Name.StartsWith(transformName))
                {
                    string sPackagePath = p.GetPackagePath(dtsObject);
                    if (listConfigPaths.Contains(sPackagePath))
                    {
                        HasConfiguration = true;
                        break;
                    }
                }
            }
            return(returnValue);
        }
        private void ScanProperties(BackgroundWorker worker, string objectPath, Type objectType, string objectTypeName, string containerID, string objectID, string objectName, IDTSPropertiesProvider provider, string containerKey)
        {
            if (worker.CancellationPending)
            {
                return;
            }

            foreach (DtsProperty property in provider.Properties)
            {
                try
                {
                    string expression = provider.GetExpression(property.Name);
                    if (expression == null)
                    {
                        continue;
                    }

                    System.Diagnostics.Debug.Assert(PackageHelper.ControlFlowInfos.ContainsKey(containerKey));

                    ExpressionInfo info = new ExpressionInfo();
                    info.ContainerID = containerID;
                    info.ObjectID = objectID;
                    info.Type = objectType;
                    info.ObjectName = objectName;

                    if (property.Name.StartsWith("["))
                    {
                        info.ObjectPath = objectPath + ".Properties" + property.Name + "";
                    }
                    else
                    {
                        info.ObjectPath = objectPath + ".Properties[" + property.Name + "]";
                    }

                    info.ObjectType = objectTypeName;
                    info.PropertyName = property.Name;
                    info.Expression = expression;
                    info.HasExpression = (info.Expression != null);
                    info.Icon = PackageHelper.ControlFlowInfos[containerKey].Icon;
                    worker.ReportProgress(0, info);
                }
                catch { }
            }
        }
Beispiel #6
0
        //Determine if the task has an expression
        private bool HasExpression(Executable executable, System.Collections.Generic.List <string> listConfigPaths, out bool HasConfiguration)
        {
            IDTSPropertiesProvider task = (IDTSPropertiesProvider)executable;
            bool returnValue            = false;

            HasConfiguration = false;

#if !DENALI && !SQL2014 //has built-in expression highlighting
            foreach (DtsProperty p in task.Properties)
            {
                try
                {
                    if (!string.IsNullOrEmpty(task.GetExpression(p.Name)))
                    {
                        returnValue = true;
                        break;
                    }
                }
                catch { }
            }
#endif

            //check for package configurations separately so you can break out of the expensive expressions search as soon as you find one
            foreach (DtsProperty p in task.Properties)
            {
                string sPackagePath = p.GetPackagePath(task);
                if (listConfigPaths.Contains(sPackagePath))
                {
                    HasConfiguration = true;
                    break;
                }
            }

            if (executable is ForEachLoop)
            {
                ForEachEnumeratorHost forEachEnumerator = ((ForEachLoop)executable).ForEachEnumerator;

#if !DENALI && !SQL2014 //has built-in expression highlighting
                if (!returnValue)
                {
                    foreach (DtsProperty p in forEachEnumerator.Properties)
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(forEachEnumerator.GetExpression(p.Name)))
                            {
                                returnValue = true;
                                break;
                            }
                        }
                        catch { }
                    }
                }
#endif

                if (!HasConfiguration)
                {
                    //check for package configurations separately so you can break out of the expensive expressions search as soon as you find one
                    foreach (DtsProperty p in forEachEnumerator.Properties)
                    {
                        string sPackagePath = p.GetPackagePath(forEachEnumerator);
                        if (listConfigPaths.Contains(sPackagePath))
                        {
                            HasConfiguration = true;
                            break;
                        }
                    }
                }
            }

            return(returnValue);
        }