public async Task BindData() { try { var data = await _api.GetStudents(true); Gc_Students.DataSource = data; } catch (Exception exception) { PopupProvider.Error("获取学生信息数据异常!", exception); } }
public ResultModel <List <Student> > SetCache() { var studentApi = new StudentApi(); var students = studentApi.GetStudents(); var cacheKey = "studentCache"; var result = _cachingManager.SetCache(students, cacheKey, DateTime.Now.AddMinutes(2)); return(result); }
/// <summary> /// 绑定学生信息数据 /// </summary> /// <returns></returns> private async Task BindStudentInfo() { var studentNo = Te_StudentNo.Text; try { _handle = OverlayScreenForm.ShowProgressPanel(this); var students = await _api.GetStudents(new Dictionary <string, object> { { "StudentNo", studentNo } }); var student = students.FirstOrDefault(); if (student == null) { PopupProvider.Warning("未检索到信息!"); return; } Te_Age.EditValue = student.Age; Te_Name.Text = student.StudentName; Te_Class.Text = student.Class; Te_Sex.Text = student.Sex ? "女" : "男"; Te_Department.Text = student.DepartmentName; Te_Phone.EditValue = student.Contact; Te_Email.Text = student.Email; Te_StudentNo.EditValue = student.StudentNo; Te_StudentId.Text = student.Id.ToString(); #region 获取当前学生剩余可借阅数量 var num = await _borrowApi.GetBorrowInfoTotal(Te_StudentId.Text); if (num != -1) { Te_BooksNum.EditValue = 3 - num; } else { Te_BooksNum.EditValue = 3; } #endregion OverlayScreenForm.CloseProgressPanel(_handle); } catch (Exception e) { OverlayScreenForm.CloseProgressPanel(_handle); PopupProvider.Error("获取学生信息异常!", e); LogHelper.Error(e.ToString()); } }
public List <Student> SetGetCache() { var studentApi = new StudentApi(); var cacheKey = "studentCache"; var result = _cachingManager.SetGetCache(cacheKey, DateTime.Now.AddMinutes(2), () => { var result = studentApi.GetStudents(); return(result); }); return(result); }
/// <summary> /// 绑定学生信息数据 /// </summary> /// <returns></returns> private async Task BindStudentInfo() { var studentNo = Te_StudentNo.Text; try { var students = await _api.GetStudents(new Dictionary <string, object> { { "StudentNo", studentNo } }); var student = students.FirstOrDefault(); if (student == null) { PopupProvider.Warning("未检索到信息!"); return; } Te_Age.EditValue = student.Age; Te_Name.Text = student.StudentName; Te_Class.Text = student.Class; Te_Sex.Text = student.Sex ? "女" : "男"; Te_Department.Text = student.DepartmentName; Te_Phone.EditValue = student.Contact; Te_Email.Text = student.Email; Te_StudentNo.EditValue = student.StudentNo; Te_StudentId.Text = student.Id.ToString(); #region 获取当前学生剩余可预约数量 var num = await _reservationApi.GetReservationInfoTotal(Te_StudentId.Text); if (num != -1) { Te_BooksNum.EditValue = 2 - num; } else { Te_BooksNum.EditValue = 2; } #endregion } catch (Exception e) { PopupProvider.Error("获取学生信息异常!", e); LogHelper.Error(e.ToString()); } }