Esempio n. 1
0
        public ErrorController(IErrorView view, IEnumerable <BackgroundException> exceptions, string transcript)
        {
            View = view;

            View.SetModel(exceptions);
            View.ModelErrorMessageGetter =
                delegate(object rowObject)
            {
                BackgroundException failure = (BackgroundException)rowObject;
                return(GetReadableTitle(failure) + ": " + failure.getMessage());
            };

            View.ModelHostGetter = delegate(object rowObject)
            {
                BackgroundException failure = (BackgroundException)rowObject;
                if (null == failure.getPath())
                {
                    return(failure.getSession().getHost().toURL());
                }
                return(failure.getPath().getAbsolute());
            };
            View.ModelDescriptionGetter =
                delegate(object rowObject) { return(GetDetailedCauseMessage((BackgroundException)rowObject)); };

            bool log = !string.IsNullOrEmpty(transcript);

            View.Transcript        = transcript;
            View.TranscriptVisible = log &&
                                     Preferences.instance().getBoolean("alert.toggle.transcript");
            View.TranscriptEnabled      = log;
            View.ToggleTranscriptEvent += View_ToggleTranscriptEvent;
        }
 /// <summary>
 /// Display an alert dialog with a summary of all failed tasks
 /// </summary>
 protected void Alert()
 {
     _controller.Invoke(delegate
     {
         if (this.getExceptions().size() == 1)
         {
             BackgroundException failure =
                 this.getExceptions().get(0) as BackgroundException;
             string footer = Preferences.instance().getProperty("website.help");
             if (null != failure.getPath())
             {
                 footer = Preferences.instance().getProperty("website.help") + "/" +
                          failure.getPath().getSession().getHost().getProtocol().
                          getIdentifier();
             }
             DialogResult result =
                 _controller.WarningBox(failure.getReadableTitle(),
                                        failure.getMessage(),
                                        failure.getDetailedCauseMessage(),
                                        hasTranscript() ? this.getTranscript() : null,
                                        String.Format("{0}", Locale.localizedString("Try Again", "Alert")),
                                        true, footer);
             Callback(result);
         }
         else
         {
             ICollection <BackgroundException> backgroundExceptions =
                 Utils.ConvertFromJavaList <BackgroundException>(getExceptions());
             ErrorController errorController =
                 new ErrorController(ObjectFactory.GetInstance <IErrorView>(),
                                     backgroundExceptions, getTranscript());
             DialogResult result = errorController.View.ShowDialog(_controller.View);
             Callback(result);
         }
     }, true);
 }