public ActionResult Delete(int id) { EmailRecord emailrecord = db.EmailRecords.Find(id); emailrecord.Body = Server.HtmlDecode(emailrecord.Body); return(View(emailrecord)); }
public EmailRecord Get(Guid Id) { try { EmailRecord record = null; var command = new SqlCommand { CommandText = string.Format("select Top(1) * from Email where id = @id") }; command.Parameters.Add(new SqlParameter("@id", Id)); using (var connection = Helpers.NewConnection()) { connection.Open(); command.Connection = connection; using (var reader = command.ExecuteReader()) { if (!reader.Read()) { throw new Exception("throw exception while get data"); } record = new EmailRecord { Id = Guid.Parse(reader["Id"].ToString()), Data = reader["Data"].ToString() }; } } return(record); } catch (Exception e) { throw new Exception(e.Message); } }
public ActionResult Create() { EmailRecord email = new EmailRecord(); email.LastUpdate = DateTime.Now; return(View(email)); }
private static Dictionary <string, EmailRecord> getNameValueByElementType( HtmlAgilityPack.HtmlDocument source, SalesForce salesForce ) { Dictionary <string, EmailRecord> output = new Dictionary <string, EmailRecord>(); var document = source.DocumentNode; foreach (KeyValuePair <string, bool> emailItem in salesForce.emailHeaderIdentities) { if (emailItem.Value) { HtmlAgilityPack.HtmlNode editNode = source.GetElementbyId(emailItem.Key); if (editNode.Attributes.ToList().Count(x => x.Name == "value") >= 1) { HtmlAgilityPack.HtmlAttribute attribute = editNode.Attributes["value"]; EmailRecord record = new EmailRecord(); record.emailAddress = attribute.Value; output.Add(emailItem.Key, record); } } } return(output); }
public void Create(EmailRecord emailRecord) { try { emailRecord.Id = Guid.NewGuid(); var command = new SqlCommand { CommandText = string.Format("insert into Email (id, data) values (@id, @data)"), }; command.Parameters.Add("@id", SqlDbType.UniqueIdentifier); command.Parameters.Add("@data", SqlDbType.NVarChar); command.Parameters["@id"].Value = emailRecord.Id; command.Parameters["@data"].Value = emailRecord.Data; using (var connection = Helpers.NewConnection()) { connection.Open(); command.Connection = connection; using (var transactionScope = new TransactionScope()) { command.ExecuteNonQuery(); transactionScope.Complete(); } } } catch (Exception e) { throw new Exception(e.Message); } }
public void EmailRecordStorage(string EMailTo, string EMailCc, string subject, string EmailText, List <string> myList, int RFAReferralID) { EmailRecord _emailRecord = new EmailRecord(); _emailRecord.EmRecTo = EMailTo; _emailRecord.EmRecCC = EMailCc; _emailRecord.EmRecSubject = subject; _emailRecord.EmRecBody = EmailText; _emailRecord.EmailRecDate = DateTime.Now; _emailRecord.UserID = MMCUser.UserId; int _emailRecordID = _iEmailRecordAttachmentService.addEmailRecord(Mapper.Map <MMCService.EmailRecordAttachmentService.EmailRecord>(_emailRecord)); _iEmailRecordAttachmentService.AddEmailRecordAndRFARequestLinkByRFAReferralID(RFAReferralID, _emailRecordID); foreach (var _list in myList) { EmailRecordAttachment _emailRecordAttachment = new EmailRecordAttachment(); string URL = ""; string urlPathData = _list.ToString(); string toSearched = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings[GlobalConst.VirtualDirectoryPath.VirtualPath].ToString()); string toReplace = System.Configuration.ConfigurationManager.AppSettings[GlobalConst.VirtualDirectoryPath.VirtualPath].ToString(); URL = urlPathData.Replace(toSearched, toReplace); Tuple <string, string> savePathWithDownloadPath = new Tuple <string, string>(urlPathData, URL); string _urlData = savePathWithDownloadPath.ToString(); _urlData = _urlData.Replace("(", ""); _urlData = _urlData.Replace(")", ""); string _fileName = Path.GetFileName(urlPathData); _emailRecordAttachment.EmailRecordId = _emailRecordID; _emailRecordAttachment.DocumentName = _fileName; _emailRecordAttachment.DocumentPath = _urlData; _iEmailRecordAttachmentService.addEmailRecordAttachment(Mapper.Map <MMCService.EmailRecordAttachmentService.EmailRecordAttachment>(_emailRecordAttachment)); } }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="advanced"></param> /// <returns></returns> private static Dictionary <string, EmailRecord> getNameValueByElementType( HtmlAgilityPack.HtmlDocument source, Advanced advanced ) { Dictionary <string, EmailRecord> output = new Dictionary <string, EmailRecord>(); var document = source.DocumentNode; IEnumerable <HtmlAgilityPack.HtmlNode> emailNodes = document.QuerySelectorAll(advanced.elementOne); IEnumerable <HtmlAgilityPack.HtmlNode> spanNodes = document.QuerySelectorAll(advanced.elementTwo); foreach (HtmlAgilityPack.HtmlNode node in emailNodes) { // if node is found or not bool IsRequiredNode = false; // check if node is in header settings advanced.emailHeaderIdentities.TryGetValue(node.Id, out IsRequiredNode); if (IsRequiredNode) { if (node.Attributes["fieldname"].Value == advanced.fieldNameOne) { if (node.InnerText.Contains("@")) { EmailRecord record = new EmailRecord() { emailAddress = node.InnerText, nodeIdentity = node.Id, status = "UNDEFINED" }; output.Add(node.InnerText, record); } } } } Dictionary <string, EmailRecord> newOutput = new Dictionary <string, EmailRecord>(); foreach (HtmlAgilityPack.HtmlNode node in spanNodes) { foreach (var key in output.Keys) { EmailRecord tempRecord = output[key]; if (node.Id == tempRecord.nodeIdentity + "_status") { tempRecord.status = node.InnerText; newOutput[key] = tempRecord; } } } return(newOutput); }
// // GET: /EmailRecord/Details/5 public ViewResult Details(int id) { EmailRecord emailrecord = db.EmailRecords.Find(id); emailrecord.Body = Server.HtmlDecode(emailrecord.Body); ViewBag.BodyText = emailrecord.Body; return(View(emailrecord)); }
public ActionResult DeleteConfirmed(int id) { EmailRecord emailrecord = db.EmailRecords.Find(id); db.EmailRecords.Remove(emailrecord); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> SignUp(EmailRecord emailRecord) { var firebaseClient = new FirebaseClient("https://denguelive-47836.firebaseio.com"); var result = await firebaseClient .Child("Emails") .Child(emailRecord.Location) .PostAsync(emailRecord); TempData["msg"] = "<script>alert('Sign up successful');</script>"; return(RedirectToAction("Index")); }
public ActionResult Edit(EmailRecord emailrecord) { if (ModelState.IsValid) { emailrecord.Body = Server.HtmlEncode(emailrecord.Body); db.Entry(emailrecord).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emailrecord)); }
public ActionResult Create(EmailRecord emailrecord) { if (ModelState.IsValid) { emailrecord.LastUpdate = DateTime.Now; emailrecord.Body = Server.HtmlEncode(emailrecord.Body); db.EmailRecords.Add(emailrecord); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emailrecord)); }
public int addEmailRecord(EmailRecord _emailRecord) { return(_emailRecordRepository.addEmailRecord(Mapper.Map <MMC.Core.Data.Model.EmailRecord>(_emailRecord))); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { // track enter and exit this.breakOutExited = false; if (lblExcelFileStatus.BackColor != Color.DarkGreen || lblConfirmedWorksheet.BackColor != Color.DarkGreen || lblAdvancedOptions.BackColor != Color.DarkGreen) { MessageBox.Show("Donna, you forgot a step make sure everything is green!", "Hey Donna... :-)"); return; } KeyInput input = new KeyInput(); ApplicationSettings settings = new ApplicationSettings(); // set csv output string csvOutput = settings.FILE_EXPORT_PATH; // remove files CleanUp(settings.WEB_EXPORT_PATH); try { // on new run, remove output file if (File.Exists(csvOutput)) { File.Copy(csvOutput, csvOutput.Replace(".csv", "_" + DateTime.Now.ToFileTime() + ".csv")); File.Delete(csvOutput); } } catch (Exception) { MessageBox.Show("Donna, did you close the Output.csv file? Close it, then press OK.", "Hey Donna... :-)"); File.Copy(csvOutput, csvOutput.Replace(".csv", "_" + DateTime.Now.ToFileTime() + ".csv")); File.Delete(csvOutput); } // check what was chosen Advanced.TREE_TYPE treeChosen = (this.radioEmailInactive.Checked) ? Advanced.TREE_TYPE.EMAIL_INACTIVE : Advanced.TREE_TYPE.EMAIL_ACTIVE; // based on the chosen value, load the new configuration Advanced advanced = new Advanced(treeChosen); // exit if the file goes away if (!File.Exists(this.excelFileLocation)) { return; } List <string[]> idNumbers = uwExcel.createFromExcel(this.excelFileLocation, "A", "B", txtWorksheetName.Text); // excel row number from original int rowIndexNo = 1; int startFromIndex = 0; int endIndexRow = 0; // startFrom if (settings.START_AT_ROW > 0) { startFromIndex = settings.START_AT_ROW; } // startFrom if (settings.END_AT_ROW > 0) { endIndexRow = settings.END_AT_ROW; } foreach (string[] person in idNumbers) { if (startFromIndex > 0) { if (rowIndexNo - 1 <= startFromIndex) { rowIndexNo++; continue; } } // skip if missing id number if (String.IsNullOrEmpty(person[0])) { rowIndexNo++; continue; } Process chrome = Process.Start(settings.DEFAULT_BROWSER_EXE, advanced.GetNewEndpoint(person[0], treeChosen)); Thread.Sleep(settings.DEFAULT_SLEEP_INTERVAL); foreach (var browserInstruction in input.InstructionsBrowser) { SendKeys.SendWait(browserInstruction); if (browserInstruction != "^{w}") { Thread.Sleep(settings.DEFAULT_SLEEP_INTERVAL); } } // remove files CleanUp(settings.WEB_EXPORT_PATH); var html = Clipboard.GetText(); Dictionary <string, EmailRecord> emailList = loadHtmlGetElementsBySelector(html, advanced); // if no emails returned skip if (emailList.Count == 0) { rowIndexNo++; continue; } // check index rowIndexNo++; // This text is always added, making the file longer over time // if it is not deleted. using (StreamWriter sw = File.AppendText(csvOutput)) { foreach (string key in emailList.Keys) { EmailRecord tempRecord = emailList[key]; if (tempRecord.status != Advanced.GetTreeTypeStatus(treeChosen)) { continue; } sw.WriteLine("{0},{1},{2},{3}", person[0], tempRecord.emailAddress, tempRecord.status, rowIndexNo); } } if (this.breakOutExited) { // break out break; } if (endIndexRow > 0) { if (rowIndexNo - 1 >= endIndexRow) { rowIndexNo++; // break out as it is the end. break; } } } }
private void button2_Click(object sender, EventArgs e) { // track enter and exit this.breakOutExited = false; if (lblExcelFileStatus.BackColor != Color.DarkGreen || lblConfirmedWorksheet.BackColor != Color.DarkGreen) { MessageBox.Show("Donna, you forgot a step make sure everything is green!", "Hey Donna... :-)"); return; } KeyInput input = new KeyInput(); ApplicationSettings settings = new ApplicationSettings(); // set csv output string csvOutput = settings.FILE_EXPORT_PATH; // remove files CleanUp(settings.WEB_EXPORT_PATH); try { // on new run, remove output file if (File.Exists(csvOutput)) { File.Copy(csvOutput, csvOutput.Replace(".csv", "_" + DateTime.Now.ToFileTime() + ".csv")); File.Delete(csvOutput); } } catch (Exception) { MessageBox.Show("Donna, did you close the Output.csv file? Close it, then press OK.", "Hey Donna... :-)"); File.Copy(csvOutput, csvOutput.Replace(".csv", "_" + DateTime.Now.ToFileTime() + ".csv")); File.Delete(csvOutput); } // exit if the file goes away if (!File.Exists(this.excelFileLocation)) { return; } List <string[]> idNumbers = uwExcel.createFromExcel(this.excelFileLocation, "A", "O", txtWorksheetName.Text); // excel row number from original int rowIndexNo = 1; int startFromIndex = 0; int endIndexRow = 0; // startFrom if (settings.START_AT_ROW > 0) { startFromIndex = settings.START_AT_ROW; } // startFrom if (settings.END_AT_ROW > 0) { endIndexRow = settings.END_AT_ROW; } List <SalesForce> salesForcePersons = new List <SalesForce>(); foreach (string[] person in idNumbers) { SalesForce salesForce = new SalesForce(SalesForce.TREE_TYPE.PERSON_SEARCH); // get default values salesForce.idNumber = person[0]; salesForce.oldEmail = person[14]; if (startFromIndex > 0) { if (rowIndexNo - 1 <= startFromIndex) { rowIndexNo++; continue; } } // skip if missing id number if (String.IsNullOrEmpty(person[0])) { rowIndexNo++; continue; } Process chrome = Process.Start(settings.DEFAULT_BROWSER_EXE, salesForce.GetNewEndpoint(person[0])); Thread.Sleep(settings.DEFAULT_SLEEP_INTERVAL); foreach (var browserInstruction in input.InstructionsBrowser) { SendKeys.SendWait(browserInstruction); Thread.Sleep(settings.DEFAULT_SLEEP_INTERVAL); } var html = Clipboard.GetText(); loadHtmlGetElementsBySelectorSalesForceGetEditLink(html, salesForce); // if no edit link returned skip //if (salesForce.endpointEditSearchFieldTemplate == "") //{ // rowIndexNo++; // continue; //} salesForce.rowNo = rowIndexNo; salesForcePersons.Add(salesForce); rowIndexNo++; if (endIndexRow > 0) { if (rowIndexNo - 1 >= endIndexRow) { rowIndexNo++; // break out as it is the end. break; } } } List <SalesForce> updatedSalesforceList = new List <SalesForce>(); foreach (SalesForce salesForceElement in salesForcePersons) { Process chromeEdit = Process.Start(settings.DEFAULT_BROWSER_EXE, salesForceElement.GetEditEndpoint()); Thread.Sleep(settings.DEFAULT_SLEEP_INTERVAL); foreach (var browserInstruction in input.InstructionsBrowser) { SendKeys.SendWait(browserInstruction); Thread.Sleep(settings.DEFAULT_SLEEP_INTERVAL); } var htmlEdit = Clipboard.GetText(); Dictionary <string, EmailRecord> emailDictionary = loadHtmlGetElementsBySelector(htmlEdit, salesForceElement); List <string> emailList = new List <string>(); // if no emails returned skip if (emailDictionary.Count > 0) { foreach (KeyValuePair <string, EmailRecord> emailRecord in emailDictionary) { EmailRecord record = emailRecord.Value; emailList.Add(record.emailAddress); } } // copy the object SalesForce salesForceNew = salesForceElement.DeepCopy(); // assign the new email list salesForceNew.emailRecordList = emailList; // make new list updatedSalesforceList.Add(salesForceNew); } foreach (SalesForce updatedSalesForceItem in updatedSalesforceList) { string emailToWrite = ""; bool hasEmailChanged = false; if (updatedSalesForceItem.emailRecordList.Count > 0) { // weigh out emails string domain = GetEmail(updatedSalesForceItem.emailRecordList); // find the email to write emailToWrite = updatedSalesForceItem.emailRecordList.Find(p => p.Contains(domain)); if (updatedSalesForceItem.oldEmail != emailToWrite || updatedSalesForceItem.oldEmail == "" && emailToWrite != "") { hasEmailChanged = true; } } // This text is always added, making the file longer over time // if it is not deleted. using (StreamWriter sw = File.AppendText(csvOutput)) { sw.WriteLine("{0},{1},{2},{3},{4}", updatedSalesForceItem.idNumber, hasEmailChanged, emailToWrite, updatedSalesForceItem.oldEmail, updatedSalesForceItem.rowNo); } } }
public int addEmailRecord(EmailRecord _emailRecord) { return(_emailRecordRepo.Add(_emailRecord).EmailRecordId); }
public ActionResult SendSystemEmail(EmailRecord record) { var emailModel = new SmtpEmail(); bool isSave; bool toNewStudents; bool toFacssVolunteers; bool toPickupVolunteers; bool toHousingVolunteers; bool toAllVolunteers; string str = Request["savetorecord"]; if (str == "on") { isSave = true; } else { isSave = false; } str = Request["toAllNewStudents"]; if (str == "on") { toNewStudents = true; } else { toNewStudents = false; } str = Request["toFacssVolunteers"]; if (str == "on") { toFacssVolunteers = true; } else { toFacssVolunteers = false; } str = Request["toPickupVolunteers"]; if (str == "on") { toPickupVolunteers = true; } else { toPickupVolunteers = false; } str = Request["toHousingVolunteers"]; if (str == "on") { toHousingVolunteers = true; } else { toHousingVolunteers = false; } str = Request["toAllVolunteers"]; if (str == "on") { toAllVolunteers = true; } else { toAllVolunteers = false; } record.LastUpdate = DateTime.Now; record.Body = Server.HtmlEncode(record.Body); if (isSave) { web_db.EmailRecords.Add(record); web_db.SaveChanges(); } if (toNewStudents) { var slist = db.NewStudents.ToList(); foreach (var s in slist) { emailModel.Bcc.Add(s.Email); } } if (toAllVolunteers) { var vlist = db.Volunteers.ToList(); foreach (var v in vlist) { emailModel.Bcc.Add(v.Email); } var mlist = db.ManualAssignInfoes.ToList(); foreach (var m in mlist) { if (emailModel.Bcc.Contains(m.VolEmail)) { continue; } emailModel.Bcc.Add(m.VolEmail); } } else { if (toFacssVolunteers) { var facss = db.Organizations.Where(o => o.Name.Contains("FACSS")).FirstOrDefault(); var vlist = facss.Volunteers.ToList(); foreach (var v in vlist) { emailModel.Bcc.Add(v.Email); } } if (toPickupVolunteers) { var vlist = db.Volunteers.ToList().Where(v => v.PickupNewStudents != null && v.PickupNewStudents.Count > 0).ToList(); foreach (var v in vlist) { emailModel.Bcc.Add(v.Email); } var mlist = db.ManualAssignInfoes.Where(m => m.Type == ManualAssignType.IntPickup).ToList(); foreach (var m in mlist) { if (emailModel.Bcc.Contains(m.VolEmail)) { continue; } emailModel.Bcc.Add(m.VolEmail); } } if (toHousingVolunteers) { var vlist = db.Volunteers.ToList().Where(v => v.TempHouseNewStudents != null && v.TempHouseNewStudents.Count > 0).ToList(); foreach (var v in vlist) { emailModel.Bcc.Add(v.Email); } var mlist = db.ManualAssignInfoes.Where(m => m.Type == ManualAssignType.IntHousing).ToList(); foreach (var m in mlist) { if (emailModel.Bcc.Contains(m.VolEmail)) { continue; } emailModel.Bcc.Add(m.VolEmail); } } } emailModel.Subject = record.Title; emailModel.Body = Server.HtmlDecode(record.Body); emailModel.Send(); return(Content(emailModel.Count + "emails were sent out successfully!")); }