Example #1
0
 public void Save(AniDB_Updated obj)
 {
     using (var session = WebCache.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }
Example #2
0
		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 aidList = Utils.TryGetProperty("AniDB_Updated", docXRef, "AnimeIDList").Trim().ToUpper();
				string uname = Utils.TryGetProperty("AniDB_Updated", docXRef, "Username");

				string utime = Utils.TryGetProperty("AniDB_Updated", docXRef, "UpdatedTime");
				long updateTime = 0;
				long.TryParse(utime, out updateTime);

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

				AniDB_UpdatedRepository repUpdates = new AniDB_UpdatedRepository();
				AniDB_Updated aniUpdated = new AniDB_Updated();
				aniUpdated.AnimeIDList = aidList;
				aniUpdated.Username = uname;
				aniUpdated.UpdateTime = updateTime;
				aniUpdated.DateTimeCreated = DateTime.Now;
				repUpdates.Save(aniUpdated);

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

			}
			catch (Exception ex)
			{
				Response.Write(Constants.ERROR_XML);
			}
		}