Ejemplo n.º 1
0
 //
 // GET: /Job/
 public ActionResult Index()
 {
     if (Session["username"] == null)
     {
         return(RedirectToAction("Login", "Home"));
     }
     return(View(IJO.GetAll()));
 }
Ejemplo n.º 2
0
        public SchedulerModule() {
            this.RequiresAuthentication();

            Get["/scheduler"] = x => {
                dynamic vmod = new ExpandoObject();
                vmod.JobList = JobRepository.GetAll();
                return View["page-scheduler", vmod];
            };

            Post["/scheduler/now"] = x => {
                var alias = (string)Request.Form.Alias;
                var command = (string)Request.Form.Command;
                Job.Schedule(alias, command);
                return Response.AsRedirect("/");
            };

            Post["/scheduler/cron"] = x => {
                var alias = (string)Request.Form.Alias;
                var command = (string)Request.Form.Command;
                var cron = (string)Request.Form.CronResult;
                Job.Schedule(alias, command, cron);
                return Response.AsRedirect("/");
            };

            //Post["/scheduler/other"] = x => {
            //    var _alias = (string)Request.Form.Alias;
            //    var _command = (string)Request.Form.Command;
            //    var _cron = (string)Request.Form.CronResult;
            //    Job.Schedule(_alias, _command, _cron);
            //    dynamic model = new ExpandoObject();
            //    return Response.AsRedirect("/");
            //};

            Get["/scheduler/enable/{guid}"] = x => {
                string guid = x.guid;
                JobRepository.Enable(guid);
                return Response.AsJson(true);
            };

            Get["/scheduler/disable/{guid}"] = x => {
                string guid = x.guid;
                JobRepository.Disable(guid);
                return Response.AsJson(true);
            };

            Get["/scheduler/Launch/{guid}"] = x => {
                string guid = x.guid;
                Job.ReSchedule(guid);
                return Response.AsJson(true);
            };

            Get["/scheduler/delete/{guid}"] = x => {
                string guid = x.guid;
                JobRepository.Delete(guid);
                return Response.AsJson(true);
            };
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            List <Campanha> campanhas        = new CampanhaRepository().GetAll().ToList();
            SelectList      listaDeCampanhas = new SelectList(campanhas, "CampanhaId", "Nome");

            ViewBag.CampanhasListName = listaDeCampanhas;

            _jobRepository = new JobRepository();
            return(View(_jobRepository.GetAll().FirstOrDefault(c => c.JobId == id)));
        }
        public void TestGetAllJobsMethod()
        {
            // Arrange
            var jobrepo = new JobRepository();

            //Act
            var jobs = jobrepo.GetAll(7);

            //Asert
            NUnit.Framework.Assert.AreEqual(2, jobs.Count);
        }
Ejemplo n.º 5
0
 public JobModel GetJobByEmployeeId(string employeeId)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     JobModel jobModel = new JobModel();
     Job job = new Job();
     AutoMapper.Mapper.Map(jobModel, job);
     job = repo.GetAll().Where(x => x.EmployeeId == employeeId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, jobModel);
     return jobModel;
 }
Ejemplo n.º 6
0
 public List<JobModel> GetCompletedJobListByServiceProviderId(string serviceProviderId)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     List<JobModel> jobModelList = new List<JobModel>();
     List<Job> job = new List<Job>();
     AutoMapper.Mapper.Map(jobModelList, job);
     job = repo.GetAll().Where(x => x.ServiceProviderId == serviceProviderId && x.Status==JobStatus.Completed).OrderByDescending(x=>x.JobId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, jobModelList);
     return jobModelList;
 }
Ejemplo n.º 7
0
        private List <SelectListItem> JobList()
        {
            List <SelectListItem> output = new List <SelectListItem>();

            foreach (var item in _jobRepo.GetAll().Where(x => x.IsDefault).OrderBy(x => x.Order))
            {
                output.Add(new SelectListItem()
                {
                    Text = item.Title, Value = item.ID.ToString()
                });
            }

            var list = _jobRepo.GetAll().Where(x => !x.IsDefault && x.Status == VersionableItemStatus.Live && x.Visbility == VersionableVisbility.Public).OrderBy(x => x.Order);

            foreach (var item in list)
            {
                output.Add(new SelectListItem()
                {
                    Text = item.Title, Value = item.ID.ToString()
                });
            }
            return(output);
        }
Ejemplo n.º 8
0
 public bool CheckExistance(int jobId)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     var job = repo.GetAll().Where(x => x.JobId == jobId).Count();
     //unitOfWork.Commit();
     if (job > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
        public void CalculateModifiedYearJob_Test()
        {
            var dbContext  = TypiconDbContextFactory.Create();
            var jobRepo    = new JobRepository();
            var jobHandler = Build(dbContext, jobRepo);

            var job = new CalculateModifiedYearJob(1, 2019);

            jobRepo.Create(job);

            var task = jobHandler.ExecuteAsync(job);

            task.Wait();

            Assert.AreEqual(0, jobRepo.GetAll().Count());
        }
        public void ReloadRulesJob_Test(bool isTrue, TypiconVersionStatus status)
        {
            var context = TypiconDbContextFactory.Create();

            var jobRepo = new JobRepository();

            var handler = new ReloadRulesJobHandler(GetConfigRepo(), context, jobRepo);

            var job = new ReloadRulesJob(1, status);

            jobRepo.Create(job);

            var task = handler.ExecuteAsync(job);

            task.Wait();

            Assert.AreEqual(0, jobRepo.GetAll().Count());
        }
Ejemplo n.º 11
0
        public async Task HostingService_OutputForm()
        {
            var date = new DateTime(2019, 2, 1);

            var dbContext = TypiconDbContextFactory.Create();
            var jobRepo   = new JobRepository();

            var yearHandler = CalculateModifiedYearJobHandlerTest.Build(dbContext, jobRepo);
            var yearJob     = new CalculateModifiedYearJob(1, 2019);

            jobRepo.Create(yearJob);

            Task task = yearHandler.ExecuteAsync(yearJob);

            task.Wait();

            var weekHandler = CalculateOutputFormWeekJobTest.Build(dbContext, jobRepo);
            var weekJob     = new CalculateOutputFormWeekJob(1, 1, date);

            jobRepo.Create(weekJob);

            task = weekHandler.ExecuteAsync(weekJob);
            task.Wait();

            var service = new JobAsyncHostedService(jobRepo, CommandProcessorFactory.Create(dbContext));

            await service.StartAsync(CancellationToken.None);

            while (jobRepo.GetAll().Count() > 0)
            {
                Thread.Sleep(50);
            }

            var queryProcessor = QueryProcessorFactory.Create();

            var week = queryProcessor.Process(new OutputWeekQuery(1, date, new OutputFilter()
            {
                Language = "cs-ru"
            }));

            Assert.AreEqual(true, week.Success);
        }
Ejemplo n.º 12
0
        public void GetAll_Should_Return_All_Jobs()
        {
            RunTest(() =>
            {
                var jobOne = new Job {
                    Id = Guid.NewGuid()
                };
                var jobTwo = new Job {
                    Id = Guid.NewGuid()
                };
                using (var database = _context.LiteDatabase)
                {
                    var collection = database.GetCollection <Job>();
                    collection.InsertBulk(new[] { jobOne, jobTwo });
                }

                var jobs = _jobRepository.GetAll();
                jobs.Count.Should().Be(2);

                jobs.Count(x => x.Id == jobOne.Id).Should().Be(1);
                jobs.Count(x => x.Id == jobTwo.Id).Should().Be(1);
            });
        }
Ejemplo n.º 13
0
 public IActionResult Get()
 {
     return(Ok(_jobRepository.GetAll()));
 }
Ejemplo n.º 14
0
 //[HttpGet]
 public ActionResult Index()
 {
     _jobRepository = new JobRepository();
     ModelState.Clear();
     return(View(_jobRepository.GetAll()));
 }
Ejemplo n.º 15
0
 public List<JobModel> GetJobListByClientId(string clientId)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     List<JobModel> jobModelList = new List<JobModel>();
     List<Job> job = new List<Job>();
     AutoMapper.Mapper.Map(jobModelList, job);
     job = repo.GetAll().Where(x => x.ClientId == clientId).OrderByDescending(x=>x.JobId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, jobModelList);
     return jobModelList;
 }
Ejemplo n.º 16
0
 public IEnumerable <Job> GetAll()
 {
     return(_repo.GetAll());
 }
Ejemplo n.º 17
0
 public List<JobModel> GetJobsByEmployeeId(string employeeId,JobStatus status)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     List<JobModel> jobModelList = new List<JobModel>();
     List<Job> job = new List<Job>();
     AutoMapper.Mapper.Map(jobModelList, job);
     job = repo.GetAll().Where(x => x.EmployeeId == employeeId && x.Status == status && x.IsPaid==true ).OrderByDescending(x=>x.JobId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, jobModelList);
     return jobModelList;
 }
Ejemplo n.º 18
0
 public ActionResult AllJobs()
 {
     return(View(jobRepository.GetAll()));
 }
Ejemplo n.º 19
0
 public List<JobModel> GetStatusOfEmployee(string employeeId,string status)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     List<JobModel> jobModelList = new List<JobModel>();
     List<Job> job = new List<Job>();
     AutoMapper.Mapper.Map(jobModelList, job);
     //job = repo.GetAll().Where(x => status.Contains(x.Status.ToString())).ToList();
     job = repo.GetAll().Where(x => x.EmployeeId == employeeId && x.Status.ToString()==status).OrderByDescending(x=>x.JobId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(job, jobModelList);
     return jobModelList;
 }
Ejemplo n.º 20
0
 public List<JobModel> Paging(PagingModel model)
 {
     //unitOfWork.StartTransaction();
     JobRepository repo = new JobRepository(unitOfWork);
     List<JobModel> jobModelList = new List<JobModel>();
     List<Job> jobList = new List<Job>();
     //ResponseMessage responseMessage = new ResponseMessage();
     //PagingInfo Info = new PagingInfo();
     string searchparam = model.SearchText == null ? "" : model.SearchText;
     jobList = repo.GetAll().Where(x => x.Description.ToLower().Contains(searchparam.ToLower())).OrderByDescending(x=>x.JobId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(jobList, jobModelList);
     return jobModelList;
 }
Ejemplo n.º 21
0
        public JobModel UpadteJob(JobModel model)
        {
            //unitOfWork.StartTransaction();
            JobRepository repo = new JobRepository(unitOfWork);
            Job job = new Job();
            job = repo.GetAll().Where(x => x.JobId == model.JobId).FirstOrDefault();
            AutoMapper.Mapper.Map(model, job);
            repo.Update(job);
            //unitOfWork.Commit();
            AutoMapper.Mapper.Map(job, model);

            return model;
        }