/// <summary> /// Execute the Visual Basic Script if no include errors and no compile erors exist. /// If present, include errors and compile errors will be logged in the Results file(s). /// </summary> public void Execute() { String includeErrors = ""; String compileErrors = ""; // Start the results gathering the the Results file(s). scriptSession.StartResultsGatheringWithExpandedFileNaming(this.scriptFileName); // Get the script host that will do the actual execution of the Visual Basic Script. DvtkScriptSupport.DvtkScriptHost dvtkScriptHost = GetDvtkScriptHost(); // Set the source code. dvtkScriptHost.SourceCode = GetExpandedContent(out includeErrors); // If include errors exist, log in the Results file(s) and stop execution. if (includeErrors.Length > 0) { scriptSession.WriteError(includeErrors); } else // If no include errors exist... { Compile(dvtkScriptHost, out compileErrors); // If compile errors exist, log in the Results file(s) and stop execution. if (compileErrors.Length > 0) { scriptSession.WriteError(compileErrors); } // If no compile error exist, execute the script. else { try { // Run the script using the script host. dvtkScriptHost.Invoke("DvtkScript", "Main"); } catch (Exception theException) { String invokeError = string.Format("An exception occured while executing Visual Basic Script \"{0}\":\r\n{1}", scriptFullFileName, theException.Message); scriptSession.WriteError(invokeError); } } } // End the results gathering the the Results file(s). scriptSession.EndResultsGathering(); }
/// <summary> /// Execute the Visual Basic Script if no include errors and no compile erors exist. /// /// If present, include errors and compile errors will be logged in the Results file(s). /// </summary> /// <param name="includeError">If an include errors exists, the string will contain an error description.</param> /// <param name="compileError">If a compile errors exists, the string will contain an error description.</param> /// <returns> /// true if no include errors and no compile errors are present. /// false otherwise. /// </returns> public void Execute(object [] theArguments) { String includeErrors = ""; String compileErrors = ""; // Start the results gathering the the Results file(s). scriptSession.StartResultsGatheringWithExpandedFileNaming(this.scriptFileName); // Get the script host that will do the actual execution of the Visual Basic Script. DvtkScriptSupport.DvtkScriptHost dvtkScriptHost = GetDvtkScriptHost(); // Set the source code. dvtkScriptHost.SourceCode = GetExpandedContent(out includeErrors); // If include errors exist, log in the Results file(s) and stop execution. if (includeErrors.Length > 0) { scriptSession.WriteError(includeErrors); } else // If no include errors exist... { Compile(dvtkScriptHost, out compileErrors); // If compile errors exist, log in the Results file(s) and stop execution. if (compileErrors.Length > 0) { scriptSession.WriteError(compileErrors); } // If no compile error exist, execute the script. else { bool invoked = false; try { // Run the script using the script host. dvtkScriptHost.Invoke("DvtkScript", "Main", theArguments); invoked = true; } catch (System.Exception theException) { // String invokeError = string.Format("Unable to invoke Visual Basic Script.\n- Script: {0}\n- Needed entry point: Main\n- Needed module: DvtkScript\n\nException text:\n{1}", scriptFullFileName , theException.Message); // scriptSession.WriteError(invokeError); } catch { // String invokeError = string.Format("Unable to invoke Visual Basic Script.\n- Script: {0}\n- Needed entry point: Main\n- Needed module: DvtkScript", scriptFullFileName); // scriptSession.WriteError(invokeError); } if (!invoked) { try { // Run the script using the script host. dvtkScriptHost.Invoke("DvtkScript", "Main", null); invoked = true; } catch (System.Exception theException) { // String invokeError = string.Format("Unable to invoke Visual Basic Script.\n- Script: {0}\n- Needed entry point: Main\n- Needed module: DvtkScript\n\nException text:\n{1}", scriptFullFileName , theException.Message); // scriptSession.WriteError(invokeError); } catch { // String invokeError = string.Format("Unable to invoke Visual Basic Script.\n- Script: {0}\n- Needed entry point: Main\n- Needed module: DvtkScript", scriptFullFileName); // scriptSession.WriteError(invokeError); } } if (!invoked) { String invokeError = string.Format("Unable to invoke Visual Basic Script."); scriptSession.WriteError(invokeError); } } } // End the results gathering the the Results file(s). scriptSession.EndResultsGathering(); }