You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace StuMgmClient
  5. {
  6. class SystemCtrl
  7. {
  8. internal static ErrCode VerifLogin(string userName, string pawssword, out Roles role, out string token)
  9. {
  10. role = Roles.Error;
  11. token = string.Empty;
  12. UserInfo cs = new UserInfo(userName, pawssword);
  13. ClientRequest req = new ClientRequest(FuncCode.VerifLogin, cs);
  14. object o;
  15. ErrCode err = SystemComm.GetData(req, out o);
  16. if (err != ErrCode.Success)
  17. return err;
  18. if (!(o is UserInfo))
  19. return ErrCode.ErrData;
  20. role = ((UserInfo)o).UserRole;
  21. token = ((UserInfo)o).Token;
  22. return ErrCode.Success;
  23. }
  24. internal static ErrCode GetCourseInfo(out List<CourseInfo> courseInfo)
  25. {
  26. courseInfo = null;
  27. //******
  28. ClientRequest req = new ClientRequest(FuncCode.GetCourseInfo, null);
  29. object o;
  30. ErrCode err = SystemComm.GetData(req, out o);
  31. if (err != ErrCode.Success)
  32. return err;
  33. if (!(o is List<CourseInfo>))
  34. return ErrCode.ErrData;
  35. courseInfo = (List<CourseInfo>)o;
  36. return ErrCode.Success;
  37. }
  38. internal static ErrCode RefreshUserCourseInfo(string token)
  39. {
  40. UserCourseInfo info;
  41. ErrCode err;
  42. err = GetUserCourseInfo(token, out info);
  43. if (err != ErrCode.Success)
  44. return err;
  45. err = SystemData.RefreshUserCourseInfo(info);
  46. if (err != ErrCode.Success)
  47. return err;
  48. return ErrCode.Success;
  49. }
  50. static ErrCode GetUserCourseInfo(string token ,out UserCourseInfo info)
  51. {
  52. info = null;
  53. ClientRequest req = new ClientRequest(FuncCode.GetUserCourseInfo, token);
  54. object o;
  55. ErrCode err = SystemComm.GetData(req, out o);
  56. if (err != ErrCode.Success)
  57. return err;
  58. if (!(o is UserCourseInfo))
  59. return ErrCode.ErrData;
  60. info = (UserCourseInfo)o;
  61. return ErrCode.Success;
  62. }
  63. }
  64. }