Exemple #1
0
        private void RefreshAdminData()
        {
            try
            {
                if (VM_ShokoServer.Instance.ShowCommunity)
                {
                    if (!(DataContext is VM_AniDB_Anime anime))
                    {
                        return;
                    }

                    CommunityTVDBLinks.Clear();
                    CommunityTraktLinks.Clear();

                    btnTvDBCommLinks1.IsEnabled = false;
                    btnTvDBCommLinks2.IsEnabled = false;
                    CommTvDBButtonText          = Commons.Properties.Resources.CommunityLinks_CheckingOnline;

                    btnTraktCommLinks1.IsEnabled = false;
                    btnTraktCommLinks2.IsEnabled = false;
                    CommTraktButtonText          = Commons.Properties.Resources.CommunityLinks_CheckingOnline;

                    if (!communityWorker.IsBusy)
                    {
                        communityWorker.RunWorkerAsync(anime);
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        private void RefreshAdminData()
        {
            try
            {
                if (JMMServerVM.Instance.ShowCommunity)
                {
                    AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM;
                    if (anime == null)
                    {
                        return;
                    }

                    CommunityTVDBLinks.Clear();
                    CommunityTraktLinks.Clear();

                    btnTvDBCommLinks1.IsEnabled = false;
                    btnTvDBCommLinks2.IsEnabled = false;
                    CommTvDBButtonText          = "Checking Online...";

                    btnTraktCommLinks1.IsEnabled = false;
                    btnTraktCommLinks2.IsEnabled = false;
                    CommTraktButtonText          = "Checking Online...";

                    if (!communityWorker.IsBusy)
                    {
                        communityWorker.RunWorkerAsync(anime);
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemple #3
0
        void communityWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (!(e.Result is SearchCommunityResults res))
                {
                    return;
                }

                if (!(DataContext is VM_AniDB_Anime anime))
                {
                    return;
                }

                if (anime.AnimeID != res.AnimeID)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(res.ErrorMessage))
                {
                    return;
                }

                foreach (VM_CrossRef_AniDB_TvDBV2 tvxref in res.TvDBLinks)
                {
                    CommunityTVDBLinks.Add(tvxref);
                }

                foreach (VM_CrossRef_AniDB_TraktV2 traktxref in res.TraktLinks)
                {
                    CommunityTraktLinks.Add(traktxref);
                }

                btnTvDBCommLinks1.IsEnabled = true;
                btnTvDBCommLinks2.IsEnabled = true;

                CommTvDBButtonText = Commons.Properties.Resources.CommunityLinks_NoLinksAvailable;
                if (CommunityTVDBLinks.Count > 0)
                {
                    CommTvDBButtonText = Commons.Properties.Resources.CommunityLinks_NeedApproval;
                    foreach (VM_CrossRef_AniDB_TvDBV2 xref in CommunityTVDBLinks)
                    {
                        if (xref.IsAdminApprovedBool)
                        {
                            CommTvDBButtonText = Commons.Properties.Resources.CommunityLinks_ApprovalExists;
                            break;
                        }
                    }
                }

                btnTraktCommLinks1.IsEnabled = true;
                btnTraktCommLinks2.IsEnabled = true;

                CommTraktButtonText = Commons.Properties.Resources.CommunityLinks_NoLinksAvailable;
                if (CommunityTraktLinks.Count > 0)
                {
                    CommTraktButtonText = Commons.Properties.Resources.CommunityLinks_NeedApproval;
                    foreach (VM_CrossRef_AniDB_TraktV2 xref in CommunityTraktLinks)
                    {
                        if (xref.IsAdminApprovedBool)
                        {
                            CommTraktButtonText = Commons.Properties.Resources.CommunityLinks_ApprovalExists;
                            break;
                        }
                    }
                }

                //SearchStatus = string.Format("{0} Anime still need TvDB approval", link.AnimeNeedingApproval);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
            }
        }
        void communityWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                SearchCommunityResults res = e.Result as SearchCommunityResults;
                if (res == null)
                {
                    return;
                }

                AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM;
                if (anime == null)
                {
                    return;
                }

                if (anime.AnimeID != res.AnimeID)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(res.ErrorMessage))
                {
                    return;
                }

                foreach (CrossRef_AniDB_TvDBVMV2 tvxref in res.TvDBLinks)
                {
                    CommunityTVDBLinks.Add(tvxref);
                }

                foreach (CrossRef_AniDB_TraktVMV2 traktxref in res.TraktLinks)
                {
                    CommunityTraktLinks.Add(traktxref);
                }

                btnTvDBCommLinks1.IsEnabled = true;
                btnTvDBCommLinks2.IsEnabled = true;

                CommTvDBButtonText = "No Community Links Available";
                if (CommunityTVDBLinks.Count > 0)
                {
                    CommTvDBButtonText = "Links Need Approval";
                    foreach (CrossRef_AniDB_TvDBVMV2 xref in CommunityTVDBLinks)
                    {
                        if (xref.IsAdminApprovedBool)
                        {
                            CommTvDBButtonText = "Approval Exists";
                            break;
                        }
                    }
                }

                btnTraktCommLinks1.IsEnabled = true;
                btnTraktCommLinks2.IsEnabled = true;

                CommTraktButtonText = "No Community Links Available";
                if (CommunityTraktLinks.Count > 0)
                {
                    CommTraktButtonText = "Links Need Approval";
                    foreach (CrossRef_AniDB_TraktVMV2 xref in CommunityTraktLinks)
                    {
                        if (xref.IsAdminApprovedBool)
                        {
                            CommTraktButtonText = "Approval Exists";
                            break;
                        }
                    }
                }

                //SearchStatus = string.Format("{0} Anime still need TvDB approval", link.AnimeNeedingApproval);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }