Ejemplo n.º 1
0
        /// <summary>
        /// This method is ivoked once, when the user double clicks on it at design time.
        /// </summary>
        /// <param name="dtsComponentMetadata"></param>
        /// <param name="serviceProvider"></param>
        public void Initialize(IDTSComponentMetaData100 dtsComponentMetadata, IServiceProvider serviceProvider)
        {
            // Save a reference to the components metadata and service provider
            _sp = serviceProvider;
            _md = dtsComponentMetadata;

            // Check model: if no model was specified, add it one now.
            IDTSCustomProperty100 model = null;

            try
            {
                model  = dtsComponentMetadata.CustomPropertyCollection[ComponentConstants.PROPERTY_KEY_MODEL];
                _model = JSONSourceComponentModel.LoadFromJson(model.Value.ToString());
            }
            catch (Exception e) {
                // No model found. Add a new now.
                _model      = new JSONSourceComponentModel();
                model       = dtsComponentMetadata.CustomPropertyCollection.New();
                model.Name  = ComponentConstants.PROPERTY_KEY_MODEL;
                model.Value = _model.ToJsonConfig();
            }

            if (_md == null)
            {
                _md = (IDTSComponentMetaData100)_md.Instantiate();
            }

            _virtualInputLane = dtsComponentMetadata.InputCollection[ComponentConstants.NAME_INPUT_LANE_PARAMS].GetVirtualInput();
        }
Ejemplo n.º 2
0
 public void LoadModel(JSONSourceComponentModel m)
 {
     // Given a model, load it into the whole UI
     _sourceView.LoadModel(m.DataSource);
     _columnView.LoadModel(m.DataMapping);
     _advancedView.LoadModel(m.AdvancedSettings);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// This method will collect all the info of the view and will save it into a variable that can be publicly accessed.
        /// </summary>
        private void SaveModel()
        {
            // Rely on each specified view to do so.
            JSONSourceComponentModel result = new JSONSourceComponentModel();

            result.AdvancedSettings = _advancedView.SaveToModel();
            result.DataMapping      = _columnView.SaveToModel();
            result.DataSource       = _sourceView.SaveToModel();

            _savedModel = result;
        }
Ejemplo n.º 4
0
        /// <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);
        }
        public static JSONSourceComponentModel LoadFromJson(string jsonConfig)
        {
            JSONSourceComponentModel res = JsonConvert.DeserializeObject <JSONSourceComponentModel>(jsonConfig);

            return(res);
        }