public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; TextRelay txt_subject = (TextRelay)info.GetTextEntry(2); string subject = txt_subject.Text; TextRelay txt_message = (TextRelay)info.GetTextEntry(3); string message = txt_message.Text; if (info.ButtonID == 1) { Account acct = (Account)Targ.Account; string key = acct.Username; string to = (string)EmailHolder.Emails[key]; message += "\n\n This email was sent by " + from.Name + " at the time of " + DateTime.Now.ToString() + " using the email system on the " + RegisterEmailClient.ServerName + " shard."; EmailEventArgs eea = new EmailEventArgs(true, null, to, subject, message); RegisterEmailClient.SendMail(eea); from.SendMessage("The email is being sent."); } else { from.SendMessage("You decide not to send the email."); } }
protected void ReportExportEmail_Click(object sender, EmailEventArgs e) { string mimeType, encoding, fileNameExtension; string[] streams; MsWarning[] warnings; //Asked by jen to attach file as Pdf formate //byte[] content = ReportViewer.LocalReport.Render( // "PDF", "<DeviceInfo></DeviceInfo>", // out mimeType, out encoding, out fileNameExtension, out streams, out warnings); byte[] content = ReportViewer.LocalReport.Render("Excel", "<DeviceInfo><SimplePageHeaders>False</SimplePageHeaders></DeviceInfo>", out mimeType, out encoding, out fileNameExtension, out streams, out warnings); string attachmentName = Regex.Replace(TheReport().Name, "\\W|[0-9]", "") + "." + fileNameExtension; #pragma warning disable 618 MailMessage message = new MailMessage { ReplyTo = e.ReplyTo }; #pragma warning restore 618 message.From = new MailAddress("*****@*****.**"); foreach (MailAddress to in e.To) { message.To.Add(to); } message.Subject = e.Subject; message.IsBodyHtml = true; message.Body = e.Body; message.Attachments.Add(new Attachment(new MemoryStream(content), attachmentName)); new SmtpClient().Send(message); }
protected void ReportExportEmail_Click(object sender, EmailEventArgs e) { string mimeType, encoding, fileNameExtension; string[] streams; MsWarning[] warnings; byte[] content; if (TheReport().Name.ToLower().Contains("water")) { content = ReportViewer.LocalReport.Render("Excel", "<DeviceInfo><SimplePageHeaders>False</SimplePageHeaders></DeviceInfo>", out mimeType, out encoding, out fileNameExtension, out streams, out warnings); } else { content = ReportViewer.LocalReport.Render( "PDF", "<DeviceInfo></DeviceInfo>", out mimeType, out encoding, out fileNameExtension, out streams, out warnings); } string attachmentName = Regex.Replace(TheReport().Name, "\\W|[0-9]", "") + "." + fileNameExtension; MailMessage message = new MailMessage(); message.From = new MailAddress("*****@*****.**"); message.ReplyTo = e.ReplyTo; foreach (MailAddress to in e.To) { message.To.Add(to); } message.Subject = e.Subject; message.IsBodyHtml = true; message.Body = e.Body; message.Attachments.Add(new Attachment(new MemoryStream(content), attachmentName)); new SmtpClient().Send(message); }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; switch (info.ButtonID) { case 0: { from.SendMessage("Please be sure to register your email address at some point in time."); break; } case 1: { TextRelay txt = (TextRelay)info.GetTextEntry(2); string s = (string)txt.Text.Trim(); Account acct = (Account)from.Account; string key = (string)acct.Username; if (CanValidate(s, key, from)) { string email = (string)EmailHolder.Confirm[key]; if (!EmailHolder.Emails.ContainsKey(key)) { EmailHolder.Emails.Add(key, email); } else { EmailHolder.Emails.Remove(key); EmailHolder.Emails.Add(key, email); } if (EmailHolder.Confirm.ContainsKey(key)) { EmailHolder.Confirm.Remove(key); EmailHolder.Codes.Remove(key); } string msg = "Congragulation on sucessfully registering your email address, You will now be able to recieve special announcment s via email and use the in game commands \"[account\" to manage your password and email address and \"[email\" to send emails to other players. \n \n" + "Thank You"; EmailEventArgs eea = new EmailEventArgs(true, null, email, "Email Registered", msg); RegisterEmailClient.SendMail(eea); from.SendMessage("Thank you for registering your email."); } else { from.SendMessage("The code you entered is either not correct, or no longer valid."); } break; } } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; switch (info.ButtonID) { case 0: { from.SendMessage("You decide not the send the email."); break; } case 1: { TextRelay txt1 = (TextRelay)info.GetTextEntry(2); string subject = txt1.Text.Trim(); TextRelay txt2 = (TextRelay)info.GetTextEntry(3); string msg1 = txt2.Text.Trim(); TextRelay txt3 = (TextRelay)info.GetTextEntry(4); string msg2 = txt3.Text.Trim(); List <MailAddress> emails = new List <MailAddress>(); IEnumerator key = EmailHolder.Emails.Keys.GetEnumerator(); for (int i = 0; i < EmailHolder.Emails.Count; ++i) { key.MoveNext(); string k = (string)key.Current; MailAddress ma = new MailAddress(EmailHolder.Emails[k]); if (!emails.Contains(ma)) { emails.Add(ma); } } EmailEventArgs eea = new EmailEventArgs(false, emails, "", subject, (msg1 + msg2)); RegisterEmailClient.SendMail(eea); break; } } }
public async Task KafkaMessagingTest003_PublishNotificationMessages_ExpectNoExceptions() { this.testLogger.LogDebug("*** KafkaMessagingTest003 ***"); var topic = "MICROSERVICE-CUSTOMER-EMAIL-NOTIFICATION"; var kProducer = new app.common.messaging.generic.KafkaProducer <EmailEventArgs>(this.loggerFactory); // Config for fast synchronous write without buffering var producerConfig = new Dictionary <string, object> { { "bootstrap.servers", this.serverAddress }, { "retries", 0 }, { "queue.buffering.max.ms", 0 }, { "batch.num.messages", 1 }, { "socket.nagle.disable", true } }; kProducer.Setup(producerConfig); // Generate 10 notification events var opTimer = Stopwatch.StartNew(); for (int i = 0; i < 10; i++) { var evt = new EmailEventArgs { subject = $"Notification Test:{i+1}", textMsg = $"Notification Test:{i+1} :: BODY", htmlMsg = $"<p>Notification Test: <b>{i+1}</b> :: BODY</p>", notifyTo = new List <string>() { "*****@*****.**", "*****@*****.**" }, notifyCC = new List <string>(), notifyBCC = new List <string>() }; // We want these events going off as soon as possible await kProducer.ProduceAsync(topic, evt); // kProducer.ProduceAsync(topic, evt); } opTimer.Stop(); this.testLogger.LogInformation($"Took {opTimer.Elapsed.TotalSeconds} sec to send 100 events"); kProducer.Dispose(); }
public override void OnResponse(NetState sender, RelayInfo info) { PlayerMobile from = (PlayerMobile)sender.Mobile; Account acct = (Account)from.Account; string key = (string)acct.Username; switch (info.ButtonID) { case 0: { from.SendMessage("You decide not to change your password."); break; } case 1: { TextRelay txt = (TextRelay)info.GetTextEntry(2); string s = (string)txt.Text.Trim(); TextRelay txt2 = (TextRelay)info.GetTextEntry(3); string s2 = (string)txt2.Text.Trim(); TextRelay txt3 = (TextRelay)info.GetTextEntry(4); string s3 = (string)txt3.Text.Trim(); if (ValidatePassword(from, s, s2, s3)) { acct.SetPassword(s2); from.SendMessage("Your password has changed, your new account details are being sent to you by email."); string msg = "You have changed your password to \n\n" + s2 + "\n\n On account\n\n" + acct.Username + "\n\n This email has been sent as a protection method against account hacking, this message was sent at " + DateTime.Now.ToString() + " server time.\n Thank You"; string email = (string)EmailHolder.Emails[acct.Username]; EmailEventArgs eea = new EmailEventArgs(true, null, email, "Password Changed", msg); RegisterEmailClient.SendMail(eea); } else { from.SendMessage("Either the password you entered did not match your old password, or you new password was entered incorrectly a second time, please try again."); } break; } } }
public void OnremiseEmailSent(object sender, EmailEventArgs args) { SmtpClient client = new SmtpClient(); client.Port = 587; client.Host = "smtp.gmail.com"; client.EnableSsl = true; client.Timeout = 10000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; string emailCore = "Hello, \nThe book '" + args.title + "' is now ready for you to borrow."; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "LibraryOfNTIC"); MailMessage mm = new MailMessage("*****@*****.**", args.email, "Library Notification", emailCore); mm.BodyEncoding = UTF8Encoding.UTF8; mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(mm); }
/// <summary> /// Handles new emails found in the feed /// </summary> /// <param name="sender"></param> /// <param name="emailEventArgs"></param> private void FeedOnNewEmailsFound(object sender, EmailEventArgs emailEventArgs) { // check that emails were found if (emailEventArgs.Emails == null) { return; } // get symbols from emails var symbols = emailEventArgs.Emails.Select(_stockParser.ParseStockSymbol) .Where(s => !string.IsNullOrWhiteSpace(s)) .ToList(); // get stocks from symbols var stocks = _stockRetriever.GetStocks(_stockDataProvider, symbols); // add stocks to collection _stocks.AddRange(stocks); }
protected void EmailButtonSend_Click(object sender, EventArgs e) { if (Page.IsValid) { // build the args EmailEventArgs args = new EmailEventArgs(); args.ReplyTo = new MailAddress(ReplyField.Text); foreach (string to in ToField.Text.Split(new char[] { ',', ';' })) { if (!"".Equals(to.Trim())) { args.AddRecipient(new MailAddress(to.Trim())); } } args.Subject = SubjectField.Text; args.Body = BodyField.Text.Replace(" ", " ").Replace(Environment.NewLine, "<br/>"); //****BUZID:12217 //args.AttachmentType = (HTMLAttachment.Checked) // ? EmailEventArgs.EmailAttachmentType.HTML // : EmailEventArgs.EmailAttachmentType.PDF; args.AttachmentType = EmailEventArgs.EmailAttachmentType.PDF; //**** args.AttachmentName = Subject + " - " + ((SoftwareSystemComponentState) Context.Items[SoftwareSystemComponentStateFacade.HttpContextKey]).Id + " - " + DateTime.Now.ToString("M-d-yyyy"); // clear the form ClearForm(); // hide the form EmailPanel.Visible = false; // broadcast the event if (Send != null) { Send(this, args); } EmailUpdatePanel.Update(); } }
public override void OnResponse(NetState sender, RelayInfo info) { if (EmailHolder.Emails == null) { EmailHolder.Emails = new Dictionary <string, string>(); } if (EmailHolder.Confirm == null) { EmailHolder.Confirm = new Dictionary <string, string>(); } if (EmailHolder.Codes == null) { EmailHolder.Codes = new Dictionary <string, string>(); } Mobile from = sender.Mobile; switch (info.ButtonID) { case 0: { from.SendMessage("You will recieve this gump again next login."); break; } case 1: { TextRelay relay = (TextRelay)info.GetTextEntry(2); string txt1 = (string)relay.Text.Trim(); TextRelay relay2 = (TextRelay)info.GetTextEntry(3); string txt2 = (string)relay2.Text.Trim(); if (ValidateEmail(txt1, txt2)) { string c = CreateConFirmation(); Account acct = (Account)from.Account; string test = (string)acct.Username; string email = txt1; if (!EmailHolder.Confirm.ContainsKey(test)) { EmailHolder.Confirm.Add(test, txt1); EmailHolder.Codes.Add(test, c); } else { EmailHolder.Confirm.Remove(test); EmailHolder.Codes.Remove(test); EmailHolder.Confirm.Add(test, txt1); EmailHolder.Codes.Add(test, c); } string msg = "Thank you for submiting your email, you must use the 10 character long confirmation code below to confirm you got this email \n \n" + c + "\n \n To use this confirmation code you must type \"[auth\" in game and enter the code exactly as it appears here in the email into the text box provided. \n \n" + "Thank You";; EmailEventArgs eea = new EmailEventArgs(true, null, email, "Email Registration", msg); RegisterEmailClient.SendMail(eea); from.SendMessage("You have been sent a confirmation code, it will expire when you next log out."); } else { from.SendMessage("You have not entered your email correctly, please try again."); from.SendGump(new RegisterEmailGump()); } break; } } }
private void __setupRepo() { // Configure repository this._custrepo = new MongoRepository <Customer>(this._loggerFactory); this._custrepo.Setup( this._config["ConnectionStrings:CustomerDb:url"], this._config["ConnectionStrings:CustomerDb:db"], this._config["ConnectionStrings:CustomerDb:collection"]); Func <AppEventArgs <Customer>, Task> evtStreamHandler = (evt) => { // Queue application event return(Task.Run(async() => { this._logger.LogTrace(LoggingEvents.Trace, $"Creating update stream message for evt:{evt.appEventType} for Customer:{evt.afterChange.entityid}"); // Required to fix serialization error during Insert op if (evt.appEventType == AppEventType.Insert) { evt.beforeChange = new Customer(); } await this._appEventProducer.ProduceAsync(this._crudMsgQueueTopic, evt); })); }; Func <AppEventArgs <Customer>, Task> evtMailHandler = (evt) => { // We will send out a notification for every update var notifyEvt = new EmailEventArgs { notifyTo = new List <string>() { evt.afterChange.email }, notifyCC = new List <string>(), notifyBCC = new List <string>() }; switch (evt.appEventType) { case AppEventType.Insert: notifyEvt.subject = $"Your record has been created"; notifyEvt.textMsg = $"Dear {evt.afterChange.name}, Your record has been created. Please verify the details \n Phone:{evt.afterChange.phone}"; notifyEvt.htmlMsg = $"<p>Dear {evt.afterChange.name}, <br/> Your record has been created. <br/> Please verify the details:- <br/> Phone: <b>{evt.afterChange.phone}</b></p>"; break; case AppEventType.Delete: notifyEvt.subject = $"Your record has been deleted"; notifyEvt.textMsg = $"Dear {evt.afterChange.name}, We are sorry to see you leave!"; notifyEvt.htmlMsg = $"<p>Dear {evt.afterChange.name}, <br/> We are sorry to see you leave! </p>"; break; case AppEventType.Update: default: notifyEvt.subject = $"Your information has been updated"; notifyEvt.textMsg = $"Dear {evt.afterChange.name}, Your information has been updated. Please verify the details \n Phone:{evt.afterChange.phone}"; notifyEvt.htmlMsg = $"<p>Dear {evt.afterChange.name}, <br/> Your information has been updated. <br/> Please verify the details:- <br/> Phone: <b>{evt.afterChange.phone}</b></p>"; break; } // Queue notification event return(Task.Run(async() => { this._logger.LogTrace(LoggingEvents.Trace, $"Creating notification message for evt:{evt.appEventType} for Customer:{evt.afterChange.entityid}"); try{ await this._notificationProducer.ProduceAsync(this._notificationMsgQueueTopic, notifyEvt); } catch (Exception ex) { this._logger.LogError(LoggingEvents.Critical, ex, $"Error in steaming evt:{evt.appEventType} for Customer:{evt.afterChange.entityid}"); } })); }; this._evtHandlerLst.Add(this._custrepo.Subscribe(AppEventType.Any, evtStreamHandler)); this._evtHandlerLst.Add(this._custrepo.Subscribe(AppEventType.Any, evtMailHandler)); }
/// <summary> /// Handles new emails found in the feed /// </summary> /// <param name="sender"></param> /// <param name="emailEventArgs"></param> private void FeedOnNewEmailsFound(object sender, EmailEventArgs emailEventArgs) { // check that emails were found if (emailEventArgs.Emails == null) return; // get symbols from emails var symbols = emailEventArgs.Emails.Select(_stockParser.ParseStockSymbol) .Where(s => !string.IsNullOrWhiteSpace(s)) .ToList(); // get stocks from symbols var stocks = _stockRetriever.GetStocks(_stockDataProvider, symbols); // add stocks to collection _stocks.AddRange(stocks); }
public void StartServer(CancellationToken cancellationToken) { this._logger.LogDebug(LoggingEvents.Debug, "Started Data Replication Server"); Console.WriteLine(" *** Started App Data Replication Server ***"); // This is the event handler for emailNotification queue. Make sure this does not throw exception // Kafka message handling block would not be responsible to handle any exceptions Func <KMessage <AppEventArgs <Customer> >, Task> appEventHandler = async(message) => { this._logger.LogTrace(LoggingEvents.Trace, $"Response: Partition:{message.Partition}, Offset:{message.Offset} :: {message.Message}"); AppEventArgs <Customer> evt = message.Message; try { Customer customer = evt.afterChange; switch (evt.appEventType) { case AppEventType.Insert: _logger.LogTrace(LoggingEvents.Trace, String.Format("Adding new Customer:{0}", customer.name)); await _custrepo.AddAsync(customer); await this._searchrepo.AddAsync(customer); break; case AppEventType.Delete: var cust = await _custrepo.GetByEntityIdAsync(customer.entityid); if (cust == null) { _logger.LogTrace(LoggingEvents.Trace, $"Trying to delete Customer {customer.name} with EmtityID: {customer.entityid} that does not exist"); } else { await _custrepo.DeleteAsync(customer.entityid); } if (this._searchrepo.Exists(customer.id)) { await this._searchrepo.DeleteAsync(customer.id); } break; case AppEventType.Update: _logger.LogTrace(LoggingEvents.Trace, $"Processing request to update customer:{customer.entityid}"); await _custrepo.UpdateAsync(customer); await _searchrepo.UpdateAsync(customer); break; default: _logger.LogTrace(LoggingEvents.Trace, $"No action required for event:{evt.id} of type:{evt.appEventType}"); break; } this._logger.LogDebug(LoggingEvents.Trace, $"Processed Customer CRUD event {evt.id}"); } catch (Exception ex) { var msg = $"Event:{evt.id} - Error:{ex.Message}"; this._logger.LogError(LoggingEvents.Error, ex, msg); // We will send out a notification for every update var notifyEvt = new EmailEventArgs { subject = "Data Replication Error", textMsg = $"Error replicating customer information. {msg}", htmlMsg = $"<p> Error replicating customer information. </p><p> <b>Message Details: </b> {msg} <p>", notifyTo = new List <string>() { "*****@*****.**" }, notifyCC = new List <string>(), notifyBCC = new List <string>() }; await this._notificationProducer.ProduceAsync(this._notificationMsgQueueTopic, notifyEvt); } }; this._appEventMsgConsumer.Consume(cancellationToken, appEventHandler, null, null); this._appEventMsgConsumer.Dispose(); Console.WriteLine(" *** Stopped App Data Replication Server ***"); this._logger.LogDebug(LoggingEvents.Debug, "Stopped App Data Replication Server"); }