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);
			}
		}
예제 #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);
			}
		}
예제 #3
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;
			}
		}