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

            try
            {
                CrossRef_AniDB_MALRepository repCrossRef = new CrossRef_AniDB_MALRepository();

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

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

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

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

                string sepType = Utils.TryGetProperty("DeleteCrossRef_AniDB_MALRequest", docXRef, "StartEpisodeType");
                int    epType  = 0;
                int.TryParse(sepType, out epType);

                string sepNumber = Utils.TryGetProperty("DeleteCrossRef_AniDB_MALRequest", docXRef, "StartEpisodeNumber");
                int    epNumber  = 0;
                int.TryParse(sepNumber, out epNumber);

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

                List <CrossRef_AniDB_MAL> recs = repCrossRef.GetByAnimeIDUser(animeid, uname, epType, epNumber);
                foreach (CrossRef_AniDB_MAL xref in recs)
                {
                    repCrossRef.Delete(xref.CrossRef_AniDB_MALID);
                }

                // now send to mirror
                string uri = string.Format("http://{0}/DeleteCrossRef_AniDB_MAL.aspx", Constants.MirrorWAIX);
                XMLService.SendData(uri, xmlData);
            }
            catch (Exception ex)
            {
                Response.Write(Constants.ERROR_XML);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";

            try
            {
                CrossRef_AniDB_MALRepository repCrossRef = new CrossRef_AniDB_MALRepository();

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

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

                string uname    = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "Username");
                string malTitle = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "MALTitle");

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

                string mID   = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "MALID");
                int    malID = 0;
                int.TryParse(mID, out malID);

                string sepType = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "StartEpisodeType");
                int    epType  = 0;
                int.TryParse(sepType, out epType);

                string sepNumber = Utils.TryGetProperty("AddCrossRef_AniDB_MAL_Request", docXRef, "StartEpisodeNumber");
                int    epNumber  = 0;
                int.TryParse(sepNumber, out epNumber);


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

                CrossRef_AniDB_MAL        xref = null;
                List <CrossRef_AniDB_MAL> recs = repCrossRef.GetByAnimeIDUser(animeid, uname, epType, epNumber);
                if (recs.Count == 1)
                {
                    xref = recs[0];
                }

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

                xref.AnimeID            = animeid;
                xref.CrossRefSource     = 1;
                xref.MALID              = malID;
                xref.MALTitle           = malTitle;
                xref.Username           = uname;
                xref.StartEpisodeType   = epType;
                xref.StartEpisodeNumber = epNumber;
                repCrossRef.Save(xref);

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