private static Transformation CreateSortFromXml(Vulcan.Packages.VulcanPackage vulcanPackage, IDTSComponentMetaData90 parentComponent, MainPipe dataFlowTask, XPathNavigator sortNav) { if (sortNav == null || sortNav.Name.ToUpperInvariant() != "Sort".ToUpperInvariant()) { return null; } string sortName = sortNav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value; bool eliminateDuplicates = sortNav.SelectSingleNode("@EliminateDuplicates", vulcanPackage.VulcanConfig.NamespaceManager).ValueAsBoolean; int maximumThreads = sortNav.SelectSingleNode("@MaximumThreads", vulcanPackage.VulcanConfig.NamespaceManager).ValueAsInt; //MaximumThreads can not be 0, according to SSIS if (maximumThreads == 0) { maximumThreads = -1; } Message.Trace(Severity.Debug, "Begin: UnionAll Transformation {0}", sortName); Sort sortTask = new Sort( vulcanPackage, dataFlowTask, parentComponent, sortName, sortName, eliminateDuplicates, maximumThreads ); foreach (XPathNavigator navInput in sortNav.Select("rc:InputColumn", vulcanPackage.VulcanConfig.NamespaceManager)) { string inputColumnName = navInput.SelectSingleNode("@InputColumnName", vulcanPackage.VulcanConfig.NamespaceManager).Value; Sort.InputColumnUsageType inputColumnUsageType = (Sort.InputColumnUsageType)Enum.Parse(typeof(Sort.InputColumnUsageType), navInput.SelectSingleNode("@InputColumnUsageType").Value); Sort.SortType SortType = (Sort.SortType)Enum.Parse(typeof(Sort.SortType), navInput.SelectSingleNode("@SortType").Value); List<Sort.ComparisonFlag> comparisonFlagList = new List<Sort.ComparisonFlag>(); foreach (XPathNavigator navComparisonFlag in navInput.Select("rc:ComparisonFlag", vulcanPackage.VulcanConfig.NamespaceManager)) { comparisonFlagList.Add((Sort.ComparisonFlag)Enum.Parse(typeof(Sort.ComparisonFlag), navComparisonFlag.Value)); } sortTask.SetInputColumnProperty(inputColumnName, inputColumnUsageType, SortType, comparisonFlagList); } return sortTask; }
public void SetInputColumnProperty(string inputColumnName, Sort.InputColumnUsageType inputColumnUsageType, Sort.SortType sortType, List<Sort.ComparisonFlag> comparisonFlagList) { int sortOrderForCurrentColumn; int intComparisonFlag = 0; if (inputColumnUsageType == InputColumnUsageType.PassThrough) { sortOrderForCurrentColumn = 0; } else { if (sortType == SortType.ASC) { sortOrderForCurrentColumn = _sortOrder; _sortOrder++; } else if (sortType == SortType.DESC) { sortOrderForCurrentColumn = (-1) * _sortOrder; _sortOrder++; } else { sortOrderForCurrentColumn = 0; } } foreach (Sort.ComparisonFlag comparisonFlag in comparisonFlagList) { switch (comparisonFlag) { case ComparisonFlag.None: intComparisonFlag += 0; break; case ComparisonFlag.IgnoreCase: intComparisonFlag += 1; break; case ComparisonFlag.IgnoreKanaType: intComparisonFlag += 65536; break; case ComparisonFlag.IgnoreNonspacingCharacters: intComparisonFlag += 2; break; case ComparisonFlag.IgnoreSymbols: intComparisonFlag += 4; break; case ComparisonFlag.SortPunctuationAsSymbols: intComparisonFlag += 4096; break; default: intComparisonFlag += 0; break; } } SetInputColumnProperty(inputColumnName, sortOrderForCurrentColumn, intComparisonFlag); }