Example #1
0
        private string _buildErrorMessage(int lcid)
        {
            string        s;
            ServiceStatus rspStatus = (this.rspDto != null) ? this.rspDto.Status : null;

            if (rspStatus != null)
            {
                s = rspStatus.GetDisplayMessage(lcid);
                if (string.IsNullOrEmpty(s))
                {
                    s = adfsConfig.ShowDebugMsg
                        ? rspStatus.Code + " (" + rspStatus.Message + ")</p><p>" + this.param
                        : ServiceStatus.GetDefaultErrorMessage(lcid);
                }
            }
            else
            {
                s = this.param;
            };
            string portalUrl = null;

            if ((this.rspDto != null) && this.rspDto.Extensions.ContainsKey(AuthResponseExtension.UserAssistencePortalUrl))
            {
                portalUrl = (string)this.rspDto.Extensions[AuthResponseExtension.UserAssistencePortalUrl];
                if (!string.IsNullOrWhiteSpace(portalUrl))
                {
                    portalUrl += "&lang=" + resMgr.GetString(RES_LANGUAGE, new CultureInfo(lcid));
                    s          = new Regex("#PortalUrl#", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant).Replace(s, portalUrl);
                }
            }
            ;
            if (string.IsNullOrWhiteSpace(portalUrl))                                                                                                      // remove placeholder and <a href=...> tag around it
            {
                s = new Regex(@"<a\s+[^>]*href=.#PortalUrl#.[^>]*>([^<]*)</a>", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant).Replace(s, "$1"); // <a href="#PortalUrl#">foo</a> => foo
                s = new Regex("#PortalUrl#", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant).Replace(s, "");
            }
            ;
            return(s);
        }