Example #1
0
        public async Task <SchedulerHeaderDto> GetCurrentScheduler(string currentSchedulerName)
        {
            IReadOnlyList <IScheduler> schedulers = await SchedulerRepository.Instance.LookupAll().ConfigureAwait(false);

            List <SchedulerHeaderDto> schedulerHeaders = schedulers.Select(x => new SchedulerHeaderDto(x)).ToList();

            if (schedulerHeaders.Count <= 0)
            {
                throw new Exception("No scheduler defined in this application.");
            }

            if (string.IsNullOrEmpty(currentSchedulerName))
            {
                return(schedulerHeaders[0]);
            }

            //Try to find exact match
            SchedulerHeaderDto currentScheduler = schedulerHeaders.FirstOrDefault(s => s.Name.Equals(currentSchedulerName));

            if (currentScheduler != null)
            {
                return(currentScheduler);
            }

            //Try to find best match
            currentScheduler = schedulerHeaders.FirstOrDefault(s => currentSchedulerName.StartsWith(s.Name, StringComparison.OrdinalIgnoreCase));
            return(currentScheduler ?? schedulerHeaders[0]);

            //Try to find default language

            //Get first one
        }
        public SchedulerDto(IScheduler scheduler, SchedulerMetaData metaData)
        {
            Name = scheduler.SchedulerName;
            SchedulerInstanceId = scheduler.SchedulerInstanceId;
            Status = SchedulerHeaderDto.TranslateStatus(scheduler);

            ThreadPool = new SchedulerThreadPoolDto(metaData);
            JobStore   = new SchedulerJobStoreDto(metaData);
            Statistics = new SchedulerStatisticsDto(metaData);
        }
        public async Task <IActionResult> Index()
        {
            SchedulerHeaderDto schedulerHeader = await _schedulerManager.GetCurrentScheduler(LocalSchedulerName);

            string cookieValue = Crypto.DesEncrypt(schedulerHeader.Name);

            Response.Cookies.Append(
                HybridConsts.SchedulerCookieName,
                cookieValue,
                new CookieOptions
            {
                Expires  = DateTime.UtcNow.AddYears(2),
                HttpOnly = true
            }
                );

            return(View());
        }