/// <summary> /// Gets Data Type for particular HashType /// </summary> /// <param name="hashType">HashType to get the Data Type</param> /// <param name="dataType">Output DataType for HashType</param> /// <param name="dataLength">Data Length for HashType</param> public static void GetHashTypeDataType(HashColumnsTransformation.HashType hashType, DataType outputDataType, out int dataLength) { switch (hashType) { case HashColumnsTransformation.HashType.None: dataLength = 1; break; case HashColumnsTransformation.HashType.MD5: dataLength = 16; break; case HashColumnsTransformation.HashType.RipeMD160: case HashColumnsTransformation.HashType.SHA1: dataLength = 20; break; case HashColumnsTransformation.HashType.SHA256: dataLength = 32; break; case HashColumnsTransformation.HashType.SHA384: dataLength = 48; break; case HashColumnsTransformation.HashType.SHA512: dataLength = 64; break; case HashColumnsTransformation.HashType.CRC32: dataLength = 4; break; default: dataLength = 16; break; } if (hashType != HashColumnsTransformation.HashType.None) { switch (outputDataType) { case DataType.DT_BYTES: break; case DataType.DT_WSTR: dataLength = dataLength * 2; break; case DataType.DT_STR: dataLength = dataLength * 2; break; default: break; } } }
/// <summary> /// Sets DataType of the Output Clumn according the HashType /// </summary> /// <param name="hashType">Hash Type of the output Column</param> /// <param name="outputColumn">Ourtput Column to set data type</param> public static void SetHashColumnDataType(HashColumnsTransformation.HashType hashType, IDTSOutputColumn outputColumn, int locale) { int dataLength; DataType dt = outputColumn.DataType; if (dt != DataType.DT_BYTES && dt != DataType.DT_WSTR && dt != DataType.DT_WSTR) { dt = DataType.DT_BYTES; } GetHashTypeDataType(hashType, dt, out dataLength); outputColumn.SetDataTypeProperties(dt, dataLength, 0, 0, outputColumn.CodePage); }
public static void SetHashColumnProperties(HashColumnsTransformation.HashOuputColumnProperties propsToSet, IDTSOutputColumn hashColumn, HashColumnsTransformation.HashType hashType, HashColumnsTransformation.HashImplementationType implementation, HashColumnsTransformation.HashOutputDataType dataType, int locale) { List <int> propsToRemove = new List <int>(); foreach (IDTSCustomProperty prop in hashColumn.CustomPropertyCollection) { if ( (prop.Name == Resources.HashAlgorithmPropertyName && (propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashAlgorithm) == HashColumnsTransformation.HashOuputColumnProperties.HashAlgorithm) || (prop.Name == Resources.HashColumnHashInputColumnsPropertyName && (propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashColumns) == HashColumnsTransformation.HashOuputColumnProperties.HashColumns) || (prop.Name == Resources.HashColumnHashFieldSeparatorPropertyName && (propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashFieldSeparator) == HashColumnsTransformation.HashOuputColumnProperties.HashFieldSeparator) || (prop.Name == Resources.HashColumnHashImplementationTypePropertyName && (propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashImplementationType) == HashColumnsTransformation.HashOuputColumnProperties.HashImplementationType) || (prop.Name == Resources.HashColumnNullReplacementValue && (propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashNullReplacement) == HashColumnsTransformation.HashOuputColumnProperties.HashNullReplacement) || (prop.Name == Resources.HashColumnStringTrimmingPropertyName && (propsToSet & HashColumnsTransformation.HashOuputColumnProperties.TrimStrings) == HashColumnsTransformation.HashOuputColumnProperties.TrimStrings) ) { propsToRemove.Add(prop.ID); } } foreach (int id in propsToRemove) { hashColumn.CustomPropertyCollection.RemoveObjectByID(id); } if ((propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashAlgorithm) == HashColumnsTransformation.HashOuputColumnProperties.HashAlgorithm) { //as the Output columns are Hash Columns, add HashType property with default MD5 IDTSCustomProperty hashAlgorithm = hashColumn.CustomPropertyCollection.New(); hashAlgorithm.Description = Resources.HashTypePropertyDescription; hashAlgorithm.Name = Resources.HashAlgorithmPropertyName; hashAlgorithm.ContainsID = false; hashAlgorithm.EncryptionRequired = false; hashAlgorithm.ExpressionType = DTSCustomPropertyExpressionType.CPET_NONE; hashAlgorithm.TypeConverter = typeof(HashColumnsTransformation.HashType).AssemblyQualifiedName; hashAlgorithm.Value = hashType; } if ((propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashImplementationType) == HashColumnsTransformation.HashOuputColumnProperties.HashImplementationType) { IDTSCustomProperty hashImplementation = hashColumn.CustomPropertyCollection.New(); hashImplementation.Description = "Implementation version of the Hash Type"; hashImplementation.Name = Resources.HashColumnHashImplementationTypePropertyName; //"HashImplementationType"; hashImplementation.ContainsID = false; hashImplementation.EncryptionRequired = false; hashImplementation.ExpressionType = DTSCustomPropertyExpressionType.CPET_NONE; hashImplementation.TypeConverter = typeof(HashColumnsTransformation.HashImplementationType).AssemblyQualifiedName; hashImplementation.Value = implementation; } if ((propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashColumns) == HashColumnsTransformation.HashOuputColumnProperties.HashColumns) { IDTSCustomProperty hashColumns = hashColumn.CustomPropertyCollection.New(); hashColumns.Description = "List of input columns to build HASH"; hashColumns.Name = Resources.HashColumnHashInputColumnsPropertyName; // "HashInputColumns"; hashColumns.ContainsID = true; hashColumns.EncryptionRequired = false; hashColumns.ExpressionType = DTSCustomPropertyExpressionType.CPET_NONE; hashColumns.Value = string.Empty; } if ((propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashFieldSeparator) == HashColumnsTransformation.HashOuputColumnProperties.HashFieldSeparator) { IDTSCustomProperty hashFieldSeparator = hashColumn.CustomPropertyCollection.New(); hashFieldSeparator.Description = "Specifies the field separator for Unicode String Implementations"; hashFieldSeparator.Name = Resources.HashColumnHashFieldSeparatorPropertyName; hashFieldSeparator.ContainsID = false; hashFieldSeparator.EncryptionRequired = false; hashFieldSeparator.ExpressionType = DTSCustomPropertyExpressionType.CPET_NONE; hashFieldSeparator.Value = DefaultFieldtSeparator; } if ((propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashNullReplacement) == HashColumnsTransformation.HashOuputColumnProperties.HashNullReplacement) { IDTSCustomProperty hashFieldSeparator = hashColumn.CustomPropertyCollection.New(); hashFieldSeparator.Description = "Specifies the NULL replacement value for non NULL safe Unicode String Implementations"; hashFieldSeparator.Name = Resources.HashColumnNullReplacementValue; hashFieldSeparator.ContainsID = false; hashFieldSeparator.EncryptionRequired = false; hashFieldSeparator.ExpressionType = DTSCustomPropertyExpressionType.CPET_NONE; hashFieldSeparator.Value = DefaultNullReplacement; } if ((propsToSet & HashColumnsTransformation.HashOuputColumnProperties.TrimStrings) == HashColumnsTransformation.HashOuputColumnProperties.TrimStrings) { IDTSCustomProperty stringTrimming = hashColumn.CustomPropertyCollection.New(); stringTrimming.Description = "Specifies whether and how string values should be trimmed"; stringTrimming.Name = Resources.HashColumnStringTrimmingPropertyName; stringTrimming.ContainsID = false; stringTrimming.EncryptionRequired = false; stringTrimming.ExpressionType = DTSCustomPropertyExpressionType.CPET_NONE; stringTrimming.TypeConverter = typeof(HashColumnsTransformation.StringTrimming).AssemblyQualifiedName; stringTrimming.Value = HashColumnsTransformation.StringTrimming.None; } if ( ((propsToSet & HashColumnsTransformation.HashOuputColumnProperties.HashAlgorithm) == HashColumnsTransformation.HashOuputColumnProperties.HashAlgorithm) ) { //Set data type for the column accordingly with the hashType - default for MD4 SetHashColumnDataType(hashType, hashColumn, locale); } }
/// <summary> /// Sets HashColumn default properties /// </summary> /// <param name="hashColumn">HashColumn which properties should be set</param> internal static void SetHashColumnProperties(HashColumnsTransformation.HashOuputColumnProperties propsToSet, IDTSOutputColumn hashColumn, HashColumnsTransformation.HashType hashTYpe) { SetHashColumnProperties(propsToSet, hashColumn, HashColumnsTransformation.HashType.MD5, HashColumnsTransformation.HashImplementationType.BinarySafe, HashColumnsTransformation.HashOutputDataType.DT_BYTES, 0); }