예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        /// <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());
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        /// <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);
        }