public void ConvertWp7PushNotifications() { var profile = CreateProfile("profile1"); Model.Old.WP7PushNotification wp71 = new WP7PushNotification(); wp71.Added = DateTime.UtcNow.Date; wp71.Counter = 1; wp71.DeviceID = "Test1"; wp71.LiveTile = true; wp71.LiveTileFrequency = 3; wp71.LiveTileLastUpdate = DateTime.UtcNow.Date.AddDays(-2); wp71.Modified = DateTime.UtcNow.AddDays(-10).Date; wp71.ProfileId = profile.Id; wp71.PushNotifications = true; wp71.URI = "gfdgdfgdfg"; insertToOldDatabase(wp71); Convert(); var dbProfile = SessionNew.QueryOver <Model.Profile>().Where(x => x.UserName == "profile1").SingleOrDefault(); var newWp71 = SessionNew.QueryOver <Model.WP7PushNotification>().SingleOrDefault(); Assert.AreEqual(wp71.Added, newWp71.Added); Assert.AreEqual(wp71.Counter, newWp71.Counter); Assert.AreEqual(wp71.DeviceID, newWp71.DeviceID); Assert.AreEqual(wp71.LiveTile, newWp71.LiveTile); Assert.AreEqual(wp71.LiveTileFrequency, newWp71.LiveTileFrequency); Assert.AreEqual(wp71.LiveTileLastUpdate, newWp71.LiveTileLastUpdate); Assert.AreEqual(wp71.Modified, newWp71.Modified); Assert.AreEqual(dbProfile.GlobalId, newWp71.ProfileId); Assert.AreEqual(wp71.PushNotifications, newWp71.PushNotifications); Assert.AreEqual(wp71.URI, newWp71.URI); }
public string WP7Register(string deviceid, string uri, Guid profileId) { if (!String.IsNullOrWhiteSpace(deviceid)) { var session = Session; using (var tx = session.BeginSaveTransaction()) { var res = session.QueryOver <WP7PushNotification>().Where(x => x.DeviceID == deviceid); var device = res.SingleOrDefault(); if (device != null) { // Do we need to update the URI? if (device.URI != uri) { device.URI = uri; } device.ProfileId = profileId; device.Modified = Configuration.TimerService.UtcNow; } else { device = new WP7PushNotification() { DeviceID = deviceid, URI = uri, Added = Configuration.TimerService.UtcNow, Modified = Configuration.TimerService.UtcNow, ProfileId = profileId }; session.SaveOrUpdate(device); } tx.Commit(); } } return(deviceid); }
public void ConvertWp7PushNotifications_FromDeletedProfile() { var profile = CreateProfile("profile1", isDeleted: true); Model.Old.WP7PushNotification wp71 = new WP7PushNotification(); wp71.Added = DateTime.UtcNow.Date; wp71.Counter = 1; wp71.DeviceID = "Test1"; wp71.LiveTile = true; wp71.LiveTileFrequency = 3; wp71.LiveTileLastUpdate = DateTime.UtcNow.Date.AddDays(-2); wp71.Modified = DateTime.UtcNow.AddDays(-10).Date; wp71.ProfileId = profile.Id; wp71.PushNotifications = true; wp71.URI = "gfdgdfgdfg"; insertToOldDatabase(wp71); Convert(); var count = SessionNew.QueryOver <Model.WP7PushNotification>().RowCount(); Assert.AreEqual(0, count); }
public string Register(string deviceid, string uri) { if (!String.IsNullOrWhiteSpace(deviceid)) { var session = NHibernateContext.Current().Session; using (var tx = session.BeginGetTransaction()) { var res = session.QueryOver <WP7PushNotification>().Where(x => x.DeviceID == deviceid); var device = res.SingleOrDefault(); if (device != null) { // Do we need to update the URI? if (device.URI != uri) { device.URI = uri; } } else { device = new WP7PushNotification() { DeviceID = deviceid, URI = uri, Added = DateTime.Now, Modified = DateTime.Now }; session.SaveOrUpdate(device); } tx.Commit(); } } return(deviceid); }