Esempio n. 1
0
        private void ByMonths(object sender, EventArgs e)
        {
            try
            {
                System.Data.SqlClient.SqlCommand mnth = Statistics.Purchases.ByMonths();
                mnth.Connection = this.connection;
                System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(mnth);
                System.Data.DataTable st = new System.Data.DataTable("Summary");
                sda.Fill(st);

                ZedGraph.GraphPane pane = this.zgcStatistics.GraphPane;
                pane.CurveList.Clear();
                pane.GraphObjList.Clear();

                pane.YAxis.Title.Text = "Сумма, р";
                ZedGraph.PointPairList list = new ZedGraph.PointPairList();
                foreach (System.Data.DataRow row in st.Rows)
                {
                    int year = 1970;
                    int month = 1;
                    if(!System.Convert.IsDBNull(row["Year"]) &&
                       !System.Convert.IsDBNull(row["Month"]) ){
                        year = (int)row["Year"];
                        month = (int)row["Month"];
                        System.DateTime dt = new DateTime(year, month, 1);
                        ZedGraph.XDate xDate = new ZedGraph.XDate(dt);
                        decimal val = (decimal)row["Summary"];
                        list.Add(xDate.XLDate, (double)val);
                    }
                }
                ZedGraph.BarItem curve = pane.AddBar("", list, Color.Blue);

                // Для оси X установим календарный тип
                pane.XAxis.Type = ZedGraph.AxisType.Date;

                // pretty it up a little
                pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
                pane.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);

                // Tell ZedGraph to calculate the axis ranges
                this.zgcStatistics.AxisChange();
                this.zgcStatistics.Invalidate();
            }catch (System.Exception ex){
                MessageBox.Show(ex.Message);
            }
            return;
        }
Esempio n. 2
0
        private void ProcessList()
        {
            if (currentUser == null)
            {
                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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private void ByVendorsPerMonth(object sender, EventArgs e)
        {
            try
            {
                if( this.lbxObjects.SelectedItems.Count > 0 ){
                    List<Guid> ids = new List<Guid>();
                    //foreach( ListViewItem obj in this.lbxObjects.SelectedItems ){
                    foreach( DataRowView obj in this.lbxObjects.SelectedItems ){
                        if (!System.Convert.IsDBNull(obj["VendorID"]))
                            ids.Add((Guid)obj["VendorID"]);
                    }
                    System.Data.SqlClient.SqlCommand mnth = Statistics.Purchases.ByVendorsPerMonth(ids);
                    mnth.Connection = this.connection;
                    System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(mnth);
                    System.Data.DataTable st = new System.Data.DataTable("Summary");
                    sda.Fill(st);

                    ZedGraph.GraphPane pane = this.zgcStatistics.GraphPane;
                    pane.CurveList.Clear();
                    pane.GraphObjList.Clear();

                    pane.YAxis.Title.Text = "Сумма, р";
                    System.Collections.Hashtable lsts = new System.Collections.Hashtable();

                    foreach (System.Data.DataRow row in st.Rows)
                    {
                        ZedGraph.PointPairList list = null;
                        string v_name = (string)row["VendorName"];
                        if (lsts.ContainsKey(v_name))
                        {
                            list = (ZedGraph.PointPairList)lsts[v_name];
                        }
                        else
                        {
                            list = new ZedGraph.PointPairList();
                            lsts.Add(v_name, list);
                        }
                        int year = 1970;
                        int month = 1;
                        if (!System.Convert.IsDBNull(row["Year"]) &&
                           !System.Convert.IsDBNull(row["Month"]))
                        {
                            year = (int)row["Year"];
                            month = (int)row["Month"];
                            System.DateTime dt = new DateTime(year, month, 1);
                            ZedGraph.XDate xDate = new ZedGraph.XDate(dt);
                            decimal val = (decimal)row["Summary"];
                            list.Add(xDate.XLDate, (double)val);
                        }
                    }

                    Random rand = new Random();
                    System.Collections.IEnumerator lenum = lsts.GetEnumerator();
                    while(lenum.MoveNext() )
                    {
                        int r = rand.Next(255);
                        int g = rand.Next(255);
                        int b = rand.Next(255);
                        Color clr = Color.FromArgb(r, g, b);
                        System.Collections.DictionaryEntry lde = (System.Collections.DictionaryEntry)lenum.Current;
                        ZedGraph.BarItem curve = pane.AddBar((string)lde.Key, (ZedGraph.PointPairList)lde.Value, clr);
                    }

                    // Для оси X установим календарный тип
                    pane.XAxis.Type = ZedGraph.AxisType.Date;

                    // pretty it up a little
                    pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
                    pane.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);

                    // Tell ZedGraph to calculate the axis ranges
                    this.zgcStatistics.AxisChange();
                    this.zgcStatistics.Invalidate();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return;
        }