コード例 #1
0
        public StudentController(UserManager <User> userManager, HSEContestDbContext db, TestingSystemConfig config, IHttpContextAccessor httpContextAccessor) : base(db, config)
        {
            curId = userManager.GetUserId(httpContextAccessor.HttpContext.User);
            var curUser = userManager.GetUserAsync(httpContextAccessor.HttpContext.User).Result;

            isProff = userManager.IsInRoleAsync(curUser, "professor").Result;
        }
コード例 #2
0
ファイル: DbWriter.cs プロジェクト: esbazhin/HSE.Contest
        public static TestResponse WriteToDb(HSEContestDbContext _db, TestingResult res, bool recheck)
        {
            bool ok = false;

            if (recheck)
            {
                var existing = _db.TestingResults.FirstOrDefault(r => r.SolutionId == res.SolutionId && r.TestId == res.TestId);

                if (existing != null)
                {
                    existing.Commentary = res.Commentary;
                    existing.ResultCode = res.ResultCode;
                    existing.Score      = res.Score;
                    existing.TestData   = res.TestData;

                    _db.SaveChanges();

                    ok = true;
                }
            }
            else
            {
                var x           = _db.TestingResults.Add(res);
                var beforeState = x.State;
                int r           = _db.SaveChanges();
                var afterState  = x.State;

                ok = beforeState == EntityState.Added && afterState == EntityState.Unchanged && r == 1;
            }

            TestResponse response;

            if (ok)
            {
                response = new TestResponse
                {
                    OK           = true,
                    Message      = "success",
                    Result       = res.ResultCode,
                    Score        = res.Score,
                    TestResultId = res.Id,
                    TestId       = res.TestId,
                };
            }
            else
            {
                response = new TestResponse
                {
                    OK      = false,
                    Message = "can't write result to db",
                    Result  = ResultCode.IE,
                    Score   = res.Score,
                    TestId  = res.TestId,
                };
            }

            return(response);
        }
コード例 #3
0
        public TestingSystemWorker()
        {
            string pathToConfig = "c:\\config\\config.json";
            _config = JsonConvert.DeserializeObject<TestingSystemConfig>(System.IO.File.ReadAllText(pathToConfig));

            DbContextOptionsBuilder<HSEContestDbContext> options = new DbContextOptionsBuilder<HSEContestDbContext>();
            options.UseNpgsql(_config.DatabaseInfo.GetConnectionStringFrom(_config.FrontEnd));
            _db = new HSEContestDbContext(options.Options);

            _busControl = RabbitHutch.CreateBus(_config.MessageQueueInfo, _config.TestingSystemWorker);
        }
コード例 #4
0
 public CompilerServicesOrchestrationController(HSEContestDbContext db, TestingSystemConfig config)
 {
     _db     = db;
     _config = config;
 }
コード例 #5
0
 public CodeStyleRulesController(HSEContestDbContext db)
 {
     _db = db;
 }
コード例 #6
0
 public CodeStyleTesterController(HSEContestDbContext db)
 {
     _db = db;
 }
コード例 #7
0
 public FunctionalTesterController(HSEContestDbContext db)
 {
     _db = db;
 }
コード例 #8
0
 public FunctionalTestingOrchestratorController(HSEContestDbContext db, TestingSystemConfig config)
 {
     _db     = db;
     _config = config;
 }
コード例 #9
0
 public CompilerController(HSEContestDbContext context)
 {
     _db = context;
 }
コード例 #10
0
 public TestingSystemController(HSEContestDbContext db, TestingSystemConfig config)
 {
     _pathToConfigDir = "c:\\config";
     _db     = db;
     _config = config;
 }
コード例 #11
0
 public ProfessorController(HSEContestDbContext db, TestingSystemConfig config) : base(db, config)
 {
 }
コード例 #12
0
 public GroupsController(UserManager <User> userManager, HSEContestDbContext db)
 {
     _db          = db;
     _userManager = userManager;
 }
コード例 #13
0
 public UsersController(UserManager <User> userManager, RoleManager <IdentityRole> roleManager, HSEContestDbContext db)
 {
     _userManager = userManager;
     _roleManager = roleManager;
     _db          = db;
 }
コード例 #14
0
 public ReflectionTesterController(HSEContestDbContext db)
 {
     _db = db;
 }