public virtual string GetCaption()
        {
            if (WindowCaption != null)
            {
                if (!string.IsNullOrEmpty(WindowCaption.ToString()))
                {
                    return(WindowCaption);
                }
            }
            var caption = "";

            if (Icon == null)
            {
                return(caption);
            }
            switch (Icon.ToString())
            {
            case "INFO":
                caption = InfoCaption;
                break;

            case "WARNING":
                caption = WarningCaption;
                break;

            case "QUESTION":
                caption = QuestionCaption;
                break;

            case "ERROR":
                caption = ErrorCaption;
                break;
            }
            return(caption);
        }
        protected override bool InternalExecute(ProcessExecutingContext context)
        {
            string buttonsJsString;
            string iconJsString;
            string messageBoxString = "Ext.MessageBox";
            string defaultButtons   = "OK";

            string[] defaultButtonsArray = { "ok" };
            string   defaultIcon         = "INFO";
            string   defaultMessage      = "DefaultQuestionMessage";
            var      page = Page as Terrasoft.UI.WebControls.PageSchemaUserControl;

            if (MessageText == null)
            {
                return(false);
            }
            if (ProcessInstanceId == null && page != null)
            {
                var instanceId = ((Terrasoft.UI.WebControls.Page)page.AspPage).InstanceId.ToString();
                ProcessInstanceId = instanceId + page.PageContainer.UniqueID;
            }
            var responseMessages = ResponseMessages as Dictionary <string, string>;

            if (responseMessages == null)
            {
                responseMessages = new Dictionary <string, string>();
            }

            var parameters = PageParameters as Dictionary <string, object>;

            if (parameters == null)
            {
                parameters = new Dictionary <string, object>();
            }

            if (!string.IsNullOrEmpty(Buttons))
            {
                switch (Buttons)
                {
                case "OK":
                    if (!responseMessages.ContainsKey("ok"))
                    {
                        responseMessages.Add("ok", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                case "OKCANCEL":
                    if (!responseMessages.ContainsKey("ok"))
                    {
                        responseMessages.Add("ok", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("cancel"))
                    {
                        responseMessages.Add("cancel", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                case "YESNO":
                    if (!responseMessages.ContainsKey("yes"))
                    {
                        responseMessages.Add("yes", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("no"))
                    {
                        responseMessages.Add("no", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                case "YESNOCANCEL":
                    if (!responseMessages.ContainsKey("yes"))
                    {
                        responseMessages.Add("yes", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("no"))
                    {
                        responseMessages.Add("no", defaultMessage);
                    }
                    if (!responseMessages.ContainsKey("cancel"))
                    {
                        responseMessages.Add("cancel", defaultMessage);
                    }
                    buttonsJsString = messageBoxString + "." + Buttons;
                    break;

                default:
                    foreach (string button in defaultButtonsArray)
                    {
                        if (!responseMessages.ContainsKey(button))
                        {
                            responseMessages.Add(button, defaultMessage);
                        }
                    }
                    buttonsJsString = messageBoxString + "." + defaultButtons;
                    break;
                }
            }
            else
            {
                foreach (string button in defaultButtonsArray)
                {
                    if (!responseMessages.ContainsKey(button))
                    {
                        responseMessages.Add(button, defaultMessage);
                    }
                }
                buttonsJsString = messageBoxString + "." + defaultButtons;
            }
            if (!string.IsNullOrEmpty(Icon))
            {
                switch (Icon)
                {
                case "INFO":
                case "WARNING":
                case "QUESTION":
                case "ERROR":
                    iconJsString = messageBoxString + "." + Icon;
                    break;

                default:
                    iconJsString = messageBoxString + "." + defaultIcon;
                    break;
                }
            }
            else
            {
                iconJsString = messageBoxString + "." + defaultIcon;
            }

            var functionJsStringBuilder = new StringBuilder();

            functionJsStringBuilder.Append("function(btn) {");

            var isUpload = false;

            if (parameters.ContainsKey("IsUpload") && parameters["IsUpload"] != null)
            {
                isUpload = (bool)parameters["IsUpload"];
            }

            foreach (KeyValuePair <string, string> responseMessage in responseMessages)
            {
                functionJsStringBuilder.Append("if (btn == '" + responseMessage.Key +
                                               "') {window.Terrasoft.AjaxMethods.ThrowClientEvent('" +
                                               ProcessInstanceId + "','" + responseMessage.Value + "', '', { isUpload : " + Json.Serialize(isUpload) + " });} else ");
            }
            functionJsStringBuilder.Append("{window.Terrasoft.AjaxMethods.ThrowClientEvent('" + ProcessInstanceId +
                                           "','DefaultQuestionMessage');}}");
            WindowCaption = GetCaption();
            ScriptManager scriptManager = null;

            if (page == null)
            {
                scriptManager = ((Terrasoft.UI.WebControls.Page)System.Web.HttpContext.Current.CurrentHandler).FindControl("ScriptManager") as ScriptManager;
            }
            else
            {
                scriptManager = page.GetPropertyValue("ScriptManager") as ScriptManager;
            }
            scriptManager.AddScript("Ext.MessageBox.message('" + WindowCaption.ToString() + "','" + MessageText.ToString().Replace("'", @"\'") + "'," +
                                    buttonsJsString + "," + iconJsString + "," + functionJsStringBuilder.ToString() + ", this);");
            return(true);
        }