/// <summary> /// Modifies Deployment manifest based on "method" property /// </summary> public override bool DoStep() { if (FileName == "") { throw new InvalidOperationException("Must specify a file name for for ScripterStep!"); } ILog log = null; FileStream f = null; try { // create a log log = LogFactory.Create(); log.StatusMessage = "******************************************************************"; log.StatusMessage = "*** ScripterStep Starting... *************************************"; log.StatusMessage = "******************************************************************"; // get a stream to the script file f = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); S.Scripter script = new S.Scripter(f, log); } catch (Exception e) { log.FailMessage = "ScripterStep hit an exception! \n" + e.Message.ToString() + "\n\n" + e.StackTrace; } return(true); }
/// <summary> /// HandleWindow /// </summary> /// <param name="topHwnd"></param> /// <param name="hwnd"></param> /// <param name="process"></param> /// <param name="title"></param> /// <param name="notification"></param> /// <returns></returns> public override UIHandlerAction HandleWindow(System.IntPtr topHwnd, System.IntPtr hwnd, System.Diagnostics.Process process, string title, UIHandlerNotification notification) { ILog log = null; FileStream f = null; try { // create a log log = LogFactory.Create(); log.StatusMessage = "CustomUIHandler invoked"; // wait when invoked; allow UIA properties to get in sync with Win32 Thread.Sleep(1000); // get a stream to the script file f = new FileStream(ScriptFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); // process the script file with the requested handler switch (Handler) { case HandlerID.Scripter: { S.Scripter script = new S.Scripter(f, log); } break; default: { UIScript script = new UIScript(f, topHwnd, log); script.Execute(); } break; } // we got here. it means script was executed with no exceptions if (String.Compare(SetPassWhenDone, Boolean.TrueString, true, CultureInfo.InvariantCulture) == 0) { log.PassMessage = "Test Passed. Script executed with no exceptions and setting result was requested"; } else if (String.Compare(SetPassWhenDone, Boolean.FalseString, true, CultureInfo.InvariantCulture) == 0) { log.StatusMessage = "CustomUIHandler done - not setting result"; } else { log.FailMessage = "Invalid 'SetPassWhenDone' property value specified"; } // end handler return(UIHandlerAction.Abort); } catch (Exception e) { if (log != null) { log.FailMessage = "Exception caught in the UIHandler: " + e.ToString(); } // end handler return(UIHandlerAction.Abort); } finally { // close the stream file if it was successfully created if (f != null) { f.Close(); } log.StatusMessage = "CustomUIHandler finished"; } }