/// <exclude />
        public static void RedirectUserToErrorPage(string uiContainerName, Exception exception)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            string redirectUrl;

            switch (uiContainerName)
            {
            case "Document":
                redirectUrl = UrlUtils.ResolveAdminUrl("content/misc/errors/error.aspx") + "?" + ConvertExceptionToQueryString(exception);
                break;

            case null:
            case "Wizard":
            case "DataDialog":
            case "ConfirmDialog":
                redirectUrl = UrlUtils.ResolveAdminUrl("content/misc/errors/error_dialog.aspx") + "?" + ConvertExceptionToQueryString(exception);
                break;

            default:
                Log.LogWarning("ErrorServices", string.Format("Unhandled redirect! Unknown container: '{0}", uiContainerName));
                throw new NotImplementedException(string.Format("Unknown container: '{0}'", uiContainerName));
            }

            HttpContext.Current.Response.Redirect(redirectUrl, true);
        }
示例#2
0
        private static void GenerateBoxImage(HttpContext context, string boxtype, string title, Bitmap previewImage,
                                             List <string> textLines)
        {
            string filePath = context.Server.MapPath(UrlUtils.ResolveAdminUrl($"images/{boxtype}box.png"));

            using (var bitmap = (Bitmap)Bitmap.FromFile(filePath))
            {
                var imageCreator = new ImageTemplatedBoxCreator(bitmap, new Point(55, 40), new Point(176, 78))
                {
                    MinHeight = 50
                };


                int textLeftPadding = (boxtype == "function" ? 30 : 36);

                imageCreator.SetTitle(title, new Size(textLeftPadding, 9), new Size(70, 15), Color.Black,
                                      "Tahoma", 8.0f, FontStyle.Bold);

                if (previewImage != null)
                {
                    imageCreator.SetPreviewImage(previewImage, new Size(10, 32), new Size(10, 16));
                }
                else
                {
                    if (textLines != null)
                    {
                        imageCreator.SetTextLines(textLines, new Size(textLeftPadding, 0), new Size(100, 80),
                                                  Color.Black, "Tahoma", 8.0f, FontStyle.Regular);
                    }
                }

                context.Response.ContentType = "image/png";
                context.Response.Cache.SetExpires(DateTime.Now.AddDays(10));

                using (Bitmap boxBitmap = imageCreator.CreateBitmap())
                {
                    boxBitmap.Save(context.Response.OutputStream, ImageFormat.Png);
                }
            }
        }