private void Process(MgaFCO currentobj)
        {
            if (currentobj == null)
            {
                this.Logger.WriteError("Context is invalid. This component can be executed only if a valid context is open in the main editor (e.g.: Test Bench, Component Assembly).");
                return;
            }

            MgaGateway.PerformInTransaction(() =>
            {
                this.Logger.WriteInfo("Processing {0} [{1}] model", currentobj.Name, currentobj.MetaBase.Name);
            });

            using (var masterInterpreter = new CyPhyMasterInterpreterAPI(currentobj.Project, this.Logger))
            {
                masterInterpreter.IsInteractive = this.InteractiveMode;
                this.Logger.WriteDebug("Interactive mode: {0}", masterInterpreter.IsInteractive);

                Rules.ContextCheckerResult[] contextCheckerResults = null;

                // check context
                var checkerSuccess = false;
                try
                {
                    checkerSuccess = masterInterpreter.TryCheckContext(currentobj as MgaModel, out contextCheckerResults);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    this.Logger.WriteDebug(ex.ToString());
                    this.Logger.WriteError(ex.Message);
                    return;
                }

                List<Rules.ContextCheckerResult> sortedResults = contextCheckerResults.ToList();

                // sort results Passed, Failed, then alphabetically based on message.
                sortedResults.Sort((x, y) =>
                {
                    return x.Success == y.Success ?
                        x.Message.CompareTo(y.Message) :
                        y.Success.CompareTo(x.Success);
                });

                // Print Checker results
                MgaGateway.PerformInTransaction(() =>
                {
                    foreach (var result in sortedResults)
                    {
                        if (result.Success)
                        {
                            this.Logger.WriteCheckPassed(" <i><a href=\"mga:{0}\">{1}</a></i> {2}", result.Subject.ID, result.Subject.Name, result.Message);
                        }
                        else
                        {
                            this.Logger.WriteCheckFailed(" <i><a href=\"mga:{0}\">{1}</a></i> {2}", result.Subject.ID, result.Subject.Name, result.Message);
                        }
                    }
                });

                if (sortedResults.Any(x => x.Success == false))
                {
                    this.Logger.WriteError("Context is invalid see messeges above. Please fix the problems.");

                    bool controlWasHeld = false;
                    int VK_CONTROL = 0x11;
                    // if user held the control ignore the checker results ... for debugging purposes ONLY!
                    if ((bool)((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000))
                    {
                        controlWasHeld = true;
                    }

                    if (controlWasHeld == false)
                    {
                        return;
                    }
                    else
                    {
                        this.Logger.WriteWarning("Bypassing checker results. This mode is strictly for debugging purposes.");
                    }
                }

                if (checkerSuccess == false)
                {
                    return;
                }

                // context is valid
                // show GUI for the user
                ConfigurationSelection selection = null;

                try
                {
                    selection = masterInterpreter.ShowConfigurationSelectionForm(currentobj as MgaModel);
                    MgaGateway.PerformInTransaction(() =>
                    {
                        this.Logger.WriteDebug("MasterExe command: CyPhyMasterExe.exe \"{0}\" \"{1}\" \"{2}\"", currentobj.Project.ProjectConnStr, GMELightObject.ShortenAbsPath(currentobj.AbsPath),
                            String.Join("\" \"", selection.SelectedConfigurations.Cast<IMgaFCO>().Select(f => GMELightObject.ShortenAbsPath(f.AbsPath)).ToArray()));
                    });
                }
                catch (ExecutionCanceledByUserException ex)
                {
                    this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message);
                    return;
                }



                MasterInterpreterResult[] miResults = null;

                // Get a progress dialog
                using (var progressDialog = new ProgressDialog(masterInterpreter))
                {
                    masterInterpreter.MultipleConfigurationProgress += progressDialog.MultipleConfigurationProgressHandler;
                    masterInterpreter.SingleConfigurationProgress += progressDialog.SingleConfigurationProgressHandler;

                    if (masterInterpreter.IsInteractive)
                    {
                        progressDialog.ShowWithDisabledMainWindow();
                    }

                    try
                    {
                        miResults = masterInterpreter.RunInTransactionWithConfig(selection);
                    }
                    catch (AnalysisModelInterpreterConfigurationFailedException ex)
                    {
                        this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message);
                    }
                    catch (ExecutionCanceledByUserException ex)
                    {
                        this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message);
                    }
                }

                if (selection.OpenDashboard)
                {
                    masterInterpreter.OpenDashboardWithChrome();
                }

                masterInterpreter.WriteSummary(miResults);
            }
        }
        private void Process(MgaFCO currentobj)
        {
            if (currentobj == null)
            {
                this.Logger.WriteError("Context is invalid. This component can be executed only if a valid context is open in the main editor (e.g.: Test Bench, Component Assembly).");
                return;
            }

            MgaGateway.PerformInTransaction(() =>
            {
                this.Logger.WriteInfo("Processing {0} [{1}] model", currentobj.Name, currentobj.MetaBase.Name);
            });

            using (var masterInterpreter = new CyPhyMasterInterpreterAPI(currentobj.Project, this.Logger))
            {
                masterInterpreter.IsInteractive = this.InteractiveMode;
                this.Logger.WriteDebug("Interactive mode: {0}", masterInterpreter.IsInteractive);

                Rules.ContextCheckerResult[] contextCheckerResults = null;

                // check context
                var checkerSuccess = false;
                try
                {
                    checkerSuccess = masterInterpreter.TryCheckContext(currentobj as MgaModel, out contextCheckerResults);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    this.Logger.WriteDebug(ex.ToString());
                    this.Logger.WriteError(ex.Message);
                    return;
                }

                List <Rules.ContextCheckerResult> sortedResults = contextCheckerResults.ToList();

                // sort results Passed, Failed, then alphabetically based on message.
                sortedResults.Sort((x, y) =>
                {
                    return(x.Success == y.Success ?
                           x.Message.CompareTo(y.Message) :
                           y.Success.CompareTo(x.Success));
                });

                // Print Checker results
                MgaGateway.PerformInTransaction(() =>
                {
                    foreach (var result in sortedResults)
                    {
                        if (result.Success)
                        {
                            this.Logger.WriteCheckPassed(" <i><a href=\"mga:{0}\">{1}</a></i> {2}", result.Subject.ID, result.Subject.Name, result.Message);
                        }
                        else
                        {
                            this.Logger.WriteCheckFailed(" <i><a href=\"mga:{0}\">{1}</a></i> {2}", result.Subject.ID, result.Subject.Name, result.Message);
                        }
                    }
                });

                bool controlWasHeld = false;
                int  VK_CONTROL     = 0x11;
                // if user held the control ignore the checker results ... for debugging purposes ONLY!
                if ((bool)((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000))
                {
                    controlWasHeld = true;
                }
                if (this.InteractiveMode == false)
                {
                    controlWasHeld = false;
                }

                if (sortedResults.Any(x => x.Success == false))
                {
                    this.Logger.WriteError("Context is invalid see messages above. Please fix the problems.");

                    if (controlWasHeld == false)
                    {
                        return;
                    }
                    else
                    {
                        this.Logger.WriteWarning("Bypassing checker results. This mode is strictly for debugging purposes.");
                    }
                }

                if (checkerSuccess == false)
                {
                    return;
                }

                // context is valid
                // show GUI for the user
                ConfigurationSelection selection = null;

                try
                {
                    selection = masterInterpreter.ShowConfigurationSelectionForm(currentobj as MgaModel, enableDebugging: controlWasHeld);
                    if (selection.SelectedConfigurations == null)
                    {
                        // user selected "Run in parallel"
                        return;
                    }
                    MgaGateway.PerformInTransaction(() =>
                    {
                        this.Logger.WriteDebug("MasterExe command: CyPhyMasterExe.exe \"{0}\" \"{1}\" \"{2}\"", currentobj.Project.ProjectConnStr, GMELightObject.ShortenAbsPath(currentobj.AbsPath),
                                               String.Join("\" \"", selection.SelectedConfigurations.Cast <IMgaFCO>().Select(f => GMELightObject.ShortenAbsPath(f.AbsPath)).ToArray()));
                    });
                }
                catch (ExecutionCanceledByUserException ex)
                {
                    this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message);
                    return;
                }



                MasterInterpreterResult[] miResults = null;

                // Get a progress dialog
                using (var progressDialog = new ProgressDialog(masterInterpreter))
                {
                    masterInterpreter.MultipleConfigurationProgress += progressDialog.MultipleConfigurationProgressHandler;
                    masterInterpreter.SingleConfigurationProgress   += progressDialog.SingleConfigurationProgressHandler;

                    if (masterInterpreter.IsInteractive)
                    {
                        progressDialog.ShowWithDisabledMainWindow();
                    }

                    try
                    {
                        miResults = masterInterpreter.RunInTransactionWithConfig(selection);
                    }
                    catch (AnalysisModelInterpreterConfigurationFailedException ex)
                    {
                        this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message);
                    }
                    catch (ExecutionCanceledByUserException ex)
                    {
                        this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message);
                    }
                }

                masterInterpreter.WriteSummary(miResults);
            }
        }