Example #1
0
        private bool FileFilter(object obj)
        {
            TraktSeriesData ser = obj as TraktSeriesData;

            if (ser == null)
            {
                return(false);
            }

            string filterType = cboFilterType.SelectedItem.ToString();

            if (filterType.Equals(FilterTypeAll))
            {
                return(true);
            }

            if (filterType.Equals(FilterTypeMissing) && !ser.HasUserTraktLink)
            {
                return(true);
            }
            if (filterType.Equals(FilterTypeDifferent) && ser.HasCommTraktLink && !ser.UserTraktLinkMatch)
            {
                return(true);
            }

            return(false);
        }
Example #2
0
        private void CommandBinding_RefreshSeries(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            if (obj.GetType() == typeof(TraktSeriesData))
            {
                TraktSeriesData traktSer = obj as TraktSeriesData;

                // Refresh Trakt links
                List <JMMServerBinary.Contract_CrossRef_AniDB_TraktV2> traktxrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTraktCrossRefV2(traktSer.AnimeID);
                List <CrossRef_AniDB_TraktVMV2> links = new List <CrossRef_AniDB_TraktVMV2>();
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_TraktV2 traktxref in traktxrefs)
                {
                    links.Add(new CrossRef_AniDB_TraktVMV2(traktxref));
                }

                traktSer.SetUserTraktLinks(links);
                traktSer.CompareTraktLinks();
            }
        }
Example #3
0
        void dataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            TraktWorkerJob   job    = e.Argument as TraktWorkerJob;
            BackgroundWorker worker = sender as BackgroundWorker;

            // Get all the seies data
            List <JMMServerBinary.Contract_AnimeSeries> sersRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
            List <AnimeSeriesVM> allSeries = new List <AnimeSeriesVM>();

            foreach (JMMServerBinary.Contract_AnimeSeries contract in sersRaw)
            {
                AnimeSeriesVM ser = new AnimeSeriesVM(contract);
                allSeries.Add(ser);
                if (stopWorker)
                {
                    return;
                }
            }

            List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>();

            sortCriteria.Add(new SortPropOrFieldAndDirection("SeriesName", false, SortType.eString));
            allSeries = Sorting.MultiSort <AnimeSeriesVM>(allSeries, sortCriteria);

            if (stopWorker)
            {
                return;
            }

            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
            {
                WorkerStatus = JMMClient.Properties.Resources.Community_TraktRef;
            });

            // get all the trakt links
            List <CrossRef_AniDB_TraktVMV2> allTraktCrossRefs = new List <CrossRef_AniDB_TraktVMV2>();
            List <JMMServerBinary.Contract_CrossRef_AniDB_TraktV2> traktxrefs = JMMServerVM.Instance.clientBinaryHTTP.GetAllTraktCrossRefs();

            foreach (JMMServerBinary.Contract_CrossRef_AniDB_TraktV2 raw in traktxrefs)
            {
                allTraktCrossRefs.Add(new CrossRef_AniDB_TraktVMV2(raw));
                if (stopWorker)
                {
                    return;
                }
            }

            int counter      = 0;
            int problemCount = 0;

            foreach (AnimeSeriesVM ser in allSeries)
            {
                counter++;
                //Thread.Sleep(200);

                dataWorker.ReportProgress(0, new TraktWorkerStatusContainer(JMMClient.Properties.Resources.Community_TraktPopulating, allSeries.Count, counter, ser.SeriesName));

                TraktSeriesData trakt = new TraktSeriesData(ser);

                // populate the Trakt data
                trakt.SetUserTraktLinks(allTraktCrossRefs.Where(x => x.AnimeID == ser.AniDB_ID));

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    job.TraktData.Add(trakt);
                });


                if (stopWorker)
                {
                    return;
                }
            }
            if (stopWorker)
            {
                return;
            }


            int curFile = 0;

            foreach (TraktSeriesData data in job.TraktData)
            {
                if (stopWorker)
                {
                    return;
                }
                //Thread.Sleep(250);

                if (problemCount == job.MaxProblems)
                {
                    return;
                }

                curFile++;
                dataWorker.ReportProgress(0, new TraktWorkerStatusContainer(JMMClient.Properties.Resources.Community_TraktSeriesCheck, job.TraktData.Count, curFile, data.SeriesName));

                if (stopWorker)
                {
                    return;
                }
                if (job.CheckTraktLinks)
                {
                    data.Status = JMMClient.Properties.Resources.Community_TraktDataCheck;
                    bool valid = true;

                    if (data.HasUserTraktLink)
                    {
                        foreach (CrossRef_AniDB_TraktVMV2 xref in data.UserTraktLinks)
                        {
                            bool thisValid = JMMServerVM.Instance.clientBinaryHTTP.CheckTraktLinkValidity(xref.TraktID, job.FixTraktLinks);
                            if (!thisValid)
                            {
                                valid = false;
                                problemCount++;
                            }
                        }
                        data.IsTraktLinkValid = valid;
                    }
                }

                if (stopWorker)
                {
                    return;
                }
                if (job.CheckCommunityLinks)
                {
                    data.Status = JMMClient.Properties.Resources.Community_TraktCompare;

                    List <JMMServerBinary.Contract_Azure_CrossRef_AniDB_Trakt> xrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTraktCrossRefWebCache(data.AnimeID, false);
                    List <CrossRef_AniDB_TraktVMV2> commTraktLinks = new List <CrossRef_AniDB_TraktVMV2>();
                    foreach (JMMServerBinary.Contract_Azure_CrossRef_AniDB_Trakt xref in xrefs)
                    {
                        CrossRef_AniDB_TraktVMV2 xrefComm = new CrossRef_AniDB_TraktVMV2(xref);
                        commTraktLinks.Add(xrefComm);
                    }
                    data.SetCommTraktLinks(commTraktLinks);

                    if (data.HasUserTraktLink)
                    {
                        data.CompareTraktLinks();
                        if (!data.UserTraktLinkMatch && data.HasCommTraktLink)
                        {
                            problemCount++;
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
        void dataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            TraktWorkerJob job = e.Argument as TraktWorkerJob;
            BackgroundWorker worker = sender as BackgroundWorker;

            // Get all the seies data
            List<JMMServerBinary.Contract_AnimeSeries> sersRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
            List<AnimeSeriesVM> allSeries = new List<AnimeSeriesVM>();
            foreach (JMMServerBinary.Contract_AnimeSeries contract in sersRaw)
            {
                AnimeSeriesVM ser = new AnimeSeriesVM(contract);
                allSeries.Add(ser);
                if (stopWorker) return;
            }

            List<SortPropOrFieldAndDirection> sortCriteria = new List<SortPropOrFieldAndDirection>();
            sortCriteria.Add(new SortPropOrFieldAndDirection("SeriesName", false, SortType.eString));
            allSeries = Sorting.MultiSort<AnimeSeriesVM>(allSeries, sortCriteria);

            if (stopWorker) return;

            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
            {
                WorkerStatus = "Getting all Trakt Cross Ref data...";
            });

            // get all the trakt links
            List<CrossRef_AniDB_TraktVMV2> allTraktCrossRefs = new List<CrossRef_AniDB_TraktVMV2>();
            List<JMMServerBinary.Contract_CrossRef_AniDB_TraktV2> traktxrefs = JMMServerVM.Instance.clientBinaryHTTP.GetAllTraktCrossRefs();
            foreach (JMMServerBinary.Contract_CrossRef_AniDB_TraktV2 raw in traktxrefs)
            {
                allTraktCrossRefs.Add(new CrossRef_AniDB_TraktVMV2(raw));
                if (stopWorker) return;
            }

            int counter = 0;
            int problemCount = 0;

            foreach (AnimeSeriesVM ser in allSeries)
            {
                counter++;
                //Thread.Sleep(200);

                dataWorker.ReportProgress(0, new TraktWorkerStatusContainer("Populating series data", allSeries.Count, counter, ser.SeriesName));

                TraktSeriesData trakt = new TraktSeriesData(ser);

                // populate the Trakt data
                trakt.SetUserTraktLinks(allTraktCrossRefs.Where(x => x.AnimeID == ser.AniDB_ID));

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
                {
                    job.TraktData.Add(trakt);
                });

                if (stopWorker) return;
            }
            if (stopWorker) return;

            int curFile = 0;
            foreach (TraktSeriesData data in job.TraktData)
            {
                if (stopWorker) return;
                //Thread.Sleep(250);

                if (problemCount == job.MaxProblems) return;

                curFile++;
                dataWorker.ReportProgress(0, new TraktWorkerStatusContainer("Checking series", job.TraktData.Count, curFile, data.SeriesName));

                if (stopWorker) return;
                if (job.CheckTraktLinks)
                {
                    data.Status = "Checking if Trakt data is valid...";
                    bool valid = true;

                    if (data.HasUserTraktLink)
                    {
                        foreach (CrossRef_AniDB_TraktVMV2 xref in data.UserTraktLinks)
                        {
                            bool thisValid = JMMServerVM.Instance.clientBinaryHTTP.CheckTraktLinkValidity(xref.TraktID, job.FixTraktLinks);
                            if (!thisValid)
                            {
                                valid = false;
                                problemCount++;
                            }
                        }
                        data.IsTraktLinkValid = valid;
                    }
                }

                if (stopWorker) return;
                if (job.CheckCommunityLinks)
                {
                    data.Status = "Checking Trakt link against community recommendation...";

                    List<JMMServerBinary.Contract_Azure_CrossRef_AniDB_Trakt> xrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTraktCrossRefWebCache(data.AnimeID, false);
                    List<CrossRef_AniDB_TraktVMV2> commTraktLinks = new List<CrossRef_AniDB_TraktVMV2>();
                    foreach (JMMServerBinary.Contract_Azure_CrossRef_AniDB_Trakt xref in xrefs)
                    {
                        CrossRef_AniDB_TraktVMV2 xrefComm = new CrossRef_AniDB_TraktVMV2(xref);
                        commTraktLinks.Add(xrefComm);
                    }
                    data.SetCommTraktLinks(commTraktLinks);

                    if (data.HasUserTraktLink)
                    {
                        data.CompareTraktLinks();
                        if (!data.UserTraktLinkMatch && data.HasCommTraktLink) problemCount++;
                    }
                    else
                    { }
                }
            }
        }