public void ExecuteInProcess() { var action1 = new ScheduleElementId(); var action2 = new ScheduleElementId(); var exitCondition = new ScheduleElementId(); var passThroughCondition = new ScheduleElementId(); var subSchedule = new ScheduleId(); var schedule = BuildSchedule( action1, action2, subSchedule, exitCondition, passThroughCondition); var knownSchedules = ScheduleStorage.CreateInstanceWithoutTimeline(); var scheduleInfo = knownSchedules.Add( schedule, "a", "b"); ISchedule storedSchedule = null; var executor = new Mock<IExecuteSchedules>(); Func<ISchedule, ScheduleId, ScheduleExecutionInfo, IExecuteSchedules> builder = (s, i, e) => { storedSchedule = s; return executor.Object; }; var distributor = new ScheduleDistributor(knownSchedules, builder); var returnedExecutor = distributor.Execute(scheduleInfo.Id); Assert.AreSame(executor.Object, returnedExecutor); VerifySchedule(schedule, storedSchedule); }
public void Setup() { _graphBuilder = new EventGraphBuilder(); _builder = new HistoryEventsBuilder(); _sendForApprovalId = Identity.Lambda("SendForApproval").ScheduleId(); _builder.AddProcessedEvents(_graphBuilder.WorkflowStartedEvent()); }
public void Setup() { _eventGraphBuilder = new EventGraphBuilder(); _eventsBuilder = new HistoryEventsBuilder(); _eventsBuilder.AddWorkflowRunId(ParentWorkflowId); _scheduleId = Identity.New(WorkflowName, WorkflowVersion).ScheduleId(ParentWorkflowId); }
public void Return_timer_decision_and_continue_execution_with_signal_timedout_when_signal_and_workflow_item_completed_events_comes_together_but_signals_comes_after_timeout( Type workflowType, ScheduleId promoteEmployee, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completedStamp = currentTime.AddHours(-4); var graph = completedGraph(completedStamp); _builder.AddNewEvents(graph); var hrSignal = _graphBuilder.WorkflowSignaledEvent("HRApproved", "", currentTime.AddHours(-1)); _builder.AddNewEvents(hrSignal); var managerApproved = _graphBuilder.WorkflowSignaledEvent("ManagerApproved", "", currentTime.AddHours(-1)); _builder.AddNewEvents(managerApproved); _builder.AddNewEvents(_graphBuilder.DecisionStartedEvent(DateTime.UtcNow)); var workflow = (Workflow)Activator.CreateInstance(workflowType); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions.Length, Is.EqualTo(5)); var triggerEventId = graph.First().EventId; decisions[0].AssertWaitForAllSignals(promoteEmployee, triggerEventId, completedStamp, TimeSpan.FromHours(2), _waitingSignals); decisions[1].AssertSignalTimer(promoteEmployee, triggerEventId, TimeSpan.FromHours(0)); Assert.That(decisions[2], Is.EqualTo(new ScheduleLambdaDecision(_hrApprovalTimedout, ""))); Assert.That(decisions[3], Is.EqualTo(new ScheduleLambdaDecision(_managerApprovalTimedout, ""))); decisions[4].AssertSignalTimedout(promoteEmployee, triggerEventId, _waitingSignals, hrSignal.EventId); }
private void ShowSuccess(GatewayComponent gatewayComponent, Person person, PaymentInfo paymentInfo, PaymentSchedule schedule, FinancialPaymentDetail paymentDetail, RockContext rockContext) { tdTransactionCodeReceipt.Description = TransactionCode; tdTransactionCodeReceipt.Visible = !string.IsNullOrWhiteSpace(TransactionCode); tdScheduleId.Description = ScheduleId.ToString(); tdScheduleId.Visible = ScheduleId.HasValue; tdNameReceipt.Description = paymentInfo.FullName; tdPhoneReceipt.Description = paymentInfo.Phone; tdEmailReceipt.Description = paymentInfo.Email; tdAddressReceipt.Description = string.Format("{0} {1}, {2} {3}", paymentInfo.Street1, paymentInfo.City, paymentInfo.State, paymentInfo.PostalCode); rptAccountListReceipt.DataSource = GetSelectedAccounts().Where(a => a.Amount != 0); rptAccountListReceipt.DataBind(); tdTotalReceipt.Description = paymentInfo.Amount.ToString("C"); tdPaymentMethodReceipt.Description = paymentInfo.CurrencyTypeValue.Description; string acctNumber = paymentInfo.MaskedNumber; if (string.IsNullOrWhiteSpace(acctNumber) && paymentDetail != null && !string.IsNullOrWhiteSpace(paymentDetail.AccountNumberMasked)) { acctNumber = paymentDetail.AccountNumberMasked; } tdAccountNumberReceipt.Description = acctNumber; tdAccountNumberReceipt.Visible = !string.IsNullOrWhiteSpace(acctNumber); tdWhenReceipt.Description = schedule != null?schedule.ToString() : "Today"; pnlConfirmation.Visible = false; pnlSuccess.Visible = true; }
public void Signal_timer_is_ignored_when_it_is_fired_after_receiving_the_signal_and_signal_timer_and_signal_are_processed_together_also_signal_was_received_after_timedout( Type workflowType, ScheduleId approveExpenses, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completedStamp = currentTime.AddMinutes(-121); var lg = completedGraph(completedStamp); _builder.AddProcessedEvents(lg); var signalTriggerEventId = lg.First().EventId; _builder.AddProcessedEvents(WaitForSignalEvent(approveExpenses, signalTriggerEventId, completedStamp, "Approved", "Rejected")); var s = _graphBuilder.WorkflowSignaledEvent("Approved", "input", completedTime: currentTime); _builder.AddNewEvents(s); var timerFiredGraph = _graphBuilder.TimerFiredGraph(approveExpenses, TimeSpan.FromHours(1), TimerType.SignalTimer, signalTriggerEventId, currentTime); _builder.AddNewEvents(timerFiredGraph); var workflow = (Workflow)Activator.CreateInstance(workflowType); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions.Length, Is.EqualTo(2)); Assert.That(decisions[0], Is.EqualTo(new ScheduleLambdaDecision(_approvalTimedout, ""))); decisions[1].AssertSignalTimedout(approveExpenses, signalTriggerEventId, new[] { "Approved", "Rejected" }, s.EventId); }
public void Setup() { _graphBuilder = new EventGraphBuilder(); var graph = _graphBuilder.WaitForSignalEvent(ScheduleId.Raw("id"), 10, new [] { "e1", "e2" }, SignalWaitType.Any); _event = new WaitForSignalsEvent(graph, Enumerable.Empty <HistoryEvent>()); }
public void Signal_is_ignored_when_it_is_received_after_signal_timer_and_signal_timer_and_signal_are_processed_together( Type workflowType, ScheduleId confirmEmailId, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completeDateTime = currentTime.AddHours(-2); var lg = completedGraph(completeDateTime); _builder.AddProcessedEvents(lg); var signalTriggerEventId = lg.First().EventId; _builder.AddProcessedEvents(WaitForSignalEvent(confirmEmailId, signalTriggerEventId, completeDateTime, "Confirmed")); var timerFiredGraph = _graphBuilder.TimerFiredGraph(confirmEmailId, TimeSpan.FromHours(1), TimerType.SignalTimer, signalTriggerEventId, currentTime); _builder.AddNewEvents(timerFiredGraph); var s = _graphBuilder.WorkflowSignaledEvent("Confirmed", "input", completedTime: currentTime); _builder.AddNewEvents(s); var workflow = (Workflow)Activator.CreateInstance(workflowType); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions.Length, Is.EqualTo(2)); decisions[0].AssertSignalTimedout(confirmEmailId, signalTriggerEventId, new[] { "Confirmed" }, timerFiredGraph.First().EventId); Assert.That(decisions[1], Is.EqualTo(new ScheduleLambdaDecision(_blockAccountId, ""))); }
public void Return_timer_decision_and_continue_execution_with_signal_timedout_when_signal_and_workflow_item_completed_events_comes_together_but_signal_comes_after_timeout( Type workflowType, ScheduleId approveExpenses, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completedStamp = currentTime.AddHours(-4); var graph = completedGraph(completedStamp); _builder.AddNewEvents(graph); var s = _graphBuilder.WorkflowSignaledEvent("Rejected", "", currentTime.AddHours(-1)); _builder.AddNewEvents(s); _builder.AddNewEvents(_graphBuilder.DecisionStartedEvent(DateTime.UtcNow)); var workflow = (Workflow)Activator.CreateInstance(workflowType); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions.Length, Is.EqualTo(4)); var triggerEventId = graph.First().EventId; decisions[0].AssertWaitForAnySignal(approveExpenses, triggerEventId, completedStamp, TimeSpan.FromHours(2), "Approved", "Rejected"); decisions[1].AssertSignalTimer(approveExpenses, triggerEventId, TimeSpan.FromHours(0)); Assert.That(decisions[2], Is.EqualTo(new ScheduleLambdaDecision(_approvalTimedout, ""))); decisions[3].AssertSignalTimedout(approveExpenses, triggerEventId, new[] { "Approved", "Rejected" }, s.EventId); }
public override int GetHashCode() { int hash = 1; if (ItemId != 0L) { hash ^= ItemId.GetHashCode(); } if (TrainerBuildupConfigId != 0) { hash ^= TrainerBuildupConfigId.GetHashCode(); } if (ScheduleId.Length != 0) { hash ^= ScheduleId.GetHashCode(); } if (U4.Length != 0) { hash ^= U4.GetHashCode(); } if (TrainerId != 0L) { hash ^= TrainerId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void Setup() { _builder = new EventGraphBuilder(); _identity = Identity.New("name", "ver", "pos"); _scheduleId = _identity.ScheduleId(); _childWorkflowItem = new Mock <IChildWorkflowItem>(); }
public override int GetHashCode() { int hash = 1; if (QuestGroupId != 0L) { hash ^= QuestGroupId.GetHashCode(); } if (ScheduleId.Length != 0) { hash ^= ScheduleId.GetHashCode(); } if (U3.Length != 0) { hash ^= U3.GetHashCode(); } if (ItemSetId != 0L) { hash ^= ItemSetId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (LoginBonusId.Length != 0) { hash ^= LoginBonusId.GetHashCode(); } if (ScheduleId.Length != 0) { hash ^= ScheduleId.GetHashCode(); } if (U3 != 0) { hash ^= U3.GetHashCode(); } if (ItemSetId != 0UL) { hash ^= ItemSetId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Stores the created schedule and it's associated actions and conditions. /// </summary> /// <param name="schedule">The schedule.</param> /// <param name="actionMap">The collection mapping the registered actions to the schedule element that holds the action.</param> /// <param name="conditionMap">The collection mapping the registered conditions to the schedule element that holds the condition.</param> /// <returns>The ID of the newly created schedule.</returns> public ScheduleId StoreSchedule( ISchedule schedule, Dictionary <ScheduleActionRegistrationId, ScheduleElementId> actionMap, Dictionary <ScheduleConditionRegistrationId, ScheduleElementId> conditionMap) { { Debug.Assert(schedule != null, "The schedule should not be a null reference."); Debug.Assert(actionMap != null, "The collection of actions should not be a null reference."); Debug.Assert(conditionMap != null, "The collection of conditions should not be a null reference."); } var id = new ScheduleId(); m_Schedule = schedule; foreach (var pair in actionMap) { m_Actions.Add(pair.Key, pair.Value); } foreach (var pair in conditionMap) { m_Conditions.Add(pair.Key, pair.Value); } return(id); }
public void Signal_timer_is_ignored_when_it_is_fired_after_receiving_the_signals_and_signal_timer_and_signals_are_processed_together_also_signal_was_received_after_timedout( Type workflowType, ScheduleId promoteEmployee, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completedStamp = currentTime.AddHours(-2); var lg = completedGraph(completedStamp); _builder.AddProcessedEvents(lg); var signalTriggerEventId = lg.First().EventId; _builder.AddProcessedEvents(WaitForSignalEvent(promoteEmployee, signalTriggerEventId, completedStamp, _waitingSignals)); var hrSignal = _graphBuilder.WorkflowSignaledEvent("HRApproved", "input", completedTime: currentTime.AddMinutes(1)); _builder.AddNewEvents(hrSignal); var managerSignal = _graphBuilder.WorkflowSignaledEvent("ManagerApproved", "input", completedTime: currentTime.AddMinutes(1)); _builder.AddNewEvents(managerSignal); var timerFiredGraph = _graphBuilder.TimerFiredGraph(promoteEmployee, TimeSpan.FromHours(1), TimerType.SignalTimer, signalTriggerEventId, currentTime.AddMinutes(1)); _builder.AddNewEvents(timerFiredGraph); var workflow = (Workflow)Activator.CreateInstance(workflowType); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions.Length, Is.EqualTo(3)); Assert.That(decisions[0], Is.EqualTo(new ScheduleLambdaDecision(_hrApprovalTimedout, ""))); Assert.That(decisions[1], Is.EqualTo(new ScheduleLambdaDecision(_managerApprovalTimedout, ""))); decisions[2].AssertSignalTimedout(promoteEmployee, signalTriggerEventId, _waitingSignals, hrSignal.EventId); }
public override int GetHashCode() { int hash = 1; if (EggDropId != 0) { hash ^= EggDropId.GetHashCode(); } if (ScheduleId.Length != 0) { hash ^= ScheduleId.GetHashCode(); } if (U3 != 0) { hash ^= U3.GetHashCode(); } if (U4 != 0) { hash ^= U4.GetHashCode(); } if (U5 != 0) { hash ^= U5.GetHashCode(); } if (U6 != 0) { hash ^= U6.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (EventBannerId.Length != 0) { hash ^= EventBannerId.GetHashCode(); } if (U2 != 0) { hash ^= U2.GetHashCode(); } if (U3 != 0) { hash ^= U3.GetHashCode(); } if (ScheduleId.Length != 0) { hash ^= ScheduleId.GetHashCode(); } if (U5.Length != 0) { hash ^= U5.GetHashCode(); } if (BannerId != 0) { hash ^= BannerId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Removes the schedule with the specified ID. /// </summary> /// <param name="id">The ID of the schedule that should be removed.</param> public void Remove(ScheduleId id) { if ((id != null) && m_Schedules.ContainsKey(id)) { m_Schedules.Remove(id); } }
public override int GetHashCode() { int hash = 1; if (ItemExchangeGroupId != 0) { hash ^= ItemExchangeGroupId.GetHashCode(); } if (U2 != 0) { hash ^= U2.GetHashCode(); } if (ScheduleId.Length != 0) { hash ^= ScheduleId.GetHashCode(); } if (BannerId != 0) { hash ^= BannerId.GetHashCode(); } if (U5 != 0) { hash ^= U5.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 26, Configuration.FieldSeparator), Id, PlacerAppointmentId?.ToDelimitedString(), FillerAppointmentId?.ToDelimitedString(), OccurrenceNumber.HasValue ? OccurrenceNumber.Value.ToString(Consts.NumericFormat, culture) : null, PlacerGroupNumber?.ToDelimitedString(), ScheduleId?.ToDelimitedString(), RequestEventReason?.ToDelimitedString(), AppointmentReason?.ToDelimitedString(), AppointmentType?.ToDelimitedString(), AppointmentDuration.HasValue ? AppointmentDuration.Value.ToString(Consts.NumericFormat, culture) : null, AppointmentDurationUnits?.ToDelimitedString(), RequestedStartDateTimeRange != null ? string.Join(Configuration.FieldRepeatSeparator, RequestedStartDateTimeRange.Select(x => x.ToDelimitedString())) : null, PriorityArq, RepeatingInterval?.ToDelimitedString(), RepeatingIntervalDuration, PlacerContactPerson != null ? string.Join(Configuration.FieldRepeatSeparator, PlacerContactPerson.Select(x => x.ToDelimitedString())) : null, PlacerContactPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, PlacerContactPhoneNumber.Select(x => x.ToDelimitedString())) : null, PlacerContactAddress != null ? string.Join(Configuration.FieldRepeatSeparator, PlacerContactAddress.Select(x => x.ToDelimitedString())) : null, PlacerContactLocation?.ToDelimitedString(), EnteredByPerson != null ? string.Join(Configuration.FieldRepeatSeparator, EnteredByPerson.Select(x => x.ToDelimitedString())) : null, EnteredByPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, EnteredByPhoneNumber.Select(x => x.ToDelimitedString())) : null, EnteredByLocation?.ToDelimitedString(), ParentPlacerAppointmentId?.ToDelimitedString(), ParentFillerAppointmentId?.ToDelimitedString(), PlacerOrderNumber != null ? string.Join(Configuration.FieldRepeatSeparator, PlacerOrderNumber.Select(x => x.ToDelimitedString())) : null, FillerOrderNumber != null ? string.Join(Configuration.FieldRepeatSeparator, FillerOrderNumber.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public void Continue_with_manager_approval_timeout_when_hrapproval_is_received_and_processed_before_timeout_and_signal_timer_is_fired( Type workflowType, ScheduleId promoteEmployee, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completedStamp = currentTime.AddHours(-2); var lg = completedGraph(completedStamp); _builder.AddProcessedEvents(lg); var signalTriggerEventId = lg.First().EventId; _builder.AddProcessedEvents(WaitForSignalEvent(promoteEmployee, signalTriggerEventId, completedStamp, _waitingSignals)); _builder.AddProcessedEvents(_graphBuilder.WorkflowSignaledEvent("HRApproved", "input", completedTime: currentTime.AddHours(-1))); _builder.AddProcessedEvents(_graphBuilder.WorkflowItemSignalledEvent(promoteEmployee, signalTriggerEventId, "HRApproved")); var timerFiredGraph = _graphBuilder.TimerFiredGraph(promoteEmployee, TimeSpan.FromHours(1), TimerType.SignalTimer, signalTriggerEventId, currentTime); _builder.AddNewEvents(timerFiredGraph); var workflow = (Workflow)Activator.CreateInstance(workflowType); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions.Length, Is.EqualTo(2)); decisions[0].AssertSignalTimedout(promoteEmployee, signalTriggerEventId, new[] { "ManagerApproved" }, timerFiredGraph.First().EventId); Assert.That(decisions[1], Is.EqualTo(new ScheduleLambdaDecision(_managerApprovalTimedout, ""))); }
public GetAvailabilitiesQuery(FacilityId facilityId, ScheduleId scheduleId, DateTime?startTime, DateTime?endTime) { FacilityId = facilityId; ScheduleId = scheduleId; StartTime = startTime; EndTime = endTime; }
public void Continue_with_manager_approval_timeout_when_hrapproval_is_received_before_timeout_and_manager_approval_is_received_after_timeout_and_both_signals_are_processed_togather( Type workflowType, ScheduleId promoteEmployee, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completedStamp = currentTime.AddMinutes(-121); var lg = completedGraph(completedStamp); _builder.AddProcessedEvents(lg); var signalTriggerEventId = lg.First().EventId; _builder.AddProcessedEvents(WaitForSignalEvent(promoteEmployee, signalTriggerEventId, completedStamp, _waitingSignals)); var hrSignal = _graphBuilder.WorkflowSignaledEvent("HRApproved", "input", completedTime: currentTime.AddHours(-1)); _builder.AddNewEvents(hrSignal); var managerSignal = _graphBuilder.WorkflowSignaledEvent("ManagerApproved", "input", completedTime: currentTime); _builder.AddNewEvents(managerSignal); var workflow = (Workflow)Activator.CreateInstance(workflowType); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions.Length, Is.EqualTo(3)); Assert.That(decisions[0], Is.EqualTo(new WorkflowItemSignalledDecision(promoteEmployee, signalTriggerEventId, "HRApproved", hrSignal.EventId))); Assert.That(decisions[1], Is.EqualTo(new ScheduleLambdaDecision(_managerApprovalTimedout, ""))); decisions[2].AssertSignalTimedout(promoteEmployee, signalTriggerEventId, new[] { "ManagerApproved" }, managerSignal.EventId); }
public void Setup() { _graphBuilder = new EventGraphBuilder(); _builder = new HistoryEventsBuilder(); _confirmEmailId = Identity.Lambda("ConfirmEmail").ScheduleId(); _builder.AddProcessedEvents(_graphBuilder.WorkflowStartedEvent()); }
public void Signal_timer_is_ignored_when_it_is_fired_after_receiving_the_signal( Type workflowType, ScheduleId promoteEmployee, CompletedEventGraph completedGraph) { var currentTime = DateTime.UtcNow; var completedStamp = currentTime.AddHours(-2); var lg = completedGraph(completedStamp); _builder.AddProcessedEvents(lg); var signalTriggerEventId = lg.First().EventId; _builder.AddProcessedEvents(WaitForSignalEvent(promoteEmployee, signalTriggerEventId, completedStamp, _waitingSignals)); _builder.AddProcessedEvents(_graphBuilder.WorkflowSignaledEvent("HRApproved", "input", completedTime: currentTime.AddHours(-1))); _builder.AddProcessedEvents(_graphBuilder.WorkflowItemSignalledEvent(promoteEmployee, signalTriggerEventId, "HRApproved")); _builder.AddProcessedEvents(_graphBuilder.WorkflowSignaledEvent("ManagerApproved", "input", completedTime: currentTime.AddHours(-1))); _builder.AddProcessedEvents(_graphBuilder.WorkflowItemSignalledEvent(promoteEmployee, signalTriggerEventId, "ManagerApproved")); var timerFiredGraph = _graphBuilder.TimerFiredGraph(promoteEmployee, TimeSpan.FromHours(1), TimerType.SignalTimer, signalTriggerEventId, currentTime); var workflow = (Workflow)Activator.CreateInstance(workflowType); _builder.AddNewEvents(timerFiredGraph); var decisions = workflow.Decisions(_builder.Result()).ToArray(); Assert.That(decisions, Is.Empty); }
public void Setup() { _graphBuilder = new EventGraphBuilder(); _builder = new HistoryEventsBuilder(); _promoteId = Identity.Lambda("PromoteEmployee").ScheduleId(); _builder.AddProcessedEvents(_graphBuilder.WorkflowStartedEvent()); }
public override int GetHashCode() { int hash = 1; if (MonsterEnhancementId != 0UL) { hash ^= MonsterEnhancementId.GetHashCode(); } if (TrainerId != 0UL) { hash ^= TrainerId.GetHashCode(); } if (MonsterIdCurrent != 0UL) { hash ^= MonsterIdCurrent.GetHashCode(); } if (MonsterIdNext != 0UL) { hash ^= MonsterIdNext.GetHashCode(); } if (ScheduleId.Length != 0) { hash ^= ScheduleId.GetHashCode(); } if (Type.Length != 0) { hash ^= Type.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 26, Configuration.FieldSeparator), Id, PlacerAppointmentId?.ToDelimitedString(), FillerAppointmentId?.ToDelimitedString(), OccurrenceNumber.HasValue ? OccurrenceNumber.Value.ToString(Consts.NumericFormat, culture) : null, PlacerGroupNumber?.ToDelimitedString(), ScheduleId?.ToDelimitedString(), EventReason?.ToDelimitedString(), AppointmentReason?.ToDelimitedString(), AppointmentType?.ToDelimitedString(), AppointmentDuration.HasValue ? AppointmentDuration.Value.ToString(Consts.NumericFormat, culture) : null, AppointmentDurationUnits?.ToDelimitedString(), AppointmentTimingQuantity != null ? string.Join(Configuration.FieldRepeatSeparator, AppointmentTimingQuantity.Select(x => x.ToDelimitedString())) : null, PlacerContactPerson?.ToDelimitedString(), PlacerContactPhoneNumber?.ToDelimitedString(), PlacerContactAddress?.ToDelimitedString(), PlacerContactLocation?.ToDelimitedString(), FillerContactPerson?.ToDelimitedString(), FillerContactPhoneNumber?.ToDelimitedString(), FillerContactAddress?.ToDelimitedString(), FillerContactLocation?.ToDelimitedString(), EnteredByPerson?.ToDelimitedString(), EnteredByPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, EnteredByPhoneNumber.Select(x => x.ToDelimitedString())) : null, EnteredByLocation?.ToDelimitedString(), ParentPlacerAppointmentId?.ToDelimitedString(), ParentFillerAppointmentId?.ToDelimitedString(), FillerStatusCode?.ToDelimitedString() ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public void Setup() { _builder = new EventGraphBuilder(); _scheduleId = Guflow.Decider.Identity.New(ActivityName, ActivityVersion, PositionalName).ScheduleId(); var completedActivityEventGraph = _builder.ActivityCompletedGraph(_scheduleId, Identity, Result, Input); _activityCompletedEvent = new ActivityCompletedEvent(completedActivityEventGraph.First(), completedActivityEventGraph); }
public void Setup() { _eventGraphBuilder = new EventGraphBuilder(); _builder = new HistoryEventsBuilder(); _scheduleId = Identity.New(WorkflowName, WorkflowVersion, PositionalName).ScheduleId(); _eventGraph = _eventGraphBuilder.ChildWorkflowStartedEventGraph(_scheduleId, "runid", "input").ToArray(); _completedEvent = new ChildWorkflowStartedEvent(_eventGraph.First(), _eventGraph); }
public void Setup() { _builder = new EventGraphBuilder(); _scheduleId = Guflow.Decider.Identity.New(ActivityName, ActivityVersion, PositionalName).ScheduleId(); var failedActivityEventGraph = _builder.ActivityFailedGraph(_scheduleId, Identity, Reason, Detail); _activityFailedEvent = new ActivityFailedEvent(failedActivityEventGraph.First(), failedActivityEventGraph); }
/// <summary> /// Initializes a new instance of the <see cref="ExecutingVertexEventArgs"/> class. /// </summary> /// <param name="schedule">The ID of the schedule that is currently being executed.</param> /// <param name="vertex">The index of the vertex that is currently being executed.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="schedule"/> is <see langword="null" />. /// </exception> public ExecutingVertexEventArgs(ScheduleId schedule, int vertex) { { Lokad.Enforce.Argument(() => schedule); } m_Schedule = schedule; m_Vertex = vertex; }
/// <summary> /// Initializes a new instance of the <see cref="SubScheduleVertex"/> class. /// </summary> /// <param name="index">The index of the vertex in the graph.</param> /// <param name="subSchedule">The ID of the schedule that should be executed.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="subSchedule"/> is <see langword="null" />. /// </exception> public SubScheduleVertex(int index, ScheduleId subSchedule) { { Lokad.Enforce.Argument(() => subSchedule); } Index = index; m_SubSchedule = subSchedule; }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleInformation"/> class. /// </summary> /// <param name="id">The ID of the schedule that is being described by this information object.</param> /// <param name="name">The name of the schedule that is being described by this information object.</param> /// <param name="description">The description of the schedule that is being described by this information object.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="id"/> is <see langword="null" />. /// </exception> public ScheduleInformation( ScheduleId id, string name, string description) { { Lokad.Enforce.Argument(() => id); } m_Id = id; m_Name = name; m_Description = description; }
public void CycleWithNoEdgesFromStart() { var knownSchedules = new Mock<IStoreSchedules>(); var verifier = new ScheduleVerifier(knownSchedules.Object); var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); graph.AddVertex(start); var end = new EndVertex(2); graph.AddVertex(end); var vertex1 = new InsertVertex(3); graph.AddVertex(vertex1); var vertex2 = new InsertVertex(4); graph.AddVertex(vertex2); var vertex3 = new InsertVertex(5); graph.AddVertex(vertex3); graph.AddEdge(new ScheduleEdge(start, end)); graph.AddEdge(new ScheduleEdge(vertex1, end)); graph.AddEdge(new ScheduleEdge(vertex1, vertex2)); graph.AddEdge(new ScheduleEdge(vertex2, vertex3)); graph.AddEdge(new ScheduleEdge(vertex3, vertex1)); var schedule = new Schedule(graph, start, end); var id = new ScheduleId(); var failures = new List<Tuple<ScheduleIntegrityFailureType, IScheduleVertex>>(); var result = verifier.IsValid( id, schedule, (f, v) => failures.Add(new Tuple<ScheduleIntegrityFailureType, IScheduleVertex>(f, v))); Assert.IsFalse(result); Assert.AreEqual(3, failures.Count); Assert.AreEqual(ScheduleIntegrityFailureType.ScheduleVertexIsNotReachableFromStart, failures[0].Item1); Assert.AreSame(vertex1, failures[0].Item2); Assert.AreEqual(ScheduleIntegrityFailureType.ScheduleVertexIsNotReachableFromStart, failures[1].Item1); Assert.AreSame(vertex2, failures[1].Item2); Assert.AreEqual(ScheduleIntegrityFailureType.ScheduleVertexIsNotReachableFromStart, failures[2].Item1); Assert.AreSame(vertex3, failures[2].Item2); }
public void ExecuteWithAlreadyRunningSchedule() { var action1 = new ScheduleElementId(); var action2 = new ScheduleElementId(); var exitCondition = new ScheduleElementId(); var passThroughCondition = new ScheduleElementId(); var subSchedule = new ScheduleId(); var schedule = BuildSchedule( action1, action2, subSchedule, exitCondition, passThroughCondition); var knownSchedules = ScheduleStorage.CreateInstanceWithoutTimeline(); var scheduleInfo = knownSchedules.Add( schedule, "a", "b"); var executor = new Mock<IExecuteSchedules>(); int index = 0; Func<ISchedule, ScheduleId, ScheduleExecutionInfo, IExecuteSchedules> builder = (s, id, e) => { index++; return executor.Object; }; var distributor = new ScheduleDistributor(knownSchedules, builder); var returnedExecutor = distributor.Execute(scheduleInfo.Id); Assert.AreSame(executor.Object, returnedExecutor); Assert.AreEqual(1, index); var otherReturnedExecutor = distributor.Execute(scheduleInfo.Id); Assert.AreSame(executor.Object, otherReturnedExecutor); Assert.AreEqual(1, index); }
public void Process() { var subExecutor = new Mock<IExecuteSchedules>(); { subExecutor.Setup(s => s.IsLocal) .Returns(false); } var distributor = new Mock<IDistributeScheduleExecutions>(); { distributor.Setup( d => d.Execute( It.IsAny<ScheduleId>(), It.IsAny<IEnumerable<IScheduleVariable>>(), It.IsAny<ScheduleExecutionInfo>(), It.IsAny<bool>())) .Returns(subExecutor.Object) .Verifiable(); } var id = new ScheduleId(); var processor = new SubScheduleVertexProcessor(distributor.Object); using (var info = new ScheduleExecutionInfo()) { var state = processor.Process(new SubScheduleVertex(1, id), info); Assert.AreEqual(ScheduleExecutionState.Executing, state); distributor.Verify( d => d.Execute( It.Is<ScheduleId>(incoming => incoming.Equals(id)), It.IsAny<IEnumerable<IScheduleVariable>>(), It.IsAny<ScheduleExecutionInfo>(), It.IsAny<bool>()), Times.Once()); } }
/// <summary> /// Adds the <see cref="ISchedule"/> object with the variables it affects and the dependencies for that schedule. /// </summary> /// <param name="schedule">The schedule that should be stored.</param> /// <param name="name">The name of the schedule that is being described by this information object.</param> /// <param name="description">The description of the schedule that is being described by this information object.</param> /// <returns>An object identifying and describing the schedule.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="schedule"/> is <see langword="null" />. /// </exception> public ScheduleInformation Add( ISchedule schedule, string name, string description) { { Lokad.Enforce.Argument(() => schedule); } var id = new ScheduleId(); var info = new ScheduleInformation(id, name, description); m_Schedules.Add(id, new ScheduleMap(info, schedule)); return info; }
public bool Contains(ScheduleId id) { return (id != null) && m_Schedules.ContainsKey(id); }
/// <summary> /// Replaces the schedule current stored against the given ID with a new one. /// </summary> /// <param name="scheduleToReplace">The ID of the schedule that should be replaced.</param> /// <param name="newSchedule">The new schedule.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="scheduleToReplace"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="newSchedule"/> is <see langword="null" />. /// </exception> /// <exception cref="UnknownScheduleException"> /// Thrown if <paramref name="scheduleToReplace"/> is not linked to a known schedule. /// </exception> public void Update( ScheduleId scheduleToReplace, ISchedule newSchedule) { { Lokad.Enforce.Argument(() => scheduleToReplace); Lokad.Enforce.Argument(() => newSchedule); Lokad.Enforce.With<UnknownScheduleException>( m_Schedules.ContainsKey(scheduleToReplace), Resources.Exceptions_Messages_UnknownSchedule); } var oldInfo = m_Schedules[scheduleToReplace].Information; var info = new ScheduleInformation( scheduleToReplace, oldInfo.Name, oldInfo.Description); m_Schedules[scheduleToReplace] = new ScheduleMap(info, newSchedule); }
/// <summary> /// Returns the schedule that is mapped to the given ID. /// </summary> /// <param name="id">The ID for the schedule.</param> /// <returns>The schedule.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="id"/> is <see langword="null" />. /// </exception> /// <exception cref="UnknownScheduleException"> /// Thrown if <paramref name="id"/> is not linked to a known schedule. /// </exception> public ISchedule Schedule(ScheduleId id) { { Lokad.Enforce.Argument(() => id); Lokad.Enforce.With<UnknownScheduleException>( m_Schedules.ContainsKey(id), Resources.Exceptions_Messages_UnknownSchedule); } return m_Schedules[id].Schedule; }
public void StartVertexWithInboundEdges() { var knownSchedules = new Mock<IStoreSchedules>(); var verifier = new ScheduleVerifier(knownSchedules.Object); Schedule schedule; { var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); graph.AddVertex(start); var end = new EndVertex(2); graph.AddVertex(end); var vertex1 = new InsertVertex(3); graph.AddVertex(vertex1); var vertex2 = new InsertVertex(4); graph.AddVertex(vertex2); graph.AddEdge(new ScheduleEdge(start, vertex1)); graph.AddEdge(new ScheduleEdge(vertex1, vertex2)); graph.AddEdge(new ScheduleEdge(vertex2, start)); graph.AddEdge(new ScheduleEdge(vertex2, end)); schedule = new Schedule(graph, start, end); } var id = new ScheduleId(); var failures = new List<Tuple<ScheduleIntegrityFailureType, IScheduleVertex>>(); var result = verifier.IsValid( id, schedule, (f, v) => failures.Add(new Tuple<ScheduleIntegrityFailureType, IScheduleVertex>(f, v))); Assert.IsFalse(result); Assert.AreEqual(1, failures.Count); Assert.AreEqual(ScheduleIntegrityFailureType.ScheduleIsMissingStart, failures[0].Item1); Assert.AreSame(schedule.Start, failures[0].Item2); }
private static Schedule BuildSchedule( ScheduleElementId action1, ScheduleElementId action2, ScheduleId scheduleId, ScheduleElementId exitCondition, ScheduleElementId passThroughCondition) { var variable = new Mock<IScheduleVariable>(); // Making a schedule that looks like: // start --> node1 -----------------------> node2 -> end // ^ | // |-- node5 <-- node4 <-- node3<-| // ^ | // node7--| |-> node6 // ^ | // |--------------| Schedule schedule = null; { var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); graph.AddVertex(start); var end = new EndVertex(2); graph.AddVertex(end); var vertex1 = new ExecutingActionVertex(3, action1); graph.AddVertex(vertex1); var vertex2 = new ExecutingActionVertex(4, action2); graph.AddVertex(vertex2); var vertex3 = new SynchronizationStartVertex(5, new IScheduleVariable[] { variable.Object }); graph.AddVertex(vertex3); var vertex4 = new ExecutingActionVertex(6, action2); graph.AddVertex(vertex4); var vertex5 = new SynchronizationEndVertex(7); graph.AddVertex(vertex5); var vertex6 = new SubScheduleVertex(8, scheduleId); graph.AddVertex(vertex6); var vertex7 = new InsertVertex(9); graph.AddVertex(vertex7); graph.AddEdge(new ScheduleEdge(start, vertex1)); graph.AddEdge(new ScheduleEdge(vertex1, vertex2)); graph.AddEdge(new ScheduleEdge(vertex2, end, exitCondition)); graph.AddEdge(new ScheduleEdge(vertex2, vertex3)); graph.AddEdge(new ScheduleEdge(vertex3, vertex4)); graph.AddEdge(new ScheduleEdge(vertex4, vertex5, passThroughCondition)); graph.AddEdge(new ScheduleEdge(vertex4, vertex6)); graph.AddEdge(new ScheduleEdge(vertex5, vertex1)); graph.AddEdge(new ScheduleEdge(vertex6, vertex7)); graph.AddEdge(new ScheduleEdge(vertex7, vertex4)); schedule = new Schedule(graph, start, end); } return schedule; }
/// <summary> /// Adds the schedule with the specified ID as a sub-schedule to the current schedule. /// </summary> /// <param name="schedule">The ID of the sub-schedule.</param> /// <returns>The vertex that contains the information about the given sub-schedule.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="schedule"/> is <see langword="null" />. /// </exception> public SubScheduleVertex AddSubSchedule(ScheduleId schedule) { { Lokad.Enforce.Argument(() => schedule); } return m_Builder.AddSubSchedule(schedule); }
private bool DoesSubScheduleLinkTo(ScheduleId scheduleId, ISchedule schedule) { var result = false; schedule.TraverseAllScheduleVertices( schedule.Start, (node, edges) => { var scheduleNode = node as SubScheduleVertex; if (scheduleNode == null) { return true; } var subScheduleId = scheduleNode.ScheduleToExecute; if (subScheduleId.Equals(scheduleId)) { result = true; return false; } var isKnownSchedule = m_Schedules.Contains(subScheduleId); if (!isKnownSchedule) { result = false; return true; } var doesSubScheduleLink = DoesSubScheduleLinkTo(scheduleId, m_Schedules.Schedule(subScheduleId)); if (doesSubScheduleLink) { result = true; return false; } return true; }); return result; }
public void InsertInWithSubSchedule() { var conditionId1 = new ScheduleElementId(); var conditionId2 = new ScheduleElementId(); var builder = new FixedScheduleBuilder(); var insertVertex = builder.AddInsertPoint(); builder.LinkFromStart(insertVertex, conditionId1); builder.LinkToEnd(insertVertex, conditionId2); var scheduleId = new ScheduleId(); builder.InsertIn(insertVertex, scheduleId); var schedule = builder.Build(); int index = 0; var vertexTypes = new List<Type> { typeof(StartVertex), typeof(InsertVertex), typeof(SubScheduleVertex), typeof(InsertVertex), typeof(EndVertex) }; var conditions = new List<ScheduleElementId> { conditionId1, null, null, conditionId2 }; schedule.TraverseAllScheduleVertices( schedule.Start, (vertex, edges) => { Assert.AreEqual(vertexTypes[index], vertex.GetType()); if (index < conditions.Count) { Assert.AreEqual(1, edges.Count()); Assert.AreEqual(conditions[index], edges.First().Item1); } index++; return true; }); }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleExecutor"/> class. /// </summary> /// <param name="executors">The collection of vertex processors.</param> /// <param name="conditions">The collection of execution conditions.</param> /// <param name="schedule">The schedule that should be executed.</param> /// <param name="id">The ID of the schedule that is being executed.</param> /// <param name="executionInfo">The object that stores information about the current running schedule.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="executors"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="conditions"/> is <see langword="null" />. /// </exception> /// <exception cref="CannotExecuteScheduleWithoutProcessorsException"> /// Thrown if <paramref name="executors"/> is an empty collection. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="schedule"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="id"/> is <see langword="null" />. /// </exception> public ScheduleExecutor( IEnumerable<IProcesExecutableScheduleVertices> executors, IStoreScheduleConditions conditions, ISchedule schedule, ScheduleId id, ScheduleExecutionInfo executionInfo = null) { { Lokad.Enforce.Argument(() => executors); Lokad.Enforce.With<CannotExecuteScheduleWithoutProcessorsException>( executors.Any(), Resources.Exceptions_Messages_CannotExecuteScheduleWithoutProcessors); Lokad.Enforce.Argument(() => conditions); Lokad.Enforce.Argument(() => schedule); Lokad.Enforce.Argument(() => id); } m_Executors = executors.ToDictionary(v => v.VertexTypeToProcess, v => v); m_Conditions = conditions; m_Schedule = schedule; m_ScheduleId = id; m_ExecutionInfo = new ScheduleExecutionInfo(executionInfo); }
public void AddSubSchedule() { var scheduleId = new ScheduleId(); var builder = new FixedScheduleBuilder(); var subScheduleVertex = builder.AddSubSchedule(scheduleId); builder.LinkFromStart(subScheduleVertex); builder.LinkToEnd(subScheduleVertex); Assert.AreEqual(scheduleId, subScheduleVertex.ScheduleToExecute); Assert.AreEqual(2, subScheduleVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(subScheduleVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
private void RaiseOnVertexProcess(ScheduleId schedule, int vertexIndex) { var local = OnVertexProcess; if (local != null) { local(this, new ExecutingVertexEventArgs(schedule, vertexIndex)); } }
public void AddSubSchedule() { var owner = new Mock<IOwnScheduleDefinitions>(); var schedule = new ScheduleId(); ScheduleId storedId = null; var scheduleVertex = new SubScheduleVertex(0, schedule); var scheduleBuilder = new Mock<IBuildFixedSchedules>(); { scheduleBuilder.Setup(s => s.AddSubSchedule(It.IsAny<ScheduleId>())) .Callback<ScheduleId>(s => storedId = s) .Returns(scheduleVertex); } var builder = new ScheduleDefinitionBuilder(owner.Object, scheduleBuilder.Object); var vertex = builder.AddSubSchedule(schedule); Assert.AreSame(scheduleVertex, vertex); Assert.AreSame(schedule, storedId); }
public void VertexWithMultipleEdgesInOneDirection() { var knownSchedules = new Mock<IStoreSchedules>(); var verifier = new ScheduleVerifier(knownSchedules.Object); var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); graph.AddVertex(start); var end = new EndVertex(2); graph.AddVertex(end); var vertex1 = new InsertVertex(3); graph.AddVertex(vertex1); graph.AddEdge(new ScheduleEdge(start, vertex1)); graph.AddEdge(new ScheduleEdge(vertex1, end)); graph.AddEdge(new ScheduleEdge(vertex1, end)); var schedule = new Schedule(graph, start, end); var id = new ScheduleId(); var failures = new List<Tuple<ScheduleIntegrityFailureType, IScheduleVertex>>(); var result = verifier.IsValid( id, schedule, (f, v) => failures.Add(new Tuple<ScheduleIntegrityFailureType, IScheduleVertex>(f, v))); Assert.IsFalse(result); Assert.AreEqual(1, failures.Count); Assert.AreEqual(ScheduleIntegrityFailureType.VertexLinksToOtherVertexInMultipleWays, failures[0].Item1); Assert.AreSame(vertex1, failures[0].Item2); }
private bool VerifySubSchedulesDoNotLinkBackToParentSchedule( ScheduleId id, ISchedule schedule, Action<ScheduleIntegrityFailureType, IScheduleVertex> onValidationFailure) { bool result = true; schedule.TraverseAllScheduleVertices( schedule.Start, (node, edges) => { var scheduleNode = node as SubScheduleVertex; if (scheduleNode == null) { return true; } var subScheduleId = scheduleNode.ScheduleToExecute; var isKnownSchedule = m_Schedules.Contains(subScheduleId); if (!isKnownSchedule) { result = false; onValidationFailure(ScheduleIntegrityFailureType.UnknownSubSchedule, node); return false; } var doesSubScheduleLink = DoesSubScheduleLinkTo(id, m_Schedules.Schedule(subScheduleId)); if (doesSubScheduleLink) { result = false; onValidationFailure(ScheduleIntegrityFailureType.SubScheduleLinksBackToParentSchedule, node); } return true; }); return result; }
public void SubScheduleWithLinkBackToParent() { var id = new ScheduleId(); var subScheduleId = new ScheduleId(); ISchedule subSchedule; { var subGraph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); var end = new EndVertex(2); var vertex1 = new SubScheduleVertex(3, id); subGraph.AddVertex(start); subGraph.AddVertex(end); subGraph.AddVertex(vertex1); subGraph.AddEdge(new ScheduleEdge(start, vertex1)); subGraph.AddEdge(new ScheduleEdge(vertex1, end)); subSchedule = new Schedule(subGraph, start, end); } IScheduleVertex errorVertex; Schedule schedule; { var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); var end = new EndVertex(2); var vertex1 = new SubScheduleVertex(3, subScheduleId); graph.AddVertex(start); graph.AddVertex(end); graph.AddVertex(vertex1); graph.AddEdge(new ScheduleEdge(start, vertex1)); graph.AddEdge(new ScheduleEdge(vertex1, end)); schedule = new Schedule(graph, start, end); errorVertex = vertex1; } var knownSchedules = new Mock<IStoreSchedules>(); { knownSchedules.Setup(s => s.Contains(It.IsAny<ScheduleId>())) .Returns<ScheduleId>(subScheduleId.Equals); knownSchedules.Setup(s => s.Schedule(It.IsAny<ScheduleId>())) .Returns<ScheduleId>(scheduleId => subSchedule); } var failures = new List<Tuple<ScheduleIntegrityFailureType, IScheduleVertex>>(); var verifier = new ScheduleVerifier(knownSchedules.Object); var result = verifier.IsValid( id, schedule, (f, v) => failures.Add(new Tuple<ScheduleIntegrityFailureType, IScheduleVertex>(f, v))); Assert.IsFalse(result); Assert.AreEqual(1, failures.Count); Assert.AreEqual(ScheduleIntegrityFailureType.SubScheduleLinksBackToParentSchedule, failures[0].Item1); Assert.AreSame(errorVertex, failures[0].Item2); }
public bool IsValid( ScheduleId id, ISchedule schedule, Action<ScheduleIntegrityFailureType, IScheduleVertex> onValidationFailure) { { Lokad.Enforce.Argument(() => schedule); Lokad.Enforce.Argument(() => onValidationFailure); } var result = VerifyStartVertexOnlyHasOutboundEdges(schedule, onValidationFailure); result &= VerifyEndVertexOnlyHasInboundEdges(schedule, onValidationFailure); result &= VerifyTrackForwardsFromStart(schedule, onValidationFailure); result &= VerifyTrackBackwardsFromEnd(schedule, onValidationFailure); result &= VerifyVerticesAreOnlyConnectedByOneEdgeInGivenDirection(schedule, onValidationFailure); // result &= VerifySynchronizationBlockHasStartAndEnd(schedule, onValidationFailure); // result &= VerifySynchronizationVariablesAreUpdatedInBlock(schedule, onValidationFailure); result &= VerifySubSchedulesDoNotLinkBackToParentSchedule(id, schedule, onValidationFailure); return result; }
/// <summary> /// Adds the schedule with the specified ID as a sub-schedule to the current schedule. /// </summary> /// <param name="schedule">The ID of the sub-schedule.</param> /// <returns>The vertex that contains the information about the given sub-schedule.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="schedule"/> is <see langword="null" />. /// </exception> public SubScheduleVertex AddSubSchedule(ScheduleId schedule) { { Lokad.Enforce.Argument(() => schedule); } var result = new SubScheduleVertex(m_Schedule.VertexCount, schedule); m_Schedule.AddVertex(result); return result; }
public void RunWithSubScheduleVertex() { var subExecutor = new Mock<IExecuteSchedules>(); { subExecutor.Setup(s => s.IsLocal) .Returns(false); } var distributor = new Mock<IDistributeScheduleExecutions>(); { distributor.Setup( d => d.Execute( It.IsAny<ScheduleId>(), It.IsAny<IEnumerable<IScheduleVariable>>(), It.IsAny<ScheduleExecutionInfo>(), It.IsAny<bool>())) .Returns(subExecutor.Object); } var id = new ScheduleId(); var schedule = BuildThreeVertexSchedule(new SubScheduleVertex(3, id)); using (var info = new ScheduleExecutionInfo(new CurrentThreadTaskScheduler())) { using (var executor = new ScheduleExecutor( new List<IProcesExecutableScheduleVertices> { new StartVertexProcessor(), new EndVertexProcessor(), new SubScheduleVertexProcessor(distributor.Object), }, ScheduleConditionStorage.CreateInstanceWithoutTimeline(), schedule, new ScheduleId(), info)) { var state = ScheduleExecutionState.None; executor.OnFinish += (s, e) => { state = e.State; }; executor.Start(); Assert.AreEqual(ScheduleExecutionState.Completed, state); } } }
/// <summary> /// Stores the created schedule and it's associated actions and conditions. /// </summary> /// <param name="schedule">The schedule.</param> /// <param name="actionMap">The collection mapping the registered actions to the schedule element that holds the action.</param> /// <param name="conditionMap">The collection mapping the registered conditions to the schedule element that holds the condition.</param> /// <returns>The ID of the newly created schedule.</returns> public ScheduleId StoreSchedule( ISchedule schedule, Dictionary<ScheduleActionRegistrationId, ScheduleElementId> actionMap, Dictionary<ScheduleConditionRegistrationId, ScheduleElementId> conditionMap) { { Debug.Assert(schedule != null, "The schedule should not be a null reference."); Debug.Assert(actionMap != null, "The collection of actions should not be a null reference."); Debug.Assert(conditionMap != null, "The collection of conditions should not be a null reference."); } var id = new ScheduleId(); m_Schedule = schedule; foreach (var pair in actionMap) { m_Actions.Add(pair.Key, pair.Value); } foreach (var pair in conditionMap) { m_Conditions.Add(pair.Key, pair.Value); } return id; }
/// <summary> /// Inserts the given schedule in the position of the insert vertex. The given schedule /// will be connected via its start and end vertices. The insert vertex will be removed /// if it has no more inserts left. /// </summary> /// <param name="insertVertex">The vertex which will be replaced.</param> /// <param name="scheduleToInsert">The ID of the schedule that will be inserted.</param> /// <returns> /// A tuple containing newly created sub-schedule vertex and the insert vertices that were place before and after /// the newly inserted sub-schedule vertex. /// </returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="insertVertex"/> is <see langword="null" />. /// </exception> /// <exception cref="UnknownScheduleVertexException"> /// Thrown if <paramref name="insertVertex"/> does not exist in the current schedule. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="scheduleToInsert"/> is <see langword="null" />. /// </exception> /// <exception cref="NoInsertsLeftOnVertexException"> /// Thrown if <paramref name="insertVertex"/> has no more inserts left. /// </exception> public Tuple<InsertVertex, SubScheduleVertex, InsertVertex> InsertIn( InsertVertex insertVertex, ScheduleId scheduleToInsert) { var subScheduleVertex = new SubScheduleVertex(m_Schedule.VertexCount, scheduleToInsert); var internalResult = InsertIn(insertVertex, subScheduleVertex); return new Tuple<InsertVertex, SubScheduleVertex, InsertVertex>( internalResult.Item1, subScheduleVertex, internalResult.Item2); }