public static List <DuyetLichHop> ThemLichDinhKy(DateTime dStart, DateTime dEnd) { using (QuanLyVanBanEntities db = new QuanLyVanBanEntities()) { List <DuyetLichHop> lstDuyetLich = new List <DuyetLichHop>(); foreach (var item in db.LichHops.Where(n => n.Status == true && n.RecurrenceRule != null)) { if (dStart.Date <= dEnd.Date) { KiemTraDinhKy(dStart, dEnd, item.RecurrenceRule, lstDuyetLich, item); } } return(lstDuyetLich); } }
public static void WriteLog(string module, string action, string description) { try { NhanVien user = (NhanVien)HttpContext.Current.Session["DangNhap"]; if (user == null) { user = new NhanVien(); user.TenDangNhap = "anonymous"; } using (QuanLyVanBanEntities db = new QuanLyVanBanEntities()) { NhatKy item = new NhatKy(); item.DateTime = DateTime.Now; item.Module = module; item.Action = action; item.Description = description; item.Author = user.TenDangNhap; item.IpAddress = GetClientIpAddress(); db.NhatKies.Add(item); db.SaveChanges(); // SendMail var config = db.CauHinhs.Where(x => x.MaCauHinh == "EMAIL-LOG").FirstOrDefault(); if (config != null) { string strEmail = config.DuLieu; if (!string.IsNullOrEmpty(strEmail)) { var tool = new Tools(); string strTitle = db.CauHinhs.Where(x => x.MaCauHinh == "EMAIL-LOG-TITLE").Select(x => x.DuLieu).FirstOrDefault(); string strHtml = db.CauHinhs.Where(x => x.MaCauHinh == "EMAIL-LOG-BODY").Select(x => x.DuLieu).FirstOrDefault(); strTitle = strTitle.Replace("{ACTION}", action); strHtml = strHtml.Replace("{USERNAME}", user.TenDangNhap); strHtml = strHtml.Replace("{FULLNAME}", user.HoTen); strHtml = strHtml.Replace("{LOG}", description); tool.SendMail(strHtml, strEmail, strTitle); } } } } catch (Exception) { } }
public SchedulerTaskService(QuanLyVanBanEntities context) { db = context; }