protected void AddProblem(Node violatingNode, params object[] resolutionParameters)
        {
            var problem = new Problem(GetResolution(resolutionParameters), violatingNode);

            if (Problems.Any(p => p.Id == problem.Id && p.SourceFile == problem.SourceFile && p.SourceLine == problem.SourceLine))
            {
                return;
            }

            Problems.Add(problem);
        }
Example #2
0
        public async Task <IActionResult> Add(int cid, ContestProblem model)
        {
            if (Problems.Any(cp => cp.ShortName == model.ShortName))
            {
                ModelState.AddModelError("xys::duplicate", "Duplicate short name for problem.");
            }
            var probDetect = await Store.CheckAvailabilityAsync(cid, model.ProblemId, User);

            if (!probDetect.ok)
            {
                ModelState.AddModelError("xys::prob", probDetect.msg);
            }

            if (ModelState.IsValid)
            {
                var oldprobs = Problems;
                model.Color     = "#" + model.Color.TrimStart('#');
                model.ContestId = cid;
                await Store.CreateAsync(model);

                await HttpContext.AuditAsync("attached", $"{model.ProblemId}");

                var newprobs = await Store.ListAsync(cid);

                var nowp = newprobs.SingleOrDefault(p => p.ProblemId == model.ProblemId);
                await Notifier.Create(cid, nowp);

                foreach (var @new in newprobs)
                {
                    if (@new.Rank > nowp.Rank)
                    {
                        await Notifier.Update(cid, @new);
                    }
                }

                StatusMessage = $"Problem {model.ShortName} saved.";
                return(RedirectToAction("Home", "Jury"));
            }
            else
            {
                return(Window(model));
            }
        }
Example #3
0
        public void RequiresAnimatorParameter(string parameter, AnimatorControllerParameterType type)
        {
            var animator = RequiresComponent <Animator>();

            if (animator != null && animator.runtimeAnimatorController == null)
            {
                if (!Problems.Any(problem => problem is MissingAnimatorController))
                {
                    Problems.Add(new MissingAnimatorController(of, Entity, animator));
                }
            }
#if UNITY_EDITOR
            if (animator != null && animator.runtimeAnimatorController is AnimatorController controller)
            {
                if (controller.parameters.Any(controllerParameter => controllerParameter.name == parameter && controllerParameter.type == type))
                {
                    return;
                }
                Problems.Add(new MissingAnimatorParameter(Entity, parameter, type, of));
            }
#endif
        }
Example #4
0
 public void Initialize()
 {
     if (!Categories.Any())
     {
         Categories.Add(new Category {
             Name = "Root"
         });
     }
     SaveChanges();
     if (!Authors.Any())
     {
         Authors.Add(new Author {
             Name = "Administrator"
         });
     }
     SaveChanges();
     if (!Problems.Any())
     {
         Problems.Add(new Problem {
             Name = "abc", Content = "cde", CategoryId = 1, AuthorId = 1
         });
     }
     SaveChanges();
 }
Example #5
0
        public async Task <IActionResult> Edit(int cid, int pid, ContestProblem model)
        {
            if (!Problems.Any(cp => cp.ProblemId == pid))
            {
                return(NotFound());
            }
            if (Problems.Any(cp => cp.ShortName == model.ShortName && cp.ProblemId != pid))
            {
                ModelState.AddModelError("xys::duplicate", "Duplicate short name for problem.");
            }
            if (!ModelState.IsValid)
            {
                return(Window(model));
            }

            await Store.UpdateAsync(cid, pid,
                                    () => new ContestProblem
            {
                Color       = "#" + model.Color.TrimStart('#'),
                AllowSubmit = model.AllowSubmit,
                ShortName   = model.ShortName,
                Score       = model.Score,
            });

            await HttpContext.AuditAsync("updated", $"{pid}");

            var newprobs = await Store.ListAsync(cid);

            foreach (var @new in newprobs)
            {
                await Notifier.Update(cid, @new);
            }

            StatusMessage = $"Problem {model.ShortName} saved.";
            return(RedirectToAction("Home", "Jury"));
        }
Example #6
0
 public bool Valid()
 {
     return(!Problems.Any());
 }