public async Task <JsonResult> Subscribe(EmailModel model) { if (!IsValidSubcribeRequest(model.IsCapchaValid)) { return(Json(-1)); } if (ModelState.IsValid) { var createModel = new SubscriberCreateModel(); createModel.IsActivated = true; createModel.SourceUrl = "TravelBlog"; createModel.Email = model.Email; createModel.CreatedDate = DateTime.Now; createModel.ModuleName = "CMS"; var response = await _subscribeService.Subscribe(createModel); bool isSuccess = response.GetDataResponse(); if (isSuccess) { // Send mail to customer service await _emailSender.SendEmailAsync("New subscribe", string.Format("Email has been subscribe: {0}", model.Email)); } return(Json(isSuccess ? 1 : 0)); } return(Json(0)); }
static void Main(string[] args) { client.Subscribe("bigbigChannel", m => { Console.WriteLine($"我是bigbigChannel,接收到信息:{m}"); }); Thread t = new Thread(Run); t.Start(); }
public void Subscribe(string requestKey) { try { _proxy.Subscribe(requestKey); _timer.Change(TimeSpan.Zero, _defaultWaitTime); } catch (EndpointNotFoundException enfEx) { Trace.WriteLine(enfEx.Message); Trace.Write("wait:" + _defaultWaitTime.TotalSeconds + "s"); _timer.Change(_defaultWaitTime, _defaultWaitTime); } _keyMaps.AddOrUpdate(requestKey, DateTime.Now, (m, n) => DateTime.Now); }
public ISubscribable Subscribe(Guid userId, Guid activityId) { _subscribeService.Subscribe(userId, activityId); return(UpdateActivityCache(activityId)); }