Example #1
0
        private void ProcessObject(object component, TreeNode parentNode)
        {
            if (this.CancellationPending)
            {
                return;
            }

            Package package = component as Package;

            if (package != null)
            {
                // Package node is created in calling function.
                CheckConnectionManagers(package, parentNode);
            }

            DtsContainer container = component as DtsContainer;

            if (container != null)
            {
                string   containerKey = PackageHelper.GetContainerKey(container);
                TaskHost taskHost     = null;

                if (package == null)
                {
                    int imageIndex = GetControlFlowImageIndex(containerKey);
                    parentNode = AddNode(parentNode, container.Name, imageIndex, component);
                    taskHost   = container as TaskHost;
                }

                if (taskHost != null)
                {
                    CheckTask(taskHost, parentNode);
                }
                else if (containerKey == PackageHelper.ForLoopCreationName)
                {
                    CheckForLoop(container as IDTSPropertiesProvider, parentNode);
                }
                else if (containerKey == PackageHelper.ForEachLoopCreationName)
                {
                    CheckForEachLoop(container as ForEachLoop, parentNode);
                }
                else if (containerKey == PackageHelper.SequenceCreationName)
                {
                    ScanProperties(container as IDTSPropertiesProvider, parentNode);
                }
                else
                {
                    // Package, Event Handlers etc
                    ScanProperties(container as IDTSPropertiesProvider, parentNode);
                }

                string          currentPath = string.Empty;
                IDTSPackagePath packagePath = component as IDTSPackagePath;
                if (packagePath != null)
                {
                    currentPath = packagePath.GetPackagePath();
                }

                ScanVariables(container.Variables, parentNode, currentPath);
            }

            EventsProvider eventsProvider = component as EventsProvider;

            if (eventsProvider != null)
            {
                TreeNode eventsNode = AddFolder("EventHandlers", parentNode);
                foreach (DtsEventHandler eventhandler in eventsProvider.EventHandlers)
                {
                    ProcessObject(eventhandler, eventsNode);
                }
            }

            IDTSSequence sequence = component as IDTSSequence;

            if (sequence != null)
            {
                ProcessSequence(sequence, parentNode);
                ScanPrecedenceConstraints(container.ID, sequence.PrecedenceConstraints, parentNode);
            }
        }
Example #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
            }
        }
Example #3
0
        /// <summary>
        /// Get the SsisTargetServerVersion of a project. See PackageHelper.SetTargetServerVersion and PackageHelper.TargetServerVersion or actual usage.
        /// </summary>
        /// <param name="project">The project to get the version of</param>
        /// <returns>The DTSTargetServerVersion of the project specified.</returns>
        /// <remarks>Do not use directly, see PackageHelper.SetTargetServerVersion and PackageHelper.TargetServerVersion for actual usage.</remarks>
        internal static SsisTargetServerVersion GetTargetServerVersion(EnvDTE.Project project)
        {
#if DENALI || SQL2014
            return(CompilationVersion);
#else
            // TODO: If this doesn't work <2016, we can just hardcode, based on conditional compiation
            object settings = project.GetIConfigurationSettings();
            DataWarehouseProjectManager projectManager = (DataWarehouseProjectManager)PackageHelper.GetPropertyValue(settings, "ProjectManager");
            Microsoft.DataTransformationServices.Project.DataTransformationsProjectConfigurationOptions options = (Microsoft.DataTransformationServices.Project.DataTransformationsProjectConfigurationOptions)projectManager.ConfigurationManager.CurrentConfiguration.Options;
            return((SsisTargetServerVersion)options.TargetServerVersion);
#endif
        }