private void TestConnection(object sender, EventArgs e, IfrmCommandEditor editor, ICommandControls commandControls)
 {
     try
     {
         var engine          = (IAutomationEngineInstance)commandControls.CreateAutomationEngineInstance(editor.ScriptEngineContext);
         var oleDBConnection = CreateConnection(engine);
         oleDBConnection.Open();
         oleDBConnection.Close();
         MessageBox.Show("Connection Successful", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Connection Failed: {ex}", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        private void PassParametersCheckbox_CheckedChanged(object sender, EventArgs e, IfrmCommandEditor editor, ICommandControls commandControls, bool isMouseEnter = false)
        {
            var assignArgCheckBox = (CheckBox)sender;

            _assignmentsGridViewHelper.Visible = assignArgCheckBox.Checked;

            //load arguments if selected and file exists
            if (assignArgCheckBox.Checked)
            {
                var currentScriptEngine = commandControls.CreateAutomationEngineInstance(null);
                currentScriptEngine.AutomationEngineContext.Arguments.AddRange(editor.ScriptEngineContext.Arguments);

                var startFile = v_TaskPath;
                if (startFile.Contains("{ProjectPath}"))
                {
                    startFile = startFile.Replace("{ProjectPath}", editor.ScriptEngineContext.ProjectPath);
                }

                startFile = startFile.ConvertUserVariableToString(currentScriptEngine);

                if (!isMouseEnter && File.Exists(startFile))
                {
                    _assignmentsGridViewHelper.DataSource = v_ArgumentAssignments;
                    DataTable vArgumentAssignmentsCopy = v_ArgumentAssignments.Copy();
                    v_ArgumentAssignments.Clear();

                    JObject scriptObject = JObject.Parse(File.ReadAllText(startFile));
                    var     arguments    = scriptObject["Arguments"].ToObject <List <ScriptArgument> >();

                    foreach (var argument in arguments)
                    {
                        if (argument.ArgumentName == "ProjectPath")
                        {
                            continue;
                        }

                        DataRow foundArguments = vArgumentAssignmentsCopy.Select("ArgumentName = '" + "{" + argument.ArgumentName + "}" + "'").FirstOrDefault();
                        if (foundArguments != null)
                        {
                            var foundArgumentValue = foundArguments[2];
                            v_ArgumentAssignments.Rows.Add("{" + argument.ArgumentName + "}", argument.ArgumentType, foundArgumentValue, argument.Direction.ToString());
                        }
                        else
                        {
                            v_ArgumentAssignments.Rows.Add("{" + argument.ArgumentName + "}", argument.ArgumentType, argument.ArgumentValue, argument.Direction.ToString());
                        }
                    }
                }

                for (int i = 0; i < _assignmentsGridViewHelper.Rows.Count; i++)
                {
                    DataGridViewComboBoxCell typeComboBox = new DataGridViewComboBoxCell();
                    typeComboBox.Items.Add(v_ArgumentAssignments.Rows[i].ItemArray[1]);
                    typeComboBox.Tag = v_ArgumentAssignments.Rows[i].ItemArray[1];
                    _assignmentsGridViewHelper.Rows[i].Cells[1]          = typeComboBox;
                    _assignmentsGridViewHelper.Rows[i].Cells[1].ReadOnly = true;

                    DataGridViewComboBoxCell returnComboBox = new DataGridViewComboBoxCell();
                    returnComboBox.Items.Add("In");
                    returnComboBox.Items.Add("Out");
                    returnComboBox.Items.Add("InOut");
                    _assignmentsGridViewHelper.Rows[i].Cells[3]          = returnComboBox;
                    _assignmentsGridViewHelper.Rows[i].Cells[3].ReadOnly = true;
                }
            }
            else if (!assignArgCheckBox.Checked)
            {
                v_ArgumentAssignments.Clear();
            }
        }