/// <summary> /// 获取所有的图片信息 /// </summary> /// <param name="directory"></param> /// <returns></returns> public static List <PictureModel> GetPictureList(LoadFilter filter) { var result = new List <PictureModel>(); //先获取所有的 var items = new ItemBusiness().GetItems(); //获取所有的分类 var categories = new CategoryBusiness().GetCategories(); //获取所有的图片 var picturesInDatabase = new PictureBusiness().GetPictures(); //文件夹里面的 var picturesInFolder = filter.FromFolder ? GetPictureFromFolder(filter) : new List <PictureModel>(); //已入库的 var picturesSaved = new List <PictureModel>(); //未入库的 var picturesDraft = new List <PictureModel>(); //分别处理 picturesInFolder.ForEach(x => { if (picturesInDatabase.Exists(y => y.EId == x.EId)) { picturesSaved.Add(x); } else { picturesDraft.Add(x); } }); //包含文件夹 if (filter.FromFolder) { if (filter.IncludeSaved) { result.AddRange(picturesSaved); } if (filter.IncludeDraft) { result.AddRange(picturesDraft); } } //包含数据库 if (filter.FromDatabase) { picturesInDatabase.ForEach(x => { if (!result.Exists(y => y.EId == x.EId)) { result.Add(x); } }); } return(result); }
/// <summary> /// 保存图片 /// </summary> /// <param name="pictures"></param> /// <returns></returns> public static bool SavePicture(PictureModel picture) { var result = new PictureBusiness().SavePicture(picture); return(result); }