public virtual ActionResult Remove(string[] id) { var result = new Dictionary <string, object>(); var rev = false; var mess = ""; if (id != null) { var infos = new List <FlashEntity>(); foreach (var i in id) { var info = new FlashEntity { Id = i.Convert <long>(), SaveType = SaveType.Remove }; infos.Add(info); } rev = this.SaveEntities(infos); mess = rev ? "" : infos?.FirstOrDefault()?.Errors?.FirstOrDefault()?.Message; } result.Add("Status", rev); result.Add("Message", mess); return(this.Jsonp(result)); }
public virtual void Move(string id) { var info = new FlashEntity { Id = id.Convert <long>(), Folder = new FolderEntity { Id = Request["folderid"].Convert <long>() }, SaveType = SaveType.Modify }; info.SetProperty(it => it.Folder.Id); Ioc.Resolve <IApplicationService, FlashEntity>().Save <FlashEntity>(info); Response.Write(GetErrorMessage(info)); }
/// <summary> /// 得到错误信息 /// </summary> /// <param name="info"></param> /// <returns></returns> protected virtual string GetErrorMessage(FlashEntity info) { if (info == null || info.Errors == null || info.Errors.Count == 0) { return(""); } var sb = new StringBuilder(); foreach (var errorEntity in info.Errors) { sb.AppendFormat(@"{0}\r\n", errorEntity.Message); } return(sb.ToString()); }
/// <summary> /// 得到实体 /// </summary> /// <param name="path"></param> /// <param name="folderId"></param> /// <returns></returns> protected virtual FlashEntity GetSaveEntity(string path, long folderId) { if (string.IsNullOrEmpty(path) || Request.Files.Count == 0) { return(null); } string fileName = string.Format("{0}{1}", path, Path.GetFileName(Request.Files[0].FileName)); var info = new FlashEntity { FileName = fileName, Name = Path.GetFileName(Request.Files[0].FileName), Folder = new FolderEntity { Id = folderId }, SaveType = SaveType.Add, Account = new AccountEntity { Id = Identity.Id }, FileByte = new byte[Request.Files[0].ContentLength] }; Request.Files[0].InputStream.Read(info.FileByte, 0, info.FileByte.Length); return(info); }
/// <summary> /// 得到实体 /// </summary> /// <param name="page"></param> /// <param name="path"></param> /// <param name="folderId"></param> /// <returns></returns> static public FlashEntity GetFlashEntity(this AuthorizePageBase page, string path, long folderId) { if (string.IsNullOrEmpty(path) || page.Request.Files.Count == 0) { return(null); } string fileName = string.Format("{0}{1}", path, Path.GetFileName(page.Request.Files[0].FileName)); var info = new FlashEntity { FileName = fileName, Name = Path.GetFileName(page.Request.Files[0].FileName), Folder = new FolderEntity { Id = folderId }, SaveType = SaveType.Add, Account = new AccountEntity { Id = 0 }, FileByte = new byte[page.Request.Files[0].ContentLength] }; page.Request.Files[0].InputStream.Read(info.FileByte, 0, info.FileByte.Length); return(info); }