コード例 #1
0
        public static void LinkAniDBMovieDB(int animeID, int movieDBID, bool fromWebCache)
        {
            // check if we have this information locally
            // if not download it now
            MovieDB_MovieRepository repMovies = new MovieDB_MovieRepository();
            MovieDB_Movie           movie     = repMovies.GetByOnlineID(movieDBID);

            if (movie == null)
            {
                // we download the series info here just so that we have the basic info in the
                // database before the queued task runs later
                UpdateMovieInfo(movieDBID, false);
                movie = repMovies.GetByOnlineID(movieDBID);
                if (movie == null)
                {
                    return;
                }
            }

            // download and update series info and images
            UpdateMovieInfo(movieDBID, true);

            CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();
            CrossRef_AniDB_Other           xref        = repCrossRef.GetByAnimeIDAndType(animeID, CrossRefType.MovieDB);

            if (xref == null)
            {
                xref = new CrossRef_AniDB_Other();
            }

            xref.AnimeID = animeID;
            if (fromWebCache)
            {
                xref.CrossRefSource = (int)CrossRefSource.WebCache;
            }
            else
            {
                xref.CrossRefSource = (int)CrossRefSource.User;
            }

            xref.CrossRefType = (int)CrossRefType.MovieDB;
            xref.CrossRefID   = movieDBID.ToString();
            repCrossRef.Save(xref);
            AniDB_Anime.UpdateStatsByAnimeID(animeID);

            logger.Trace("Changed moviedb association: {0}", animeID);

            CommandRequest_WebCacheSendXRefAniDBOther req =
                new CommandRequest_WebCacheSendXRefAniDBOther(xref.CrossRef_AniDB_OtherID);

            req.Save();
        }
コード例 #2
0
        public static void RemoveLinkAniDBMovieDB(int animeID)
        {
            CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();
            CrossRef_AniDB_Other           xref        = repCrossRef.GetByAnimeIDAndType(animeID, CrossRefType.MovieDB);

            if (xref == null)
            {
                return;
            }

            repCrossRef.Delete(xref.CrossRef_AniDB_OtherID);

            CommandRequest_WebCacheDeleteXRefAniDBOther req = new CommandRequest_WebCacheDeleteXRefAniDBOther(animeID, CrossRefType.MovieDB);

            req.Save();
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

            try
            {
                CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();

                StreamReader reader  = new StreamReader(this.Request.InputStream);
                String       xmlData = reader.ReadToEnd();

                XmlDocument docXRef = new XmlDocument();
                docXRef.LoadXml(xmlData);

                string uname = Utils.TryGetProperty("DeleteCrossRef_AniDB_OtherRequest", docXRef, "Username");

                string aid     = Utils.TryGetProperty("DeleteCrossRef_AniDB_OtherRequest", docXRef, "AnimeID");
                int    animeid = 0;
                int.TryParse(aid, out animeid);

                string xtype    = Utils.TryGetProperty("DeleteCrossRef_AniDB_OtherRequest", docXRef, "CrossRefType");
                int    xrefType = 0;
                int.TryParse(xtype, out xrefType);

                if (string.IsNullOrEmpty(uname) || animeid <= 0 || xrefType <= 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                List <CrossRef_AniDB_Other> recs = repCrossRef.GetByAnimeIDAndTypeAndUser(animeid, uname, (CrossRefType)xrefType);
                foreach (CrossRef_AniDB_Other xref in recs)
                {
                    repCrossRef.Delete(xref.CrossRef_AniDB_OtherID);
                }

                // now send to mirror
                string uri = string.Format("http://{0}/DeleteCrossRef_AniDB_Other.aspx", Constants.MirrorWAIX);
                XMLService.SendData(uri, xmlData);
            }
            catch (Exception ex)
            {
                Response.Write(Constants.ERROR_XML);
            }
        }
コード例 #4
0
        public static void ScanForMatches()
        {
            AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
            List <AnimeSeries>    allSeries = repSeries.GetAll();

            CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();

            foreach (AnimeSeries ser in allSeries)
            {
                AniDB_Anime anime = ser.GetAnime();
                if (anime == null)
                {
                    continue;
                }

                if (anime.IsMovieDBLinkDisabled)
                {
                    continue;
                }

                // don't scan if it is associated on the TvDB
                if (anime.GetCrossRefTvDBV2().Count > 0)
                {
                    continue;
                }

                // don't scan if it is associated on the MovieDB
                if (anime.GetCrossRefMovieDB() != null)
                {
                    continue;
                }

                // don't scan if it is not a movie
                if (!anime.SearchOnMovieDB)
                {
                    continue;
                }

                logger.Trace("Found anime movie without MovieDB association: " + anime.MainTitle);

                CommandRequest_MovieDBSearchAnime cmd = new CommandRequest_MovieDBSearchAnime(ser.AniDB_ID, false);
                cmd.Save();
            }
        }
コード例 #5
0
        public override void ProcessCommand()
        {
            try
            {
                CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();
                CrossRef_AniDB_Other           xref        = repCrossRef.GetByID(CrossRef_AniDB_OtherID);
                if (xref == null)
                {
                    return;
                }

                XMLService.Send_CrossRef_AniDB_Other(xref);
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error processing CommandRequest_WebCacheSendXRefAniDBOther: {0}" + ex.ToString(), ex);
                return;
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

            try
            {
                string aid     = Utils.GetParam("AnimeID");
                int    animeid = 0;
                int.TryParse(aid, out animeid);

                if (animeid <= 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                string xtype    = Utils.GetParam("CrossRefType");
                int    xrefType = 0;
                int.TryParse(xtype, out xrefType);

                if (xrefType <= 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                string uname = Utils.GetParam("uname");
                if (uname.Trim().Length == 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();
                CrossRef_AniDB_Other           xref        = null;

                // check for user specific
                List <CrossRef_AniDB_Other> recs;
                if (xref == null)
                {
                    recs = repCrossRef.GetByAnimeIDAndTypeAndUser(animeid, uname, (CrossRefType)xrefType);
                    if (recs.Count > 0)
                    {
                        xref = recs[0];                                     // should only be one
                    }
                }

                // check for other users (anonymous)
                if (xref == null)
                {
                    // check for other users (anonymous)
                    recs = repCrossRef.GetByAnimeIDAndType(animeid, (CrossRefType)xrefType);
                    if (recs.Count == 0)
                    {
                        Response.Write(Constants.ERROR_XML);
                        return;
                    }

                    // find the most popular result

                    List <CrossRefStatOther> results = new List <CrossRefStatOther>();
                    foreach (CrossRef_AniDB_Other xrefloc in recs)
                    {
                        bool found = false;
                        foreach (CrossRefStatOther stat in results)
                        {
                            if (stat.CrossRefID.Equals(xrefloc.CrossRefID, StringComparison.InvariantCultureIgnoreCase))
                            {
                                found = true;
                                stat.ResultCount++;
                            }
                        }
                        if (!found)
                        {
                            CrossRefStatOther stat = new CrossRefStatOther();
                            stat.ResultCount = 1;
                            stat.CrossRefID  = xrefloc.CrossRefID;
                            stat.CrossRef    = xrefloc;
                            results.Add(stat);
                        }
                    }

                    CrossRefStatOther mostPopular = null;
                    foreach (CrossRefStatOther stat in results)
                    {
                        if (mostPopular == null)
                        {
                            mostPopular = stat;
                        }
                        else
                        {
                            if (stat.ResultCount > mostPopular.ResultCount)
                            {
                                mostPopular = stat;
                            }
                        }
                    }

                    xref = mostPopular.CrossRef;
                }

                CrossRef_AniDB_OtherResult result = new CrossRef_AniDB_OtherResult(xref);
                string ret = Utils.ConvertToXML(result, typeof(CrossRef_AniDB_OtherResult));
                Response.Write(ret);
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
                return;
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

            try
            {
                CrossRef_AniDB_OtherRepository repCrossRef = new CrossRef_AniDB_OtherRepository();

                StreamReader reader  = new StreamReader(this.Request.InputStream);
                String       xmlData = reader.ReadToEnd();

                XmlDocument docXRef = new XmlDocument();
                docXRef.LoadXml(xmlData);

                string uname = Utils.TryGetProperty("AddCrossRef_AniDB_Other_Request", docXRef, "Username");

                string aid     = Utils.TryGetProperty("AddCrossRef_AniDB_Other_Request", docXRef, "AnimeID");
                int    animeid = 0;
                int.TryParse(aid, out animeid);

                string xrefID = Utils.TryGetProperty("AddCrossRef_AniDB_Other_Request", docXRef, "CrossRefID");

                string xtype    = Utils.TryGetProperty("AddCrossRef_AniDB_Other_Request", docXRef, "CrossRefType");
                int    xrefType = 0;
                int.TryParse(xtype, out xrefType);



                if (string.IsNullOrEmpty(uname) || string.IsNullOrEmpty(xrefID) || animeid <= 0 || xrefType <= 0)
                {
                    Response.Write(Constants.ERROR_XML);
                    return;
                }

                CrossRef_AniDB_Other        xref = null;
                List <CrossRef_AniDB_Other> recs = repCrossRef.GetByAnimeIDAndTypeAndUser(animeid, uname, (CrossRefType)xrefType);
                if (recs.Count == 1)
                {
                    xref = recs[0];
                }

                if (recs.Count == 0)
                {
                    xref = new CrossRef_AniDB_Other();
                }
                else
                {
                    xref = recs[0];
                }

                xref.AnimeID        = animeid;
                xref.AdminApproved  = 0;
                xref.CrossRefSource = 1;
                xref.CrossRefType   = xrefType;
                xref.CrossRefID     = xrefID;
                xref.Username       = uname;
                repCrossRef.Save(xref);

                // now send to mirror
                string uri = string.Format("http://{0}/AddCrossRef_AniDB_Other.aspx", Constants.MirrorWAIX);
                XMLService.SendData(uri, xmlData);
            }
            catch (Exception ex)
            {
                Response.Write(Constants.ERROR_XML);
            }
        }