public MailDeliveryInfo GetDeliveryInfoFor(Guid messageId) { return((from m in db.Get <SentMailMessage>() where m.Id == messageId select new MailDeliveryInfo { MessageId = m.Id, DeliveryStatus = m.DeliveryStatus, SentOn = m.SentOn, FailedOn = m.FailedOn, FailureCount = m.FailureCount, FailureMessage = m.FailureMessage }) .SingleOrDefault()); }
protected bool IsReportPassCodeValid(string eventName, Guid passCode) { eventName = eventName.ToLower(); IDomainDataContext db = ObjectFactory.GetInstance <IDomainDataContext>(); return(db.Get <Event>().Any(e => e.Name.ToLower() == eventName && e.ApplicationConfig.ReportPassCode == passCode)); }
public static User RegisterNewUser(IDomainDataContext db, string userName, string password, string emailAddress, string displayName, bool isApproved, params string[] roleNames) { if (string.IsNullOrWhiteSpace(userName)) { throw new ArgumentException("User Name cannot be blank/empty"); } if (db.Get <User>().Any(u => u.UserName.Equals(userName, StringComparison.InvariantCultureIgnoreCase))) { throw new ArgumentException("User Name is already in use"); } if (!string.IsNullOrWhiteSpace(emailAddress) && !emailAddress.IsValidEmailAddress()) { throw new ArgumentException("Email Address does not appear to be valid"); } var user = new User(userName, password, emailAddress, displayName, isApproved); db.Add(user); DomainEvents.Raise(new Events.UserRegistered(user, password)); return(user); }
public DataSyncChangeSet EventData(string eventName, DateTime newerThan) { var evt = db.Get <Event>().Where(e => e.Name.Equals(eventName, StringComparison.InvariantCultureIgnoreCase)).First(); return(syncAgent.GetChangesNewerThan(evt, newerThan)); }
public void SynchroniseOutstanding() { var thisServer = db.Get <MyMood.Domain.MoodServer>().Where(s => s.Name == Configuration.WebConfiguration.ServerName).FirstOrDefault(); if (thisServer != null) { var otherServers = (from s in db.Get <MyMood.Domain.MoodServer>() where s.Id != thisServer.Id && (!s.LastSuccessfulSync.HasValue || s.LastSuccessfulSync.Value.AddMinutes(Configuration.WebConfiguration.ServerSyncIntervalMinutes) < DateTime.UtcNow) select s) .ToArray(); var eventsToSync = (from e in db.Get <Event>() select e) .ToArray(); var client = new HttpClient(); foreach (var otherServer in otherServers) { client.BaseAddress = new Uri(otherServer.BaseAddress); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); foreach (var evt in eventsToSync) { try { var outgoingChanges = this.GetChangesNewerThan(evt, otherServer.LastSuccessfulSync ?? DateTime.MinValue); var response = client.PostAsJsonAsync <DataSyncChangeSet>("api/datasync?eventName=" + evt.Name, outgoingChanges).Result; if (response.IsSuccessStatusCode) { var incomingChanges = response.Content.ReadAsAsync <DataSyncChangeSet>().Result; this.SyncEntityChanges(evt, incomingChanges, null); } else { this.logger.Error(this.GetType(), string.Format("Failed during data sync between {0} and {1} for event {2} - HTTP {3} {4}", thisServer.Name, otherServer.Name, (int)response.StatusCode, response.ReasonPhrase)); } otherServer.LastSuccessfulSync = DateTime.UtcNow; db.Add(new MoodServerSyncReport(thisServer, otherServer, DateTime.UtcNow)); db.SaveChanges(); } catch (Exception ex) { this.logger.Error(this.GetType(), ex, string.Format("Failed during data sync between {0} and {1}", thisServer.Name, otherServer.Name)); } } } } }