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

			try
			{
				Response.Write(Constants.ERROR_XML);
				return;

				string sfsize = Utils.GetParam("fsize");
				long fsize = 0;
				long.TryParse(sfsize, out fsize);

				if (fsize <= 0)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}

				string hash = Utils.GetParam("hash");
				if (hash.Trim().Length == 0)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}

				AniDB_FileRepository rep = new AniDB_FileRepository();

				AniDB_File anifile = rep.GetByHashAndFileSize(hash, fsize);
				if (anifile == null)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}

				AniDB_FileRequest data = new AniDB_FileRequest(anifile);
				string ret = Utils.ConvertToXML(data, typeof(AniDB_FileRequest));

				Response.Write(ret);
			}
			catch (Exception ex)
			{
				Response.Write(ex.ToString());
				return;
			}
		}
Ejemplo n.º 2
0
		protected void Page_Load(object sender, EventArgs e)
		{
			Response.ContentType = "text/xml";

			try
			{
				Response.Write(Constants.ERROR_XML);
				return;

				AniDB_FileRepository rep = new AniDB_FileRepository();

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

				XmlSerializer serializer = new XmlSerializer(typeof(AniDB_FileRequest));
				XmlDocument docSearchResult = new XmlDocument();
				docSearchResult.LoadXml(xmlData);

				XmlNodeReader xmlreader = new XmlNodeReader(docSearchResult.DocumentElement);
				object obj = serializer.Deserialize(xmlreader);
				AniDB_FileRequest result = (AniDB_FileRequest)obj;


				if (result == null)
				{
					Response.Write(Constants.ERROR_XML);
					return;
				}


				AniDB_File anifile = rep.GetByFileID(result.FileID);
				if (anifile == null)
					anifile = new AniDB_File();

				anifile.Populate(result);
				rep.Save(anifile);
			}
			catch (Exception ex)
			{
				Response.Write(Constants.ERROR_XML);
			}
		}