main
Paul Schneider 10 years ago
parent b0c504347a
commit 8fcfb16634
1 changed files with 10 additions and 29 deletions

@ -33,37 +33,17 @@ namespace Yavsc.Services
public async Task<MessageWithPayloadResponse> public async Task<MessageWithPayloadResponse>
NotifyAsync(GoogleAuthSettings googleSettings, IEnumerable<string> registrationIds, YaEvent ev) NotifyAsync(GoogleAuthSettings googleSettings, IEnumerable<string> registrationIds, YaEvent ev)
{ {
MessageWithPayloadResponse response; MessageWithPayloadResponse response = null;
try await Task.Run(()=>{
{ response = googleSettings.NotifyEvent(registrationIds, ev);
using (var web = new HttpClient()) });
{
response = await web.NotifyEvent(googleSettings, registrationIds, ev);
}
}
catch (WebException ex)
{
string errorMsgGCM;
using (var respstream = ex.Response.GetResponseStream())
{
using (StreamReader rdr = new StreamReader(respstream))
{
errorMsgGCM = rdr.ReadToEnd();
rdr.Close();
}
respstream.Close();
}
if (errorMsgGCM == null)
throw;
throw new Exception(errorMsgGCM, ex);
}
return response; return response;
} }
public Task<bool> SendEmailAsync(SiteSettings siteSettings, SmtpSettings smtpSettings, string email, string subject, string message) public Task<bool> SendEmailAsync(SiteSettings siteSettings, SmtpSettings smtpSettings, string email, string subject, string message)
{ {
try { try
{
MimeMessage msg = new MimeMessage(); MimeMessage msg = new MimeMessage();
msg.From.Add(new MailboxAddress( msg.From.Add(new MailboxAddress(
siteSettings.Owner.Name, siteSettings.Owner.Name,
@ -83,7 +63,8 @@ namespace Yavsc.Services
sc.Send(msg); sc.Send(msg);
} }
} }
catch (Exception) { catch (Exception)
{
return Task.FromResult(false); return Task.FromResult(false);
} }
return Task.FromResult(true); return Task.FromResult(true);

Loading…