Esempio n. 1
0
        public static void ShowAppError(Aquamonix.Mobile.Lib.Domain.Responses.ErrorResponseBody error, Action callback = null)
        {
            ExceptionUtility.Try(() =>
            {
                string title = StringLiterals.GenericErrorAlertTitle;
                string body  = String.Empty;

                if (error != null)
                {
                    if (!String.IsNullOrEmpty(error.ResponseMessageShort))
                    {
                        title = error.ResponseMessageShort;
                    }
                    if (!String.IsNullOrEmpty(error.ResponseMessageLong))
                    {
                        body = error.ResponseMessageLong;
                    }
                }

                if (String.IsNullOrEmpty(body))
                {
                    if (error != null && error.ResponseCode != null && error.Process != null)
                    {
                        body = String.Format("{0} (ResponseCode:{1}, Process:{2})", StringLiterals.UnknownErrorText, error.ResponseCode, error.Process);
                    }
                    else
                    {
                        body = Domain.StringLiterals.UnknownErrorText;
                    }
                }

                #if DEBUG
                if (body != null)
                {
                    if (!String.IsNullOrEmpty(error.CommandId))
                    {
                        body += String.Format("\nCommand ID: {0}", error.CommandId);
                    }
                    if (error.ResponseCode != null && error.ResponseCode.GetValueOrDefault() != 0)
                    {
                        body += String.Format("\nResponse Code: {0}", error.ResponseCode);
                    }
                }
                #endif

                //dismiss error alert
                if (error != null && !String.IsNullOrEmpty(body))
                {
                    ProgressUtility.Dismiss();
                }

                ShowErrorAlert(title, body, callback);
            });
        }