Exemple #1
0
            public CoverError(ErrorType errorType, CoverRef cover)
                : base(errorType)
            {
                this.cover = cover;

                if (errorType != ErrorType.CoverMissingParent)
                {
                    throw new ArgumentOutOfRangeException(nameof(errorType), errorType, null);
                }

                switch (cover.CoverType)
                {
                case CoverType.Role:
                case CoverType.Artist:
                    this.Id = cover.ActorId;
                    this.Id = cover.ActorId;
                    break;

                case CoverType.Video:
                case CoverType.Background:
                    this.Id = cover.VideoId;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                this.Id = this.Id ?? cover.Id;
            }
            public override async Task FixAsync(DataCenter dataCenter)
            {
                var oldId = this.cover.Id;

                switch (this.Type)
                {
                    case ErrorType.CoverMissingParent:
                        switch (this.cover.CoverType)
                        {
                            case CoverType.Artist:
                                break;

                            case CoverType.Video:
                                break;

                            case CoverType.Background:
                                break;

                            case CoverType.Role:
                                if (this.cover.ActorId != null)
                                {
                                    if (this.cover.VideoId != null)
                                    {
                                        if (this.cover.SeriesId != null)
                                        {

                                        }
                                        else
                                        {
                                            var roleCol = await dataCenter.VideoRoleManager.FindAsync(this.cover.VideoId);
                                            var matchs = roleCol.Roles().Where(z => z.ActorId == this.cover.ActorId).ToArray();
                                            if (matchs.Length != 1) return;
                                            var cover = await dataCenter.CoverManager.FindAsync((matchs[0] as ICoverParent).CoverId);
                                            if (cover != null) return;
                                            cover = await dataCenter.CoverManager.FindAsync(this.cover.Id);
                                            cover.Id = (matchs[0] as ICoverParent).CoverId;
                                            await dataCenter.CoverManager.InsertOrUpdateAsync(cover);
                                            await dataCenter.CoverManager.RemoveAsync(oldId);
                                        }
                                    }
                                    else
                                    {

                                    }
                                }

                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
            public CoverError(ErrorType errorType, CoverRef cover)
                : base(errorType)
            {
                this.cover = cover;

                if (errorType != ErrorType.CoverMissingParent)
                {
                    throw new ArgumentOutOfRangeException(nameof(errorType), errorType, null);
                }

                switch (cover.CoverType)
                {
                    case CoverType.Role:
                    case CoverType.Artist:
                        this.Id = cover.ActorId;
                        this.Id = cover.ActorId;
                        break;

                    case CoverType.Video:
                    case CoverType.Background:
                        this.Id = cover.VideoId;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }

                this.Id = this.Id ?? cover.Id;
            }
 public static Error FromCoverMissingParent(CoverRef cover) => new CoverError(ErrorType.CoverMissingParent, cover);
Exemple #5
0
            public override async Task FixAsync(DataCenter dataCenter)
            {
                var oldId = this.cover.Id;

                switch (this.Type)
                {
                case ErrorType.CoverMissingParent:
                    switch (this.cover.CoverType)
                    {
                    case CoverType.Artist:
                        break;

                    case CoverType.Video:
                        break;

                    case CoverType.Background:
                        break;

                    case CoverType.Role:
                        if (this.cover.ActorId != null)
                        {
                            if (this.cover.VideoId != null)
                            {
                                if (this.cover.SeriesId != null)
                                {
                                }
                                else
                                {
                                    var roleCol = await dataCenter.VideoRoleManager.FindAsync(this.cover.VideoId);

                                    var matchs = roleCol.Roles().Where(z => z.ActorId == this.cover.ActorId).ToArray();
                                    if (matchs.Length != 1)
                                    {
                                        return;
                                    }
                                    var cover = await dataCenter.CoverManager.FindAsync((matchs[0] as ICoverParent).CoverId);

                                    if (cover != null)
                                    {
                                        return;
                                    }
                                    cover = await dataCenter.CoverManager.FindAsync(this.cover.Id);

                                    cover.Id = (matchs[0] as ICoverParent).CoverId;
                                    await dataCenter.CoverManager.InsertOrUpdateAsync(cover);

                                    await dataCenter.CoverManager.RemoveAsync(oldId);
                                }
                            }
                            else
                            {
                            }
                        }

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
Exemple #6
0
 public static Error FromCoverMissingParent(CoverRef cover) => new CoverError(ErrorType.CoverMissingParent, cover);