private async Task <BAuthorEntity> CreateAuthor(string name) { if (name == null || name == "") { return(null); } BAuthorEntity author = await authorService.FindByNameAsync(name); if (author != null) { return(author); } author = new BAuthorEntity(); //author.Id = Guid.NewGuid().ToString(); author.Name = name; author.Alias = "."; author.Valid = true; author = await authorService.SaveAsync(author); return(author); }
private async Task ValidatorByAlias(EditContext editContext) { authorEntity.Alias = authorEntity.Alias.Trim(); if (StringUtils.IsEqual(authorEntity.Alias, ".")) { // authorEntity.Alias = "."; return; } if (StringUtils.IsEqual(authorEntity.Name, authorEntity.Alias)) { messageStore.Add(editContext.Field("Alias"), "映射别名不能与名称相等"); return; } if (StringUtils.IsNotEqual(authorEntity.Alias, ".")) { BAuthorEntity other = await this.authorService.FindByNameAsync(authorEntity.Alias); // 如果映射的数据不存在,或不合法,或不是主数据 if (other == null || !other.Valid || StringUtils.IsNotEqual(other.Alias, ".")) { messageStore.Add(editContext.Field("Alias"), "映射别名未找到主数据、或匹配的主数据不合法"); } } }
protected override async Task OnInitializedAsync() { tagId = base.Options; authorEntity = await authorService.FindAsync(tagId); await base.OnInitializedAsync(); }
private async Task OnAuthor(string id) { All = false; authorEntity = await authorService.FindAsync(Id); await Refresh(); }
private async Task ValidatorByName(EditContext editContext) { BAuthorEntity other = await this.authorService.FindByNameAsync(authorEntity.Name); if (other != null && StringUtils.IsNotEqual(authorEntity.Id, other.Id)) { messageStore.Add(editContext.Field("Name"), "名字重复了"); } }
protected override async Task OnInitializedAsync() { bookId = base.Options; bookEntity = await bookService.FindAsync(bookId); bookTagEntities = await bookTagService.ListByBookAsync(bookId); authorEntity = await authorService.FindByNameAsync(bookEntity.Author); await base.OnInitializedAsync(); }
protected override async Task OnInitializedAsync() { authorEntity = await authorService.FindAsync(Id); string nameAlias = StringUtils.IsEqual(".", authorEntity.Alias) ? authorEntity.Name : authorEntity.Alias; authorEntities = await authorService.ListByNameAliasAsync(nameAlias); authorEntities.ForEach(a => { authors.Add(a.Name); }); await Refresh(); }
protected override async Task OnInitializedAsync() { authorId = base.Options ?? null; if (StringUtils.IsBlank(authorId)) { authorEntity = new BAuthorEntity(); } else { authorEntity = await authorService.FindCloneAsync(authorId); } await base.OnInitializedAsync(); }
private async Task DiscoveryComic(string path, bool children) { DirectoryInfo root = new DirectoryInfo(path); if (!root.Exists) { Console.WriteLine("目录不存在"); // 文件目录不存在 // TODO: 这里应该有个报警. return; } if (children) { DirectoryInfo[] dirs = root.GetDirectories(); foreach (var dir in dirs) { await DiscoveryComic(dir.FullName, children); } } FileInfo[] files = root.GetFiles(); foreach (var file in files) { if (!ComicUtils.IsArchive(file.Name)) { // 如果当前文件不是漫画档案 continue; } CBookEntity book = await CreateBook(file); BAuthorEntity author = await CreateAuthor(book.Author); } }