コード例 #1
0
        private void getStudent(long BaseId)
        {
            try
            {
                var query = GetAllStudentsAsync(BaseId);
                query.Wait();

                List <DataClass.DataTransferObjects.StudentsScoresDto> data = query.Result;

                if (data.Any())
                {
                    var res = data.GroupBy(x => new { x.StudentId })
                              .Select(x => new
                    {
                        x.Key.StudentId,
                        Name  = x.FirstOrDefault().Name,
                        LName = x.FirstOrDefault().LName,
                        FName = x.FirstOrDefault().FName,
                        Sum   = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
                    }).OrderByDescending(x => x.Sum).ToArray();

                    dataGrid.ItemsSource = res.ToList();
                }
                else
                {
                    dataGrid.ItemsSource = null;
                    MainWindow.main.showGrowlNotification(NotificationKEY: AppVariable.No_Data_KEY, param: "TopStudent");
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #2
0
        public void getTopStudent(long BaseId)
        {
            using (var db = new DataClass.myDbContext())
            {
                var query = db.Scores.Join(
                    db.Students,
                    c => c.StudentId,
                    v => v.Id,
                    (c, v) => new DataClass.DataTransferObjects.StudentsScoresDto {
                    Id = c.Id, BaseId = v.BaseId, StudentId = v.Id, Name = v.Name, LName = v.LName, FName = v.FName, Scores = c.Scores
                }
                    ).OrderBy(x => x.Scores).Where(x => x.BaseId == BaseId).ToList();


                var res = query.GroupBy(x => new { x.StudentId })
                          .Select(x => new
                {
                    x.Key.StudentId,
                    Name  = x.FirstOrDefault().Name,
                    LName = x.FirstOrDefault().LName,
                    FName = x.FirstOrDefault().FName,
                    Sum   = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
                }).OrderByDescending(x => x.Sum).Take(6).ToArray();

                foreach (var item in res)
                {
                    Arthas.Controls.Metro.MetroProgressBar metroProgressBar;
                    TextBlock textBlock;
                    Control   _currentUser;
                    metroProgressBar = new Arthas.Controls.Metro.MetroProgressBar()
                    {
                        FlowDirection = FlowDirection.LeftToRight,
                        Background    = AppVariable.GetBrush("#15a4fa"),
                        CornerRadius  = new CornerRadius(0),
                        Value         = item.Sum
                    };
                    textBlock = new TextBlock()
                    {
                        Opacity  = .4,
                        Margin   = new Thickness(0, 5, 0, 0),
                        FontSize = 15,
                        Text     = item.Name + " " + item.LName
                    };


                    _currentUser = metroProgressBar;
                    stkDash.Children.Add(textBlock);

                    stkDash.Children.Add(_currentUser);
                }
            }
        }
コード例 #3
0
        //get Scores to double[]
        private double[] getScoreArray(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            return(score.Select(x => Convert.ToDouble(x.Sum)).ToArray());
        }
コード例 #4
0
        private List <DataClass.DataTransferObjects.myChartTemplate> getDataList(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            return(score.Select(x => new DataClass.DataTransferObjects.myChartTemplate {
                Book = x.Book, Caption = x.Date, Scores = x.Sum, StudentId = x.StudentId
            }).ToList());
        }
コード例 #5
0
        //get Score Average to string
        private string getAverage(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();
            var dCount = score.Select(x => x.Date).Count();
            var sum    = score.Sum(x => x.Sum);

            return(decimal.Divide(sum, dCount).ToString("0.00"));
        }
コード例 #6
0
        private string getAverageStatus(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            var sum = score.Sum(x => x.Sum);

            var dCount = score.Select(x => x.Date).Count();

            var Avg = decimal.Divide(sum, dCount).ToString("0.00");

            var one   = decimal.Divide(dCount * 4, 1).ToString("0.00");
            var sec   = decimal.Divide(dCount * 4, 2).ToString("0.00");
            var thi   = decimal.Divide(dCount * 4, 3).ToString("0.00");
            var forth = decimal.Divide(dCount * 4, 4).ToString("0.00");

            string status = string.Empty;

            if (Convert.ToDecimal(Avg) >= Convert.ToDecimal(sec))
            {
                status = "خیلی خوب";
            }
            else if (Convert.ToDecimal(Avg) < Convert.ToDecimal(one) && Convert.ToDecimal(Avg) >= Convert.ToDecimal(thi))
            {
                status = "خوب";
            }
            else if (Convert.ToDecimal(Avg) < Convert.ToDecimal(sec) && Convert.ToDecimal(Avg) >= Convert.ToDecimal(forth))
            {
                status = "قابل قبول";
            }
            else if (Convert.ToDecimal(Avg) < Convert.ToDecimal(forth))
            {
                status = "نیاز به تلاش بیشتر";
            }

            return(status);
        }
コード例 #7
0
        private string getAverageStatus(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            var sum = score.Sum(x => x.Sum);

            var dCount = score.Select(x => x.Date).Count();

            var TotalScore = Convert.ToDecimal(dCount * 4);
            var HalfScore  = Convert.ToDecimal(decimal.Divide(dCount * 4, 2).ToString("0.00"));
            var ThirdScore = Convert.ToDecimal(decimal.Divide(dCount * 4, 3).ToString("0.00"));
            var ForthScore = Convert.ToDecimal(decimal.Divide(dCount * 4, 4).ToString("0.00"));

            string status = string.Empty;

            if (sum == TotalScore || (TotalScore - sum) <= 1)
            {
                status = "خیلی خوب";
            }
            else if (sum >= HalfScore && sum < TotalScore)
            {
                status = "خوب";
            }
            else if (sum >= ThirdScore && sum < HalfScore)
            {
                status = "قابل قبول";
            }
            else if (sum >= ForthScore && sum < ThirdScore || sum <= ForthScore)
            {
                status = "نیاز به تلاش بیشتر";
            }

            return(status);
        }
コード例 #8
0
        private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                dynamic selectedItem = dataGrid.SelectedItems[0];

                waterfallFlow.Children.Clear();

                getStudentScore(selectedItem.Id); // get Student scores

                //get scores merge duplicates and replace string to int
                var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                            .Select(x => new
                {
                    x.Key.StudentId,
                    x.Key.Book,
                    x.Key.Date,
                    Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
                }).ToArray();

                //get Book Count for generate chart
                var bookCount = score.GroupBy(x => new { x.Book })
                                .Select(g => new
                {
                    g.Key.Book
                }).ToList();

                //generate chart based on count of books
                foreach (var item in bookCount)
                {
                    Mapper = Mappers.Xy <DataClass.DataTransferObjects.myChartTemplate>()
                             .X((myData, index) => index)
                             .Y(myData => myData.Scores);

                    var records = getDataList(item.Book).OrderByDescending(x => x.Caption).ToArray();

                    Results = records.AsChartValues();

                    Labels = new ObservableCollection <string>(records.Select(x => x.Caption));

                    var chart = new CartesianChart();

                    var series = new SeriesCollection
                    {
                        new ColumnSeries {
                            Title         = item.Book + Environment.NewLine + getAverageStatus(item.Book) + Environment.NewLine + "میانگین: " + getAverage(item.Book),
                            Configuration = Mapper, Values = Results, DataLabels = true, FontFamily = TryFindResource("TeacherYar.Fonts.IRANSans") as FontFamily,
                            Fill          = TryFindResource("PrimaryBrush") as Brush
                        }
                    };
                    chart.Margin         = new System.Windows.Thickness(5);
                    chart.Series         = series;
                    chart.LegendLocation = LegendLocation.Top;
                    chart.AxisX.Add(new Axis
                    {
                        FontFamily     = TryFindResource("TeacherYar.Fonts.IRANSans") as FontFamily,
                        Labels         = Labels,
                        LabelsRotation = -20,
                        Separator      = new LiveCharts.Wpf.Separator {
                            Step = 1
                        }
                    });
                    chart.AxisY.Add(new Axis {
                        FontFamily = TryFindResource("TeacherYar.Fonts.IRANSans") as FontFamily
                    });
                    chart.DataTooltip.Background = TryFindResource("SecondaryRegionBrush") as Brush;
                    var mainBorder = new Border();
                    mainBorder.Width        = 300;
                    mainBorder.Height       = 320;
                    mainBorder.Effect       = TryFindResource("EffectShadow3") as Effect;
                    mainBorder.CornerRadius = new System.Windows.CornerRadius(5);
                    mainBorder.Margin       = new System.Windows.Thickness(10);
                    mainBorder.Background   = TryFindResource("RegionBrush") as Brush;
                    mainBorder.Child        = chart;

                    waterfallFlow.Children.Add(mainBorder);
                }
            }
            catch (ArgumentNullException) { }
            catch (NullReferenceException)
            {
            }
        }
コード例 #9
0
        private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                dynamic selectedItem = dataGrid.SelectedItems[0];

                waterfallFlow.Children.Clear();
                Series series = new ColumnSeries();

                switch (FindElement.Settings.ChartType ?? 0)
                {
                case 0:
                    series = new ColumnSeries {
                    };
                    break;

                case 1:
                    series = new StackedColumnSeries {
                    };
                    break;

                case 2:
                    series = new LineSeries {
                    };
                    break;

                case 3:
                    series = new StepLineSeries {
                    };
                    break;

                case 4:
                    series = new StackedAreaSeries {
                    };
                    break;
                }

                getStudentScore(selectedItem.Id); // get Student scores

                //get scores merge duplicates and replace string to int
                var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                            .Select(x => new
                {
                    x.Key.StudentId,
                    x.Key.Book,
                    x.Key.Date,
                    Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
                }).ToArray();

                //get Book Count for generate chart
                var bookCount = score.GroupBy(x => new { x.Book })
                                .Select(g => new
                {
                    g.Key.Book
                }).ToList();

                MaterialChart _addUser;
                Control       _currentUser;

                //generate chart based on count of books
                foreach (var item in bookCount)
                {
                    _addUser     = new MaterialChart(item.Book, selectedItem.Name + " " + selectedItem.LName, getDateArray(item.Book), getScoreArray(item.Book), getAverage(item.Book), getAverageStatus(item.Book), series, AppVariable.GetBrush(FindElement.Settings.ChartColor ?? AppVariable.CHART_GREEN));
                    _currentUser = _addUser;
                    waterfallFlow.Children.Add(_currentUser);
                }

                waterfallFlow.Refresh();
            }
            catch (ArgumentNullException) { }
            catch (NullReferenceException)
            {
            }
        }