public async Task RunAsync() { SchedulerContext db = new SchedulerContext(); var tracks = (from a in db.EmailTracks where !a.IsLinkOpened || !a.IsThankYouMailSent select a).ToList(); var emails = (from a in db.EmailRecipients select a).ToDictionary(a => a.RecipientId); foreach (var item in tracks) { if (item.IsThankYouMailSent) { continue; } if (item.IsLinkOpened && !item.IsThankYouMailSent) { await SendThankYouMail(db, emails[item.RecipientId], item); } else if (!item.IsLinkOpened && item.LastRemindedDate != DateTime.Today && item.ReminderCount < 3) { await SendReminderMail(db, emails[item.RecipientId], item); } } }
public ActionResult Edit(Employee employee, FullAddress fullAddress, FullName fullName, string JobTitle, string Groups) { if (ModelState.IsValid) { using (var db = new SchedulerContext()) { var result = db.Employees.SingleOrDefault(b => b.ID == employee.ID); var result2 = db.FullNames.SingleOrDefault(b => b.ID == fullName.ID); var result3 = db.FullAddresses.SingleOrDefault(b => b.ID == fullAddress.ID); if (result != null & result2 != null & result3 != null) { Debug.WriteLine("-----------------------------------------------------------------------------------Made It" + employee.ID); result2 = fullName; result3 = fullAddress; result.Name = result2; result.HomeAddress = result3; result.JobTitle = JobTitle; result.Groups = Groups; db.SaveChanges(); } } } return(RedirectToAction("Index")); }
public FormAuditoriesList() { InitializeComponent(); db = new SchedulerContext(); TextBoxes = new List <TextBox>(); TextBoxes.Add(textBoxNumber); }
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>()); } }
public async Task TestSchedulerFactoryObjectWithApplicationContext() { TestObject tb = new TestObject("tb", 99); StaticApplicationContext ac = new StaticApplicationContext(); IScheduler scheduler = A.Fake <IScheduler>(); SchedulerContext schedulerContext = new SchedulerContext(); A.CallTo(() => scheduler.Context).Returns(schedulerContext).NumberOfTimes(4); SchedulerFactoryObject schedulerFactoryObject = new TestSchedulerFactoryObject(scheduler); schedulerFactoryObject.JobFactory = null; IDictionary schedulerContextMap = new Hashtable(); schedulerContextMap.Add("testObject", tb); schedulerFactoryObject.SchedulerContextAsMap = schedulerContextMap; schedulerFactoryObject.ApplicationContext = ac; schedulerFactoryObject.ApplicationContextSchedulerContextKey = "appCtx"; try { schedulerFactoryObject.AfterPropertiesSet(); await schedulerFactoryObject.Start(); IScheduler returnedScheduler = (IScheduler)schedulerFactoryObject.GetObject(); Assert.AreEqual(tb, returnedScheduler.Context["testObject"]); Assert.AreEqual(ac, returnedScheduler.Context["appCtx"]); } finally { schedulerFactoryObject.Dispose(); } }
public ActionResult Create([Bind(Include = "ID,DayID,ShiftID")] WorkDay workDay) { var workDayDate = db.Days.Where(x => x.ID == workDay.DayID).First(); var workDayShift = db.Shifts.Where(x => x.ID == workDay.ShiftID).First(); // Here comes code for connecting the date with workday. You come from the calendar and if you register a workday, then a event is created in the calendar. var kalender = new SchedulerContext(); Event newEvent = new Event(); newEvent.start_date = workDayDate.Date; newEvent.end_date = workDayDate.Date.AddHours(23); newEvent.text = workDayShift.ShiftName; kalender.Events.Add(newEvent); kalender.SaveChanges(); if (ModelState.IsValid) { var redirectID = workDay.ShiftID; db.WorkDays.Add(workDay); db.SaveChanges(); return(RedirectToAction("ShowShift", "WorkShift", new { id = redirectID })); } ViewBag.DayID = new SelectList(db.Days, "ID", "ID", workDay.DayID); ViewBag.ShiftID = new SelectList(db.Shifts, "ID", "ShiftName", workDay.ShiftID); return(View(workDay)); }
public FormLectorsList() { InitializeComponent(); db = new SchedulerContext(); TextBoxes = new List <TextBox>(); TextBoxes.Add(textBoxFIO); }
public GeneratorService(SchedulerContext schedulerContext, SchoolContext schoolContext) { _schedulerContext = schedulerContext; _schoolContext = schoolContext; _queue = new ConcurrentQueue <ResultCell>(); }
public async Task ExecuteCommand(int id, int commandId) { // The client to execute command on is not connected any more so report to the caller that the command didn't executed var connectedClient = ConnectedClientsRegistry.Value.GetConnectedClients().FirstOrDefault(cc => cc.Client.Id == id); if (connectedClient == null) { Clients.Caller.commandExecutionInfo("failed", "Client is not reachable at this time"); return; } // Get the connectionId for the specific client device var connectionId = connectedClient.ConnectionId; using (var context = new SchedulerContext()) { var command = context.Commands.First(c => c.Id == commandId); // Store in the database info about the current execution var commandExecution = new CommandExecution { ClientId = id, Command = command, Type = MachineCommandType.ManualTriggered, Result = ExecutionResult.Pending }; context.CommandsExecutuions.Add(commandExecution); await context.SaveChangesAsync().ConfigureAwait(false); Clients.Client(connectionId).executeCommand(commandExecution); Clients.Group(Resources.WepAppClientsGroupName).commandExecutionInfo("started", commandExecution); } }
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); } }
public Task InitializeAsync() { Container.RegisterInstance <Bootstrapper>(this); var sc = new SchedulerContext( new SharedScheduler(TaskScheduler.FromCurrentSynchronizationContext(), DispatcherScheduler.Current), new SharedScheduler(TaskScheduler.Default, Scheduler.Default)); Container.RegisterInstance <ISchedulerContext>(sc); ObservableObjectBase.DispatcherSynchronizationContext = SynchronizationContext.Current; return(Task.Factory.StartNew(() => { base.Initialize(); // Do init async // Bootstrap example definitions Container.Resolve <IModule>().Initialize(); var vm = ServiceLocator.Container.Resolve <IMainWindowViewModel>(); // Bootstrap D3D to save time on startup SciChart.Drawing.DirectX.Context.D3D10.Direct3D10RenderSurface.InitEngineAsync().Then(r => { vm.InitReady = true; }); })); }
public static void Seed(SchedulerContext context) { if (context.Events.Any()) { return; // DB has been seeded } var events = new List <SchedulerEvent>() { new SchedulerEvent { Name = "Event 1", StartDate = new DateTime(2019, 1, 15, 2, 0, 0), EndDate = new DateTime(2019, 1, 15, 4, 0, 0) }, new SchedulerEvent() { Name = "Event 2", StartDate = new DateTime(2019, 1, 17, 3, 0, 0), EndDate = new DateTime(2019, 1, 17, 6, 0, 0) }, new SchedulerEvent() { Name = "Multiday event", StartDate = new DateTime(2019, 1, 15, 0, 0, 0), EndDate = new DateTime(2019, 1, 20, 0, 0, 0) } }; events.ForEach(s => context.Events.Add(s)); context.SaveChanges(); }
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); } }
public ActionResult Edit(Customer customer, FullAddress fullAddress, FullName fullName) { if (ModelState.IsValid) { using (var db = new SchedulerContext()) { var result = db.Customers.SingleOrDefault(b => b.ID == customer.ID); var result2 = db.FullNames.SingleOrDefault(b => b.ID == fullName.ID); var result3 = db.FullAddresses.SingleOrDefault(b => b.ID == fullAddress.ID); var query = db.Customers.Count(); if (result != null & result2 != null & result3 != null) { Debug.WriteLine("-----------------------------------------------------------------------------------Made It"); result2 = fullName; result3 = fullAddress; result.Name = result2; result.HomeAddress = result3; db.SaveChanges(); } } } return(RedirectToAction("Index")); }
public void TestSchedulerFactoryObjectWithApplicationContext() { TestObject tb = new TestObject("tb", 99); StaticApplicationContext ac = new StaticApplicationContext(); IScheduler scheduler = MockRepository.GenerateMock <IScheduler>(); SchedulerContext schedulerContext = new SchedulerContext(); scheduler.Stub(x => x.Context).Return(schedulerContext).Repeat.Times(4); SchedulerFactoryObject schedulerFactoryObject = new TestSchedulerFactoryObject(scheduler); schedulerFactoryObject.JobFactory = (null); IDictionary schedulerContextMap = new Hashtable(); schedulerContextMap.Add("testObject", tb); schedulerFactoryObject.SchedulerContextAsMap = (schedulerContextMap); schedulerFactoryObject.ApplicationContext = (ac); schedulerFactoryObject.ApplicationContextSchedulerContextKey = ("appCtx"); try { schedulerFactoryObject.AfterPropertiesSet(); schedulerFactoryObject.Start(); IScheduler returnedScheduler = (IScheduler)schedulerFactoryObject.GetObject(); Assert.AreEqual(tb, returnedScheduler.Context["testObject"]); Assert.AreEqual(ac, returnedScheduler.Context["appCtx"]); } finally { schedulerFactoryObject.Dispose(); } }
public JsonSchedulerContext(SchedulerContext schedulerContext) { entrySet = new Dictionary <string, object>(); foreach (var item in schedulerContext) { entrySet.Add(item.Key, item.Value); } }
public void Tasks_executed_using_SchedulerContext_Run_do_not_leak_to_other_threads() { var threadIds = new ConcurrentBag <int>(); SchedulerContext.Run(() => RunTasksAndCollectThreadIds(threadIds)); threadIds.Distinct().Count().Should().Be(1); }
public FormGroupsList() { InitializeComponent(); db = new SchedulerContext(); TextBoxes = new List <TextBox>(); TextBoxes.Add(textBoxName); comboBoxYear.SelectedIndex = 0; }
public async Task SendThankYouMail(SchedulerContext db, EmailRecipient item, EmailTrack track) { await SendThankYouMail(item, track); track.IsThankYouMailSent = true; await db.SaveChangesAsync(); }
public FormDisciplinesList() { InitializeComponent(); db = new SchedulerContext(); TextBoxes = new List <TextBox>(); TextBoxes.Add(textBoxHoursPlan); TextBoxes.Add(textBoxName); }
public Task Execute(IJobExecutionContext context) { _sc = context.Scheduler.Context; _name = context.JobDetail.Key.Name; _tagGroup = (TagGroup)_sc.Get(_name); return _tagGroup.OnSchedulerTriggerRead(); }
public async Task Log(LogEntry logEntry) { using (var context = new SchedulerContext()) { logEntry.CreatedAt = DateTime.UtcNow; context.LogEntries.Add(logEntry); await context.SaveChangesAsync().ConfigureAwait(false); } }
protected ControllerCoreBasicApi(ILogger <TClass> logger, ICustomMemoryCache cache, SchedulerContext scheduleContext) { this._logger = logger; this._cache = cache; this._cacheKey_all = $"{typeof(TEntity)}_All"; this._cacheKey_byId = $"{typeof(TEntity)}_byId:"; this._context = scheduleContext; this._query = this._context.Set <TEntity>(); }
public async Task SendReminderMail(SchedulerContext db, EmailRecipient item, EmailTrack track) { await SendReminderEmail(item, track); track.LastRemindedDate = DateTime.Today; track.ReminderCount++; await db.SaveChangesAsync(); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new SchedulerContext()) { db.Database.Migrate(); } }
public void StartStopTest() { var scheduler = new Scheduler(error => { throw new AggregateException(error); }); var context = new SchedulerContext(); scheduler.Start(new Clock(), false); scheduler.StartScheduling(context); scheduler.PauseForQuiescence(context); scheduler.StopScheduling(context); }
public override void Initialize() { var sc = new SchedulerContext( new SharedScheduler(TaskScheduler.FromCurrentSynchronizationContext(), DispatcherScheduler.Current), new SharedScheduler(TaskScheduler.Default, Scheduler.Default)); Container.RegisterInstance <ISchedulerContext>(sc); ObservableObjectBase.DispatcherSynchronizationContext = SynchronizationContext.Current; base.Initialize(); }
public async Task RunAsync() { SchedulerContext db = new SchedulerContext(); var emails = (from a in db.EmailRecipients where !db.EmailTracks.Any(t => t.RecipientId == a.RecipientId) select a).ToList(); foreach (var item in emails) { await SendMail(db, item); } }
public async Task Tasks_queued_to_the_synchronization_context_do_not_leak_to_other_threads() { var threadIds = new ConcurrentBag <int>(); using (SchedulerContext.Establish()) { await RunTasksAndCollectThreadIds(threadIds); } threadIds.Distinct().Count().Should().Be(1); }
public static bool GravarErro(Exception ex, SchedulerContext context) { int sis_id = -1; try { sis_id = context.Contains("sis_id") ? context.GetInt("sis_id") : -1; } catch { } return(GravarErro(ex, sis_id)); }
/// <summary> /// Constructor with a context as a parameter /// </summary> /// <param name="_context">Shared context between repositories</param> public StudentsRepositories(SchedulerContext _context) { context = _context; }
public StudentsRepositories() { context = new SchedulerContext(); }
public GradeLevelsRepository() { context = new SchedulerContext(); }
/// <summary> /// Constructor with a context as a parameter /// </summary> /// <param name="_context">Shared context between repositories</param> public GradeLevelsRepository(SchedulerContext _context) { context = _context; }
public BlocksRepository() { context = new SchedulerContext(); }
public TeachersRepositories() { context = new SchedulerContext(); }
/// <summary> /// Constructor with a context as a parameter /// </summary> /// <param name="_context">Shared context between repositories</param> public TeachersRepositories(SchedulerContext _context) { context = _context; }