public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param) { if (this.enabled == false) { return; } try { // Need to call this interpreter in the same way as the MasterInterpreter will call it. // initialize main parameters var parameters = new InterpreterMainParameters() { Project = project, CurrentFCO = currentobj, SelectedFCOs = selectedobjs, StartModeParam = param }; this.mainParameters = parameters; parameters.ProjectDirectory = project.GetRootDirectoryPath(); // set up the output directory MgaGateway.PerformInTransaction(delegate { string outputDirName = project.Name; if (currentobj != null) { outputDirName = currentobj.Name; } var outputDirAbsPath = Path.GetFullPath(Path.Combine( parameters.ProjectDirectory, "results", outputDirName)); parameters.OutputDirectory = outputDirAbsPath; if (Directory.Exists(outputDirAbsPath)) { Logger.WriteWarning("Output directory {0} already exists. Unexpected behavior may result.", outputDirAbsPath); } else { Directory.CreateDirectory(outputDirAbsPath); } }); PreConfigArgs preConfigArgs = new PreConfigArgs() { ProjectDirectory = parameters.ProjectDirectory, Project = parameters.Project }; // call the preconfiguration with no parameters and get preconfig var preConfig = this.PreConfig(preConfigArgs); // get previous GUI config var settings_ = META.ComComponent.DeserializeConfiguration(parameters.ProjectDirectory, typeof(CyPhy2CADPCB_Settings), this.ComponentProgID); CyPhy2CADPCB_Settings settings = (settings_ != null) ? settings_ as CyPhy2CADPCB_Settings : new CyPhy2CADPCB_Settings(); // Set configuration based on Workflow Parameters. This will override all [WorkflowConfigItem] members. settings = InitializeSettingsFromWorkflow(settings); // get interpreter config through GUI var config = this.DoGUIConfiguration(preConfig, settings); if (config == null) { Logger.WriteWarning("Operation canceled by the user."); return; } // if config is valid save it and update it on the file system META.ComComponent.SerializeConfiguration(parameters.ProjectDirectory, config, this.ComponentProgID); // assign the new configuration to mainParameters parameters.config = config; // call the main (ICyPhyComponent) function this.Main(parameters); } catch (Exception ex) { Logger.WriteError("Interpretation failed {0}<br>{1}", ex.Message, ex.StackTrace); } finally { DisposeLogger(); MgaGateway = null; project = null; currentobj = null; selectedobjs = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param) { if (this.enabled == false) { return; } try { // Need to call this interpreter in the same way as the MasterInterpreter will call it. // initialize main parameters var parameters = new InterpreterMainParameters() { Project = project, CurrentFCO = currentobj, SelectedFCOs = selectedobjs, StartModeParam = param }; this.mainParameters = parameters; parameters.ProjectDirectory = project.GetRootDirectoryPath(); // set up the output directory MgaGateway.PerformInTransaction(delegate { string outputDirName = project.Name; if (currentobj != null) { outputDirName = currentobj.Name; } var outputDirAbsPath = Path.GetFullPath(Path.Combine( parameters.ProjectDirectory, "results", outputDirName)); parameters.OutputDirectory = outputDirAbsPath; if (Directory.Exists(outputDirAbsPath)) { Logger.WriteWarning("Output directory {0} already exists. Unexpected behavior may result.", outputDirAbsPath); } else { Directory.CreateDirectory(outputDirAbsPath); } //this.Parameters.PackageName = Schematic.Factory.GetModifiedName(currentobj.Name); }); PreConfigArgs preConfigArgs = new PreConfigArgs() { ProjectDirectory = parameters.ProjectDirectory, Project = parameters.Project }; // call the preconfiguration with no parameters and get preconfig var preConfig = this.PreConfig(preConfigArgs); // get previous GUI config var settings_ = META.ComComponent.DeserializeConfiguration(parameters.ProjectDirectory, typeof(CyPhy2Schematic_Settings), this.ComponentProgID); CyPhy2Schematic_Settings settings = (settings_ != null) ? settings_ as CyPhy2Schematic_Settings : new CyPhy2Schematic_Settings(); // Set configuration based on Workflow Parameters. This will override all [WorkflowConfigItem] members. settings = InitializeSettingsFromWorkflow(settings); // Don't skip GUI -- we've been invoked directly here. settings.skipGUI = null; // get interpreter config through GUI var config = this.DoGUIConfiguration(preConfig, settings); if (config == null) { Logger.WriteWarning("Operation canceled by the user."); return; } // if config is valid save it and update it on the file system META.ComComponent.SerializeConfiguration(parameters.ProjectDirectory, config, this.ComponentProgID); // assign the new configuration to mainParameters parameters.config = config; // call the main (ICyPhyComponent) function this.Main(parameters); } catch (Exception ex) { Logger.WriteError("Interpretation failed {0}<br>{1}", ex.Message, ex.StackTrace); } finally { if (MgaGateway != null && MgaGateway.territory != null) { MgaGateway.territory.Destroy(); } DisposeLogger(); MgaGateway = null; project = null; currentobj = null; selectedobjs = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } }