コード例 #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
        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);
            }
        }