private void XDataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MessageInfo messageInfo = (MessageInfo)xDataGrid.SelectedValue;
            eUserMsgKey mess        = messageInfo.MessageKey;

            Amdocs.Ginger.Common.eUserMsgSelection messageBoxResult = Reporter.ToUser(mess, "%1", "%2", "%3");
            MessageBox.Show("You selected: " + messageBoxResult);
        }
Пример #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);
            }
        }