コード例 #1
0
        public static void UpdateSingleUser(int contest_id, Entity.StandingItem si)
        {
            var userindex = (Standings[contest_id] as List <Entity.StandingItem>).FindIndex(x => x.UserID == si.UserID);

            if (userindex == -1)
            {
                (Standings[contest_id] as List <Entity.StandingItem>).Add(si);
            }
            else
            {
                (Standings[contest_id] as List <Entity.StandingItem>)[userindex] = si;
            }
        }
コード例 #2
0
ファイル: ServerCallback.cs プロジェクト: w7yuu/CenaPlus
 public void StandingsPush(int contest_id, Entity.StandingItem si)
 {
     if (Bll.StandingsCache.Standings[contest_id] == null)
     {
         Thread t = new Thread(GetStandingsProc);
         t.Start(contest_id);
     }
     else
     {
         StandingsCache.UpdateSingleUser(contest_id, si);
     }
     if (OnStandingPushed != null)
     {
         System.Threading.Tasks.Task.Factory.StartNew(() => OnStandingPushed(contest_id, si));
     }
 }
コード例 #3
0
 /// <summary>
 /// 重构某用户的排名信息
 /// </summary>
 /// <param name="user_id"></param>
 /// <param name="contest_id"></param>
 /// <param name="problemids"></param>
 public static void UpdateSingleUser(int user_id, int contest_id, List <int> problemids)
 {
     using (Dal.DB db = new Dal.DB())
     {
         Entity.StandingItem standing = new Entity.StandingItem();
         standing.Type = (Entity.ContestType)(from c in db.Contests
                                              where c.ID == contest_id
                                              select c.TypeAsInt).FirstOrDefault();
         standing.UserID     = user_id;
         standing.Competitor = (from u in db.Users
                                where u.ID == user_id
                                select u.NickName).FirstOrDefault();
         if (standing.Type == Entity.ContestType.Codeforces || standing.Type == Entity.ContestType.TopCoder)
         {
             standing.SuccessfulHack = (from h in db.Hacks
                                        where h.HackerID == user_id &&
                                        h.StatusAsInt == (int)Entity.HackStatus.Success &&
                                        problemids.Contains(h.Record.Problem.ID)
                                        select h.ID).Count();
             standing.UnsuccessfulHack = (from h in db.Hacks
                                          where h.HackerID == user_id &&
                                          h.StatusAsInt == (int)Entity.HackStatus.Failure &&
                                          problemids.Contains(h.Record.Problem.ID)
                                          select h.ID).Count();
         }
         if (standing.Details == null)
         {
             standing.Details = new Entity.StandingDetail[problemids.Count];
         }
         int userindex = (Standings[contest_id] as List <Entity.StandingItem>).FindIndex(x => x.UserID == user_id);
         if (userindex == -1)
         {
             (Standings[contest_id] as List <Entity.StandingItem>).Add(standing);
         }
         else
         {
             (Standings[contest_id] as List <Entity.StandingItem>)[userindex] = standing;
         }
         foreach (int problem_id in problemids)
         {
             UpdateSingleDetail(user_id, problem_id, contest_id, standing.Type);
         }
     }
 }
コード例 #4
0
 public void Refresh(int contest_id, Entity.StandingItem si)
 {
     Dispatcher.Invoke(new Action(() => {
         if (contest_id == this.contest_id)
         {
             var standingindex = StandingItems.FindIndex(x => x.UserID == si.UserID);
             if (standingindex == -1)
             {
                 StandingItems.Add(si);
             }
             else
             {
                 StandingItems[standingindex] = si;
             }
             Sort();
             dgStandings.Items.Refresh();
         }
     }));
 }
コード例 #5
0
 public void StandingsPush(int contest_id, Entity.StandingItem si)
 {
     if (Bll.StandingsCache.Standings[contest_id] == null)
     {
         System.Threading.Tasks.Task.Factory.StartNew(() =>
         {
             App.Current.Dispatcher.Invoke(new Action(() =>
             {
                 App.Server.GetStandings(contest_id);
             }));
         });
     }
     else
     {
         StandingsCache.UpdateSingleUser(contest_id, si);
     }
     if (OnStandingPushed != null)
     {
         System.Threading.Tasks.Task.Factory.StartNew(() => OnStandingPushed(contest_id, si));
     }
 }
コード例 #6
0
ファイル: StandingsCache.cs プロジェクト: wan-qy/CenaPlus
 /// <summary>
 /// 重构某用户的排名信息
 /// </summary>
 /// <param name="user_id"></param>
 /// <param name="contest_id"></param>
 /// <param name="problemids"></param>
 public static void UpdateSingleUser(int user_id, int contest_id, List<int> problemids)
 {
     using (Dal.DB db = new Dal.DB())
     {
         Entity.StandingItem standing = new Entity.StandingItem();
         standing.Type = (Entity.ContestType)(from c in db.Contests
                                               where c.ID == contest_id
                                               select c.TypeAsInt).FirstOrDefault();
         standing.UserID = user_id;
         standing.Competitor = (from u in db.Users
                                 where u.ID == user_id
                                 select u.NickName).FirstOrDefault();
         if (standing.Type == Entity.ContestType.Codeforces || standing.Type == Entity.ContestType.TopCoder)
         {
             standing.SuccessfulHack = (from h in db.Hacks
                                         where h.HackerID == user_id
                                         && h.StatusAsInt == (int)Entity.HackStatus.Success
                                         && problemids.Contains(h.Record.Problem.ID)
                                         select h.ID).Count();
             standing.UnsuccessfulHack = (from h in db.Hacks
                                           where h.HackerID == user_id
                                           && h.StatusAsInt == (int)Entity.HackStatus.Failure
                                           && problemids.Contains(h.Record.Problem.ID)
                                           select h.ID).Count();
         }
         if (standing.Details == null)
             standing.Details = new Entity.StandingDetail[problemids.Count];
         int userindex=(Standings[contest_id] as List<Entity.StandingItem>).FindIndex(x=>x.UserID==user_id);
         if (userindex == -1)
         {
             (Standings[contest_id] as List<Entity.StandingItem>).Add(standing);
         }
         else
         {
             (Standings[contest_id] as List<Entity.StandingItem>)[userindex] = standing;
         }
         foreach (int problem_id in problemids)
         {
             UpdateSingleDetail(user_id, problem_id, contest_id, standing.Type);
         }
     }
 }