Esempio n. 1
0
        public void Add_CreatesNewTask()
        {
            var options = new DbContextOptionsBuilder <SchedulerContext>()
                          .UseInMemoryDatabase(databaseName: "Add_CreatesNewTask")
                          .Options;

            using (var context = new SchedulerContext(options))
            {
                SchedulerRepository repo = new SchedulerRepository(context);
                repo.AddScheduledTask(new ScheduledTask
                {
                    Id               = 1,
                    Active           = true,
                    Name             = "some task",
                    CommantToExecute = "some command",
                    StartDateTime    = DateTime.Now.AddYears(1)
                });
            }

            using (var context = new SchedulerContext(options))
            {
                SchedulerRepository repo = new SchedulerRepository(context);
                var tasks = repo.GetScheduledTasks();
                Assert.Single(tasks);
            }
        }
Esempio n. 2
0
        public void Delete_RemovesTask()
        {
            var options = new DbContextOptionsBuilder <SchedulerContext>()
                          .UseInMemoryDatabase(databaseName: "Delete_RemovesTask")
                          .Options;


            using (var context = new SchedulerContext(options))
            {
                SchedulerRepository repo = new SchedulerRepository(context);
                var task = new ScheduledTask
                {
                    Id               = 1,
                    Active           = true,
                    Name             = "some task",
                    CommantToExecute = "some command",
                    StartDateTime    = DateTime.Now.AddYears(1)
                };

                repo.AddScheduledTask(task);
                repo.RemoveSchecduledTaskById(1);
            }

            using (var context = new SchedulerContext(options))
            {
                SchedulerRepository repo = new SchedulerRepository(context);
                var task = repo.GetScheduledTasks();
                Assert.Empty(task);
            }
        }
Esempio n. 3
0
        public OctopusAsyncRepository(IOctopusAsyncClient client, RepositoryScope repositoryScope = null)
        {
            Client                    = client;
            Scope                     = repositoryScope ?? RepositoryScope.Unspecified();
            Accounts                  = new AccountRepository(this);
            ActionTemplates           = new ActionTemplateRepository(this);
            Artifacts                 = new ArtifactRepository(this);
            Backups                   = new BackupRepository(this);
            BuiltInPackageRepository  = new BuiltInPackageRepositoryRepository(this);
            CertificateConfiguration  = new CertificateConfigurationRepository(this);
            Certificates              = new CertificateRepository(this);
            Channels                  = new ChannelRepository(this);
            CommunityActionTemplates  = new CommunityActionTemplateRepository(this);
            Configuration             = new ConfigurationRepository(this);
            DashboardConfigurations   = new DashboardConfigurationRepository(this);
            Dashboards                = new DashboardRepository(this);
            Defects                   = new DefectsRepository(this);
            DeploymentProcesses       = new DeploymentProcessRepository(this);
            Deployments               = new DeploymentRepository(this);
            Environments              = new EnvironmentRepository(this);
            Events                    = new EventRepository(this);
            FeaturesConfiguration     = new FeaturesConfigurationRepository(this);
            Feeds                     = new FeedRepository(this);
            Interruptions             = new InterruptionRepository(this);
            LibraryVariableSets       = new LibraryVariableSetRepository(this);
            Lifecycles                = new LifecyclesRepository(this);
            MachinePolicies           = new MachinePolicyRepository(this);
            MachineRoles              = new MachineRoleRepository(this);
            Machines                  = new MachineRepository(this);
            Migrations                = new MigrationRepository(this);
            OctopusServerNodes        = new OctopusServerNodeRepository(this);
            PerformanceConfiguration  = new PerformanceConfigurationRepository(this);
            PackageMetadataRepository = new PackageMetadataRepository(this);
            ProjectGroups             = new ProjectGroupRepository(this);
            Projects                  = new ProjectRepository(this);
            ProjectTriggers           = new ProjectTriggerRepository(this);
            Proxies                   = new ProxyRepository(this);
            Releases                  = new ReleaseRepository(this);
            RetentionPolicies         = new RetentionPolicyRepository(this);
            Schedulers                = new SchedulerRepository(this);
            ServerStatus              = new ServerStatusRepository(this);
            Spaces                    = new SpaceRepository(this);
            Subscriptions             = new SubscriptionRepository(this);
            TagSets                   = new TagSetRepository(this);
            Tasks                     = new TaskRepository(this);
            Teams                     = new TeamsRepository(this);
            Tenants                   = new TenantRepository(this);
            TenantVariables           = new TenantVariablesRepository(this);
            UserInvites               = new UserInvitesRepository(this);
            UserRoles                 = new UserRolesRepository(this);
            Users                     = new UserRepository(this);
            VariableSets              = new VariableSetRepository(this);
            Workers                   = new WorkerRepository(this);
            WorkerPools               = new WorkerPoolRepository(this);
            ScopedUserRoles           = new ScopedUserRoleRepository(this);
            UserPermissions           = new UserPermissionsRepository(this);

            loadRootResource      = new Lazy <Task <RootResource> >(LoadRootDocumentInner, true);
            loadSpaceRootResource = new Lazy <Task <SpaceRootResource> >(LoadSpaceRootDocumentInner, true);
        }
Esempio n. 4
0
        public void Get_GetsAllTasks()
        {
            var options = new DbContextOptionsBuilder <SchedulerContext>()
                          .UseInMemoryDatabase(databaseName: "Get_GetsAllTasks")
                          .Options;


            using (var context = new SchedulerContext(options))
            {
                SchedulerRepository repo = new SchedulerRepository(context);
                for (int i = 1; i <= 100; i++)
                {
                    var task = new ScheduledTask
                    {
                        Id               = i,
                        Active           = true,
                        Name             = "some task",
                        CommantToExecute = "some command",
                        StartDateTime    = DateTime.Now.AddYears(1)
                    };
                    repo.AddScheduledTask(task);
                }
            }

            using (var context = new SchedulerContext(options))
            {
                SchedulerRepository repo = new SchedulerRepository(context);
                var task = repo.GetScheduledTasks();
                Assert.Equal(100, task.Count <ScheduledTask>());
            }
        }
Esempio n. 5
0
        public AppSchedulerControl Create()
        {
            SchedulerConfigurationService schedulerConfigurationService = new SchedulerConfigurationService();
            SchedulerRepository           schedulerRepository           = new SchedulerRepository(schedulerConfigurationService);
            AppSchedulerControl           appSchedulerControl           = new AppSchedulerControl(schedulerRepository);

            return(appSchedulerControl);
        }
Esempio n. 6
0
        public ActionResult EditJob(int id)
        {
            var dto = JobRepository.GetJob(id);
            var vm  = JobViewModel.Create(dto);

            vm.JobGroups = SchedulerRepository.GetJobGroups().ToSelectList();
            return(View(vm));
        }
Esempio n. 7
0
 public ActionResult CreateJobGroup(JobGroupViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     SchedulerRepository.AddJobGroup(model.ToDto());
     return(RedirectToAction("job-group-manager", new { schedulerId = model.SchedulerId }));
 }
Esempio n. 8
0
 public ActionResult EditScheduler(SchedulerViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     SchedulerRepository.Update(model.ToDto());
     return(RedirectToAction("scheduler-manager"));
 }
Esempio n. 9
0
        public ActionResult CreateJobGroup(int schedulerId)
        {
            var scheduler = SchedulerRepository.GetScheduler(schedulerId);
            var vm        = new JobGroupViewModel();

            vm.SchedulerId   = scheduler.Id.Value;
            vm.SchedulerName = scheduler.Name;
            return(View(vm));
        }
Esempio n. 10
0
        public async Task WorkerRepository_DoesNotIncludeLeaveByDefault()
        {
            var repo = new SchedulerRepository <Worker>(context);
            await repo.AddRange(SchedulerSeedData.GenerateWorkersWithLeave(10));

            var worker = await repo.FirstOrDefault(w => w.Name.Contains("Worker"));

            Assert.Empty(worker.Leave);
        }
Esempio n. 11
0
        public ActionResult CreateJob(int?groupId = null)
        {
            var vm = new JobViewModel();

            if (groupId.HasValue)
            {
                vm.GroupId = groupId.Value;
            }
            vm.JobGroups = SchedulerRepository.GetJobGroups().ToSelectList();
            return(View(vm));
        }
Esempio n. 12
0
        public ActionResult DeleteJobGroup(int jobGroupId)
        {
            int? schedulerId = null;
            bool result      = SchedulerRepository.TryRemoveJobGroup(jobGroupId, out schedulerId);

            if (result)
            {
                return(RedirectToAction("job-group-manager", new { schedulerId = schedulerId.Value }));
            }
            return(RedirectToAction("scheduler-manager"));
        }
Esempio n. 13
0
        public ActionResult SchedulerManager()
        {
            var dtos = SchedulerRepository.GetSchedulers();
            var vms  = new List <SchedulerViewModel>();

            foreach (var dto in dtos)
            {
                vms.Add(SchedulerViewModel.Create(dto));
            }
            return(View(vms));
        }
Esempio n. 14
0
        public ActionResult EditScheduler(int id)
        {
            var dto = SchedulerRepository.GetScheduler(id);

            if (dto != null)
            {
                var vm = SchedulerViewModel.Create(dto);
                return(View(vm));
            }
            return(RedirectToAction("scheduler-manager"));
        }
Esempio n. 15
0
        public ActionResult JobGroupManager(int schedulerId)
        {
            var dtos = SchedulerRepository.GetJobGroups(schedulerId);
            var vms  = new List <JobGroupViewModel>();

            foreach (var dto in dtos)
            {
                vms.Add(JobGroupViewModel.Create(dto));
            }
            ViewBag.SchedulerId = schedulerId;
            return(View(vms));
        }
Esempio n. 16
0
        public ActionResult CreateScheduler(SchedulerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var dto = model.ToDto();
            var vm  = SchedulerViewModel.Create(dto);

            SchedulerRepository.Create(model.ToDto());
            return(RedirectToAction("scheduler-manager"));
        }
Esempio n. 17
0
 public UnitOfWork(IDataService dataService)
 {
     _dataService              = dataService;
     User                      = new UserRepository(_dataService);
     Company                   = new CompanyRepository(_dataService);
     Room                      = new RoomRepository(_dataService);
     StayType                  = new StayTypesRepository(_dataService);
     Guest                     = new GuestRepository(_dataService);
     Reservation               = new ReservationRepository(_dataService);
     RoomReservation           = new SchedulerRepository(_dataService);
     RoomReservationRepository = new RoomReservationRepository(_dataService);
 }
        public OctopusAsyncRepository(IOctopusAsyncClient client)
        {
            this.Client = client;

            Accounts                 = new AccountRepository(client);
            ActionTemplates          = new ActionTemplateRepository(client);
            Artifacts                = new ArtifactRepository(client);
            Backups                  = new BackupRepository(client);
            BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client);
            CertificateConfiguration = new CertificateConfigurationRepository(client);
            Certificates             = new CertificateRepository(client);
            Channels                 = new ChannelRepository(client);
            CommunityActionTemplates = new CommunityActionTemplateRepository(client);
            Configuration            = new ConfigurationRepository(client);
            DashboardConfigurations  = new DashboardConfigurationRepository(client);
            Dashboards               = new DashboardRepository(client);
            Defects                  = new DefectsRepository(client);
            DeploymentProcesses      = new DeploymentProcessRepository(client);
            Deployments              = new DeploymentRepository(client);
            Environments             = new EnvironmentRepository(client);
            Events = new EventRepository(client);
            FeaturesConfiguration = new FeaturesConfigurationRepository(client);
            Feeds                    = new FeedRepository(client);
            Interruptions            = new InterruptionRepository(client);
            LibraryVariableSets      = new LibraryVariableSetRepository(client);
            Lifecycles               = new LifecyclesRepository(client);
            MachinePolicies          = new MachinePolicyRepository(client);
            MachineRoles             = new MachineRoleRepository(client);
            Machines                 = new MachineRepository(client);
            Migrations               = new MigrationRepository(client);
            OctopusServerNodes       = new OctopusServerNodeRepository(client);
            PerformanceConfiguration = new PerformanceConfigurationRepository(client);
            ProjectGroups            = new ProjectGroupRepository(client);
            Projects                 = new ProjectRepository(client);
            ProjectTriggers          = new ProjectTriggerRepository(client);
            Proxies                  = new ProxyRepository(client);
            Releases                 = new ReleaseRepository(client);
            RetentionPolicies        = new RetentionPolicyRepository(client);
            Schedulers               = new SchedulerRepository(client);
            ServerStatus             = new ServerStatusRepository(client);
            Subscriptions            = new SubscriptionRepository(client);
            TagSets                  = new TagSetRepository(client);
            Tasks                    = new TaskRepository(client);
            Teams                    = new TeamsRepository(client);
            Tenants                  = new TenantRepository(client);
            TenantVariables          = new TenantVariablesRepository(client);
            UserRoles                = new UserRolesRepository(client);
            Users                    = new UserRepository(client);
            VariableSets             = new VariableSetRepository(client);
            Workers                  = new WorkerRepository(client);
            WorkerPools              = new WorkerPoolRepository(client);
        }
Esempio n. 19
0
        private static IScheduler CreateScheduler(string customerCode)
        {
            var ramJobStore = new RAMJobStore();

            var schedulerResources = new QuartzSchedulerResources
            {
                JobRunShellFactory = new StdJobRunShellFactory(),
                JobStore           = ramJobStore,
                Name = $"TasksScheduler_{customerCode}"
            };

            var threadPool = new DefaultThreadPool();

            threadPool.Initialize();

            schedulerResources.ThreadPool = threadPool;

            var quartzScheduler = new QuartzScheduler(schedulerResources, TimeSpan.Zero);

            ITypeLoadHelper loadHelper;

            try
            {
                loadHelper = ObjectUtils.InstantiateType <ITypeLoadHelper>(typeof(SimpleTypeLoadHelper));
            }
            catch (Exception e)
            {
                throw new SchedulerConfigException("Unable to instantiate type load helper: {0}".FormatInvariant(e.Message), e);
            }

            loadHelper.Initialize();

            ramJobStore.Initialize(loadHelper, quartzScheduler.SchedulerSignaler);

            var standartScheduler = new StdScheduler(quartzScheduler);

            schedulerResources.JobRunShellFactory.Initialize(standartScheduler);

            quartzScheduler.Initialize();

            SchedulerRepository schedRep = SchedulerRepository.Instance;

            schedRep.Bind(standartScheduler);

            return(standartScheduler);
        }
        /// <summary>
        /// Create the Scheduler instance for the given factory and scheduler name.
        /// Called by afterPropertiesSet.
        /// </summary>
        /// <remarks>
        /// Default implementation invokes SchedulerFactory's <code>GetScheduler</code>
        /// method. Can be overridden for custom Scheduler creation.
        /// </remarks>
        /// <param name="schedulerFactory">the factory to create the Scheduler with</param>
        /// <param name="schedName">the name of the scheduler to create</param>
        /// <returns>the Scheduler instance</returns>
        /// <seealso cref="AfterPropertiesSet"/>
        /// <seealso cref="ISchedulerFactory.GetScheduler()"/>
        protected virtual IScheduler CreateScheduler(ISchedulerFactory schedulerFactory, string schedName)
        {
            SchedulerRepository repository = SchedulerRepository.Instance;

            lock (repository)
            {
                IScheduler existingScheduler = (schedulerName != null ? repository.Lookup(schedulerName) : null);
                IScheduler newScheduler      = schedulerFactory.GetScheduler();
                if (newScheduler == existingScheduler)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "Active Scheduler of name '{0}' already registered in Quartz SchedulerRepository. Cannot create a new Spring-managed Scheduler of the same name!",
                                  schedulerName));
                }
                if (!exposeSchedulerInRepository)
                {
                    // Need to explicitly remove it if not intended for exposure,
                    // since Quartz shares the Scheduler instance by default!
                    SchedulerRepository.Instance.Remove(newScheduler.SchedulerName);
                }
                return(newScheduler);
            }
        }
        public OctopusRepository(IOctopusClient client, RepositoryScope repositoryScope = null)
        {
#if FULL_FRAMEWORK
            LocationChecker.CheckAssemblyLocation();
#endif
            Client                           = client;
            Scope                            = repositoryScope ?? RepositoryScope.Unspecified();
            Accounts                         = new AccountRepository(this);
            ActionTemplates                  = new ActionTemplateRepository(this);
            Artifacts                        = new ArtifactRepository(this);
            Backups                          = new BackupRepository(this);
            BuiltInPackageRepository         = new BuiltInPackageRepositoryRepository(this);
            BuildInformationRepository       = new BuildInformationRepository(this);
            CertificateConfiguration         = new CertificateConfigurationRepository(this);
            Certificates                     = new CertificateRepository(this);
            Channels                         = new ChannelRepository(this);
            CommunityActionTemplates         = new CommunityActionTemplateRepository(this);
            Configuration                    = new ConfigurationRepository(this);
            DashboardConfigurations          = new DashboardConfigurationRepository(this);
            Dashboards                       = new DashboardRepository(this);
            Defects                          = new DefectsRepository(this);
            DeploymentProcesses              = new DeploymentProcessRepository(this);
            DeploymentSettings               = new DeploymentSettingsRepository(this);
            Deployments                      = new DeploymentRepository(this);
            Environments                     = new EnvironmentRepository(this);
            Events                           = new EventRepository(this);
            FeaturesConfiguration            = new FeaturesConfigurationRepository(this);
            Feeds                            = new FeedRepository(this);
            Interruptions                    = new InterruptionRepository(this);
            LibraryVariableSets              = new LibraryVariableSetRepository(this);
            Lifecycles                       = new LifecyclesRepository(this);
            Licenses                         = new LicensesRepository(this);
            MachinePolicies                  = new MachinePolicyRepository(this);
            MachineRoles                     = new MachineRoleRepository(this);
            Machines                         = new MachineRepository(this);
            Migrations                       = new MigrationRepository(this);
            OctopusServerNodes               = new OctopusServerNodeRepository(this);
            PerformanceConfiguration         = new PerformanceConfigurationRepository(this);
            ProjectGroups                    = new ProjectGroupRepository(this);
            Projects                         = new ProjectRepository(this);
            Runbooks                         = new RunbookRepository(this);
            RunbookProcesses                 = new RunbookProcessRepository(this);
            RunbookSnapshots                 = new RunbookSnapshotRepository(this);
            RunbookRuns                      = new RunbookRunRepository(this);
            ProjectTriggers                  = new ProjectTriggerRepository(this);
            Proxies                          = new ProxyRepository(this);
            Releases                         = new ReleaseRepository(this);
            RetentionPolicies                = new RetentionPolicyRepository(this);
            Schedulers                       = new SchedulerRepository(this);
            ServerStatus                     = new ServerStatusRepository(this);
            Spaces                           = new SpaceRepository(this);
            Subscriptions                    = new SubscriptionRepository(this);
            TagSets                          = new TagSetRepository(this);
            Tasks                            = new TaskRepository(this);
            Teams                            = new TeamsRepository(this);
            TelemetryConfigurationRepository = new TelemetryConfigurationRepository(this);
            Tenants                          = new TenantRepository(this);
            TenantVariables                  = new TenantVariablesRepository(this);
            UserRoles                        = new UserRolesRepository(this);
            Users                            = new UserRepository(this);
            VariableSets                     = new VariableSetRepository(this);
            Workers                          = new WorkerRepository(this);
            WorkerPools                      = new WorkerPoolRepository(this);
            ScopedUserRoles                  = new ScopedUserRoleRepository(this);
            UserPermissions                  = new UserPermissionsRepository(this);
            UserTeams                        = new UserTeamsRepository(this);
            UserInvites                      = new UserInvitesRepository(this);
            UpgradeConfiguration             = new UpgradeConfigurationRepository(this);
            loadRootResource                 = new Lazy <RootResource>(LoadRootDocumentInner, true);
            loadSpaceRootResource            = new Lazy <SpaceRootResource>(LoadSpaceRootDocumentInner, true);
        }
Esempio n. 22
0
 public ActionResult DeleteScheduler(int schedulerId)
 {
     SchedulerRepository.Delete(schedulerId);
     return(RedirectToAction("scheduler-manager"));
 }
Esempio n. 23
0
 public AppSchedulerControl(SchedulerRepository schedulerIRepository)
 {
     _schedulerIRepository = schedulerIRepository;
 }
Esempio n. 24
0
 public PriceScheduler() : base(new FileLogger("PriceScheduler"))
 {
     this._schedulerRepository = ServiceFactory.GetPriceSchedulerRepository();
     this.IsActive             = ServiceFactory.PriceSchedulerConfig();
 }
Esempio n. 25
0
 public SchedulerService()
 {
     _schedulerRepository = new SchedulerRepository();
 }