private static void RemoveContent(CommonDbContext dbcontext, Categories categories) { //dbcontext.Entry(contentList); foreach (var contentItem in categories.ContentList) { QiniuTool.DeleteImage(contentItem.MediaResource.Select(x => x.ActualPath.Replace("https://mioto.milbit.com/", "")).ToArray()).Wait(); //dbcontext.Entry(contentItem.MediaResource); //dbcontext.Remove(contentItem.MediaResource); } dbcontext.RemoveRange(categories.ContentList); dbcontext.SaveChanges(); }
public async Task UpdateUserInfo(Guid userId, UpdateUserInfoViewModel updateModel) { var userInfoEntry = await userAccountAccessor.OneAsync <UserAccountEntry>(x => x.Id == userId); /*remove old img from qiniu */ if (!string.IsNullOrEmpty(userInfoEntry.Avatar)) { var avatarUri = new Uri(userInfoEntry.Avatar); var saveKey = avatarUri.AbsolutePath.Remove(0); await QiniuTool.DeleteImage(new string[] { saveKey }); } /*end */ userInfoEntry.NickName = updateModel.NickName; userInfoEntry.Avatar = updateModel.Avatar; if (userInfoEntry.Profile == null) { userInfoEntry.Profile = new UserAccountProfile { }; } userInfoEntry.Profile.BirthDay = updateModel.BirthDay; userInfoEntry.Profile.Location = updateModel.Location; await userAccountAccessor.Update(userInfoEntry); }
public static void DeleteCartoon() { var dbcontext = buildDbContext(); var targetCategoryList = dbcontext.Categories .Include(x => x.Tags) .Include(x => x.ChildrenCategories) .Include(x => x.MediaResource) .Include(x => x.ContentList) .Include("ChildrenCategories.ContentList") .Include("ContentList.MediaResource") .Include("ChildrenCategories.MediaResource").Where(x => x.Name == "h-mate 完结(不含外传)").ToList(); //.Include("ChildrenCategories.MediaResource").Where(x => x.Tags.Any(c => c.Name == "新资源压缩")).ToList(); //.Include("ChildrenCategories.MediaResource").Where(x => x.Name == "妹控进行时" || x.Name == "多重人格侦探").ToList(); //.Include("ChildrenCategories.MediaResource").Where(x => x.Tags.Any(c => c.Name == "妖气漫画")).ToList(); foreach (var topCategory in targetCategoryList) { if (topCategory.ChildrenCategories != null && topCategory.ChildrenCategories.Count > 0) { foreach (var subCategory in topCategory.ChildrenCategories) { if (subCategory.ContentList != null && subCategory.ContentList.Count > 0) { foreach (var contentItem in subCategory.ContentList) { QiniuTool.DeleteImage(contentItem.MediaResource.Select(x => x.ActualPath.Replace("https://mioto.milbit.com/", "")).ToArray()).Wait(); dbcontext.Remove(contentItem.MediaResource); dbcontext.SaveChanges(); } dbcontext.RemoveRange(subCategory.ContentList); } dbcontext.SaveChanges(); } dbcontext.RemoveRange(topCategory.ChildrenCategories); dbcontext.SaveChanges(); } else { foreach (var contentItem in topCategory.ContentList) { if (contentItem.MediaResource != null && contentItem.MediaResource.Count > 0) { QiniuTool.DeleteImage(contentItem.MediaResource.Select(x => x.ActualPath.Replace("https://mioto.milbit.com/", "")).ToArray()).Wait(); dbcontext.RemoveRange(contentItem.MediaResource); dbcontext.SaveChanges(); } } dbcontext.RemoveRange(topCategory.ContentList); } dbcontext.Remove(topCategory); if (topCategory.Tags != null && topCategory.Tags.Count > 0) { dbcontext.RemoveRange(topCategory.Tags); } dbcontext.SaveChanges(); } //foreach (var item in dbcontext.ContentEntry.Include(x => x.MediaResource)) //{ // QiniuTool.DeleteImage(item.MediaResource.Select(x => x.ActualPath.Replace("https://mioto.milbit.com/", "")).ToArray()).Wait(); //} }
public void DeleteQIniu() { var imgKeyList = dbContext.FileEntry.Where(x => x.ActualPath.Contains("cartoon/toptoon/今天在哪嘞(无水印)")).Select(x => x.ActualPath.Replace("http://mioto.milbit.com/", "")).ToArray(); QiniuTool.DeleteImage(imgKeyList).Wait(); }