Ejemplo n.º 1
0
 private void SetProblemList(IEnumerable <Problem> problems)
 {
     ProblemListPanel.Controls.Clear();
     foreach (var problem in problems)
     {
         var control = new ProblemListItem(problem);
         ProblemListPanel.Controls.Add(control);
     }
 }
Ejemplo n.º 2
0
        public IHttpActionResult GetProblemList(int start, int limit)
        {
            var problems = problem_repository.GetProblems(start, limit);


            return(Ok(new CollectionResponse()
            {
                TotalCount = problem_repository.GetProblemCount(),
                Collection = ProblemListItem.MapTo(problems)
            }));
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetProblemList()
        {
            if (!user_service.IsAuthorizedToViewAllProblemList())
            {
                return(Unauthorized());
            }

            var problems = problem_repository.GetAllProblemsList();

            return(Ok(ProblemListItem.MapTo(problems)));
        }
Ejemplo n.º 4
0
        public IHttpActionResult GetUserProblems(int id, int start, int limit)
        {
            if (!user_service.IsAuthorizedToViewUserProblems(id))
            {
                return(Unauthorized());
            }

            var problems = user_repository.GetProblems(id, start, limit);


            return(Ok(new CollectionResponse()
            {
                TotalCount = user_repository.GetProblemCount(id),
                Collection = ProblemListItem.MapTo(problems)
            }));
        }
Ejemplo n.º 5
0
        private void imgSourceDirectory_Drop(object sender, DragEventArgs e)
        {
            imgSourceDirectory.Source    = new BitmapImage(new Uri("/CenaPlus.Server;component/Resources/Box.png", UriKind.Relative));
            pbLoading.Visibility         = System.Windows.Visibility.Visible;
            lbDragTip.Visibility         = System.Windows.Visibility.Collapsed;
            imgSourceDirectory.IsEnabled = false;
            System.Threading.Tasks.Task.Factory.StartNew(() => {
                var files = (from f in (e.Data.GetData(DataFormats.FileDrop) as string[])
                             where System.IO.Path.GetExtension(f) == ".cep"
                             select f).ToList();
                foreach (var f in files)
                {
                    var dir = Environment.CurrentDirectory + "\\Temp\\Analysis";
                    if (System.IO.Directory.Exists(dir))
                    {
                        System.IO.Directory.Delete(dir, true);
                    }
                    System.IO.Directory.CreateDirectory(dir);
                    Bll.ZipHelper.UnZip(f, dir);
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    jss.MaxJsonLength        = 2147483647;
                    var problem_json         = System.IO.File.ReadAllText(dir + "\\Problem.json");
                    var testcases_json       = System.IO.File.ReadAllText(dir + "\\TestCases.json");
                    var problem   = jss.Deserialize <Entity.Problem>(problem_json);
                    problem.ID    = App.Server.CreateProblem(contestID, problem.Title, problem.Content, problem.Score, problem.TimeLimit, problem.MemoryLimit, problem.Std, problem.Spj, problem.Validator, problem.StdLanguage, problem.SpjLanguage, problem.ValidatorLanguage, problem.ForbiddenLanguages);
                    var testcases = jss.Deserialize <List <Entity.TestCase> >(testcases_json);
                    foreach (var tc in testcases)
                    {
                        App.Server.CreateTestCase(problem.ID, tc.Input, tc.Output, tc.Type);
                    }
                    var p = App.Server.GetProblem(problem.ID);
                    ProblemListItem item = new ProblemListItem()
                    {
                        ID             = p.ID,
                        Title          = p.Title,
                        Score          = p.Score,
                        TestCasesCount = p.TestCasesCount
                    };
                    Dispatcher.Invoke(new Action(() => {
                        ProblemListItems.Add(item);
                        ProblemListItems.Sort((x, y) => { return(y.Score - x.Score); });
                        ProblemListView.Items.Refresh();
                    }));

                    try
                    {
                    }
                    catch
                    {
                        continue;
                    }
                    finally
                    {
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        pbLoading.Visibility         = System.Windows.Visibility.Collapsed;
                        lbDragTip.Visibility         = System.Windows.Visibility.Visible;
                        imgSourceDirectory.IsEnabled = true;
                    }));
                }
            });
        }
Ejemplo n.º 6
0
        private void imgSourceDirectory_Drop(object sender, DragEventArgs e)
        {
            imgSourceDirectory.Source = new BitmapImage(new Uri("/CenaPlus.Server;component/Resources/Box.png", UriKind.Relative));
            pbLoading.Visibility = System.Windows.Visibility.Visible;
            lbDragTip.Visibility = System.Windows.Visibility.Collapsed;
            imgSourceDirectory.IsEnabled = false;
            System.Threading.Tasks.Task.Factory.StartNew(() => {
                var files = (from f in (e.Data.GetData(DataFormats.FileDrop) as string[])
                             where System.IO.Path.GetExtension(f) == ".cep"
                             select f).ToList();
                foreach (var f in files)
                {
                    var dir = Environment.CurrentDirectory + "\\Temp\\Analysis";
                    if (System.IO.Directory.Exists(dir))
                        System.IO.Directory.Delete(dir, true);
                    System.IO.Directory.CreateDirectory(dir);
                    Bll.ZipHelper.UnZip(f, dir);
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    jss.MaxJsonLength = 2147483647;
                    var problem_json = System.IO.File.ReadAllText(dir + "\\Problem.json");
                    var testcases_json = System.IO.File.ReadAllText(dir + "\\TestCases.json");
                    var problem = jss.Deserialize<Entity.Problem>(problem_json);
                    problem.ID = App.Server.CreateProblem(contestID, problem.Title, problem.Content, problem.Score, problem.TimeLimit, problem.MemoryLimit, problem.Std, problem.Spj, problem.Validator, problem.StdLanguage, problem.SpjLanguage, problem.ValidatorLanguage, problem.ForbiddenLanguages);
                    var testcases = jss.Deserialize<List<Entity.TestCase>>(testcases_json);
                    foreach (var tc in testcases)
                    {
                        App.Server.CreateTestCase(problem.ID, tc.Input, tc.Output, tc.Type);
                    }
                    var p = App.Server.GetProblem(problem.ID);
                    ProblemListItem item = new ProblemListItem()
                    {
                        ID = p.ID,
                        Title = p.Title,
                        Score = p.Score,
                        TestCasesCount = p.TestCasesCount
                    };
                    Dispatcher.Invoke(new Action(() => {
                        ProblemListItems.Add(item);
                        ProblemListItems.Sort((x, y) => { return y.Score - x.Score; });
                        ProblemListView.Items.Refresh();
                    }));

                    try
                    {
                    }
                    catch
                    {
                        continue;
                    }
                    finally
                    {
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        pbLoading.Visibility = System.Windows.Visibility.Collapsed;
                        lbDragTip.Visibility = System.Windows.Visibility.Visible;
                        imgSourceDirectory.IsEnabled = true;
                    }));
                }
            });
        }