public static void sendEmailDateProjectEnd(object sender, ElapsedEventArgs e) { Func <MySqlDataReader, List <SendEmailEndProject> > func = (reader) => { List <SendEmailEndProject> workerSendEmail = new List <SendEmailEndProject>(); while (reader.Read()) { workerSendEmail.Add(ConvertSendEmail.convertDBtoProjects(reader)); } return(workerSendEmail); }; List <SendEmailEndProject> workerNotFinish = DBAccess.RunReader(func, "SendEmailEndProject", new List <string>(), new List <string>()); foreach (var item in workerNotFinish) { string message = $"Hi {item.UserName}<br/> the project {item.nameProject} the deadline tommorow You did {item.HourDo} from {item.hoursForProject}, You stay to do {item.stayToDo} hours "; LogicManager.SendEmail(item.EmailManager, item.EmailUser, "end dead line", message); } var d = workerNotFinish.GroupBy(p => p.EmailManager); foreach (var item in d) { string message = ""; item.ToList().ForEach(user => { message += user.UserName + " "; }); LogicManager.SendEmail("*****@*****.**", item.Key, "end dead line", message); } }
/// <summary> ///Send email day before dead line /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static List <SendEmailEndProject> SendEmailDateProjectEnd() { Func <MySqlDataReader, List <SendEmailEndProject> > func = (reader) => { List <SendEmailEndProject> workerSendEmail = new List <SendEmailEndProject>(); while (reader.Read()) { workerSendEmail.Add(ConvertSendEmail.convertDBtoProjects(reader)); } return(workerSendEmail); }; return(DBAccess.RunReader(func, "SendEmailEndProject", new List <string>(), new List <string>())); }