예제 #1
0
        public ContentResult Handle()
        {
            IUEditorHandle configHandler = null;
            string         item          = base.Request["action"];
            string         str           = item;

            if (item != null)
            {
                if (str == "config")
                {
                    configHandler = new ConfigHandler();
                    return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
                }
                else
                {
                    if (str != "uploadimage")
                    {
                        configHandler = new NotSupportedHandler();
                        return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
                    }
                    UploadConfig uploadConfig = new UploadConfig()
                    {
                        AllowExtensions = Config.GetStringList("imageAllowFiles"),
                        PathFormat      = Config.GetString("imagePathFormat"),
                        SizeLimit       = Config.GetInt("imageMaxSize"),
                        UploadFieldName = Config.GetString("imageFieldName")
                    };
                    configHandler = new UploadHandle(uploadConfig);
                    return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
                }
            }
            configHandler = new NotSupportedHandler();
            return(base.Content(JsonConvert.SerializeObject(configHandler.Process())));
        }
예제 #2
0
        // GET: UEditor
        public ContentResult Handle()
        {
            UploadConfig   config = null;
            IUEditorHandle handle = null;
            string         action = Request.Query["action"].ToString();

            switch (action)
            {
            case "config":
                handle = new ConfigHandler();
                break;

            case "uploadimage":
                config = new UploadConfig()
                {
                    AllowExtensions = Config.GetStringList("imageAllowFiles"),
                    PathFormat      = Config.GetString("imagePathFormat"),
                    SizeLimit       = Config.GetInt("imageMaxSize"),
                    UploadFieldName = Config.GetString("imageFieldName")
                };
                handle = new UploadHandle(config);
                break;

            default:
                handle = new NotSupportedHandler();
                break;
            }

            var result     = handle.Process();
            var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(result);

            return(Content(jsonString));
        }
예제 #3
0
        // GET: UEditor
        public ContentResult Handle(string action)
        {
            UploadConfig   config = null;
            IUEditorHandle handle = null;

            action = Request["action"];
            switch (action)
            {
            case "config":
                handle = new ConfigHandler();
                break;

            case "uploadimage":
                config = new UploadConfig()
                {
                    AllowExtensions = Config.GetStringList("imageAllowFiles"),
                    PathFormat      = Config.GetString("imagePathFormat"),
                    SizeLimit       = Config.GetInt("imageMaxSize"),
                    UploadFieldName = Config.GetString("imageFieldName")
                };
                handle = new UploadHandle(config);
                break;

            case "uploadtemplateimage":
                var controllerName = Request["areaName"].ToString();
                var shopId         = "0";
                if (controllerName.ToLower().Equals("selleradmin"))
                {
                    ManagerInfo sellerManager = null;
                    //long userId = UserCookieEncryptHelper.Decrypt(WebHelper.GetCookie(CookieKeysCollection.SELLER_MANAGER), "SellerAdmin");
                    string _tmpstr = Request["ShopId"];
                    //if (userId != 0)
                    //{
                    //    sellerManager = ServiceHelper.Create<IManagerService>().GetSellerManager(userId);
                    //}
                    shopId = (string.IsNullOrWhiteSpace(_tmpstr) ? "NonShopID" : _tmpstr);
                }
                config = new UploadConfig()
                {
                    AllowExtensions = Config.GetStringList("templateimageAllowFiles"),
                    PathFormat      = Config.GetString("templateimagePathFormat").Replace("{ShopID}", shopId),
                    SizeLimit       = Config.GetInt("templateimageMaxSize"),
                    UploadFieldName = Config.GetString("templateimageFieldName"),
                    ShopId          = long.Parse(shopId)
                };
                handle = new UploadHandle(config);
                break;

            default:
                handle = new NotSupportedHandler();
                break;
            }

            var result     = handle.Process();
            var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(result);

            return(Content(jsonString));
        }