public static ActionResult ClosePrompt(Session session) { session.Log("Begin PromptToCloseApplications"); try { var productName = session["ProductName"]; var processes = session["PromptToCloseProcesses"].Split(','); var displayNames = session["PromptToCloseDisplayNames"].Split(','); if (processes.Length != displayNames.Length) { session.Log( @"Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items."); return(ActionResult.Failure); } for (var i = 0; i < processes.Length; i++) { session.Log("Prompting process {0} with name {1} to close.", processes[i], displayNames[i]); using (var prompt = new PromptCloseApplication(productName, processes[i], displayNames[i])) { if (!prompt.Prompt()) { return(ActionResult.Failure); } } } } catch (Exception ex) { session.Log( "Missing properties or wrong values. Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items. \nException:" + ex.Message); return(ActionResult.Failure); } session.Log("End PromptToCloseApplications"); return(ActionResult.Success); }
public static ActionResult ClosePrompt(Session session) { session.Log("Begin PromptToCloseApplications"); try { var productName = session["ProductName"]; var processes = session["PromptToCloseProcesses"].Split(','); var displayNames = session["PromptToCloseDisplayNames"].Split(','); if (processes.Length != displayNames.Length) { session.Log( @"Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items."); return ActionResult.Failure; } for (var i = 0; i < processes.Length; i++) { session.Log("Prompting process {0} with name {1} to close.", processes[i], displayNames[i]); using (var prompt = new PromptCloseApplication(productName, processes[i], displayNames[i])) { if (!prompt.Prompt()) { return ActionResult.Failure; } } } } catch (Exception ex) { session.Log( "Missing properties or wrong values. Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items. \nException:" + ex.Message); return ActionResult.Failure; } session.Log("End PromptToCloseApplications"); return ActionResult.Success; }