Ejemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync(int offset, EFPenalty.PenaltyType showOnly, bool ignoreAutomated)
        {
            var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly, ignoreAutomated);

            penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList();

            return(View("~/Views/Penalty/PenaltyInfoList.cshtml", penalties));
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> ListAsync(int offset = 0, EFPenalty.PenaltyType showOnly = EFPenalty.PenaltyType.Any, bool hideAutomatedPenalties = true)
 {
     return(await Task.FromResult(View("_List", new ViewModels.PenaltyFilterInfo()
     {
         Offset = offset,
         ShowOnly = showOnly,
         IgnoreAutomated = hideAutomatedPenalties
     })));
 }
Ejemplo n.º 3
0
        public IActionResult List(EFPenalty.PenaltyType showOnly = EFPenalty.PenaltyType.Any, bool hideAutomatedPenalties = true)
        {
            ViewBag.Description            = Localization["WEBFRONT_DESCRIPTION_PENALTIES"];
            ViewBag.Title                  = Localization["WEBFRONT_PENALTY_TITLE"];
            ViewBag.Keywords               = Localization["WEBFRONT_KEYWORDS_PENALTIES"];
            ViewBag.HideAutomatedPenalties = hideAutomatedPenalties;

            return(View(showOnly));
        }
Ejemplo n.º 4
0
        public static EFPenalty Create(EFPenalty.PenaltyType type = EFPenalty.PenaltyType.Ban, EFClient originClient = null, EFClient targetClient = null, DateTime?occurs = null, string reason = null)
        {
            originClient ??= ClientGenerators.CreateDatabaseClient(clientId: 1);
            targetClient ??= ClientGenerators.CreateDatabaseClient(clientId: 2);
            occurs ??= DateTime.UtcNow;
            reason ??= "test";

            return(new EFPenalty()
            {
                Offender = targetClient,
                Punisher = originClient,
                When = occurs.Value,
                Offense = reason,
                Type = type,
                LinkId = targetClient.AliasLinkId
            });
        }
Ejemplo n.º 5
0
        public async Task <IList <PenaltyInfo> > GetRecentPenalties(int count, int offset, EFPenalty.PenaltyType showOnly = EFPenalty.PenaltyType.Any, bool ignoreAutomated = true)
        {
            await using var context = _contextFactory.CreateContext(false);
            var iqPenalties = context.Penalties
                              .Where(p => showOnly == EFPenalty.PenaltyType.Any ? p.Type != EFPenalty.PenaltyType.Any : p.Type == showOnly)
                              .Where(_penalty => !ignoreAutomated || _penalty.PunisherId != 1)
                              .OrderByDescending(p => p.When)
                              .Skip(offset)
                              .Take(count)
                              .Select(_penalty => new PenaltyInfo()
            {
                Id               = _penalty.PenaltyId,
                Offense          = _penalty.Offense,
                AutomatedOffense = _penalty.AutomatedOffense,
                OffenderId       = _penalty.OffenderId,
                OffenderName     = _penalty.Offender.CurrentAlias.Name,
                PunisherId       = _penalty.PunisherId,
                PunisherName     = _penalty.Punisher.CurrentAlias.Name,
                PunisherLevel    = _penalty.Punisher.Level,
                PenaltyType      = _penalty.Type,
                Expires          = _penalty.Expires,
                TimePunished     = _penalty.When,
                IsEvade          = _penalty.IsEvadedOffense
            });

            return(await iqPenalties.ToListAsync());
        }
Ejemplo n.º 6
0
        public static double CalculateMaxValue(this DistributionConfiguration config, EFPenalty.PenaltyType penaltyType, int sampleSize)
        {
            switch (config.Type)
            {
            case DistributionConfiguration.DistributionType.Normal:
                break;

            case DistributionConfiguration.DistributionType.LogNormal:
                double deviationNumber = penaltyType == EFPenalty.PenaltyType.Flag ? 3.0 : 4.0;
                double marginOfError   = 1.644 / (config.StandardDeviation / Math.Sqrt(sampleSize));
                double maxValue        = (config.StandardDeviation * deviationNumber) + marginOfError;
                return(maxValue);
            }

            return(double.MaxValue);
        }