using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ell.Web.Code.Edit;
using Newtonsoft.Json;
namespace Ell.Web.Controllers 
{
    public class EditController : Controller 
    {
        public void Index() 
        {
            HttpContext context = System.Web.HttpContext.Current;
            Handler action = null;
            switch ( context.Request["action"] ) 
            {
                case "config":
                                action = new ConfigHandler( context );
                break;
                case "uploadimage":
                                action = new UploadHandler( context, new UploadConfig() 
                {
                    AllowExtensions = Config.GetStringList( "imageAllowFiles" ),
                                                        PathFormat = Config.GetString( "imagePathFormat" ),
                                                        SizeLimit = Config.Getint( "imageMaxSize" ),
                                                        UploadFieldName = Config.GetString( "imageFieldName" )
                }
                );
                break;
                case "uploadscrawl":
                                action = new UploadHandler( context, new UploadConfig() 
                {
                    AllowExtensions = new string[] { ".png" },
                                                        PathFormat = Config.GetString( "scrawlPathFormat" ),
                                                        SizeLimit = Config.Getint( "scrawlMaxSize" ),
                                                        UploadFieldName = Config.GetString( "scrawlFieldName" ),
                                                        Base64 = true,
                                                        Base64Filename = "scrawl.png"
                                                    } );
                    break;
                    case "uploadvideo":
                                    action = new UploadHandler( context, new UploadConfig() 
                    {
                        AllowExtensions = Config.GetStringList( "videoAllowFiles" ),
                                                            PathFormat = Config.GetString( "videoPathFormat" ),
                                                            SizeLimit = Config.Getint( "videoMaxSize" ),
                                                            UploadFieldName = Config.GetString( "videoFieldName" )
                    }
                    );
                    break;
                    case "uploadfile":
                                    action = new UploadHandler( context, new UploadConfig() 
                    {
                        AllowExtensions = Config.GetStringList( "fileAllowFiles" ),
                                                            PathFormat = Config.GetString( "filePathFormat" ),
                                                            SizeLimit = Config.Getint( "fileMaxSize" ),
                                                            UploadFieldName = Config.GetString( "fileFieldName" )
                    }
                    );
                    break;
                    case "listimage":
                                    action = new ListFileManager( context, Config.GetString( "imageManagerListPath" ), Config.GetStringList( "imageManagerAllowFiles" ) );
                    break;
                    case "listfile":
                                    action = new ListFileManager( context, Config.GetString( "fileManagerListPath" ), Config.GetStringList( "fileManagerAllowFiles" ) );
                    break;
                    case "catchimage":
                                    action = new CrawlerHandler( context );
                    break;
                    default:
                                    action = new NotSupportedHandler( context );
                    break;
                }
                action.Process();
            }
            public bool IsReusable => false;
        }
    }
最后修改:2018 年 11 月 11 日 09 : 23 PM
如果觉得我的文章对你有用,请随意赞赏