protected virtual void OnReceiveMessage(object sender, ReceiveMessageEventArgs e) { var msg = e.Message; var saveToPath = Path.Combine(this.MailFolderPath, msg.Id.ToString("N") + ".eml"); msg.SaveAs(saveToPath); // notify via SignalR var hubContext = SignalR.GlobalHost.ConnectionManager.GetHubContext <SmtpServerHub>(); SmtpServerHub.NotifyReceiveMessage(msg, hubContext.Clients); }
public void Delete(Guid id) { var pathToDelete = Directory.GetFiles(App.Current.MailFolderPath, "*.eml") .Select(path => new { path, SmtpMessage.CreateFrom(path).Id }) .First(a => a.Id == id) .path; File.Delete(pathToDelete); // notify via SignalR var hubContext = SignalR.GlobalHost.ConnectionManager.GetHubContext <SmtpServerHub>(); SmtpServerHub.NotifyRemoveMessage(id, hubContext.Clients); }
public void Delete() { var hubContext = SignalR.GlobalHost.ConnectionManager.GetHubContext <SmtpServerHub>(); Directory.GetFiles(App.Current.MailFolderPath, "*.eml") .Select(path => new { path, SmtpMessage.CreateFrom(path).Id }) .ToList() .ForEach(m => { File.Delete(m.path); // notify via SignalR SmtpServerHub.NotifyRemoveMessage(m.Id, hubContext.Clients); }); }