コード例 #1
0
        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,
            });
        }
コード例 #2
0
 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,
     })));
 }
コード例 #3
0
 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,
     }));
 }
コード例 #4
0
 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 } }
     })));
 }
コード例 #5
0
 public List <SMessageReceipt> Send(SMessage request)
 {
     return(Process(CreateMessages(request).ToArray()));
 }