public JsonResult KetQua(KetQuaModel kq) { TimeZoneInfo date = TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time"); DateTime utc = DateTime.UtcNow; DateTime now = TimeZoneInfo.ConvertTimeFromUtc(utc, date); try { BaiLam bailam = new BaiLam(); bailam.MaLopKiemTra = kq.MaLopKiemTra; bailam.MaHocVien = kq.ID; bailam.TongDiem = kq.Diem; bailam.NgayKiemTra = now; using (ELearningDB db = new ELearningDB()) { var bl = db.BaiLams.Where(x => x.MaHocVien == kq.ID).ToList(); foreach (var item in bl) { if (item.MaHocVien == kq.ID && item.MaLopKiemTra == kq.MaLopKiemTra) { return(Json(false)); } } db.BaiLams.Add(bailam); db.SaveChanges(); return(Json(true)); } } catch (Exception) { return(Json(false)); } }
// GET: KetQua public ActionResult Index() { var session = (TaiKhoanLogin)Session[CommonConstants.USER_SESSION]; if (session != null && session.loai == 3) { using (ELearningDB db = new ELearningDB()) { List <KetQuaModel> KetQuas = new List <KetQuaModel>(); var lstKQ = db.BaiLams.Where(x => x.MaHocVien == session.ID).ToList(); foreach (var item in lstKQ) { KetQuaModel kq = new KetQuaModel(); kq.TenMonHoc = item.LopKiemTra.MonHoc.TenMonHoc; kq.MaDeThi = item.LopKiemTra.MaDeThi; kq.TenDeThi = item.LopKiemTra.Name; kq.NgayLam = item.NgayKiemTra.Value.ToString("dd/MM/yyyy"); kq.Diem = item.TongDiem; KetQuas.Add(kq); } return(View(KetQuas)); } } else { TempData["Error"] = "Bạn chưa đăng nhập"; return(RedirectToAction("TrangChu", "Home")); } }
public async Task <string> SendInforAlarm(AlarmModel alarm) { AbpSession.Use(1, 2); var abc = AbpSession.UserId; KetQuaModel result = new KetQuaModel(); var loginResultVNPT = _webService.AuthCenter(alarm.USERNAME, alarm.PASSWORD); if (loginResultVNPT != null) { if (loginResultVNPT.isError == false) { result.LOGIN = true; try { var thietbi = _dm_ThietBiAppService.GetThietBiByIP(alarm.IPADDRESS); if (thietbi != null) { var url = alarm.PATH.Replace("@D:\\FTP\\IPCAMERA", "http://10.10.117.175:7711"); var message = alarm.CODE + "@" + alarm.STATUS + "@" + alarm.PATH; await _lichSuHoatDongThietBiAppService.SaveLogHoatDong(thietbi, alarm.CODE, alarm.STATUS, url); await _thongTin_ThietBiAppService.UpdateTrangThaiDieuKhien(thietbi.Id, alarm.CODE, alarm.STATUS, url); var context = GlobalHost.ConnectionManager.GetHubContext <ChatHub>(); context.Clients.All.getMessageAlarm(thietbi.ConnectionID, message); result.SUCCESS = true; } } catch (Exception ex) { result.SUCCESS = false; result.ERROR = ex.InnerException.Message; } } } else { } string output = JsonConvert.SerializeObject(result); return(output); }
public ActionResult SQ_30(KetQuaModel model) { return(RedirectToAction("MainAction", model)); }
//return Views public ActionResult MainAction(KetQuaModel model) { string path = HttpContext.Server.MapPath(""); string RePath = path.Replace("SQ", "Views\\SQ"); var answer = new UserAnswer(); answer.Object = "SQ_" + model.DeSo; string correctAns = CorrectAnswerHelper.GetCorrectAnswer(answer.Object); answer.UAnswer = model.TraLoi; answer.CorrectAnswer = correctAns; decimal mark = CorrectAnswerHelper.Calculate(answer, RePath); decimal k = Convert.ToDecimal(6.5); if (8 <= mark) { model.XepLoai = "G"; } else if (k <= mark) { model.XepLoai = "K"; } else if (5 <= mark) { model.XepLoai = "Đ"; } else { model.XepLoai = "KĐ"; } model.KQ = mark; model.DapAn = correctAns; //insert CorrectAnswerHelper.Insert(model); var show = new ShowResultModel(); show.mark = model.KQ; switch (model.XepLoai) { case "G": show.quality = "Giỏi"; break; case "K": show.quality = "Khá"; break; case "Đ": show.quality = "Đạt yêu cầu"; break; default: show.quality = "Không đạt yêu cầu"; break; } string desAction = model.IDQN + "_SQ_" + model.DeSo; show.fileName = desAction; show.type = "SQ"; var permission = new PermissionModel(); permission.SetLogStatus(model.IDQN, 2); return(RedirectToAction("Index", "Result", show)); }
public static void Insert(KetQuaModel model) { var insert = new KetQuaKiemTraModel(); insert.InsertResult(model.IDQN, model.KQ, model.XepLoai, model.DeSo, model.TraLoi, model.DapAn); }
public ActionResult Individual_50(KetQuaModel model) { return(RedirectToAction("MainAction", model)); }