public void Enqueue(IDbConnection connection, MailMessage message, Guid?uid = null) { var mail = new MailRow(); mail.Uid = uid ?? Guid.NewGuid(); mail.Subject = message.Subject; mail.Body = message.Body; mail.Priority = message.Priority == MailPriority.Normal ? MailQueuePriority.Medium : (message.Priority == MailPriority.Low ? MailQueuePriority.Low : MailQueuePriority.High); mail.Status = MailStatus.InQueue; mail.LockExpiration = DateTime.Now.AddDays(-1); mail.InsertDate = DateTime.Now; mail.InsertUserId = Authorization.UserId == null ? (int?)null : Convert.ToInt32(Authorization.UserId); mail.RetryCount = 0; mail.MailFrom = message.From != null?message.From.ToString() : null; if (message.To.Count > 0) { mail.MailTo = string.Join(";", message.To.Select(x => x.ToString())); } if (message.CC.Count > 0) { mail.Cc = string.Join(";", message.CC.Select(x => x.ToString())); } if (message.Bcc.Count > 0) { mail.Bcc = string.Join(";", message.Bcc.Select(x => x.ToString())); } if (message.ReplyToList.Count > 0) { mail.ReplyTo = string.Join(";", message.ReplyToList.Select(x => x.ToString())); } connection.Insert(mail); }
private MailMessage BuildMessage(MailRow mail) { var message = new MailMessage(); message.Body = mail.Body; message.Subject = mail.Subject; if (!string.IsNullOrEmpty(mail.MailFrom)) { message.From = new MailAddress(mail.MailFrom); } message.IsBodyHtml = true; foreach (var x in SplitEmails(mail.ReplyTo)) { message.ReplyToList.Add(x); } foreach (var x in SplitEmails(mail.MailTo)) { message.To.Add(x); } foreach (var x in SplitEmails(mail.Cc)) { message.CC.Add(x); } foreach (var x in SplitEmails(mail.Bcc)) { message.Bcc.Add(x); } return(message); }
private void buttonRejectA_Click(object sender, EventArgs e)//rejection of assesment notice { //delete from 'application' database and add to 'mail' database string value = ""; if (InputBox("Reasoning", "Reason for rejecting Assesment Notice:", ref value) == DialogResult.OK) { string reasonA = value; if (value == "") { MessageBox.Show("Please enter a reason for rejection. Otherwise considered as not rejected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { appToAccept1.confirmA = 2; string msg = "Your Assesment Notice has been rejected because of the reason: " + value; MailRow mrow = new MailRow(int.Parse(listViewApplicants.SelectedItems[0].Text), textBoxWaitingName.Text, textBoxWaitingAddress.Text, msg); dbmail.insert(mrow); dbapp1.delete(listViewApplicants.SelectedItems[0].Text); clr(); } } }
private void buttonNextProgress_Click(object sender, EventArgs e) //next button action { if (listboxindex < 6) //if not to finalize { if (MessageBox.Show("Are you sure that you need to advance the progress?", "Please confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (listboxindex == 1) //to enter estimate { string value = ""; if (InputBox("Estimate Summary", "Please enter the summary of estimate:", ref value) == DialogResult.OK) { appToProgress.estimateSummary = value; if (value == "") { MessageBox.Show("Please enter the summary of estimate. Otherwise considered as not progressed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string summary = value; dbprog.updateMany(new string[] { "estimateSummary", "progress" }, listViewInProgress.SelectedItems[0].Text, new string[] { summary, "Estimated" }); listboxindex++; draw(); } } } else { listboxindex++; draw(); } } } //create an account and add to 'account' database, create bill database for each user else if (listboxindex == 6) { if (MessageBox.Show("Are you sure that you need to advance the progress? This will create an account", "Please confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int accountno; if (dbmap.hasEntry("account")) { accountno = int.Parse(dbmap.get("no", "account")); dbmap.update("no", "account", (accountno + 1).ToString()); } else { accountno = 1000000; dbmap.insert(new MapnoRow("account", 1000001)); } String[] row = dbprog.getRow(listViewInProgress.SelectedItems[0].Text); dbprog.delete(listViewInProgress.SelectedItems[0].Text); AccountRow accrow = new AccountRow(accountno, row[0], textBoxInProgressName.Text, row[2], row[3], row[4], row[5], row[6], row[7], textBoxInProgressAddress.Text, row[9], int.Parse(textBoxInProgressContact.Text), row[11], row[16], row[17], int.Parse(listViewInProgress.SelectedItems[0].Text)); dbacc.insert(accrow); dbbill.createBillingTable(accountno); string password = createRandomPassword(10); LoginRow logrow = new LoginRow(accountno.ToString(), password, 1); dblogin.insert(logrow); MailRow mrow = new MailRow(accountno, textBoxInProgressName.Text, textBoxInProgressAddress.Text, "Your username for the user account: " + accountno + ", password: "******"Assigned Account No (Username) is: " + accountno + "\nLogin Password is: " + password, "Account Number and Login Password", MessageBoxButtons.OK); clrprog(); } else { dbprog.update("progress", listViewInProgress.SelectedItems[0].Text, "Connection Established"); } } }