Пример #1
0
        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);
        }
Пример #2
0
        public static ActionResult ClosePrompt(Session session)
        {
            Logger.session = session;
            Logger.Write("Begin PromptToCloseApplications");
            try
            {
                var productName = session["ProductName"];
                Logger.Write("Current Product are {0}", productName);

                var processes    = session["PromptToCloseProcesses"].Split(',');
                var displayNames = session["PromptToCloseDisplayNames"].Split(',');

                if (processes.Length != displayNames.Length)
                {
                    Logger.Write(@"Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items.");
                    return(ActionResult.Failure);
                }

                for (var i = 0; i < processes.Length; i++)
                {
                    if (String.IsNullOrEmpty(processes[i]))
                    {
                        Logger.Write("Found empty value at index {0}", i);
                        continue;
                    }
                    Logger.Write("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(session))
                        {
                            return(ActionResult.Failure);
                        }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Missing properties or wrong values. Please check that 'PromptToCloseProcesses' and 'PromptToCloseDisplayNames' exist and have same number of items. \nException:" + ex.Message);
                return(ActionResult.Failure);
            }

            Logger.Write("End PromptToCloseApplications");
            return(ActionResult.Success);
        }