//[HttpPost] //EC.Windows.Task.Scheduler.exe http://localhost:8093/Service/Scheduler1?param1=197 public ActionResult Scheduler1(int param1) { //Allow sec /*if (this.Request.UserHostAddress != "") * { * return new JsonResult * { * JsonRequestBehavior = JsonRequestBehavior.AllowGet, * Data = new * { * ok = false, * } * }; * }*/ using (var db = new ECEntities()) { var reports = db.report.ToList(); ReportModel rm = new ReportModel(); string email = ""; Business.Actions.Email.EmailManagement em = new Business.Actions.Email.EmailManagement(); Business.Actions.Email.EmailBody eb = new Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower()); foreach (var _report in reports) { rm = new ReportModel(_report.id); if ((rm.GetThisStepDaysLeft() <= 0) && (!db.unread_report_reminder_sent.Any(t => t.report_id == _report.id && t.investigation_status_id == rm._investigation_status))) { eb.Scheduler1(rm._report.display_name); // days are exceeded - reminder never sent - need to send reminder foreach (var user in rm.MediatorsWhoHasAccessToReport()) { email = user.email; if ((email != null) && (email.Length > 0)) { try { // em.Send(email, "Case Management Deadline is past due", eb.Body, true); } catch { } } } try { unread_report_reminder_sent _reminder = new unread_report_reminder_sent(); _reminder.last_update_dt = DateTime.Now; _reminder.report_id = _report.id; _reminder.sent_dt = DateTime.Now; _reminder.investigation_status_id = rm._investigation_status; db.unread_report_reminder_sent.Add(_reminder); } catch { } } } } return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { ok = true, } }); }
public ActionResult New(ReportViewModel model) { companyModel.ID = model.currentCompanyId; model.Process(Request.Form, Request.Files); var currentReport = reportModel.AddReport(model); ViewBag.CaseNumber = currentReport.display_name;//Request.Form["caseNumber"];model.caseNumber if (currentReport.user_id > 0) { var user = companyModel.GetUser(currentReport.user_id); ViewBag.UserId = user.id; /*model.userName = */ ViewBag.Login = user.login_nm; /*model.password = */ ViewBag.Password = user.password; /*model.userEmail = */ ViewBag.Email = user.email; SignIn(user); GlobalFunctions glb = new GlobalFunctions(); glb.UpdateReportLog(user.id, 2, currentReport.id, "", null, ""); glb.UpdateReportLog(user.id, 28, currentReport.id, App_LocalResources.GlobalRes._Started, null, ""); } ReportViewModel rvm = new ReportViewModel(); rvm.Merge(currentReport); ViewBag.companylogo = companyModel._company.path_en; ReportSubmit submit = new ReportSubmit(); submit.merge(rvm, companyModel, reportModel, model); ViewBag.ReportModel = new ReportModel(currentReport.id); #region SendEmail To Admins ReportModel rm = new ReportModel(currentReport.id); Business.Actions.Email.EmailManagement em = new Business.Actions.Email.EmailManagement(); Business.Actions.Email.EmailBody eb = new Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower()); bool has_involved = false; List <string> to = new List <string>(); List <string> cc = new List <string>(); if (rm.InvolvedMediatorsUserList().Count > 0) { has_involved = true; } string body = ""; string title = LocalizationGetter.GetString("Email_Title_NewCase"); if (has_involved) { title = LocalizationGetter.GetString("Email_Title_NewCaseInvolved"); } foreach (var _user in rm.MediatorsWhoHasAccessToReport().Where(t => t.role_id != 4).ToList()) { eb = new Business.Actions.Email.EmailBody(1, 1, Request.Url.AbsoluteUri.ToLower()); to = new List <string>(); to.Add(_user.email.Trim()); if (has_involved) { eb.NewCaseInvolved(_user.first_nm, _user.last_nm, rm._report.display_name); } else { eb.NewCase(_user.first_nm, _user.last_nm, rm._report.display_name); } body = eb.Body; em.Send(to, cc, title, body, true); } #endregion return(View("CaseSubmitted", submit)); }