protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

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

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

                string sid      = Utils.TryGetProperty("DeleteCrossRef_AniDBTvDBAll_Request", docXRef, "SeriesID");
                int    seriesID = 0;
                int.TryParse(sid, out seriesID);

                CrossRef_AniDB_TvDBRepository repCrossRef = new CrossRef_AniDB_TvDBRepository();
                List <CrossRef_AniDB_TvDB>    recs        = repCrossRef.GetByTvDBID(seriesID);
                foreach (CrossRef_AniDB_TvDB xref in recs)
                {
                    repCrossRef.Delete(xref.CrossRef_AniDB_TvDBID);
                }

                // now send to mirror
                string uri = string.Format("http://{0}/DeleteCrossRef_AniDBTvDBAll.aspx", Constants.MirrorWAIX);
                XMLService.SendData(uri, xmlData);
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
                return;
            }
        }
Пример #2
0
        public static void FixDuplicateTvDBLinks()
        {
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();

            // delete all TvDB link duplicates
            CrossRef_AniDB_TvDBRepository repCrossRefTvDB = new CrossRef_AniDB_TvDBRepository();

            List <CrossRef_AniDB_TvDB> xrefsTvDBProcessed   = new List <CrossRef_AniDB_TvDB>();
            List <CrossRef_AniDB_TvDB> xrefsTvDBToBeDeleted = new List <CrossRef_AniDB_TvDB>();

            List <CrossRef_AniDB_TvDB> xrefsTvDB = repCrossRefTvDB.GetAll();

            foreach (CrossRef_AniDB_TvDB xrefTvDB in xrefsTvDB)
            {
                bool deleteXref = false;
                foreach (CrossRef_AniDB_TvDB xref in xrefsTvDBProcessed)
                {
                    if (xref.TvDBID == xrefTvDB.TvDBID && xref.TvDBSeasonNumber == xrefTvDB.TvDBSeasonNumber)
                    {
                        xrefsTvDBToBeDeleted.Add(xrefTvDB);
                        deleteXref = true;
                    }
                }
                if (!deleteXref)
                {
                    xrefsTvDBProcessed.Add(xrefTvDB);
                }
            }


            foreach (CrossRef_AniDB_TvDB xref in xrefsTvDBToBeDeleted)
            {
                string      msg   = "";
                AniDB_Anime anime = repAnime.GetByAnimeID(xref.AnimeID);
                if (anime != null)
                {
                    msg = anime.MainTitle;
                }

                logger.Warn("Deleting TvDB Link because of a duplicate: {0} ({1}) - {2}/{3}", xref.AnimeID, msg,
                            xref.TvDBID,
                            xref.TvDBSeasonNumber);
                repCrossRefTvDB.Delete(xref.CrossRef_AniDB_TvDBID);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

            try
            {
                CrossRef_AniDB_TvDBRepository repCrossRef = new CrossRef_AniDB_TvDBRepository();

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

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

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

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

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

                List <CrossRef_AniDB_TvDB> recs = repCrossRef.GetByAnimeIDUser(animeid, uname);
                foreach (CrossRef_AniDB_TvDB xref in recs)
                {
                    repCrossRef.Delete(xref.CrossRef_AniDB_TvDBID);
                }

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