public StatsDto GetFacStats(Guid facilityId)
        {
            string sql = $@"
select
(select top 1 SiteCode from Facilities where id='{facilityId}') FacilityCode,
(select max(DateCreated) from Clients where facilityid='{facilityId}') Updated,
(select count(id) from Clients where facilityid='{facilityId}') HtsClientExtract,
(select count(id) from ClientLinkages where facilityid='{facilityId}') HtsClientLinkageExtract,
(select count(id) from HtsClientTests where facilityid='{facilityId}') HtsClientTestsExtract,
(select count(id) from HtsClientTracing where facilityid='{facilityId}') HtsClientTracingExtract,
(select count(id) from HtsPartnerNotificationServices where facilityid='{facilityId}') HtsPartnerNotificationServicesExtract,
(select count(id) from HtsPartnerTracings where facilityid='{facilityId}') HtsPartnerTracingExtract,
(select count(id) from HtsTestKits where facilityid='{facilityId}') HtsTestKitsExtract
                ";

            var result = GetDbConnection().Query <dynamic>(sql).FirstOrDefault();

            if (null != result)
            {
                var stats = new StatsDto(result.FacilityCode, result.Updated);
                stats.AddStats("HtsClientExtract", result.HtsClientExtract);
                stats.AddStats("HtsClientLinkageExtract", result.HtsClientLinkageExtract);
                stats.AddStats("HtsClientTestsExtract", result.HtsClientTestsExtract);
                stats.AddStats("HtsClientTracingExtract", result.HtsClientTracingExtract);
                stats.AddStats("HtsPartnerNotificationServicesExtract", result.HtsPartnerNotificationServicesExtract);
                stats.AddStats("HtsPartnerTracingExtract", result.HtsPartnerTracingExtract);
                stats.AddStats("HtsTestKitsExtract", result.HtsTestKitsExtract);

                return(stats);
            }

            return(null);
        }
Пример #2
0
        private void AppendStatisticData(ChampionDto champion, FormattedEmbedBuilder message)
        {
            StatsDto    stats          = champion.Stats;
            int         decimals       = 3;
            NumberAlign statList       = new NumberAlign(decimals, stats.GetStats());
            NumberAlign statGrowthList = new NumberAlign(decimals, stats.GetStatGrowthList());
            string      statData       =
                $"Health         - {statList.Align(stats.Hp)} | + {statGrowthList.TrimmedAlign(stats.HpPerLevel)}" +
                Environment.NewLine +
                $"Health Regen.  - {statList.Align(stats.HpRegen)} | + {statGrowthList.TrimmedAlign(stats.HpRegenPerLevel)}" +
                Environment.NewLine +
                $"Mana           - {statList.Align(stats.Mp)} | + {statGrowthList.TrimmedAlign(stats.MpPerLevel)}" +
                Environment.NewLine +
                $"Mana Regen     - {statList.Align(stats.MpRegen)} | + {statGrowthList.TrimmedAlign(stats.MpRegenPerLevel)}" +
                Environment.NewLine +
                $"Attack Damage  - {statList.Align(stats.AttackDamage)} | + {statGrowthList.TrimmedAlign(stats.AttackDamagePerLevel)}" +
                Environment.NewLine +
                $"Attack Speed   - {statList.Align(stats.GetBaseAttackSpeed())} | + {statGrowthList.TrimmedAlign(stats.AttackSpeedPerLevel)}%" +
                Environment.NewLine +
                $"Armor          - {statList.Align(stats.Armor)} | + {statGrowthList.TrimmedAlign(stats.ArmorPerLevel)}" +
                Environment.NewLine +
                $"Magic Resist   - {statList.Align(stats.Spellblock)} | + {statGrowthList.TrimmedAlign(stats.SpellblockPerLevel)}" +
                Environment.NewLine +
                $"Attack Range   - {statList.Align(stats.AttackRange)}" +
                Environment.NewLine +
                $"Movement Speed - {statList.Align(stats.MoveSpeed)}";

            message.AddField("Stats", statData,
                             new AppendOption[] { AppendOption.Underscore },
                             new AppendOption[] { AppendOption.Codeblock }, inline: false);
        }
Пример #3
0
        public async Task <IActionResult> GetStatForUserAsync(int examId)
        {
            StatsDto statsDto = new StatsDto
            {
                NumberOfCorrectAnswers = 0,
                NumberOfWrongAnswers   = 0
            };

            var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            var userAnwers = await _repo.UserAnswerRepository.GetUserAnswersAsync(examId, userId);

            foreach (var userAnswer in userAnwers)
            {
                if (userAnswer.Content == userAnswer.Question.Answers.FirstOrDefault(a => a.isCorrect).Content)
                {
                    statsDto.NumberOfCorrectAnswers++;
                }
                else
                {
                    statsDto.NumberOfWrongAnswers++;
                }
            }
            return(Ok(statsDto));
        }
Пример #4
0
        private void loadPiechart(StatsDto dtoObj)
        {
            panel_main.Controls.Clear();
            Control_pieChart pieChart = new Control_pieChart(dtoObj);

            pieChart.Dock = DockStyle.Fill;
            panel_main.Controls.Add(pieChart);
        }
Пример #5
0
        private void loadBarGraph(StatsDto dtoObj)
        {
            panel_main.Controls.Clear();
            Control_barGraph barGraph = new Control_barGraph(dtoObj);

            barGraph.Dock = DockStyle.Fill;
            panel_main.Controls.Add(barGraph);
        }
Пример #6
0
 public static IPokemonStats ToDomainObject(this StatsDto dto)
 {
     return(new PokemonStats
     {
         Attack = dto.Attack,
         Defence = dto.Defence,
         Health = dto.Health,
         SpecialAttack = dto.SpecialAttack,
         SpecialDefence = dto.SpecialDefence,
         Speed = dto.Speed
     });
 }
Пример #7
0
        public async Task <StatsDto> GetStats()
        {
            StatsDto statsDto = new StatsDto();

            using (IDbConnection con = new SqlConnection(Configuration["MyDbConnection"]))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                statsDto = con.Query <StatsDto>("GetStats", commandType: CommandType.StoredProcedure).FirstOrDefault();
            };
            return(statsDto);
        }
Пример #8
0
        private void loadAllDto()
        {
            if (piechartStudentDto == null)
            {
                piechartStudentDto = new StatsDto(Constant.IDENTIFIER_STUDENT);

                piechartStudentDto.value1 = statsManager.getPlacedStudentCount();
                piechartStudentDto.value2 = statsManager.getNonPlacedStudentCount();

                var dataMapList = new List <IDictionary <string, int> >();
                piechartStudentDto.dataMap.Add(statsManager.getStudentBranchData());
            }

            if (piechartCompanyDto == null)
            {
                piechartCompanyDto = new StatsDto(Constant.IDENTIFIER_COMPANY);

                var compStatList = statsManager.getCompanyStatCount();
                if (compStatList != null)
                {
                    foreach (Object[] objArr in compStatList)
                    {
                        if (EnumData.companyStatus.CONFIRMED.ToString() ==
                            Utility.getEnumValueByIndex(Constant.ENUM_COMPANY_STATUS, Convert.ToInt16(objArr[1])))
                        {
                            piechartCompanyDto.value1 = Convert.ToInt32(objArr[0]);
                        }
                        else
                        {
                            piechartCompanyDto.value2 = Convert.ToInt32(objArr[0]);
                        }
                    }
                }
                piechartCompanyDto.dataMap.Add(statsManager.getStudentCompanyData());
            }

            if (barMonthDto == null)
            {
                barMonthDto = new StatsDto();
                barMonthDto.dataMap.Add(statsManager.getMonthlyCompanyMap());
                barMonthDto.dataMap.Add(statsManager.getMonthlyStudentMap());
            }

            if (barYearDto == null)
            {
                barYearDto = new StatsDto();
                barYearDto.dataMap.Add(statsManager.getYearlyCompanyMap());
                barYearDto.dataMap.Add(statsManager.getYearlyStudentMap());
            }
        }
Пример #9
0
        /// <summary>
        /// Gets the stats.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public StatsDto GetStats()
        {
            var lstWeatherHistory = WeatherHistoryStorage.GetAll().ToList();
            var grouping          = lstWeatherHistory.GroupBy(wh => wh.Weather);
            var returnValue       = new StatsDto
            {
                DroughtPeriods      = grouping.FirstOrDefault(p => p.Key == WeatherCondition.Drought)?.Count(),
                StpPeriods          = grouping.FirstOrDefault(p => p.Key == WeatherCondition.STP)?.Count(),
                RainyPeriods        = grouping.FirstOrDefault(p => p.Key == WeatherCondition.Rainy)?.Count(),
                UnknownPeriods      = grouping.FirstOrDefault(p => p.Key == WeatherCondition.Unknown)?.Count(),
                MaxTrianglePerimter = lstWeatherHistory.Max(p => p.TrianglePerimeter)
            };

            return(returnValue);
        }
Пример #10
0
        public StatsDto GetFacStats(Guid facilityId)
        {
            string sql = $@"
select
(select top 1 {nameof(Facility.SiteCode)} from {nameof(MnchContext.Facilities)} where {nameof(Facility.Id)}='{facilityId}') FacilityCode,
(select ISNULL(max({nameof(PatientMnch.Created)}),GETDATE()) from {nameof(MnchContext.MnchPatients)} where {nameof(PatientMnch.FacilityId)}='{facilityId}') Updated,
(select count(id) from {nameof(MnchContext.MnchPatients)} where facilityid='{facilityId}') {nameof(PatientMnch)},
(select count(id) from {nameof(MnchContext.MnchEnrolments)} where facilityid='{facilityId}') {nameof(MnchEnrolment)},
(select count(id) from {nameof(MnchContext.MnchArts)} where facilityid='{facilityId}') {nameof(MnchArt)},
(select count(id) from {nameof(MnchContext.AncVisits)} where facilityid='{facilityId}') {nameof(AncVisit)},
(select count(id) from {nameof(MnchContext.MatVisits)} where facilityid='{facilityId}') {nameof(MatVisit)},
(select count(id) from {nameof(MnchContext.PncVisits)} where facilityid='{facilityId}') {nameof(PncVisit)},
(select count(id) from {nameof(MnchContext.MotherBabyPairs)} where facilityid='{facilityId}') {nameof(MotherBabyPair)},
(select count(id) from {nameof(MnchContext.CwcEnrolments)} where facilityid='{facilityId}') {nameof(CwcEnrolment)},
(select count(id) from {nameof(MnchContext.CwcVisits)} where facilityid='{facilityId}') {nameof(CwcVisit)},
(select count(id) from {nameof(MnchContext.Heis)} where facilityid='{facilityId}') {nameof(Hei)},
(select count(id) from {nameof(MnchContext.MnchLabs)} where facilityid='{facilityId}') {nameof(MnchLab)}
";

            var result = GetDbConnection().Query <dynamic>(sql).FirstOrDefault();

            if (null != result)
            {
                var stats = new StatsDto(result.FacilityCode, result.Updated);
                stats.AddStats($"{nameof(PatientMnch)}", result.PatientMnch);
                stats.AddStats($"{nameof(MnchEnrolment)}", result.MnchEnrolment);
                stats.AddStats($"{nameof(MnchArt)}", result.MnchArt);
                stats.AddStats($"{nameof(AncVisit)}", result.AncVisit);
                stats.AddStats($"{nameof(MatVisit)}", result.MatVisit);
                stats.AddStats($"{nameof(PncVisit)}", result.PncVisit);
                stats.AddStats($"{nameof(MotherBabyPair)}", result.MotherBabyPair);
                stats.AddStats($"{nameof(CwcEnrolment)}", result.CwcEnrolment);
                stats.AddStats($"{nameof(CwcVisit)}", result.CwcVisit);
                stats.AddStats($"{nameof(Hei)}", result.Hei);
                stats.AddStats($"{nameof(MnchLab)}", result.MnchLab);
                return(stats);
            }

            return(null);
        }
Пример #11
0
        public IHttpActionResult AddRecord(StatsDto statsDto)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append("StatsEvent: |");
            stringBuilder.Append($" {DateTime.Now:yyyy-MM-dd HH:mm:ss} |");
            stringBuilder.Append($" {statsDto.ApplicationName.PadRight(64)} |");
            stringBuilder.Append($" {statsDto.ApplicationVersion.PadRight(16)} |");
            stringBuilder.Append($" {statsDto.SourceName.PadRight(128)} |");
            stringBuilder.Append($" {statsDto.EventName.PadRight(32)} |");

            Debug.WriteLine(stringBuilder.ToString());

            Stats stats = Mapper.Map <StatsDto, Stats>(statsDto);

            stats.Data = stats.Data ?? "";

            _applicationDbContext.Stats.Add(stats);
            _applicationDbContext.SaveChanges();

            return(Ok());
        }
Пример #12
0
        public async Task <IActionResult> GetStatsForTeacherAsync(int examId)
        {
            var exam = await _repo.ExamRepository.GetExamAsync(examId);

            if (exam.AuthorId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            List <StatsDto> stats = new List <StatsDto>();
            var             users = await _repo.UserExamRepository.GetUsersFromExamAsync(examId);

            users = users.Where(u => u.Id != exam.AuthorId);
            foreach (var user in users)
            {
                StatsDto stat = new StatsDto()
                {
                    NumberOfCorrectAnswers = 0,
                    NumberOfWrongAnswers   = 0
                };
                stat.UserName = user.KnownAs;
                var userAnwers = await _repo.UserAnswerRepository.GetUserAnswersAsync(examId, user.Id);

                foreach (var userAnswer in userAnwers)
                {
                    if (userAnswer.Content == userAnswer.Question.Answers.FirstOrDefault(a => a.isCorrect).Content)
                    {
                        stat.NumberOfCorrectAnswers++;
                    }
                    else
                    {
                        stat.NumberOfWrongAnswers++;
                    }
                }
                stats.Add(stat);
            }
            return(Ok(stats));
        }
 public Control_pieChart(StatsDto dtoObj)
 {
     this.dtoObj = dtoObj;
     InitializeComponent();
 }
Пример #14
0
 public Control_barGraph(StatsDto dtoObj)
 {
     this.dtoObj = dtoObj;
     InitializeComponent();
 }
        public HttpResponseMessage UploadStatsV2()
        {
            HttpResponseMessage response = new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                HttpRequest request = HttpContext.Current.Request;

                StreamReader sr       = new StreamReader(request.InputStream);
                StatsDto     newstats = JsonConvert.DeserializeObject <StatsDto>(sr.ReadToEnd());

                if (newstats == null)
                {
                    response.Content = new StringContent("notstats", Encoding.UTF8, "text/plain");
                    return(response);
                }

                DicServerContext ctx = new DicServerContext();

                if (newstats.Commands != null)
                {
                    foreach (NameValueStats nvs in newstats.Commands)
                    {
                        Command existing = ctx.Commands.FirstOrDefault(c => c.Name == nvs.name);

                        if (existing == null)
                        {
                            ctx.Commands.Add(new Command {
                                Name = nvs.name, Count = nvs.Value
                            });
                        }
                        else
                        {
                            existing.Count += nvs.Value;
                        }
                    }
                }

                if (newstats.Versions != null)
                {
                    foreach (NameValueStats nvs in newstats.Versions)
                    {
                        Version existing = ctx.Versions.FirstOrDefault(c => c.Value == nvs.name);

                        if (existing == null)
                        {
                            ctx.Versions.Add(new Version {
                                Value = nvs.name, Count = nvs.Value
                            });
                        }
                        else
                        {
                            existing.Count += nvs.Value;
                        }
                    }
                }

                if (newstats.Filesystems != null)
                {
                    foreach (NameValueStats nvs in newstats.Filesystems)
                    {
                        Filesystem existing = ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name);

                        if (existing == null)
                        {
                            ctx.Filesystems.Add(new Filesystem {
                                Name = nvs.name, Count = nvs.Value
                            });
                        }
                        else
                        {
                            existing.Count += nvs.Value;
                        }
                    }
                }

                if (newstats.Partitions != null)
                {
                    foreach (NameValueStats nvs in newstats.Partitions)
                    {
                        Partition existing = ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name);

                        if (existing == null)
                        {
                            ctx.Partitions.Add(new Partition {
                                Name = nvs.name, Count = nvs.Value
                            });
                        }
                        else
                        {
                            existing.Count += nvs.Value;
                        }
                    }
                }

                if (newstats.MediaFormats != null)
                {
                    foreach (NameValueStats nvs in newstats.MediaFormats)
                    {
                        MediaFormat existing = ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name);

                        if (existing == null)
                        {
                            ctx.MediaFormats.Add(new MediaFormat {
                                Name = nvs.name, Count = nvs.Value
                            });
                        }
                        else
                        {
                            existing.Count += nvs.Value;
                        }
                    }
                }

                if (newstats.Filters != null)
                {
                    foreach (NameValueStats nvs in newstats.Filters)
                    {
                        Filter existing = ctx.Filters.FirstOrDefault(c => c.Name == nvs.name);

                        if (existing == null)
                        {
                            ctx.Filters.Add(new Filter {
                                Name = nvs.name, Count = nvs.Value
                            });
                        }
                        else
                        {
                            existing.Count += nvs.Value;
                        }
                    }
                }

                if (newstats.OperatingSystems != null)
                {
                    foreach (OsStats operatingSystem in newstats.OperatingSystems)
                    {
                        OperatingSystem existing =
                            ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name &&
                                                                c.Version == operatingSystem.version);

                        if (existing == null)
                        {
                            ctx.OperatingSystems.Add(new OperatingSystem
                            {
                                Name    = operatingSystem.name,
                                Version = operatingSystem.version,
                                Count   = operatingSystem.Value
                            });
                        }
                        else
                        {
                            existing.Count += operatingSystem.Value;
                        }
                    }
                }

                if (newstats.Medias != null)
                {
                    foreach (MediaStats media in newstats.Medias)
                    {
                        Media existing = ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real);

                        if (existing == null)
                        {
                            ctx.Medias.Add(new Media {
                                Type = media.type, Real = media.real, Count = media.Value
                            });
                        }
                        else
                        {
                            existing.Count += media.Value;
                        }
                    }
                }

                if (newstats.Devices != null)
                {
                    foreach (DeviceStats device in newstats.Devices)
                    {
                        DeviceStat existing =
                            ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus &&
                                                           c.Manufacturer == device.Manufacturer &&
                                                           c.Model == device.Model &&
                                                           c.Revision == device.Revision);

                        if (existing == null)
                        {
                            ctx.DeviceStats.Add(new DeviceStat
                            {
                                Bus          = device.Bus,
                                Manufacturer = device.Manufacturer,
                                Model        = device.Model,
                                Revision     = device.Revision
                            });
                        }
                    }
                }

                ctx.SaveChanges();

                response.Content = new StringContent("ok", Encoding.UTF8, "text/plain");
                return(response);
            }
            // ReSharper disable once RedundantCatchClause
            catch
            {
                #if DEBUG
                if (Debugger.IsAttached)
                {
                    throw;
                }
                #endif
                response.Content = new StringContent("error", Encoding.UTF8, "text/plain");
                return(response);
            }
        }
        public async Task <StatsDto> MapToDto(Stats entity)
        {
            var dto = new StatsDto();

            return((StatsDto)dto.InjectFrom(entity));
        }
        public async Task <Stats> MapToEntity(StatsDto dto)
        {
            var entity = new Stats();

            return((Stats)entity.InjectFrom(dto));
        }