public override void Draw(GameTime gameTime) { GameBase.Game.GraphicsDevice.Clear(Color.CornflowerBlue); Container?.Draw(gameTime); Scheduled.Draw(gameTime); }
private static void Remove(Scheduled scheduled) { lock (_lock) { _cache.Remove(scheduled); } }
public void should_remove_slot_from_the_list_if_was_booked() { var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes); var booked = new Booked(scheduled.SlotId, "patient-123"); Given(scheduled, booked); Then(new List <AvailableSlot>(), _repository.GetSlotsAvailableOn(_now.Date)); }
private void When(Scheduled scheduled) { var(slotId, startTime, _) = scheduled; _isScheduled = true; _startTime = startTime; Id = slotId; }
public async Task cant_be_cancelled_if_wasnt_booked() { var scheduled = new Scheduled(_slotId, _now.Subtract(TimeSpan.FromHours(1)), _tenMinutes); Given(scheduled); await When(new Cancel(_slotId, "reason", DateTime.UtcNow)); Then <SlotNotBookedException>(); }
public override void Update(GameTime gameTime) { Container?.Update(gameTime); Scheduled.Update(gameTime); if (KeyboardManager.IsUniqueKeyPress(Keys.D1)) { IsScheduled = !IsScheduled; } }
[Fact] // public void should_return_an_empty_list_if_the_slot_was_scheduled() { var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes); Given(scheduled); Then( new List <PatientSlot>(), _repository.GetPatientSlots(_patientId) ); }
public async Task cant_be_cancelled_after_start_time() { var scheduled = new Scheduled(_slotId, _now.Subtract(TimeSpan.FromHours(1)), _tenMinutes); var booked = new Booked(_slotId, "patient name"); Given(scheduled, booked); await When(new Cancel(_slotId, "Reason", DateTime.UtcNow)); Then <SlotAlreadyStartedException>(); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as MedicationPrescriptionDosageInstructionComponent; if (dest != null) { base.CopyTo(dest); if (TextElement != null) { dest.TextElement = (Hl7.Fhir.Model.FhirString)TextElement.DeepCopy(); } if (AdditionalInstructions != null) { dest.AdditionalInstructions = (Hl7.Fhir.Model.CodeableConcept)AdditionalInstructions.DeepCopy(); } if (Scheduled != null) { dest.Scheduled = (Hl7.Fhir.Model.Element)Scheduled.DeepCopy(); } if (AsNeeded != null) { dest.AsNeeded = (Hl7.Fhir.Model.Element)AsNeeded.DeepCopy(); } if (Site != null) { dest.Site = (Hl7.Fhir.Model.CodeableConcept)Site.DeepCopy(); } if (Route != null) { dest.Route = (Hl7.Fhir.Model.CodeableConcept)Route.DeepCopy(); } if (Method != null) { dest.Method = (Hl7.Fhir.Model.CodeableConcept)Method.DeepCopy(); } if (Dose != null) { dest.Dose = (Hl7.Fhir.Model.Element)Dose.DeepCopy(); } if (Rate != null) { dest.Rate = (Hl7.Fhir.Model.Ratio)Rate.DeepCopy(); } if (MaxDosePerPeriod != null) { dest.MaxDosePerPeriod = (Hl7.Fhir.Model.Ratio)MaxDosePerPeriod.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
public void should_add_slot_to_the_list() { var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes); Given(scheduled); Then( new List <AvailableSlot> { new AvailableSlot(scheduled.SlotId, scheduled.StartTime, scheduled.Duration) }, _repository.GetSlotsAvailableOn(_now.Date) ); }
[Fact] //empty public void should_return_a_slot_if_was_booked() { var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes); var booked = new Booked(scheduled.SlotId, _patientId); Given(scheduled, booked); Then( new List <PatientSlot> { new PatientSlot(scheduled.SlotId, scheduled.StartTime, scheduled.Duration) }, _repository.GetPatientSlots(_patientId) ); }
public void should_add_slot_again_if_booking_was_cancelled() { var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes); var booked = new Booked(scheduled.SlotId, "patient-123"); var cancelled = new Cancelled(scheduled.SlotId, "No longer needed"); Given(scheduled, booked, cancelled); Then( new List <AvailableSlot> { new AvailableSlot(scheduled.SlotId, scheduled.StartTime, scheduled.Duration) }, _repository.GetSlotsAvailableOn(_now.Date) ); }
public void RecordTransaction() { cli.Title("Which type of transaction would you like to put on record?"); string[] tmpOpt = { "One-time purchase", "Regular expense" }; cli.ListOptions(tmpOpt); int input; while (true) { try { input = Convert.ToInt32(cli.Input()); if (input != 1 && input != 2) { throw new ArgumentException(); } else { break; } } catch (FormatException) { cli.Alert("You must enter a valid format!"); continue; } catch (ArgumentException) { cli.Alert("You must enter a valid option!"); continue; } } switch (input) { case 1: OneTime tmp = new OneTime(); oneTime.Add(tmp); break; case 2: Scheduled tmp1 = new Scheduled(); scheduled.Add(tmp1); break; } }
/// <inheritdoc /> public void ClearChunks() { UpdateQueue.Clear(); FastUpdateQueue.Clear(); UpdateBorderQueue.Clear(); var chunks = Chunks.ToArray(); Chunks.Clear(); Scheduled.Clear(); _renderedChunks = new ChunkData[0]; foreach (var chunk in chunks) { chunk.Value.Dispose(); } }
/// <summary> /// /// </summary> /// <param name="elapsed">time since update was last called, in microseconds</param> public void Update(double elapsed) { if (Playing) { Time += elapsed / Tempo * PPQ; while (tasks.Count > 0) { Scheduled nxt = tasks.First; if (tasks.GetPriority(nxt) > Time) { break; } nxt(); tasks.Remove(nxt); } } }
public void MakeReply(InteractionDef intDef, bool swap = true) { var time = GenTicks.TicksGame + interval; if (swap) { SwapRoles(); } expireTick = time + 1; latestReplyCount += 1; if (Scheduled.Any(x => x.Emitter == nextInitiator && x.IntDef == intDef && x.Iteration == latestReplyCount)) { var talks = Scheduled.Select(x => x.Talk).Distinct().Where(y => y.nextInitiator == nextInitiator || y.nextRecipient == nextInitiator).Count(); Log.Error($"[SpeakUp] {nextInitiator} tried to repeat a reply for {intDef} while talking to {nextRecipient}.\n" + $"{nextInitiator} is participating in {talks} current talks"); return; } Scheduled.Add(new Statement(nextInitiator, nextRecipient, time, intDef, this, latestReplyCount)); }
public static async Task Populate() { // Attempt to load existing data Dataset loaded = Database.Retrieve(DateTime.Now.ConvertToEffective()); if (loaded.Trips != null) { // Successfully loaded existing data from db Console.WriteLine($"{DateTime.Now} | DB | Found existing dataset #{loaded.EffectiveDate}"); Today = loaded; } else { // Populate the schedule for the first time, wait for it then save Console.WriteLine($"{DateTime.Now} | DB | Existing data not found, fetching new data"); await Scheduled.Update(); Database.Capture(); } }
public void ScheduleChunkUpdate(ChunkCoordinates position, ScheduleType type, bool prioritize = false) { var queue = UpdateQueue; if (Chunks.TryGetValue(position, out var cc)) { if ((type & ScheduleType.Lighting) != 0) { //cc.SkyLightDirty = true; } if ((type & ScheduleType.Border) != 0) { queue = UpdateBorderQueue; } if (prioritize) { queue = FastUpdateQueue; } if (queue.Contains(position) && !prioritize) { return; } if (Scheduled.TryAdd(position)) { if ((type & ScheduleType.Border) != 0) { cc.ScheduleBorder(); } queue.Enqueue(position); } //Scheduled.TryAdd(position); //queue.Enqueue(position); } }
public async Task Execute(global::Quartz.IJobExecutionContext context) { var messageData = new ScheduledMessageData(); var jobData = new global::Quartz.JobDataMap(); jobData.PutAll(context.Scheduler.Context); jobData.PutAll(context.JobDetail.JobDataMap); jobData.PutAll(context.Trigger.JobDataMap); jobData.Put("PayloadMessageHeadersAsJson", CreatePayloadHeaderString(context)); SetObjectProperties(messageData, jobData); try { var bus = (IBus)context.Scheduler.Context[BUS_CONTEXT_KEY] ?? _bus; if (bus == null) { throw new Exception("Could not find MassTransit Bus instance on the Job or the Scheduler Context."); } var destinationAddress = messageData.Destination; var sourceAddress = bus.Address; IPipe <SendContext> sendPipe = CreateMessageContext(messageData, sourceAddress); var endpoint = await bus.GetSendEndpoint(destinationAddress).ConfigureAwait(false); var scheduled = new Scheduled(); await endpoint.Send(scheduled, sendPipe, context.CancellationToken).ConfigureAwait(false); LogContext.Debug?.Log("Schedule Executed: {Key} {Schedule}", context.JobDetail.Key, context.Trigger.GetNextFireTimeUtc()); } catch (Exception ex) { LogContext.Error?.Log(ex, "Failed to send scheduled message, type: {MessageType}, destination: {DestinationAddress}", messageData.MessageType, messageData.Destination); throw new global::Quartz.JobExecutionException(ex, context.RefireCount < 5); } }
/// <inheritdoc /> public void RemoveChunk(ChunkCoordinates position, bool dispose = true) { BlockLightCalculations.Remove(position); UpdateQueue.Remove(position); UpdateBorderQueue.Remove(position); FastUpdateQueue.Remove(position); Scheduled.Remove(position); if (Chunks.TryRemove(position, out var column)) { foreach (var blockEntity in column.GetBlockEntities) { World.EntityManager.RemoveBlockEntity( new BlockCoordinates((column.X << 4) + blockEntity.X, blockEntity.Y, (column.Z << 4) + blockEntity.Z)); } if (dispose) { column.Dispose(); } } }
public IActionResult Save([FromBody] Scheduled _scheduled) { if (!ModelState.IsValid) { return(Ok()); } Scheduled s = new Scheduled(); s.Id = _scheduled.Id; s.Date = _scheduled.Date; s.Time = _scheduled.Time; s.CustomerId = _scheduled.CustomerId; s.ServiceId = _scheduled.ServiceId; s.CreatedBy = 1; s.CreatedOn = s.ModifieldOn = DateTime.Now; database.Scheduleds.Add(s); database.SaveChanges(); return(RedirectToAction("Scheduleds")); }
public IOperableTrigger GetRecoveryTrigger(JobDataMap jobDataMap) { var firedTime = Fired; var scheduledTime = Scheduled.GetValueOrDefault(DateTimeOffset.MinValue); var recoveryTrigger = new SimpleTriggerImpl($"recover_{InstanceId}_{Guid.NewGuid()}", SchedulerConstants.DefaultRecoveryGroup, scheduledTime) { JobName = JobName, JobGroup = JobGroup, Priority = Priority, MisfireInstruction = MisfireInstruction.IgnoreMisfirePolicy, JobDataMap = jobDataMap }; recoveryTrigger.JobDataMap.Put(SchedulerConstants.FailedJobOriginalTriggerName, TriggerName); recoveryTrigger.JobDataMap.Put(SchedulerConstants.FailedJobOriginalTriggerGroup, TriggerGroup); recoveryTrigger.JobDataMap.Put(SchedulerConstants.FailedJobOriginalTriggerFiretime, Convert.ToString(firedTime, CultureInfo.InvariantCulture)); recoveryTrigger.JobDataMap.Put(SchedulerConstants.FailedJobOriginalTriggerScheduledFiretime, Convert.ToString(scheduledTime, CultureInfo.InvariantCulture)); return(recoveryTrigger); }
public void EditTransaction() { if (util.GetExpenseType("modify") == typeof(OneTime)) { util.ListTransactions(typeof(OneTime)); string name = cli.Input("Which transaction would you like to modify?").ToLower(); foreach (OneTime i in oneTime) { if (i.Name.ToLower() == name) { OneTime obj = oneTime[oneTime.IndexOf(i)]; //just so i can refund it profile.Refund(obj); obj = new OneTime(); oneTime[oneTime.IndexOf(i)] = obj; break; } } } else { util.ListTransactions(typeof(Scheduled)); string name = cli.Input("Which transaction would you like to modify?").ToLower(); foreach (Scheduled i in scheduled) { if (i.Name.ToLower() == name) { Scheduled obj = scheduled[scheduled.IndexOf(i)]; profile.Refund(obj); obj = new Scheduled(); scheduled[scheduled.IndexOf(i)] = obj; //what if i just do this instead? EDIT: oh wow this actually works break; } } } }
public async Task Execute(IJobExecutionContext context) { try { var destinationAddress = new Uri(Destination); var sourceAddress = _bus.Address; IPipe <SendContext> sendPipe = CreateMessageContext(sourceAddress, context.Trigger.Key.Name); var endpoint = await _bus.GetSendEndpoint(destinationAddress).ConfigureAwait(false); var scheduled = new Scheduled(); await endpoint.Send(scheduled, sendPipe, context.CancellationToken).ConfigureAwait(false); } catch (Exception ex) { LogContext.Error?.Log(ex, "Failed to send scheduled message, type: {MessageType}, destination: {DestinationAddress}", MessageType, Destination); throw new JobExecutionException(ex, context.RefireCount < 5); } }
[Fact] // Remove completelu public void should_allow_bo_book_previously_cancelled_slot() { var patientId2 = "patient-456"; var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes); var booked = new Booked(scheduled.SlotId, _patientId); var cancelled = new Cancelled(scheduled.SlotId, "No longer needed"); var booked2 = new Booked(scheduled.SlotId, patientId2); Given(scheduled, booked, cancelled, booked2); Then( new List <PatientSlot> { new PatientSlot(scheduled.SlotId, scheduled.StartTime, scheduled.Duration, "cancelled") }, _repository.GetPatientSlots(_patientId) ); Then( new List <PatientSlot> { new PatientSlot(scheduled.SlotId, scheduled.StartTime, scheduled.Duration, "booked") }, _repository.GetPatientSlots(patientId2) ); }
public async Task SendMessage(HangfireRecurringScheduledMessageData messageData, PerformContext performContext) { try { IPipe <SendContext> sendPipe = CreateMessageContext(messageData, _bus.Address, messageData.JobKey); var endpoint = await _bus.GetSendEndpoint(messageData.Destination).ConfigureAwait(false); var scheduled = new Scheduled(); await endpoint.Send(scheduled, sendPipe, performContext.CancellationToken.ShutdownToken).ConfigureAwait(false); LogContext.Debug?.Log("Schedule Executed: {JobId}, created at: {CreatedAt}, with range: {StartTime}-{EndTime}", performContext.BackgroundJob.Id, performContext.BackgroundJob.CreatedAt, messageData.StartTime, messageData.EndTime); } catch (Exception ex) { LogContext.Error?.Log(ex, "Failed to send scheduled message: {JobId}, created at: {CreatedAt}, destination: {DestinationAddress}", performContext.BackgroundJob.Id, messageData.Destination, performContext.BackgroundJob.CreatedAt); throw new JobPerformanceException("Job Execution exception", ex); } }
public void Execute(IJobExecutionContext context) { try { var destinationAddress = new Uri(Destination); Uri sourceAddress = _bus.Address; IPipe <SendContext> sendPipe = CreateMessageContext(sourceAddress, destinationAddress, context.Trigger.Key.Name); ISendEndpoint endpoint = TaskUtil.Await(() => _bus.GetSendEndpoint(destinationAddress)); var scheduled = new Scheduled(); TaskUtil.Await(() => endpoint.Send(scheduled, sendPipe)); } catch (Exception ex) { string message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", MessageType, Destination); _log.Error(message, ex); throw new JobExecutionException(message, ex); } }
internal FlightHistoryCore.Model.FlightTime Convert() { DbModel.Estimate scheduled = null; DbModel.Estimate real = null; DbModel.Estimate estimated = null; long? eta = 0; long? updated = 0; if (Scheduled != null) { scheduled = Scheduled.Convert(); } if (Real != null) { real = Real.Convert(); } if (Estimated != null) { estimated = Estimated.Convert(); } if (Other != null) { eta = Other.Eta; updated = Other.Updated; } return(new DbModel.FlightTime() { Scheduled = scheduled, Real = real, Estimated = estimated, Eta = eta, Updated = updated }); }
public void Execute(IJobExecutionContext context) { try { var destinationAddress = new Uri(Destination); var sourceAddress = _bus.Address; IPipe<SendContext> sendPipe = CreateMessageContext(sourceAddress, context.Trigger.Key.Name); var endpoint = TaskUtil.Await(() => _bus.GetSendEndpoint(destinationAddress)); var scheduled = new Scheduled(); TaskUtil.Await(() => endpoint.Send(scheduled, sendPipe)); } catch (Exception ex) { var message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", MessageType, Destination); _log.Error(message, ex); throw new JobExecutionException(ex, context.RefireCount < 5); } }
/// <summary> /// Schedule an item for processing, potentially also starting the background process if it is not running. /// </summary> /// <remarks>If an item is already scheduled, it won't be added again, but the background task will still /// start if <paramref name="startProcess"/> is true.</remarks> /// <param name="item">An item that will be scheduled.</param> /// <param name="startProcess">A value indicating whether the background should be started if it is not running already.</param> public void Schedule(T item, bool startProcess = true) { bool scheduled = false; lock (queueLock) { if (queueSet.Add(item)) { processingQueue.Enqueue(item); scheduled = true; } } if (scheduled) { Interlocked.Increment(ref totalScheduledCount); Scheduled?.Invoke(this, BuildEventArgs()); } if (startProcess && !BackgroundTaskRunning) { StartBackgroundTask(); } }
public async Task Execute(IJobExecutionContext context) { try { var destinationAddress = new Uri(Destination); var sourceAddress = _bus.Address; IPipe <SendContext> sendPipe = CreateMessageContext(sourceAddress, context.Trigger.Key.Name); var endpoint = await _bus.GetSendEndpoint(destinationAddress).ConfigureAwait(false); var scheduled = new Scheduled(); await endpoint.Send(scheduled, sendPipe).ConfigureAwait(false); } catch (Exception ex) { var message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", MessageType, Destination); _log.Error(message, ex); throw new JobExecutionException(ex, context.RefireCount < 5); } }