Esempio n. 1
0
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            Response.Headers.Remove("Server");
            Response.Headers.Remove("X-Powered-By");
            Response.Headers.Remove("X-AspNet-Version");
            Response.Headers.Remove("X-AspNetMvc-Version");

            HttpContextBase currentContext = new HttpContextWrapper(HttpContext.Current);

            if (currentContext.Request.Params.AllKeys.Contains("ReturnUrl"))
            {
                Response.Redirect("~/Pages/Login");
            }

            if (HttpContext.Current.Cache["ScheduleItem_1"] == null)//(HttpContext.Current.Request.Url.ToString() == WebConfigurationManager.AppSettings["BaseURL"] + "/Pages/SystemManagement/StartService")
            {
                RegisterCacheEntry();
            }
            if (HttpContext.Current.Cache["IsRun"] == null)
            {
                var _scheduleService                = new ScheduleService(new ScheduleRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _termService                    = new TermService(new TermRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _mappingService                 = new MappingService(new MappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _collegeService                 = new CollegeService(new CollegeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _educationalGroupService        = new EducationalGroupService(new EducationalGroupRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _professorService               = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _educationalClassService        = new EducationalClassService(new EducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _studentEducationalClassService = new StudentEducationalClassService(new StudentEducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _professorScoreService          = new ProfessorScoreService(new ProfessorScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _indicatorService               = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _mappingTypeService             = new MappingTypeService(new MappingTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _universityLevelMappingService  = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _educationalGroupScoreService   = new EducationalGroupScoreService(new EducationalGroupScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _logService     = new LogService(new LogRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _logTypeService = new LogTypeService(new LogTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
                var _userService    = new UserService(new UserRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));

                var schedule = new ScheduleController(_scheduleService, _termService, _mappingService, _collegeService, _educationalGroupService
                                                      , _professorService, _educationalClassService, _studentEducationalClassService, _professorScoreService, _indicatorService, _mappingTypeService
                                                      , _universityLevelMappingService, _educationalGroupScoreService, _logService, _logTypeService, _userService);

                var schedules = schedule.ListAllSchedules();
                foreach (var scheduleItem in schedules)
                {
                    CheckScheduleTimeLapse("ScheduleItem_" + scheduleItem.Id);
                }
            }
        }
Esempio n. 2
0
        private bool RegisterCacheEntry()
        {
            var _scheduleService                = new ScheduleService(new ScheduleRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _termService                    = new TermService(new TermRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _mappingService                 = new MappingService(new MappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _collegeService                 = new CollegeService(new CollegeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _educationalGroupService        = new EducationalGroupService(new EducationalGroupRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _professorService               = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _educationalClassService        = new EducationalClassService(new EducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _studentEducationalClassService = new StudentEducationalClassService(new StudentEducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _professorScoreService          = new ProfessorScoreService(new ProfessorScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _indicatorService               = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _mappingTypeService             = new MappingTypeService(new MappingTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _universityLevelMappingService  = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _educationalGroupScoreService   = new EducationalGroupScoreService(new EducationalGroupScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _logService     = new LogService(new LogRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _logTypeService = new LogTypeService(new LogTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _userService    = new UserService(new UserRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));

            var schedule = new ScheduleController(_scheduleService, _termService, _mappingService, _collegeService, _educationalGroupService
                                                  , _professorService, _educationalClassService, _studentEducationalClassService, _professorScoreService, _indicatorService, _mappingTypeService
                                                  , _universityLevelMappingService, _educationalGroupScoreService, _logService, _logTypeService, _userService);

            if (HttpContext.Current.Cache["IsRun"] == null)
            {
                HttpContext.Current.Cache.Add("IsRun", "True", null, DateTime.MaxValue, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
            }


            var schedules = schedule.ListAllSchedules();

            foreach (var scheduleItem in schedules)
            {
                if (null != HttpContext.Current.Cache["ScheduleItem_" + scheduleItem.Id])
                {
                    return(false);
                }

                HttpContext.Current.Cache.Add("ScheduleItem_" + scheduleItem.Id, "Test", null,
                                              DateTime.MaxValue, TimeSpan.FromMinutes(2),
                                              CacheItemPriority.Normal,
                                              new CacheItemRemovedCallback(CacheItemRemovedCallback));
            }
            return(true);
        }
Esempio n. 3
0
        public async Task CheckScheduleTimeLapse(string key)
        {
            var log = new List <string>();

            log.Add("Test Action 1 at: " + DateTime.Now);
            //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", log);

            var _scheduleService                = new ScheduleService(new ScheduleRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _termService                    = new TermService(new TermRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _mappingService                 = new MappingService(new MappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _collegeService                 = new CollegeService(new CollegeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _educationalGroupService        = new EducationalGroupService(new EducationalGroupRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _professorService               = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _educationalClassService        = new EducationalClassService(new EducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _studentEducationalClassService = new StudentEducationalClassService(new StudentEducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _professorScoreService          = new ProfessorScoreService(new ProfessorScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _indicatorService               = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _mappingTypeService             = new MappingTypeService(new MappingTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _universityLevelMappingService  = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _educationalGroupScoreService   = new EducationalGroupScoreService(new EducationalGroupScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _logService     = new LogService(new LogRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _logTypeService = new LogTypeService(new LogTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));
            var _userService    = new UserService(new UserRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory()));

            var schedule = new ScheduleController(_scheduleService, _termService, _mappingService, _collegeService, _educationalGroupService
                                                  , _professorService, _educationalClassService, _studentEducationalClassService, _professorScoreService, _indicatorService, _mappingTypeService
                                                  , _universityLevelMappingService, _educationalGroupScoreService, _logService, _logTypeService, _userService);

            var sid = Convert.ToDecimal(key.Remove(0, 13));

            log.Add("Test Action 2 at: " + DateTime.Now);
            var sch = schedule.GetSchedule(sid);

            log.Add("Test Action 3 at: " + DateTime.Now);
            if (!string.IsNullOrEmpty(sch.ActionMethod) && sch.ActionMethod.LastIndexOf('.') > 0)
            {
                await Task.Run(() => { schedule.RunSchedule(sch); });
            }
            log.Add("Test Action 4 at: " + DateTime.Now);
        }