private void SendNotificationAsync(NotificationTemplate template, IList <SNSEndpoint> endpoints, SNSType type, string url = null) { Parallel.ForEach(endpoints, endpoint => { new Thread(() => { SNSMessage message = new SNSMessage(template, endpoint.SNSToken, type, url); var jsonObj = message.GetNotificationJson(); SendNotification(jsonObj, endpoint, 3); }).Start(); }); }
public string RequestToken(SNSType type) { String url = $"https://huaban.com/oauth/{type.strType}/?auth_callback={mOAuthCallback}&client_id={mClientID}&md={mMD}"; return(url); }
/// <summary> /// Asynchronously sending of notification /// </summary> /// <param name="notificationTemplateName"></param> /// <param name="endpoints"></param> /// <param name="type"></param> /// <param name="url"></param> /// <param name="variables"></param> /// <returns></returns> public bool Send(string notificationTemplateName, IList <SNSEndpoint> endpoints, SNSType type, string url = null, Dictionary <string, string> variables = null) { NotificationTemplate template = _notificationTemplateService.GetTemplate(notificationTemplateName, MessageType.Notification, FormatType.Text); var freshTemplate = new NotificationTemplate() { DateCreated = template.DateCreated, TemplateName = template.TemplateName, Description = template.Description, TemplateBody = template.TemplateBody, MessageType = template.MessageType, MessageTypeInternal = template.MessageTypeInternal, FormatType = template.FormatType, FormatTypeInternal = template.FormatTypeInternal, TemplatePlaceholderStrategy = template.TemplatePlaceholderStrategy, TemplatePlaceholderStrategyEnum = template.TemplatePlaceholderStrategyEnum, SubjectTitle = template.SubjectTitle }; if (variables != null) { Hashtable vars = new Hashtable(); foreach (string index in variables.Keys) { vars[(object)index] = (object)variables[index]; } freshTemplate.TemplateBody = _templateEngine.Render(template.TemplateBody, vars); } else { freshTemplate.TemplateBody = notificationTemplateName; } SendNotificationAsync(freshTemplate, endpoints.Where(_ => _.IsActive && _.IsLoggedIn).ToList(), type, url); return(true); }
public string RequestToken(SNSType type) { String url = $"https://huaban.com/oauth/{type.strType}/?auth_callback={Client.OAuthCallback}&client_id={Client.ClientID}&md={Client.MD}"; return url; }