/// <summary> /// Gets the configuration control. /// </summary> /// <param name="docProperties">The document properties.</param> /// <param name="eConfig">The current configuration.</param> /// <param name="eIncomingMetaInfo">The incoming connection meta data.</param> /// <param name="nToolId">The tool identifier.</param> /// <param name="strToolName">Name of the tool.</param> /// <returns>This object as a control for Alteryx to render.</returns> public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { var serialiser = new System.Xml.Serialization.XmlSerializer(typeof(T)); var doc = new XmlDocument(); doc.LoadXml($"<Config>{eConfig.InnerXml}</Config>"); this._config = eConfig.InnerText == string.Empty || doc.DocumentElement == null ? new T() : (T)serialiser.Deserialize(new XmlNodeReader(doc.DocumentElement)); var configWithIncomingConnection = this._config as IConfigWithIncomingConnection; if (configWithIncomingConnection != null) { configWithIncomingConnection.IncomingMetaInfo = eIncomingMetaInfo; } this.OnObjectSet(); return(this); }
public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig); if (xmlConfig == null) return this; /////////////////////////////////////////////////////////////////// // Populate GUI Controls with saved config information // /////////////////////// // FIELD COMBOX BOXES // setComboBox(comboBoxExePathField, xmlConfig, Constants.EXEPATHFIELDKEY, eIncomingMetaInfo); ///////////// // CHECKBOX // setCheckbox(checkBoxAutoEscape, xmlConfig, Constants.AUTOESCAPEKEY, eIncomingMetaInfo); ///////////////////////// // SELECTED COLUMNS BOX // setCheckedListBox(checkedListBoxSelectedCols, xmlConfig, Constants.SELECTEDCOLSKEY, eIncomingMetaInfo); /////////////////////////////////////////////////////////////////// // Output Fields // textBoxStdOutField.Text = xmlConfig.StdOutField; textBoxRetCodeField.Text = xmlConfig.RetCodeField; textBoxExceptionField.Text = xmlConfig.ExceptionField; textBoxDiagnosticField.Text = xmlConfig.DiagnosticField; return this; }
public Control GetConfigurationControl(AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { // This method is called by Alteryx to initialize this configuration control from data // stored in the module containing this tool. // Tool configuration is handled through an XML document managed by Alteryx. When it is // time to initialize this control (generally when it is made visible to the user), this // method is called, passing the XML document in with the eConfig parameter. // When this tool is connected to one or more upstream data providers, the structure of // each data stream is passed as an entry in the eIncomingMetaInfo array. This data can // then be used to dynamically construct your UI based on the type of input. // Since this tool is an input tool, the eIncomingMetaInfo parameter will be empty. // We will use the information in eConfig to populate the XmlFile text box. This will // cause the file to be examined if it exists (through the XmlFile_TextChanged event // handler) in order to populate the sample information. We will then use the remaining // information in eConfig to set the field properties if that information exists. // Call LoadFromConfiguration to get the xml file name and field information from eConfig. XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig); if (xmlConfig != null) { // Update the XmlFile and ElementName textboxes. txtUserName.Text = xmlConfig.UserName; txtPassword.Text = xmlConfig.Password; cboFolderToSearch.SelectedValue = xmlConfig.Folder; txtAttachmentPath.Text = xmlConfig.AttachmentPath; txtQueryString.Text = xmlConfig.QueryString; foreach (XmlInputField field in xmlConfig.Fields) { // Use a little LINQ to find the row in the field list that // corresponds to the current field. var item = clbFields.Items.Cast <KeyValuePair <string, string> >().Where(x => x.Value == field.Name).FirstOrDefault(); if (clbFields.Items.IndexOf(item) != -1) { clbFields.SetItemChecked(clbFields.Items.IndexOf(item), true); } } } return(this); }
public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig); if (xmlConfig == null) { return(this); } /////////////////////////////////////////////////////////////////// // Populate GUI Controls with saved config information // /////////////////////// // FIELD COMBOX BOXES // setComboBox(comboBoxDataField, xmlConfig, "DataField", eIncomingMetaInfo); setComboBox(comboBoxSchemaField, xmlConfig, "SchemaField", eIncomingMetaInfo); /////////////////////////////////////////////////////////////////// // Output Field // string outputField = xmlConfig.OutputField; textBoxOutputField.Text = outputField; return(this); }
/// <summary> /// Gets the configuration control. /// </summary> /// <param name="docProperties">The document properties.</param> /// <param name="eConfig">The current configuration.</param> /// <param name="eIncomingMetaInfo">The incoming connection meta data.</param> /// <param name="nToolId">The tool identifier.</param> /// <param name="strToolName">Name of the tool.</param> /// <returns>This object as a control for Alteryx to render.</returns> public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { var serialiser = new Serialisation.Serialiser <T>(); var doc = new XmlDocument(); doc.LoadXml($"<Config>{eConfig.InnerXml}</Config>"); this._config = eConfig.InnerText == string.Empty || doc.DocumentElement == null ? new T() : serialiser.Deserialise(doc.DocumentElement); if (this._config is IConfigWithIncomingConnection configWithIncomingConnection) { configWithIncomingConnection.IncomingMetaInfo = eIncomingMetaInfo; } this.OnObjectSet(); return(this); }
public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { // Call LoadFromConfiguration to get the xml file name and field information from eConfig. XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig); if (xmlConfig == null) { return(this); } // Populate the Group ComboBox with field names // If there is no incoming connection, use what is stored string groupField = xmlConfig.GroupField; if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null) { string groupFieldNames = xmlConfig.GroupFieldNames; string[] arrGroupFieldNames = groupFieldNames.Split(','); comboboxGroupField.Items.Clear(); foreach (string groupFieldName in arrGroupFieldNames) { comboboxGroupField.Items.Add(groupFieldName); } // Select the saved field if (!string.IsNullOrWhiteSpace(groupField)) { int selectedIndex = comboboxGroupField.FindStringExact(groupField); if (selectedIndex > 0) { comboboxGroupField.SelectedIndex = selectedIndex; } } } else { comboboxGroupField.Items.Clear(); var xmlElementMetaInfo = eIncomingMetaInfo[0]; var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild; foreach (XmlElement elementChild in xmlElementRecordInfo) { string fieldName = elementChild.GetAttribute("name"); //string fieldType = elementChild.GetAttribute("type"); //if (isStringType(fieldType)) //{ comboboxGroupField.Items.Add(fieldName); //} } // If the selectedField matches a possible field in the combo box, // make it the selected field. // If the selectedField does not match, do not select anything and // blank the selectedField. if (!string.IsNullOrWhiteSpace(groupField)) { int selectedIndex = comboboxGroupField.FindStringExact(groupField); if (selectedIndex == -1) { // Not Found XmlElement xmlElementGroupField = XmlHelpers.GetOrCreateChildNode(eConfig, Constants.GROUPFIELDKEY); xmlElementGroupField.InnerText = ""; } else { // Found comboboxGroupField.SelectedIndex = selectedIndex; } } } // end of "if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)" // Populate the XField Combobox with Fieldnames string xField = xmlConfig.XField; if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null) { string xFieldNames = xmlConfig.XFieldNames; string[] arrXFieldNames = xFieldNames.Split(','); comboboxXField.Items.Clear(); foreach (string xFieldName in arrXFieldNames) { comboboxXField.Items.Add(xFieldName); } // Select the saved field if (!string.IsNullOrWhiteSpace(xField)) { int selectedIndex = comboboxXField.FindStringExact(xField); if (selectedIndex > 0) { comboboxXField.SelectedIndex = selectedIndex; } } } else { comboboxXField.Items.Clear(); var xmlElementMetaInfo = eIncomingMetaInfo[0]; var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild; foreach (XmlElement elementChild in xmlElementRecordInfo) { string fieldName = elementChild.GetAttribute("name"); //string fieldType = elementChild.GetAttribute("type"); //if (isStringType(fieldType)) //{ comboboxXField.Items.Add(fieldName); //} } // If the selectedField matches a possible field in the combo box, // make it the selected field. // If the selectedField does not match, do not select anything and // blank the selectedField. if (!string.IsNullOrWhiteSpace(xField)) { int selectedIndex = comboboxXField.FindStringExact(xField); if (selectedIndex == -1) { // Not Found XmlElement xmlElementXField = XmlHelpers.GetOrCreateChildNode(eConfig, Constants.XFIELDKEY); xmlElementXField.InnerText = ""; } else { // Found comboboxXField.SelectedIndex = selectedIndex; } } } // end of "if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)" // Populate the YField Combobox with Fieldnames string yField = xmlConfig.YField; if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null) { string yFieldNames = xmlConfig.YFieldNames; string[] arrYFieldNames = yFieldNames.Split(','); comboboxYField.Items.Clear(); foreach (string yFieldName in arrYFieldNames) { comboboxYField.Items.Add(yFieldName); } // Select the saved field if (!string.IsNullOrWhiteSpace(yField)) { int selectedIndex = comboboxYField.FindStringExact(yField); if (selectedIndex > 0) { comboboxYField.SelectedIndex = selectedIndex; } } } else { comboboxYField.Items.Clear(); var xmlElementMetaInfo = eIncomingMetaInfo[0]; var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild; foreach (XmlElement elementChild in xmlElementRecordInfo) { string fieldName = elementChild.GetAttribute("name"); //string fieldType = elementChild.GetAttribute("type"); //if (isStringType(fieldType)) //{ comboboxYField.Items.Add(fieldName); //} } // If the selectedField matches a possible field in the combo box, // make it the selected field. // If the selectedField does not match, do not select anything and // blank the selectedField. if (!string.IsNullOrWhiteSpace(yField)) { int selectedIndex = comboboxYField.FindStringExact(yField); if (selectedIndex == -1) { // Not Found XmlElement xmlElementYField = XmlHelpers.GetOrCreateChildNode(eConfig, Constants.YFIELDKEY); xmlElementYField.InnerText = ""; } else { // Found comboboxYField.SelectedIndex = selectedIndex; } } } // end of "if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)" // Populate the Concavity Textbox and ConcavityWillUseValue string concavity = xmlConfig.Concavity; decimal dConcavity = 90; try { dConcavity = Convert.ToDecimal(concavity); } catch { } if (dConcavity > 180) { dConcavity = 180; } if (dConcavity < 0) { dConcavity = 0; } string sConcavity = ToTrimmedString(dConcavity); textboxConcavity.Text = sConcavity; labelConcavityWillUseValue.Text = sConcavity; // Populate the ScaleFactor textbox and ScaleFactorWillUseValue string scaleFactor = xmlConfig.ScaleFactor; decimal dScaleFactor = 0; if (scaleFactor == "NULL") { textboxScaleFactor.Text = ""; labelScaleFactorWillUseValue.Text = "NULL"; } else { try { dScaleFactor = Convert.ToDecimal(scaleFactor); } catch { } if (dScaleFactor > 0) { string sScaleFactor = ToTrimmedString(dScaleFactor); textboxScaleFactor.Text = sScaleFactor; labelScaleFactorWillUseValue.Text = sScaleFactor; } else { textboxScaleFactor.Text = ""; labelScaleFactorWillUseValue.Text = "NULL"; } } return(this); }
public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { // Call LoadFromConfiguration to get the xml file name and field information from eConfig. XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig); if (xmlConfig == null) { return(this); } // Populate the ComboBox with field names // If there is no incoming connection, use what is stored string selectedField = xmlConfig.SelectedField; if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null) { string fieldNames = xmlConfig.FieldNames; string[] arrFieldNames = fieldNames.Split(','); comboboxFilenameField.Items.Clear(); foreach (string fieldName in arrFieldNames) { comboboxFilenameField.Items.Add(fieldName); } // Select the saved field if (!string.IsNullOrWhiteSpace(selectedField)) { int selectedIndex = comboboxFilenameField.FindStringExact(selectedField); if (selectedIndex > 0) { comboboxFilenameField.SelectedIndex = selectedIndex; } } } else { comboboxFilenameField.Items.Clear(); var xmlElementMetaInfo = eIncomingMetaInfo[0]; var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild; foreach (XmlElement elementChild in xmlElementRecordInfo) { string fieldName = elementChild.GetAttribute("name"); string fieldType = elementChild.GetAttribute("type"); if (isStringType(fieldType)) { comboboxFilenameField.Items.Add(fieldName); } } // If the selectedField matches a possible field in the combo box, // make it the selected field. // If the selectedField does not match, do not select anything and // blank the selectedField. if (!string.IsNullOrWhiteSpace(selectedField)) { int selectedIndex = comboboxFilenameField.FindStringExact(selectedField); if (selectedIndex == -1) { // Not Found XmlElement xmlElementSelectedField = XmlHelpers.GetOrCreateChildNode(eConfig, Constants.SELECTEDFIELDKEY); xmlElementSelectedField.InnerText = ""; } else { // Found comboboxFilenameField.SelectedIndex = selectedIndex; } } } // end of "if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)" return(this); }