Esempio n. 1
0
        private void SetTried(UserSubmission usub)
        {
            if (!HasTried(usub.pnum))
            {
                TryList.Add(usub.pnum, usub);
                return;
            }

            if (usub.IsInQueue())
            {
                return;
            }
            if (TryList[usub.pnum].rank <= 0 || usub.rank < TryList[usub.pnum].rank)
            {
                TryList[usub.pnum] = usub;
            }
        }
Esempio n. 2
0
        private void SetTried(UserSubmission usub)
        {
            if (!HasTried(usub.pnum))
            {
                TryList.Add(usub.pnum, usub);
                return;
            }

            if (usub.IsInQueue()) return;
            if (TryList[usub.pnum].rank <= 0 || usub.rank < TryList[usub.pnum].rank)
            {
                TryList[usub.pnum] = usub;
            }
        }
Esempio n. 3
0
        private void ProcessListData(List <List <long> > allsub, bool addToDef = false)
        {
            if (subs == null)
            {
                subs = new List <List <long> >();
            }

            bool needToSort = false;
            bool isdef      = (this.uname == RegistryAccess.DefaultUsername);

            foreach (List <long> lst in allsub)
            {
                try
                {
                    UserSubmission usub = new UserSubmission(lst);

                    //remove usub if already existed
                    if (sidToSub.ContainsKey(usub.sid))
                    {
                        if (usub.IsInQueue())
                        {
                            continue;
                        }
                        submissions.Remove(sidToSub[usub.sid]);
                        sidToSub.Remove(usub.sid);
                    }

                    //set the properties to usub add add to list
                    usub.name  = name;
                    usub.uname = uname;
                    submissions.Add(usub);
                    sidToSub.Add(usub.sid, usub);
                    needToSort = true;

                    //if usub is not in the queue add it
                    if (!usub.IsInQueue())
                    {
                        if (addToDef)
                        {
                            subs.Add(lst);
                        }
                        if (this.LastSID < usub.sid)
                        {
                            this.LastSID = usub.sid;
                        }
                    }

                    SetTried(usub);
                    if (isdef && IsSolved(usub.pnum))
                    {
                        ProblemInfo prob = LocalDatabase.GetProblem(usub.pnum);
                        if (prob != null)
                        {
                            prob.Solved = true;
                        }
                    }
                }
                catch { }
            }

            //sort by sid
            if (needToSort)
            {
                submissions.Sort((Comparison <UserSubmission>)
                                 delegate(UserSubmission a, UserSubmission b)
                {
                    return((int)(a.sid - b.sid));
                });
            }
        }
Esempio n. 4
0
        private void ProcessListData(List<List<long>> allsub, bool addToDef = false)
        {
            if (subs == null) subs = new List<List<long>>();

            bool needToSort = false;
            bool isdef = (this.uname == RegistryAccess.DefaultUsername);
            foreach (List<long> lst in allsub)
            {
                try
                {
                    UserSubmission usub = new UserSubmission(lst);

                    //remove usub if already existed
                    if (sidToSub.ContainsKey(usub.sid))
                    {
                        if (usub.IsInQueue()) continue;
                        submissions.Remove(sidToSub[usub.sid]);
                        sidToSub.Remove(usub.sid);
                    }

                    //set the properties to usub add add to list
                    usub.name = name;
                    usub.uname = uname;
                    submissions.Add(usub);
                    sidToSub.Add(usub.sid, usub);
                    needToSort = true;

                    //if usub is not in the queue add it
                    if (!usub.IsInQueue())
                    {
                        if (addToDef) subs.Add(lst);
                        if (this.LastSID < usub.sid)
                        {
                            this.LastSID = usub.sid;
                        }
                    }

                    SetTried(usub);
                    if (isdef && IsSolved(usub.pnum))
                    {
                        ProblemInfo prob = LocalDatabase.GetProblem(usub.pnum);
                        if (prob != null) prob.Solved = true;
                    }
                }
                catch { }
            }

            //sort by sid
            if (needToSort)
            {
                submissions.Sort((Comparison<UserSubmission>)
                   delegate(UserSubmission a, UserSubmission b)
                   {
                       return (int)(a.sid - b.sid);
                   });
            }
        }