示例#1
0
 public void EnsureDatabaseCreatedTest()
 {
     using var context = new ExamContext();
     context.Database.EnsureDeleted();
     context.Database.EnsureCreated();
     context.Seed(new CryptService());
 }
示例#2
0
 public void EndExam()
 {
     ExamContext.StopExam();
     Module.StopAsync().ContinueWith((task) =>
     {
     });
 }
示例#3
0
        public static async System.Threading.Tasks.Task PopulateTestDatabaseAsync(ExamContext examContext)
        {
            Student student = StudentTestUtils.GetStudent();
            Course  course  = CourseTestUtils.GetCourse();
            await examContext.AddNewAsync(student);

            await examContext.AddNewAsync(StudentTestUtils.GetStudent2());

            await examContext.AddNewAsync(course);

            await examContext.AddNewAsync(CourseTestUtils.GetCourse2());

            await examContext.AddNewAsync(ProfessorTestUtils.GetProfessor());

            await examContext.AddNewAsync(ProfessorTestUtils.GetProfessor2());

            await examContext.AddNewAsync(StudentCourseTestUtils.GetStudentCourse(student.Id, course.Id));

            await examContext.AddNewAsync(ExamTestUtils.GetExam());

            await examContext.AddNewAsync(ClassroomTestUtils.GetClassroom());

            await examContext.AddNewAsync(GradeTestUtils.GetInitialStateGrade());

            await examContext.AddNewAsync(ClassroomAllocationTestUtils.GetClassroomAllocation());

            await examContext.AddNewAsync(GradeTestUtils.GetGradeWithValue());

            await examContext.SaveAsync();
        }
示例#4
0
 public void InitExamContext()
 {
     ExamContext              = new ExamContext();
     ExamContext.ExamMode     = IsTrainning ? ExamMode.Training : ExamMode.Examming;
     ExamContext.ExamTimeMode = ExamTimeMode.Day;
     ExamContext.Map          = MapSet.Empty;
 }
示例#5
0
        private void Reload()
        {
            using (ExamContext ctx = new ExamContext())
            {
                ctx.Courses.Load();
                ctx.Students.Load();
                ctx.Instructors.Load();
                //ctx.StCrs.Load();
                //ctx.InsCrs.Load();

                students    = ctx.Students.Local.ToList();
                instructors = ctx.Instructors.Local.ToList();
                courses     = ctx.Courses.Local.ToList();
                //stdCrs = ctx.StCrs.Local.ToList();
                //insCrs = ctx.InsCrs.Local.ToList();
            }



            //cmbStd.DataSource = ctx.Students.Local.ToList();
            cmbStd.DataSource        = students;
            cmbCourse.DataSource     = courses;
            cmbInstructor.DataSource = instructors;
            cmbInsCourses.DataSource = courses;
        }
 public override void Start(ExamContext context)
 {
     //重新设置触发距离值
     Distance = context.ExamDistance;
     //Logger.DebugFormat("{0}-重新设置触发的距离值{1}", Name, Distance);
     base.Start(context);
 }
示例#7
0
 public List <string> GetStreetsName(int cityid)
 {
     using (var ctx = new ExamContext())
     {
         var addresses = ctx.Addresses.Where(x => x.CityId == cityid).Count();
     }
 }
示例#8
0
 protected virtual async Task StartTrainingAsync(ExamContext context)
 {
     Logger.DebugFormat("启动训练模块");
     //2. 通用规则
     await StartExamItemAutoAsync(context, ExamItemCodes.CommonExamItem);
     await StartExamItemAutoAsync(context, ExamItemCodes.Start);
 }
示例#9
0
 /// <summary>
 /// 大屏幕
 /// </summary>
 /// <param name="context"></param>
 /// <param name="identityService"></param>
 public ScreenController(ExamContext context
                         , IIdentityService identityService, IExamService examService)
 {
     _examContext     = context ?? throw new ArgumentNullException(nameof(context));
     _identityService = identityService;
     _examService     = examService;
 }
示例#10
0
        private EEContext CreateContext(string userId, LUInfo luInfo)
        {
            EEContext context;
            string    intent = luInfo.Intent.intent;

            if (intent == "DoExam")
            {
                context = examCStore.GetContext(userId);
                if (context == null)
                {
                    context = new ExamContext(userId);
                }
            }
            else if (intent == "IntelligenceRoute")
            {
                context = irCStore.GetContext(userId);
                if (context == null)
                {
                    context = new IRContext(userId);
                }
            }
            else
            {
                context = new QAContext(userId, intent, luInfo.EntityList);
            }

            return(context);
        }
示例#11
0
    public static void Main(string[] args)
    {
        using (var context = new ExamContext())
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            context.Seed(new CryptService());
        }

        var builder = WebApplication.CreateBuilder(args);

        // Add services to the container.
        builder.Services.AddRazorPages();
        builder.Services.AddTransient <ICryptService, CryptService>();
        builder.Services.AddTransient(provider => new AuthService(
                                          isDevelopment: builder.Environment.IsDevelopment(),
                                          db: provider.GetRequiredService <ExamContext>(),
                                          crypt: provider.GetRequiredService <ICryptService>(),
                                          httpContextAccessor: provider.GetRequiredService <IHttpContextAccessor>()));
        builder.Services.AddTransient <ExamRepository>();
        builder.Services.AddDbContext <ExamContext>();
        builder.Services.AddAutoMapper(typeof(DtoMappings));

        builder.Services.AddHttpContextAccessor();
        builder.Services.AddAuthentication(
            Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme)
        .AddCookie(o =>
        {
            o.LoginPath        = "/User/Login";
            o.AccessDeniedPath = "/User/AccessDenied";
        });
        builder.Services.AddAuthorization(o =>
        {
            //o.AddPolicy("OwnerOrAdminRole", p => p.RequireRole(Usertype.Owner.ToString(), Usertype.Admin.ToString()));
        });

        var app = builder.Build();

        // Configure the HTTP request pipeline.
        if (!app.Environment.IsDevelopment())
        {
            app.UseExceptionHandler("/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }
        // Middleware
        app.UseHttpsRedirection();
        app.UseStaticFiles();  // no default document

        app.UseRouting();
        // WepAPI and MVC
        app.MapControllers();
        // Razor Page
        app.UseAuthentication();
        app.UseAuthorization();

        app.MapRazorPages();
        app.Run();
    }
示例#12
0
 public UnitOfWork(ExamContext context)
 {
     _context   = context;
     Exams      = new EFRepository <Exam>(_context);
     Users      = new EFRepository <User>(_context);
     Classrooms = new EFRepository <Classroom>(_context);
     QImages    = new EFRepository <QImage>(_context);
 }
示例#13
0
 protected override void StartExam()
 {
     InitExamItem();
     ExamContext.StartExam();
     Module.StartAsync(ExamContext).ContinueWith((task) =>
     {
     });
 }
 public ExamResultsController(ExamContext context, IWebHostEnvironment env,
                              GradeCalculator gradeCalculator, StudentRepository studentRepository)
 {
     _context               = context;
     Env                    = env;
     this.gradeCalculator   = gradeCalculator;
     this.studentRepository = studentRepository;
 }
示例#15
0
        //List<StCr> stdCrs;

        //List<InsCr> insCrs;



        private void CoursesForm_Load(object sender, EventArgs e)
        {
            this.FormClosed += (sender, e) =>
            {
                ctxAllCourses.Dispose();
                ctx.Dispose();
            };


            ctxAllCourses.Courses.Load();
            gridAllCourses.DataSource = ctxAllCourses.Courses.Local.ToBindingList();

            gridAllCourses.Columns["Exams"].Visible     = false;
            gridAllCourses.Columns["InsCrs"].Visible    = false;
            gridAllCourses.Columns["Questions"].Visible = false;
            gridAllCourses.Columns["CrsId"].Visible     = false;


            using (ExamContext ctx = new ExamContext())
            {
                ctx.Courses.Load();
                ctx.Students.Load();
                ctx.Instructors.Load();
                //ctx.StCrs.Load();
                //ctx.InsCrs.Load();

                students    = ctx.Students.Local.ToList();
                instructors = ctx.Instructors.Local.ToList();
                courses     = ctx.Courses.Local.ToList();
                //stdCrs = ctx.StCrs.Local.ToList();
                //insCrs = ctx.InsCrs.Local.ToList();
            }



            //cmbStd.DataSource = ctx.Students.Local.ToList();
            cmbStd.DataSource    = students;
            cmbStd.DisplayMember = "StName";
            cmbStd.ValueMember   = "StId";
            cmbStd.SelectedIndex = 0;


            cmbCourse.DataSource    = courses;
            cmbCourse.ValueMember   = "CrsId";
            cmbCourse.DisplayMember = "CrsName";
            cmbCourse.SelectedIndex = 0;


            cmbInstructor.DataSource    = instructors;
            cmbInstructor.DisplayMember = "InsName";
            cmbInstructor.ValueMember   = "InsId";
            cmbInstructor.SelectedIndex = 0;

            cmbInsCourses.DataSource    = courses;
            cmbInsCourses.ValueMember   = "CrsId";
            cmbInsCourses.DisplayMember = "CrsName";
            cmbInsCourses.SelectedIndex = 0;
        }
示例#16
0
 public UnitOfWork(ExamContext context)
 {
     _context    = context;
     Courses     = new CourseRepository(_context);
     Questions   = new QuestionRepository(_context);
     Exams       = new ExamRepository(_context);
     Students    = new StudentRepository(_context);
     Instructors = new InstructorRepository(_context);
 }
示例#17
0
        private ExamContext GetContext()
        {
            var context = new ExamContext();

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            context.Seed(new CryptService());
            return(context);
        }
示例#18
0
        public virtual void Start(ExamContext context)
        {
            if (IsRunning)
            {
                throw  new ApplicationException("触发器正在运行,不能被重复执行");
            }

            //  Logger.DebugFormat("正在启动触发器:{0}", Name);
            IsRunning = true;
        }
示例#19
0
 public ExamController(ExamContext context
                       , IIdentityService identityService
                       , IExamService examService
                       , ILogger <ExamController> logger)
 {
     _examContext     = context ?? throw new ArgumentNullException(nameof(context));
     _identityService = identityService;
     _examService     = examService;
     _logger          = logger;
 }
示例#20
0
 public void StartExam()
 {
     //第一步首先清楚上一次考试项目的扣分规则
     mainLinerLayout = (LinearLayout)this.FindViewById(Resource.Id.RuleBreakTable);
     InitBrokenRules();
     ExamContext.StartExam();
     Module.StartAsync(ExamContext).ContinueWith((task) =>
     {
     });
 }
示例#21
0
 public AuthService(
     bool isDevelopment,
     ExamContext db, ICryptService crypt,
     IHttpContextAccessor httpContextAccessor)
 {
     _isDevelopment       = isDevelopment;
     _db                  = db;
     _crypt               = crypt;
     _httpContextAccessor = httpContextAccessor;
 }
示例#22
0
        protected virtual async Task StartExamAsync(ExamContext context)
        {
            if (!context.IsExaming)
            {
                return;
            }
            await StartExamItemAutoAsync(context, ExamItemCodes.CommonExamItem);

            //启用绕车一周 to 在车上进行验证探头
            if (Settings.PrepareDrivingEnable)
            {
                var   prepareTask = StartExamItemAutoAsync(context, ExamItemCodes.PrepareDriving);
                await prepareTask;

                await Task.Run(() =>
                {
                    while (context.IsExaming && prepareTask.Result.State != ExamItemState.Finished)
                    {
                        Thread.Sleep(100);
                    }
                });
            }

            if (!context.IsExaming)
            {
                Logger.Debug("考试结束:context.IsExaming");
                return;
            }

            //吉首白天夜间都要灯光模拟
            if (context.ExamTimeMode == ExamTimeMode.Day && Settings.CheckLightingSimulation && Settings.SimulationsLightOnDay ||
                context.ExamTimeMode == ExamTimeMode.Night && Settings.CheckLightingSimulation && Settings.SimulationsLightOnNight)
            {
                Speaker.CancelAllAsync(false);
                //等待关闭发动机
                var lightTask = StartExamItemAutoAsync(context, ExamItemCodes.Light);

                await lightTask;
                await Task.Run(() =>
                {
                    while (context.IsExaming && lightTask.Result.State != ExamItemState.Finished)
                    {
                        Thread.Sleep(100);
                    }
                });
            }
            if (!context.IsExaming)
            {
                Logger.Debug("考试结束:context.IsExaming");
                return;
            }


            await StartExamItemAutoAsync(context, ExamItemCodes.Start);
        }
示例#23
0
 public void StartExam()
 {
     //第一步首先清楚上一次考试项目的扣分规则
     mainLinerLayout = (LinearLayout)this.FindViewById(Resource.Id.RuleBreakTable);
     mainLinerLayout.RemoveAllViews();
     edtTxtStartTime.Text = DateTime.Now.ToString("HH:mm:ss");
     ExamContext.StartExam();
     Module.StartAsync(ExamContext).ContinueWith((task) =>
     {
     });
 }
示例#24
0
        private void QuestionSystemForm_Load(object sender, EventArgs e)
        {
            choices = new BindingList <Choice>();

            grid.DataSource = choices;

            try
            {
                using (ExamContext ctx = new ExamContext())
                {
                    ctx.Courses.Load();
                    courses = ctx.Courses.Local.ToList();
                    cmbCourses.DataSource    = courses;
                    cmbCourses.DisplayMember = "CrsName";
                    cmbCourses.ValueMember   = "CrsId";



                    //public int CrsId { get; set; }
                    //public string CrsName { get; set; }
                    //public DateTime DateEnd { get; set; }
                    //public TimeSpan? ExamDuration { get; set; }
                    //public int? NumMcq { get; set; }


                    //public int? NumTorf { get; set; }
                    //public int ChoId { get; set; }
                    //public string ChoText { get; set; }
                    //public int State { get; set; }

                    //public virtual ICollection<ChoQue> ChoQues { get; set; }
                    //public virtual ICollection<QueInsCho> QueInsChos { get; set; }

                    grid.Columns["ChoId"].Visible      = false;
                    grid.Columns["ChoQues"].Visible    = false;
                    grid.Columns["QueInsChos"].Visible = false;


                    question.QueBody = "";
                    question.QueType = 0;

                    cmbCourses.SelectionChangeCommitted += (sender, e) =>
                    {
                        question.Crs   = cmbCourses.SelectedItem as Course;
                        question.CrsId = question.Crs.CrsId;
                    };
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can't Load Quesiton system");
            }
        }
示例#25
0
 public AccountController(ExamContext examContext
                          , IOptionsSnapshot <ExamingSettings> settings
                          , ILogger <AccountController> logger
                          , IRedisKeyRepository redisKeyRepository
                          , IHubContext <NotificationsHub> hubContext)
 {
     _settings           = settings.Value;
     _examContext        = examContext;
     _logger             = logger;
     _redisKeyRepository = redisKeyRepository;
     _hubContext         = hubContext ?? throw new ArgumentNullException(nameof(hubContext));
 }
示例#26
0
 public override void Start(ExamContext context)
 {
     if (ValidParameters())
     {
         base.Start(context);
         RegisterMessages(Messenger);
     }
     else
     {
         //Logger.WarnFormat("触发器:{0}-验证参数失败,停止执行;", Name);
     }
 }
        public HomeController(ExamContext context)
        {
            this._context = context;

            if (!_context.Exams.Any())
            {
                _context.Add(new Exam()
                {
                    Counter = 1
                });
                _context.SaveChanges();
            }
        }
示例#28
0
 public void StudentsCountSuccessTest()
 {
     using (var context = new ExamContext())
     {
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
         context.Seed(new CryptService());
     }
     using (var context = new ExamContext())
     {
         var schoolclass = context.SchoolClasses.First();
         Assert.True(schoolclass.StudentsCount > 0);
     }
 }
示例#29
0
        protected override void StartExam()
        {
            BreakRuleIndex = 0;
            //第一步首先清楚上一次考试项目的扣分规则
            mainLinerLayout = (LinearLayout)this.FindViewById(Resource.Id.RuleBreakTable);
            mainLinerLayout.RemoveAllViews();

            InitBrokenRules();

            InitExamItem();
            //TODO:这点
            //
            try
            {
                //可能
                List <Setting> lstSetting = new List <Setting> {
                };
                var setting = new Setting {
                    Key = "PrepareDrivingEnable", Value = (!chkClosePrepareDriving.Checked).ToString(), GroupName = "GlobalSettings"
                };
                lstSetting.Add(setting);
                setting = new Setting {
                    Key = "ContinueExamIfFailed", Value = (!chkExamFailEnd.Checked).ToString(), GroupName = "GlobalSettings"
                };
                lstSetting.Add(setting);
                setting = new Setting {
                    Key = "SimulationsLightOnDay", Value = (!chkCloseSimulationLights.Checked).ToString(), GroupName = "GlobalSettings"
                };
                lstSetting.Add(setting);
                setting = new Setting {
                    Key = "SimulationsLightOnNight", Value = (!chkCloseSimulationLights.Checked).ToString(), GroupName = "GlobalSettings"
                };
                lstSetting.Add(setting);

                globalSetting.PrepareDrivingEnable    = !chkClosePrepareDriving.Checked;
                globalSetting.ContinueExamIfFailed    = !chkExamFailEnd.Checked;
                globalSetting.SimulationsLightOnDay   = !chkCloseSimulationLights.Checked;
                globalSetting.SimulationsLightOnNight = !chkCloseSimulationLights.Checked;

                //UpdateSettings(lstSetting);
            }
            catch (Exception ex)
            {
                Logger.Error(ExamUIName, "startExamUpdateSettingError:" + ex.Message);
            }
            ExamContext.StartExam();
            Module.StartAsync(ExamContext).ContinueWith((task) =>
            {
            });
        }
示例#30
0
        public void TestFileStructureRule()
        {
            var project = new Project
            {
                Name = "TestProject1",
                Path = @"D:\",
            };
            var context = new ExamContext(project);
            var rule = new FileStructureRule { Template = "default.xml", IsEnabled = true, Name = "FileStructureRule", Description = "FileStructureRule Description" };

            rule.Exam(context);

            Assert.IsTrue(context.Outputs.Count > 0);
            Assert.IsTrue(context.Results.Count > 0);
        }
示例#31
0
        public void StartExam()
        {
            if (ExamContext == null || !ExamContext.EndExamTime.HasValue)
            {
                return;
            }
            //第一步首先清楚上一次考试项目的扣分规则

            InitBrokenRules();
            tvStartTime.Text = DateTime.Now.ToString("开始时间:HH:mm:ss");
            ExamContext.StartExam();
            Module.StartAsync(ExamContext).ContinueWith((task) =>
            {
            });
        }
示例#32
0
        public void RunProject(Project project, Action<Report, RunLogItem> onComplete)
        {
            var log = new RunLogItem();

            log.Start = DateTime.Now;
            log.Project = project.Name;

            if (project == null)
            {
                throw new ArgumentException();
            }

            if (project.RuleSet == null)
            {
                throw new Exception("RuleSet is not specified. ");
            }

            var context = new ExamContext(project);

            foreach (var i in project.RuleSet)
            {
                try
                {
                    i.Exam(context);
                }
                catch (Exception e)
                {
                    context.WriteOutput(i.Name, new Output
                    {
                        Summary = e.Message,
                        Details = new List<string>
                        {
                            e.ToString(),
                        },
                    });
                    context.AddResult(new ExamResult()
                    {
                        RuleName = i.Name,
                        Status = ActionStatus.Failed,
                    });
                    context.AddViolation(new Violation
                    {
                        RuleName = i.Name,
                        Description = e.Message,
                    });
                    continue;
                }
            }

            var report = context.GenerateReport();

            var path = SaveReportToFile(report);

            log.End = DateTime.Now;
            log.Status = report.Status;
            log.Report = path;
            log.Rules = project.RuleSet.Count;

            list.Insert(0, log);

            SaveRunlog(log);

            if (onComplete != null)
            {
                onComplete.Invoke(report, log);
            }
        }