public static List<考试排名> 得到考试排名(string 关键字,Guid 考试设置ID, Guid 考生ID, int 第几页, int 页的大小, out int 返回总条数,out LKPageException 异常信息)
 {
     考试设置 examSet = 考试设置.考试设置查询.Where(a => a.ID == 考试设置ID).First();
     if (examSet.是否公布考试结果 == false)
     {
         异常信息 = new LKPageException(异常处理.得到异常信息(10));
         返回总条数 = 0;
         return new List<考试排名>();
     }
     if (DateTime.Now < examSet.考试结束时间)
     {
         异常信息 = new LKPageException(异常处理.得到异常信息(9));
         返回总条数 = 0;
         return new List<考试排名>();
     }
     //先查询出与该考生同班级的所有考生
     LoveKaoExamEntities db = new LoveKaoExamEntities();
     用户表 user = db.用户表.FirstOrDefault(a=>a.ID==考生ID);
     List<Guid> listUserId = db.用户表.Where(a => a.部门ID == user.部门ID).Select(a => a.ID).ToList();
     //查询这些考生的排名
     List<考试排名> listAllRank=考试排名查询.Where(a => listUserId.Contains(a.考生ID) && a.考试设置ID == 考试设置ID).ToList();
     if (listAllRank.Any(a => a.考生ID == 考生ID) == false)
     {
         异常信息 = new LKPageException(异常处理.得到异常信息(11));
         返回总条数 = 0;
         return new List<考试排名>();
     }
     listAllRank = listAllRank.OrderByDescending(a => a.总得分).ToList();
     if (listAllRank.Count > 0)
     {
         //赋值名次,考生,考试设置,及格情况,参考书人数,我的排名属性
         for (int i = 0; i < listAllRank.Count; i++)
         {
             listAllRank[i].名次 = i + 1;
         }
         List<Guid> listStudentId = listAllRank.Select(a => a.考生ID).ToList();
         List<用户> listStudent = 用户.用户查询.Where(a => listStudentId.Contains(a.ID)).ToList();
         Guid 试卷内容ID=listAllRank[0].考试设置表.试卷内容ID;
         试卷内容 test = 试卷内容.试卷内容查询.Where(a => a.ID == 试卷内容ID).First();
         //查询我的排名
         int myRank = listAllRank.Where(a => a.考生ID == 考生ID).First().名次;
         foreach (考试排名 rank in listAllRank)
         {
             rank.考试设置 = 考试设置.把考试设置表转化成考试设置(rank.考试设置表);
             rank.考试设置.试卷内容 = test;
             rank.考生 = listStudent.First(a => a.ID == rank.考生ID);
             if (rank.总得分 / test.总分 * 100 < rank.考试设置表.及格条件)
             {
                 rank.及格情况 = "不及格";
             }
             else
             {
                 rank.及格情况 = "及格";
             }
             rank.参考人数 = listAllRank.Count;
             rank.我的排名 = myRank;
         }
     }
     if (!String.IsNullOrEmpty(关键字))
     {
         listAllRank = listAllRank.Where(a => a.考生.编号.Contains(关键字) || a.考生.姓名.Contains(关键字)).ToList();
     }
     返回总条数 = listAllRank.Count;
     List<考试排名> listRank = listAllRank.Skip(第几页 * 页的大小).Take(页的大小).ToList();
     异常信息 = new LKPageException();
     return listAllRank;
 }
 public 绑定账号信息Models(绑定账号表 c绑定账号表, LKPageException lkPageException)
 {
     绑定账号表 = c绑定账号表;
     LKPageException = lkPageException;
 }
 public 绑定账号信息Models(LKPageException lkPageException)
 {
     LKPageException = lkPageException;
 }
 public 绑定账号信息Models(绑定账号表 c绑定账号表)
 {
     绑定账号表 = c绑定账号表;
     LKPageException = new LKPageException();
 }
 public 考试排行Models(PagedList<考试排名> pagedList考试排名, LKPageException lkPageException)
 {
     PagedList考试排名 = pagedList考试排名;
     LKPageException = lkPageException;
 }
Esempio n. 6
0
 /// <summary>
 /// 返回null说明未绑定
 /// </summary>
 /// <param name="result">0正常,1绑定账号被禁用,2禁止绑定任何账号</param>
 public static 绑定账号表 得到用户绑定信息(Guid 用户ID,out LKPageException 异常信息)
 {
     try
     {
         LoveKaoExamEntities db = new LoveKaoExamEntities();
         绑定账号表 bind = db.绑定账号表.Where(a => a.本地账号ID == 用户ID).FirstOrDefault();
         if (bind == null)
         {
             异常信息 = new LKPageException();
             return null;
         }
         else
         {
             LoveKaoServiceReference.LoveKaoServiceInterfaceClient client = new LoveKaoServiceReference.LoveKaoServiceInterfaceClient();
             int result = client.得到用户绑定信息(bind.爱考网账号);
             client.Close();
             if (result == 1)
             {
                 异常信息 = new LKPageException(异常处理.得到异常信息(1));
             }
             else if (result == 2)
             {
                 异常信息 = new LKPageException(异常处理.得到异常信息(2));
             }
             else
             {
                 异常信息 = new LKPageException();
             }
             return bind;
         }
     }
     catch (Exception)
     {
         异常信息 = new LKPageException(异常处理.得到无法连接爱考网异常信息(),3);
         return new 绑定账号表();
     }
 }