Exemplo n.º 1
0
		public CrossRef_AniDB_TvDBResult(CrossRef_AniDB_TvDB xref)
		{
			this.AnimeID = xref.AnimeID;
			this.TvDBID = xref.TvDBID;
			this.TvDBSeasonNumber = xref.TvDBSeasonNumber;
			this.AdminApproved = xref.AdminApproved;
			this.SeriesName = xref.SeriesName;
		}
Exemplo n.º 2
0
		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("AddCrossRef_AniDB_TvDB_Request", docXRef, "Username");
				string sname = Utils.TryGetProperty("AddCrossRef_AniDB_TvDB_Request", docXRef, "SeriesName");

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

				string tvid = Utils.TryGetProperty("AddCrossRef_AniDB_TvDB_Request", docXRef, "TvDBID");
				int tvDBID = 0;
				int.TryParse(tvid, out tvDBID);

				string tvseason = Utils.TryGetProperty("AddCrossRef_AniDB_TvDB_Request", docXRef, "TvDBSeason");
				int tvDBSeason = 0;
				if (!int.TryParse(tvseason, out tvDBSeason))
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}


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

				CrossRef_AniDB_TvDB xref = null;
				List<CrossRef_AniDB_TvDB> recs = repCrossRef.GetByAnimeIDUser(animeid, uname);
				if (recs.Count == 1)
					xref = recs[0];

				if (recs.Count == 0)
					xref = new CrossRef_AniDB_TvDB();
				else
					xref = recs[0];

				xref.AnimeID = animeid;
				xref.AdminApproved = 0;
				xref.CrossRefSource = 1;
				xref.TvDBID = tvDBID;
				xref.TvDBSeasonNumber = tvDBSeason;
				xref.Username = uname;
				xref.SeriesName = sname;
				repCrossRef.Save(xref);

				// now send to mirror
				string uri = string.Format("http://{0}/AddCrossRef_AniDB_TvDB.aspx", Constants.MirrorWAIX);
				XMLService.SendData(uri, xmlData);

			}
			catch (Exception ex)
			{
				Response.Write(Constants.ERROR_XML);
			}
		}
 public void Save(CrossRef_AniDB_TvDB obj)
 {
     using (var session = WebCache.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }