public override Amdocs.Ginger.Common.eUserMsgSelection ToUser(string messageText, string caption, eUserMsgOption buttonsType, eUserMsgIcon messageImage, eUserMsgSelection defualtResault)
        {
            eUserMsgSelection result = defualtResault;  // if user just close the window we return the default defined result

            if (!WorkSpace.Instance.RunningInExecutionMode)
            {
                App.MainWindow.Dispatcher.Invoke(() =>
                {
                    UserMessageBox messageBoxWindow = new UserMessageBox(messageText, caption, buttonsType, messageImage, defualtResault);
                    messageBoxWindow.ShowDialog();
                    result = messageBoxWindow.messageBoxResult;
                });
            }
            else
            {
                //not showing pop up message because running from config file and not wanting to get stuck
                ToLog(eLogLevel.WARN, string.Format("Not showing the User Message: '{0}' because application loaded in execution mode. Returning default selection value: '{1}'", messageText, defualtResault.ToString()));
            }

            return(result);
        }
Esempio n. 2
0
        public static eUserMsgSelection ToUser(eUserMsgKey messageKey, params object[] messageArgs)
        {
            UserMsg      messageToShow = null;
            string       messageText   = string.Empty;
            eUserMsgIcon messageImage  = eUserMsgIcon.None;

            try
            {
                //get the message from pool
                // FIXME improve if as already found !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                if ((UserMsgsPool != null) && UserMsgsPool.Keys.Contains(messageKey))
                {
                    messageToShow = UserMsgsPool[messageKey];
                }
                if (messageToShow == null) // Message not found in message pool
                {
                    // We do want to pop the error message so below is just in case...
                    string mess = "";
                    foreach (object o in messageArgs)
                    {
                        mess += o.ToString() + " ";
                    }

                    string txt = messageKey.ToString() + " - " + mess + "{Error message key not found!}";
                    WorkSpaceReporter.ToUser(txt, "Ginger", eUserMsgOption.OK, eUserMsgIcon.Information, eUserMsgSelection.OK);

                    ToLog(eLogLevel.WARN, "The user message with key: '" + messageKey + "' was not found! and won't show to the user!");
                    return(eUserMsgSelection.None);
                }

                //set the message type
                switch (messageToShow.MessageType)
                {
                case eUserMsgType.ERROR:
                    messageImage = eUserMsgIcon.Error;
                    break;

                case eUserMsgType.INFO:
                    messageImage = eUserMsgIcon.Information;
                    break;

                case eUserMsgType.QUESTION:
                    messageImage = eUserMsgIcon.Question;
                    break;

                case eUserMsgType.WARN:
                    messageImage = eUserMsgIcon.Warning;
                    break;

                default:
                    messageImage = eUserMsgIcon.Information;
                    break;
                }

                //enter message args if exist
                if (messageArgs.Length > 0)
                {
                    messageText = string.Format(messageToShow.Message, messageArgs);
                }
                else
                {
                    messageText = messageToShow.Message;
                }

                if (AppLoggingLevel == eAppReporterLoggingLevel.Debug)
                {
                    ToLog(eLogLevel.DEBUG, "Showing User Message: '" + messageText + "'");
                }
                else if (ReportAllAlsoToConsole)
                {
                    ToConsole(eLogLevel.DEBUG, "Showing User Message: '" + messageText + "'");
                }

                //show the messege and return user selection
                eUserMsgSelection userSelection = WorkSpaceReporter.ToUser(messageText, messageToShow.Caption, messageToShow.SelectionOptions, messageImage, messageToShow.DefualtSelectionOption);

                if (AppLoggingLevel == eAppReporterLoggingLevel.Debug)
                {
                    ToLog(eLogLevel.DEBUG, "User Message Option Selection: '" + userSelection.ToString() + "'");
                }
                else if (ReportAllAlsoToConsole)
                {
                    ToConsole(eLogLevel.DEBUG, "User Message Option Selection: '" + userSelection.ToString() + "'");
                }

                return(userSelection);
            }
            catch (Exception ex)
            {
                string txt = "Failed to show the user message with the key: " + messageKey;

                ToLog(eLogLevel.ERROR, txt, ex);

                if (ReportAllAlsoToConsole)
                {
                    ToConsole(eLogLevel.ERROR, txt, ex);
                }

                WorkSpaceReporter.ToUser(txt, "Ginger", eUserMsgOption.OK, eUserMsgIcon.Information, eUserMsgSelection.OK);

                return(eUserMsgSelection.None);
            }
        }