Пример #1
0
        private void ProcessList()
        {
            if (currentUser == null)
            {
                //currentUser = LocalDatabase.DefaultUser;
                currentUser = new UserInfo();
                currentUser.uid = currentUser.uname = currentUser.name = "[-]";
                currentUser.subs = new List<List<long>>();
                currentUser.Process();
            }

            userRank = RegistryAccess.GetUserRank(currentUser.uname);
            if (userRank == null)
            {
                userRank = new UserRanklist();
                userRank.username = currentUser.uname;
                userRank.rank = 0;
                userRank.activity = new List<long>();
                for (int i = 0; i < 5; ++i) userRank.activity.Add(0);
            }

            _acOverTime.Clear();
            _subOverTime.Clear();
            _RankCount.Clear();

            _firstSub = long.MaxValue;
            _solvedCount = _unsolvedCount = _tryCount = _totalSubmission = 0;
            _subInAnsiC = _subInCPP = _subInCPP11 = _subInJava = _subInPascal = 0;
            _acCount = _waCount = _tleCount = _reCount = _peCount = 0;
            _ceCount = _oleCount = _subeCount = _mleCount = 0;

            List<long> solved = new List<long>();

            foreach (UserSubmission usub in currentUser.submissions)
            {
                //total submission count
                _totalSubmission++;

                //age meter
                if (_firstSub > usub.sbt)
                    _firstSub = usub.sbt;

                //add rank count
                if (usub.IsAccepted())
                {
                    _RankCount.Add(usub.rank, usub.pid);

                    //solve count
                    if (!solved.Contains(usub.pnum))
                    {
                        _solvedCount++;
                        solved.Add(usub.pnum);
                    }
                }

                //language
                switch ((Language)usub.lan)
                {
                    case Language.C: _subInAnsiC++; break;
                    case Language.Java: _subInJava++; break;
                    case Language.Pascal: _subInPascal++; break;
                    case Language.CPP: _subInCPP++; break;
                    case Language.CPP11: _subInCPP11++; break;
                }

                //submissionPerTime
                double xval = new ZedGraph.XDate(UnixTimestamp.FromUnixTime(usub.sbt));
                if (_totalSubmission == 1) _subOverTime.Add(xval, 0);

                _subOverTime.Add(xval, _totalSubmission);
                _acOverTime.Add(xval, _solvedCount);

                //verdict
                switch ((Verdict)usub.ver)
                {
                    case Structures.Verdict.CompileError: _ceCount++; break;
                    case Structures.Verdict.RuntimeError: _reCount++; break;
                    case Structures.Verdict.OutputLimit: _oleCount++; break;
                    case Structures.Verdict.TimLimit: _tleCount++; break;
                    case Structures.Verdict.MemoryLimit: _mleCount++; break;
                    case Structures.Verdict.WrongAnswer: _waCount++; break;
                    case Structures.Verdict.PresentationError: _peCount++; break;
                    case Structures.Verdict.Accepted: _acCount++; break;
                }
            }

            //finalize
            _tryCount = currentUser.TryList.Count;
            _unsolvedCount = _tryCount - _solvedCount;
            _subOverTime.Add(new ZedGraph.XDate(DateTime.Now), _totalSubmission);
            _acOverTime.Add(new ZedGraph.XDate(DateTime.Now), _solvedCount);
        }
Пример #2
0
        //
        // User Rank
        //
        /// <summary>
        /// Set rank-list of a user
        /// </summary>
        /// <param name="urank">User rank to save</param>
        public static void SetUserRank(Structures.UserRanklist urank)
        {
            string data = JsonConvert.SerializeObject(urank);

            SetValue(urank.username, data, "User Rank", RegistryValueKind.String);
        }
Пример #3
0
        private void BringUserToMiddle(UserRanklist usub)
        {
            if (usub == null) return;

            int midpt = worldRanklist.Height / 2;
            int item = worldRanklist.GetItemAt(1, midpt).Index;
            int indx = worldRanklist.IndexOf(usub);
            for (int i = indx; i < worldRanklist.GetItemCount() && indx > item; ++i)
            {
                worldRanklist.EnsureVisible(i);
                item = worldRanklist.GetItemAt(1, midpt).Index;
            }
        }