// 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 = UEConfig.GetStringList("imageAllowFiles"), PathFormat = UEConfig.GetString("imagePathFormat"), SizeLimit = UEConfig.GetInt("imageMaxSize"), UploadFieldName = UEConfig.GetString("imageFieldName") }; handle = new UploadHandle(config); break; case "uploadtemplateimage": default: handle = new NotSupportedHandler(); break; } var result = handle.Process(); var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(result); return(Content(jsonString)); }
public UECrawler Fetch() { using (HttpWebResponse httpWebResponse = (WebRequest.Create(SourceUrl) as HttpWebRequest).GetResponse() as HttpWebResponse) { if (httpWebResponse.StatusCode != HttpStatusCode.OK) { State = "Url returns " + httpWebResponse.StatusCode + ", " + httpWebResponse.StatusDescription; return(this); } if (httpWebResponse.ContentType.IndexOf("image") == -1) { State = "Url is not an image"; return(this); } ServerUrl = UEPathFormatter.Format(Path.GetFileName(SourceUrl), UEConfig.GetString("catcherPathFormat")); string path = Server.MapPath(ServerUrl); if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } try { BinaryReader binaryReader = new BinaryReader(httpWebResponse.GetResponseStream()); byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { byte[] array = new byte[4096]; int count; while ((count = binaryReader.Read(array, 0, array.Length)) != 0) { memoryStream.Write(array, 0, count); } bytes = memoryStream.ToArray(); } File.WriteAllBytes(path, bytes); State = "SUCCESS"; } catch (Exception ex) { State = "抓取错误:" + ex.Message; } return(this); } }
public override void Process() { try { Start = ((!string.IsNullOrEmpty(base.Request["start"])) ? Convert.ToInt32(base.Request["start"]) : 0); Size = (string.IsNullOrEmpty(base.Request["size"]) ? UEConfig.GetInt("imageManagerListSize") : Convert.ToInt32(base.Request["size"])); } catch (FormatException) { State = ResultState.InvalidParam; WriteResult(); return; } List <string> list = new List <string>(); try { string localPath = base.Server.MapPath(PathToList); list.AddRange(from x in Directory.GetFiles(localPath, "*", SearchOption.AllDirectories) where SearchExtensions.Contains(Path.GetExtension(x).ToLower()) select PathToList + x.Substring(localPath.Length).Replace("\\", "/")); Total = list.Count; FileList = (from x in list orderby x select x).Skip(Start).Take(Size).ToArray(); } catch (UnauthorizedAccessException) { State = ResultState.AuthorizError; } catch (DirectoryNotFoundException) { State = ResultState.PathNotFound; } catch (IOException) { State = ResultState.IOError; } finally { WriteResult(); } }
public static IUEConfig <T> Config <T>() where T : TestClassBase { var entity = new UEConfig <T>(); entity.SetName(x => x.Name); entity.AddTab("Profile", tab => { //TODO: Cannot user same property twice tab.AddTextBox(x => x.Name, maxChars: 50).Label("My label").Description("My description").Required("^[A-z]{9}$"); tab.AddTextBox(x => x.Name).Label("My label").Description("Should be readonly").ReadOnly(); tab.AddTextArea(x => x.Summary).Label("Summary").Description("My short summary").Required(); tab.AddCheckbox(x => x.Boolean).Label("Active"); tab.AddDropdown(x => x.Dropdown, new Dictionary <string, string> { { "1", "A" }, { "2", "B" }, { "3", "C" } }).Label("Select").Required(); }); return(entity); }
public override void Process() { try { this.Start = string.IsNullOrEmpty(this.Request["start"]) ? 0 : Convert.ToInt32(this.Request["start"]); this.Size = string.IsNullOrEmpty(this.Request["size"]) ? UEConfig.GetInt("imageManagerListSize") : Convert.ToInt32(this.Request["size"]); } catch (FormatException ex) { this.State = UEListFileManager.ResultState.InvalidParam; this.WriteResult(); return; } List <string> source = new List <string>(); try { string localPath = this.Server.MapPath(this.PathToList); source.AddRange(((IEnumerable <string>)Directory.GetFiles(localPath, "*", SearchOption.AllDirectories)).Where <string>((Func <string, bool>)(x => ((IEnumerable <string>) this.SearchExtensions).Contains <string>(Path.GetExtension(x).ToLower()))).Select <string, string>((Func <string, string>)(x => this.PathToList + x.Substring(localPath.Length).Replace("\\", "/")))); this.Total = source.Count; this.FileList = source.OrderBy <string, string>((Func <string, string>)(x => x)).Skip <string>(this.Start).Take <string>(this.Size).ToArray <string>(); } catch (UnauthorizedAccessException ex) { this.State = UEListFileManager.ResultState.AuthorizError; } catch (DirectoryNotFoundException ex) { this.State = UEListFileManager.ResultState.PathNotFound; } catch (IOException ex) { this.State = UEListFileManager.ResultState.IOError; } finally { this.WriteResult(); } }
public void AddTree(string treenName, string treeIcon, Action <IUEConfig <T> > sectionConfig) { var entity = new UEConfig <T>(); }
public static int GetInt(string key) { return(UEConfig.GetValue <int>(key)); }
public static string GetString(string key) { return(UEConfig.GetValue <string>(key)); }