// v2 public override void PerformUpgrade(int pipelineVersion) { DtsPipelineComponentAttribute pipelineComponentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); Int32 componentLatestVersion = pipelineComponentAttribute.CurrentVersion; Int32 activeComponentVersion = ComponentMetaData.Version; if (activeComponentVersion < componentLatestVersion) { try { IDTSCustomProperty100 existingRegularExpressionsOptions = ComponentMetaData.CustomPropertyCollection[REGEX_OPTIONS_PROPERTY_NAME]; } catch (Exception) { IDTSCustomProperty100 regularExpressionsOptions = ComponentMetaData.CustomPropertyCollection.New(); regularExpressionsOptions.Name = REGEX_OPTIONS_PROPERTY_NAME; regularExpressionsOptions.Description = REGEX_OPTIONS_PROPERTY_DESCRIPTION; regularExpressionsOptions.State = DTSPersistState.PS_DEFAULT; regularExpressionsOptions.TypeConverter = typeof(Int64).AssemblyQualifiedName; regularExpressionsOptions.Value = REGEX_OPTIONS_UPGRADE_VALUE; } } ComponentMetaData.Version = componentLatestVersion; }
/// <summary> /// Upgrade from SSIS 2008 to 2012/2014 /// </summary> /// <param name="pipelineVersion">components pipeline verion</param> public override void PerformUpgrade(int pipelineVersion) { try { if (LineageMapping.NeedsMapping()) { InitProperties(false); foreach (ColumnConfig config in _IsagCustomProperties.ColumnConfigList) { if (string.IsNullOrEmpty(config.CustomId)) { config.CustomId = Guid.NewGuid().ToString(); } AddInputColumnCustomProperty(config.InputColumnName, config.CustomId, LineageMapping.IdPropertyName); } LineageMapping.UpdateInputIdProperties(this.ComponentMetaData, _IsagCustomProperties); _IsagCustomProperties.Save(this.ComponentMetaData); } DtsPipelineComponentAttribute attr = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); ComponentMetaData.Version = attr.CurrentVersion; } catch (Exception ex) { bool cancel = false; this.ComponentMetaData.FireError(0, "DataConverter Upgrade", ex.ToString(), "", 0, out cancel); throw (ex); } }
/// <summary> /// Sets metadata version to assemblies current version /// </summary> /// <param name="component">pipeline component</param> /// <param name="componentMetaData">components metdadata</param> public static void UpdateVersion(PipelineComponent component, IDTSComponentMetaData100 componentMetaData) { DtsPipelineComponentAttribute componentAttr = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(component.GetType(), typeof(DtsPipelineComponentAttribute), false); int binaryVersion = componentAttr.CurrentVersion; componentMetaData.Version = binaryVersion; }
//================================================================================================= /// <summary> /// Set the componet version to match the assembly version. /// </summary> public void SetComponentVersion() { // Get the assembly version and set that as our current version. DtsPipelineComponentAttribute attr = (DtsPipelineComponentAttribute) Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); System.Diagnostics.Trace.Assert(attr != null, "Could not get attributes"); ComponentMetaData.Version = attr.CurrentVersion; }
/// <summary> /// Upgrade the metadata if it needs it. /// Right now all this does is update the version number in the XML. /// </summary> /// <param name="pipelineVersion">The curreht version of the pipeline.</param> public override void PerformUpgrade(int pipelineVersion) { // Get the attributes for the executable DtsPipelineComponentAttribute componentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int binaryVersion = componentAttribute.CurrentVersion; // Set the SSIS Package's version ID for this component to the binary version... ComponentMetaData.Version = binaryVersion; }
public override void PerformUpgrade(int pipelineVersion) { // http://toddmcdermid.blogspot.co.nz/2008/09/using-performupgrade.html DtsPipelineComponentAttribute componentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int binaryVersion = componentAttribute.CurrentVersion; // from DLL int metadataVersion = ComponentMetaData.Version; // from dtsx XML //base.PerformUpgrade(pipelineVersion); ComponentMetaData.Version = binaryVersion; }
private Int32 GetComponentVersion() { // Get the assembly version DtsPipelineComponentAttribute attr = (DtsPipelineComponentAttribute) Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); Debug.Assert(attr != null, "Could not get attributes"); return(attr.CurrentVersion); }
/// <summary> /// Version 2: Perform the upgrade from an earlier version; creates missing input column custom properties. /// </summary> /// <param name="pipelineVersion"></param> public override void PerformUpgrade(int pipelineVersion) { DtsPipelineComponentAttribute pipelineComponentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); Int32 componentLatestVersion = pipelineComponentAttribute.CurrentVersion; if (pipelineVersion < componentLatestVersion) { this.CreateInputCustomProperties(); } ComponentMetaData.Version = componentLatestVersion; }
// This will be a pass-through for now public override void PerformUpgrade(int pipelineVersion) { // Obtain the current component version from the attribute. DtsPipelineComponentAttribute componentAttribute = (DtsPipelineComponentAttribute)Attribute .GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int currentVersion = componentAttribute.CurrentVersion; if (ComponentMetaData.Version < currentVersion) { } // Update the saved component version metadata to the current version. ComponentMetaData.Version = currentVersion; }
/// <summary> /// Gets the Version of the Pipeline Component based ont he DTSPipelineComponentAttribute /// </summary> /// <param name="comp">Pipeline component to return the version</param> /// <returns>Version of the provided pipeline component</returns> public static int GetPipelineComponentVersion(PipelineComponent comp) { int version = 0; if (comp != null) { var attribs = TypeDescriptor.GetAttributes(comp.GetType()); DtsPipelineComponentAttribute pc = (DtsPipelineComponentAttribute)attribs[typeof(DtsPipelineComponentAttribute)]; System.Reflection.PropertyInfo pi = pc.GetType().GetProperty("CurrentVersion"); if (pi != null) { version = (int)pi.GetValue(pc, null); } } return(version); }
public override void PerformUpgrade(int pipelineVersion) { DtsPipelineComponentAttribute componentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int currentVersion = componentAttribute.CurrentVersion; // Get the attributes for the SSIS Package int metadataVersion = ComponentMetaData.Version; if (currentVersion < ComponentMetaData.Version) { throw new Exception(Properties.Resources.ErrorWrongRuntimeVersion); } else if (currentVersion > ComponentMetaData.Version) { ComponentMetaData.Version = currentVersion; } }
/// <summary> /// Upgrades the component metadata to the version of the component installed on the local computer. /// </summary> /// <param name="pipelineVersion">The current version of the Integration Services data flow engine.</param> public override void PerformUpgrade(int pipelineVersion) { // Obtain the current component version from the attribute. DtsPipelineComponentAttribute componentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int currentVersion = componentAttribute.CurrentVersion; // If the component version saved in the package is less than // the current version, Version 2, perform the upgrade. if (ComponentMetaData.Version < currentVersion) { // Specify that the component has an error output. ComponentMetaData.UsesDispositions = true; // Expose the external metadata collection var defaultOutput = GetDefaultOutput(); if (defaultOutput != null) { defaultOutput.ExternalMetadataColumnCollection.IsUsed = true; } // Adds an additional output category allowing the end-user to send errors to a different output var errorOutput = GetErrorOutput(); if (errorOutput == null) { errorOutput = ComponentMetaData.OutputCollection.New(); errorOutput.Name = "ErrorOutput"; errorOutput.IsErrorOut = true; // Copy the existing output columns to the error output foreach (IDTSOutputColumn100 outputColumn in GetDefaultOutputColumns()) { outputColumn.ErrorRowDisposition = DTSRowDisposition.RD_FailComponent; outputColumn.TruncationRowDisposition = DTSRowDisposition.RD_FailComponent; var errorOutputColumn = errorOutput.OutputColumnCollection.New(); errorOutputColumn.Name = outputColumn.Name; errorOutputColumn.SetDataTypeProperties(outputColumn.DataType, outputColumn.Length, outputColumn.Precision, outputColumn.Scale, outputColumn.CodePage); } } } // Update the saved component version metadata to the current version. ComponentMetaData.Version = currentVersion; }
/// <summary> /// Upgrade from SSIS 2008 to 2012/2014 /// </summary> /// <param name="pipelineVersion">components pipeline verion</param> public override void PerformUpgrade(int pipelineVersion) { try { if (Mapping.NeedsMapping()) { InitializeProperties(); if (string.IsNullOrEmpty(_isagCustomProperties.LU2_ValidparameterCustomId)) { _isagCustomProperties.LU2_ValidparameterCustomId = Guid.NewGuid().ToString(); } AddInputColumnCustomProperty(_isagCustomProperties.LU2_Validparameter, _isagCustomProperties.LU2_ValidparameterCustomId, Mapping.IdPorpertyNameList[(int)Mapping.PropertyType.ValidParamter]); if (string.IsNullOrEmpty(_isagCustomProperties.LU_MatchparameterCustomId)) { _isagCustomProperties.LU_MatchparameterCustomId = Guid.NewGuid().ToString(); } AddInputColumnCustomProperty(_isagCustomProperties.LU_Matchparameter, _isagCustomProperties.LU_MatchparameterCustomId, Mapping.IdPorpertyNameList[(int)Mapping.PropertyType.MatchParameter]); foreach (OutputConfig outConfig in _isagCustomProperties.OutputConfigList) { AddInputColumnCustomProperty(outConfig.DftColumn, outConfig.CustomId, Mapping.IdPorpertyNameList[(int)Mapping.PropertyType.OutputColumn]); } Mapping.UpdateInputIdProperties(this.ComponentMetaData, _isagCustomProperties); _isagCustomProperties.Save(this.ComponentMetaData); } DtsPipelineComponentAttribute attr = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); ComponentMetaData.Version = attr.CurrentVersion; } catch (Exception ex) { bool cancel = false; this.ComponentMetaData.FireError(0, "DataConverter Upgrade", ex.ToString(), "", 0, out cancel); throw (ex); } }
/// <summary> /// This method is invoked by the Design Time IDE when an user wants to edit the component setup. /// We here build up the UI and pass parameters from one way to the other. /// </summary> /// <param name="parentWindow"></param> /// <param name="vars"></param> /// <param name="cons"></param> /// <returns></returns> public bool Edit(System.Windows.Forms.IWin32Window parentWindow, Variables vars, Connections cons) { DtsPipelineComponentAttribute componentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(typeof(JSONSourceComponent), typeof(DtsPipelineComponentAttribute), false); SourceAdvancedUI componentEditor = new SourceAdvancedUI(vars, _sp, _virtualInputLane.VirtualInputColumnCollection, _md.Version, componentAttribute.CurrentVersion); componentEditor.LoadModel(_model); DialogResult result = componentEditor.ShowDialog(parentWindow); if (result == DialogResult.OK) { _model = componentEditor.SavedModel; // Map the virtual input columns with physical lanes. We need to add both parameter neede columns and copycolumns. // Use an hashset because we do not want to add duplicates HashSet <string> inputColumnsToAdd = new HashSet <string>(); foreach (var incol in _model.DataMapping.InputColumnsToCopy) { inputColumnsToAdd.Add(incol); } foreach (var p in _model.DataSource.HttpParameters) { if (p.Binding == ParamBinding.InputField) { inputColumnsToAdd.Add(p.BindingValue); } } AddInputColumns(inputColumnsToAdd); // About the output, add an output for each IOMap entry (json derived) and for each CopyColumn. HttpParameters are not added as output if not explicitly said so. AddOutputColumns(_model.DataMapping.IoMap, _model.DataMapping.InputColumnsToCopy); // Serialize the configuration. // TODO: use a standard way to do that _md.CustomPropertyCollection[ComponentConstants.PROPERTY_KEY_MODEL].Value = componentEditor.SavedModel.ToJsonConfig(); return(true); } return(false); }
/// <summary> /// Provides the component properties /// </summary> public override void ProvideComponentProperties() { base.ProvideComponentProperties(); _IsagCustomProperties = new IsagCustomProperties(); _IsagCustomProperties.SetDefaultValues(); ComponentMetaDataTools.UpdateVersion(this, ComponentMetaData); //Set metadata version to DLL-Version DtsPipelineComponentAttribute componentAttr = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int binaryVersion = componentAttr.CurrentVersion; ComponentMetaData.Version = binaryVersion; //Clear out base implmentation this.ComponentMetaData.RuntimeConnectionCollection.RemoveAll(); this.ComponentMetaData.InputCollection.RemoveAll(); this.ComponentMetaData.OutputCollection.RemoveAll(); //Input IDTSInput100 input = this.ComponentMetaData.InputCollection.New(); input.Name = Constants.INPUT_NAME; input.Description = Constants.INPUT_NAME; input.HasSideEffects = true; //New connection managers IDTSRuntimeConnection100 conn = this.ComponentMetaData.RuntimeConnectionCollection.New(); conn.Name = Constants.CONNECTION_MANAGER_NAME_MAIN; conn.Description = "Main Connection to SQL Server"; //Custom Properties hinzufügen IDTSCustomProperty100 prop = ComponentMetaData.CustomPropertyCollection.New(); prop.Name = Constants.PROP_CONFIG; _IsagCustomProperties.Save(ComponentMetaData); }
private int GetComponentVersion() { DtsPipelineComponentAttribute customAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(DtsPipelineComponentAttribute), false); return(customAttribute.CurrentVersion); }
/// <summary> /// Upgrades the component from earlier versions /// </summary> /// <param name="pipelineVersion"></param> public override void PerformUpgrade(int pipelineVersion) { DtsPipelineComponentAttribute componentAttribute = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DtsPipelineComponentAttribute), false); int currentVersion = componentAttribute.CurrentVersion; // Get the attributes for the SSIS Package int metadataVersion = ComponentMetaData.Version; if (currentVersion < ComponentMetaData.Version) { throw new Exception(Properties.Resources.ErrorWrongRuntimeVersion); } else if (currentVersion > ComponentMetaData.Version) { IDTSInput input = ComponentMetaData.InputCollection[0]; List <int> propsToRemove = new List <int>(); List <KeyValuePair <int, int> > colLienagesSort = new List <KeyValuePair <int, int> >(input.InputColumnCollection.Count); string sourceID = string.Empty; string sourceName = string.Empty; try { IDTSCustomProperty prop = ComponentMetaData.CustomPropertyCollection[Resources.ColumnsToXmlSourceNameProperty]; if (prop != null) { sourceName = prop.Value.ToString(); ComponentMetaData.CustomPropertyCollection.RemoveObjectByID(prop.ID); } } catch { } try { IDTSCustomProperty prop = ComponentMetaData.CustomPropertyCollection[Resources.ColumnsToXmlSourceIDProperty]; if (prop != null) { sourceID = prop.Value.ToString(); ComponentMetaData.CustomPropertyCollection.RemoveObjectByID(prop.ID); } } catch { } foreach (IDTSInputColumn col in input.InputColumnCollection) { int sortOrder = int.MaxValue; IDTSCustomProperty prop = null; propsToRemove = new List <int>(); foreach (IDTSCustomProperty p in col.CustomPropertyCollection) { if (p.Name == Resources.InputSortOrderPropertyName) { sortOrder = (int)p.Value; propsToRemove.Add(p.ID); break; } } colLienagesSort.Add(new KeyValuePair <int, int>(col.LineageID, sortOrder)); foreach (int id in propsToRemove) { col.CustomPropertyCollection.RemoveObjectByID(id); } } colLienagesSort.Sort((a, b) => a.Value.CompareTo(b.Value)); IDTSOutput output = ComponentMetaData.OutputCollection[0]; foreach (IDTSOutputColumn col in output.OutputColumnCollection) { SetPropertyType setProp = SetPropertyType.All; bool additionalPropertyExists = false; bool setDataType = !(col.DataType == DataType.DT_NTEXT || (col.DataType == DataType.DT_WSTR && col.Length <= 4000)); foreach (IDTSCustomProperty prop in col.CustomPropertyCollection) { if (prop.Name == Resources.XmlSaveOptionPropertyName) { setProp ^= SetPropertyType.XmlSaveOptions; } else if (prop.Name == Resources.XmlSerializeLineageName) { setProp ^= SetPropertyType.XmlSerializeLineage; } else if (prop.Name == Resources.XmlSerializeDataTypeName) { setProp ^= SetPropertyType.XmlSerializeDataType; } else if (prop.Name == Resources.XmlInputColumnsPropertyname) { setProp ^= SetPropertyType.XmlInputColumns; } else if (prop.Name == Resources.XmlSourceIdPropertyName) { setProp ^= SetPropertyType.XMlSourceID; } else if (prop.Name == Resources.XmlSourceNamePropertyName) { setProp ^= SetPropertyType.XmlSourceName; } else { additionalPropertyExists = true; } } if (setProp != SetPropertyType.None || additionalPropertyExists || setDataType) { SetXmlColumnProperties(col, setProp, setDataType); } if ((setProp & SetPropertyType.XmlInputColumns) == SetPropertyType.XmlInputColumns && colLienagesSort.Count > 0) { string lineages = InputColumns.BuildInputLineagesString(colLienagesSort.ConvertAll <int>(kvp => kvp.Key)); col.CustomPropertyCollection[Resources.XmlInputColumnsPropertyname].Value = lineages; } if ((setProp & SetPropertyType.XMlSourceID) == SetPropertyType.XMlSourceID) { col.CustomPropertyCollection[Resources.XmlSourceIdPropertyName].Value = sourceID; } if ((setProp & SetPropertyType.XmlSourceName) == SetPropertyType.XmlSourceName) { col.CustomPropertyCollection[Resources.XmlSourceNamePropertyName].Value = sourceName; } } ComponentMetaData.Version = currentVersion; } }