예제 #1
0
        private void btnValidate_Click(object sender, EventArgs e)
        {
            //
            // Reset any previous errors
            lvErrors.Items.Clear();

            //
            // Obtain the compiler interface from the local object
            IGPCompiler iCompiler = fmMain.ServerManager.LocalServer.Compiler;

            //
            // Get the function written
            String FunctionCode = iCompiler.WriteUserFunction(
                txtFunctionName.Text,
                (short)udParamterCount.Value,
                txtSource.Text);

            //
            // Compile and check for errors
            String[] Errors;
            bool     Validated = iCompiler.ValidateUserFunction(
                txtFunctionName.Text,
                FunctionCode,
                out Errors);

            if (!Validated)
            {
                //
                // Fill the listview with the errors
                foreach (String Item in Errors)
                {
                    ListViewItem lviError = lvErrors.Items.Add(Item);
                    lviError.ToolTipText = Item;
                }

                tabFooter.SelectedTab = pageErrors;
                //
                // Update the database to reflect this function is validated
                SetValidation(Convert.ToInt32(lvFunctions.SelectedItems[0].Tag), false);
                chkValidated.Checked = false;

                //
                // Let the user know there were errors
                MessageBox.Show("Function failed validation!", "Function Set Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //
                // Update the database to reflect this function is validated
                SetValidation(Convert.ToInt32(lvFunctions.SelectedItems[0].Tag), true);
                chkValidated.Checked = true;

                MessageBox.Show("Function correctly validated!", "Function Set Editor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        private void tsMainValidate_Click(object sender, EventArgs e)
        {
            //
            // Reset any previous errors
            lvErrors.Items.Clear();

            //
            // Obtain the compiler interface from the local object
            IGPCompiler iCompiler = (IGPCompiler)fmMain.ServerManager.LocalServer.Compiler;

            //
            // Get the Fitness class written
            String FunctionCode = iCompiler.WriteFitnessClass(txtSource.Text);

            String[] Errors    = null;
            bool     Validated = iCompiler.ValidateFitnessClass(FunctionCode, out Errors);

            //
            // Update the validation status
            SetValidation(Convert.ToInt32(lvFunctions.SelectedItems[0].Tag), Validated);
            chkValidated.Checked = Validated;
            //
            // Let the user know what happened
            if (!Validated)
            {
                //
                // Fill the listview with the errors
                foreach (String Item in Errors)
                {
                    ListViewItem lviError = lvErrors.Items.Add(Item);
                    lviError.ToolTipText = Item;
                }

                //
                // Let the user know there were errors
                MessageBox.Show("Function failed validation!", "Fitness Functions", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Function correctly validated!", "Fitness Functions", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }