public object Any(SMessage request) { var sw = Stopwatch.StartNew(); if (!request.Defer) { var results = new List <SMessageReceipt>(); results.AddRange(Email.Send(request)); results.AddRange(Facebook.Send(request)); results.AddRange(Twitter.Send(request)); Db.InsertAll(results); } else { using (var producer = MsgFactory.CreateMessageProducer()) { Email.CreateMessages(request).ForEach(producer.Publish); Facebook.CreateMessages(request).ForEach(producer.Publish); Twitter.CreateMessages(request).ForEach(producer.Publish); } } return(new SMessageResponse { TimeTakenMs = sw.ElapsedMilliseconds, }); }
public List <EmailMessage> CreateMessages(SMessage request) { return(DbFactory.Run(db => db.Select <EmailRegistration>() .ConvertAll(registration => new EmailMessage { To = registration.Email, Subject = request.Subject, Body = request.Body, }))); }
public List <PostStatusTwitter> CreateMessages(SMessage request) { return(Db.Select <UserAuthDetails>(q => q.Provider == "twitter") .ConvertAll(twitter => new PostStatusTwitter { ScreenName = twitter.UserName, AccessToken = twitter.AccessToken, AccessTokenSecret = twitter.AccessTokenSecret, Status = request.Body, })); }
public List <CallFacebook> CreateMessages(SMessage request) { return(DbFactory.Run(db => db.Select <UserOAuthProvider>(q => q.Provider == "facebook") .ConvertAll(facebook => new CallFacebook { UserName = facebook.UserName, AuthToken = facebook.AccessTokenSecret, Method = "users.setStatus", Params = { { "status", request.Body } } }))); }
public List <SMessageReceipt> Send(SMessage request) { return(Process(CreateMessages(request).ToArray())); }