private void btnFindError_Click(object sender, EventArgs e)
        {
            txtCompileStatus.Text = "Compiling...";
            var inputSchema  = GenerateSchema(grInput);
            var outputSchema = GenerateSchema(grOutput);

            var tempFile = Path.GetTempFileName();
            var result   = CompilerService.GenerateCodeAndCompile(tempFile, inputSchema, outputSchema, GetCode());

            File.Delete(tempFile);

            txtCompileStatus.Text = string.Empty;
            // Check for errors
            if (result.CompilerResult.Errors.Count > 0)
            {
                foreach (CompilerError CompErr in result.CompilerResult.Errors)
                {
                    //lblCompileStatus.ForeColor = Color.Red;
                    txtCompileStatus.ForeColor = Color.Red;
                    txtCompileStatus.Text      = txtCompileStatus.Text +
                                                 "Line number " + (CompErr.Line - result.CodeLine) +
                                                 " Error Number: " + CompErr.ErrorNumber +
                                                 ", '" + CompErr.ErrorText + ";" +
                                                 Environment.NewLine;
                }
                return;
            }
            else
            {
                //Successful Compile
                //lblCompileStatus.ForeColor = Color.Green;
                txtCompileStatus.ForeColor = Color.Green;
                txtCompileStatus.Text      = "Success!";
            }
        }
        public override object Execute(Workflow workflow)
        {
            if (workflow.Command == (int)Commands.DoubleClick)
            {
                ShowWindow();
                return(null);
            }

            if (!ValidateInputSchemas())
            {
                return(null);
            }

            var tempFile = Path.GetTempFileName();
            var result   = CompilerService.GenerateCodeAndCompile(tempFile, FullInputSchema, FullOutputSchema, CodeText);

            File.Delete(tempFile);

            try
            {
                Assembly loAssembly = result.CompilerResult.CompiledAssembly;
                // Retrieve an obj ref - generic type only
                object loObject =
                    loAssembly.CreateInstance("WinFormCodeCompile.Transform");
                if (loObject == null)
                {
                    MessageService.ShowError("Critical", "Couldn't load class.");
                    return(loObject);
                }
                try
                {
                    var type             = loObject.GetType();
                    var method           = type.GetMethod("UpdateText");
                    var invokationResult = method.Invoke(loObject, null);
                }
                catch (Exception loError)
                {
                    MessageService.ShowError("Critical", loError.Message);
                }
            }
            catch { }

            return(null);
        }
        /// <summary>
        /// Run Data menu workflow
        /// </summary>
        public override bool Run(WorkInfo workInfo)
        {
            bool bStatus;

            try
            {
                logger.Info($"{this.DisplayName} Running_workflow");
                workInfo.Log(this.DisplayName, NLog.LogLevel.Info, "Running workflow");

                if (!CanRun(workInfo))
                {
                    return(false);
                }

                logger.Trace($"Creating [{DisplayName}] Scripting object");
                workInfo.Log(this.DisplayName, NLog.LogLevel.Info, "Starting Scripting process");

                var inputFiles  = new Dictionary <string, string>();
                var outputFiles = new Dictionary <string, string>();

                for (int i = 0; i < InputNodes.Count; i++)
                {
                    inputFiles.Add($"Input_{i}", InputNodes[i].State.DataFilePath);
                }

                for (int i = 0; i < OutputNodes.Count; i++)
                {
                    outputFiles.Add($"Output_{i}.{FullOutputSchema.ChildNodes[i].ChildNodes[0].Name}", OutputNodes[i].State.DataFilePath);
                }

                var tempFile = Path.GetTempFileName();
                var result   = CompilerService.GenerateCodeAndCompile(tempFile, FullInputSchema, FullOutputSchema, CodeText, inputFiles, outputFiles);
                File.Delete(tempFile);

                try
                {
                    if (result.CompilerResult.Errors.HasErrors)
                    {
                        for (int i = 0; i < result.CompilerResult.Errors.Count; i++)
                        {
                            workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Line {result.CompilerResult.Errors[i].Line - result.CodeLine}, Error {result.CompilerResult.Errors[i].ErrorNumber}: {result.CompilerResult.Errors[i].ErrorText}");
                        }

                        return(false);
                    }

                    Assembly loAssembly = result.CompilerResult.CompiledAssembly;
                    object   loObject   = loAssembly.CreateInstance("WinFormCodeCompile.Transform");
                    if (loObject == null)
                    {
                        return(false);
                    }
                    try
                    {
                        var type             = loObject.GetType();
                        var method           = type.GetMethod("UpdateText");
                        var invokationResult = method.Invoke(loObject, null);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        workInfo.Log(this.DisplayName, NLog.LogLevel.Error, $"Line {ex.InnerException.LineNumber() - result.CodeLine}, {ex.InnerException?.Message}");

                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }

                bStatus = true;
            }
            catch (XPathException ex)
            {
                var msg = $"Critical failure in [{DisplayName}] module error: {ex.Message} ";
                logger.Error(msg);
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, msg);
                bStatus = false;
            }
            catch (Exception ex)
            {
                var msg = $"Critical failure in [{DisplayName}] module error: {ex.Message} ";
                logger.Error(msg);
                workInfo.Log(this.DisplayName, NLog.LogLevel.Error, msg);
                bStatus = false;
            }

            workInfo.Log(this.DisplayName, NLog.LogLevel.Info, $"Module completed processing with Status: {bStatus}");
            logger.Info($"{this.DisplayName} module completed processing with status:{bStatus}");
            return(bStatus);
        }