private void AssertAction(KAction aa, KAction ab) { Assert.IsTrue(new EntityComparer <KAction>(TestContext) .MustBeDifferent( "ActionId", "ScenarioId", "Scenario", "ResourceId", "Resource", "CreationDate", "LastModificationDate") .MustBeDifferentOrNull( "OriginalActionId", "VideoId", "Video", "CategoryId", "Category", "Reduced" ) .Collection("Thumbnail", CollectionComparison.Content) .Ignore( "CreatedByUserId", "ModifiedByUserId") .Compare(aa, ab)); // Vérifier les référentiels AssertCategory(aa.Category, ab.Category); AssertResource(aa.Resource, ab.Resource); AssertMultiReferentials(aa.Ref1, ab.Ref1, "RefId"); AssertMultiReferentials(aa.Ref2, ab.Ref2, "RefId"); AssertMultiReferentials(aa.Ref3, ab.Ref3, "RefId"); AssertMultiReferentials(aa.Ref4, ab.Ref4, "RefId"); AssertMultiReferentials(aa.Ref5, ab.Ref5, "RefId"); AssertMultiReferentials(aa.Ref6, ab.Ref6, "RefId"); AssertMultiReferentials(aa.Ref7, ab.Ref7, "RefId"); }
public void ShouldProvideNullWhenNoParent() { var paramValue = new KAction { WBS = "1", ActionId = 1 }; var source = new[] { paramValue, new KAction { WBS = "2", ActionId = 2 }, new KAction { WBS = "1.1", ActionId = 3 }, new KAction { WBS = "1.2", ActionId = 4 }, new KAction { WBS = "2.1", ActionId = 5 }, new KAction { WBS = "2.1.1", ActionId = 6 }, new KAction { WBS = "2.1.2", ActionId = 7 } }; var actualValue = source.VirtualizeTree(); actualValue.GetParentNode(paramValue) .Should().BeNull(); }
public void ShouldProvideMatchingNode() { var paramValue = new KAction { WBS = "2.1.2", ActionId = 7 }; var source = new[] { new KAction { WBS = "1", ActionId = 1 }, new KAction { WBS = "2", ActionId = 2 }, new KAction { WBS = "1.1", ActionId = 3 }, new KAction { WBS = "1.2", ActionId = 4 }, new KAction { WBS = "2.1", ActionId = 5 }, new KAction { WBS = "2.1.1", ActionId = 6 }, paramValue }; var actualValue = source.VirtualizeTree(); actualValue.GetParentNode(paramValue).Action.ActionId .Should().Be(5); }
/// <summary> /// Crée un nouvel élément représentant une action. /// </summary> /// <param name="action">L'action.</param> /// <returns>L'élément créé.</returns> protected override ActionGanttItem CreateNewActionItemImpl(KAction action) { ActionGanttItem item; if (this.IsViewByReferential()) { item = new ActionGanttItem(action, WBSHelper.IndentationFromWBS(action.WBS) + 1); } else { item = new ActionGanttItem(action, WBSHelper.IndentationFromWBS(action.WBS)); } item.CanResize = base.AllowTimingsDurationChange; Brush fillBrush, strokeBrush; GetActionBrushes(action, out fillBrush, out strokeBrush); item.FillBrush = fillBrush; item.StrokeBrush = strokeBrush; item.OrangeHeaderVisibility = ActionsTimingsMoveManagement.IsActionExternal(action) ? Visibility.Visible : Visibility.Collapsed; item.OrangeHeaderToolTip = LocalizationManager.GetString("VM_ActionManager_ExternalToolTip"); item.GreenHeaderToolTip = LocalizationManager.GetString("VM_ActionManager_NewToolTip"); return(item); }
/// <summary> /// Obtient l'action dérivée de l'action spécifiée dans le scénario dérivé spécifié. /// </summary> /// <param name="sourceAction">L'action source.</param> /// <param name="derivedScenario">Le scénario dérivé.</param> /// <returns>L'action dérivée, ou null si elle n'a pas été trouvée.</returns> public static KAction GetDerivedAction(KAction sourceAction, Scenario derivedScenario) { if (sourceAction == null) { return(null); } foreach (var action in derivedScenario.Actions) { bool found = false; var currentAction = action; while (currentAction.Original != null) { if (currentAction.Original == sourceAction) { found = true; break; } currentAction = currentAction.Original; } if (found) { return(action); } } return(null); }
public void CreateDerivatedScenario_Bug1552_Test() { var scenarioCible1 = new Scenario() { NatureCode = KnownScenarioNatures.Target, }; var actionEScenario1 = new KAction { Scenario = scenarioCible1, BuildDuration = 1, Reduced = new KActionReduced() { ActionTypeCode = KnownActionCategoryTypes.E, ReductionRatio = .1, }, WBS = "1", }; var newScenario = ScenarioCloneManager.CreateDerivatedScenario(null, scenarioCible1, KnownScenarioNatures.Target, false, 2); var actionEScenario2 = newScenario.Actions.First(); Assert.IsTrue(actionEScenario2.IsReduced); Assert.AreEqual(KnownActionCategoryTypes.E, actionEScenario2.Reduced.ActionTypeCode); }
public static string GetIES(this KAction action) { string label = null; // Amélioration if (action.Reduced != null) { // Amélioration I/E/S if (ActionsTimingsMoveManagement.IsActionInternal(action)) { label = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_Internal"); } else if (ActionsTimingsMoveManagement.IsActionExternal(action)) { label = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_External"); } else if (ActionsTimingsMoveManagement.IsActionDeleted(action)) { label = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_Deleted"); } else { throw new ArgumentOutOfRangeException(); } } return(label); }
/// <summary> /// Obtient la source de la cause des écarts. /// </summary> /// <param name="action">L'action où la cause des écarts a changé.</param> /// <param name="isFromValidationScenario"><c>true</c> si l'action provient du scénario de validation. <c>false</c> si elle provient du scénario cible.</param> /// <param name="targetAction">L'action du scénario cible.</param> /// <param name="validationAction">L'action du scénario de validation.</param> /// <returns></returns> private DifferenceReasonSource GetDifferenceReasonSource(KAction action, out bool isFromValidationScenario, out KAction targetAction, out KAction validationAction) { isFromValidationScenario = this.SelectedTargetScenario != null && this.SelectedTargetScenario.Actions.Contains(action); if (isFromValidationScenario) { validationAction = action; targetAction = ScenarioActionHierarchyHelper.GetAncestorAction(action, this.SelectedOriginalScenario); if (targetAction == null) { return(DifferenceReasonSource.FromSourceScenarioNew); } else { return(DifferenceReasonSource.FromBoth); } } else { targetAction = action; validationAction = ScenarioActionHierarchyHelper.GetDerivedAction(action, this.SelectedTargetScenario); if (validationAction == null) { return(DifferenceReasonSource.FromTargetScenarioDeleted); } else { return(DifferenceReasonSource.FromBoth); } } }
/// <summary> /// Initialise une nouvelle instance de la classe <see cref="ActionGanttItem"/>. /// </summary> /// <param name="action">L'action.</param> /// <param name="level">Le niveau d'indentation.</param> public ActionGanttItem(KAction action, int level) { Action = action; Indentation = level; Start = GanttDates.ToDateTime(action.BuildStart); Finish = GanttDates.ToDateTime(action.BuildFinish); UpdateContent(); }
public static IVideoTransformations CutForAction(this Video video, KAction action) { return(new VideoCut(video.FilePath) { From = TimeSpan.FromTicks(action.Start), Duration = TimeSpan.FromTicks(action.Duration) }); }
/// <summary> /// Appelé lorsque un type de réduction (IES) a été appliqué sur une action. /// </summary> /// <param name="action">L'action.</param> protected override void OnReducedTypeApplied(KAction action) { var item = this.ItemsOfTypeAction.FirstOrDefault(i => i.Action == action); if (item != null) { item.OrangeHeaderVisibility = ActionsTimingsMoveManagement.IsActionExternal(action) ? Visibility.Visible : Visibility.Collapsed; } }
/// <summary> /// Appelé lorsque la valeur de le propriété <see cref="BuildActionFinish"/> a changé. /// </summary> /// <param name="action">The action.</param> protected override void OnBuildActionFinishChanged(KAction action) { foreach (var item in this.ItemsOfTypeAction.Where(i => i.Action == action)) { _updatingitem = item; item.Finish = GanttDates.ToDateTime(action.BuildFinish); _updatingitem = null; } }
public void Initialize() { ServicesHelper.RegisterMockServices(); //Arbre initial : // G1 1 // T1 1.1 // T2 1.2 // T21 1.2.1 // T22 1.2.2 // T3 1.3 // T31 1.3.1 // T4 1.4 _g1 = new KAction() { Label = "G1", WBS = "1" }; _t1 = new KAction() { Label = "T1", WBS = "1.1" }; _t2 = new KAction() { Label = "T2", WBS = "1.2" }; _t21 = new KAction() { Label = "T21", WBS = "1.2.1" }; _t22 = new KAction() { Label = "T22", WBS = "1.2.2" }; _t3 = new KAction() { Label = "T3", WBS = "1.3" }; _t31 = new KAction() { Label = "T31", WBS = "1.3.1" }; _t4 = new KAction() { Label = "T4", WBS = "1.4" }; _actions = new KAction[] { _g1, _t1, _t2, _t21, _t22, _t3, _t31, _t4 }; _collection = new BulkObservableCollection <DataTreeGridItem>(); _manager = new GridActionsManager(_collection, v => _currentItem = v, null); _manager.ChangeView(GanttGridView.WBS, null); }
/// <summary> /// Retourne la liste des prédécesseurs sous forme de chaîne formattée. /// </summary> /// <param name="action">L'action.</param> /// <returns>Les prédécesseurs</returns> private static string FormatPredecessorsString(KAction action) { if (!action.Predecessors.Any()) { return(string.Empty); } else { return(string.Join(", ", action.Predecessors.Select(a => a.WBS))); } }
private void AssertClonedAction(KAction clone, long newDuration, bool hasReduced, double reductionRatio, long originalBuildDuration, string reducedActionTypeCode) { Assert.AreEqual(newDuration, clone.BuildDuration); Assert.AreEqual(hasReduced, clone.Reduced != null); if (hasReduced) { Assert.AreEqual(reductionRatio, clone.Reduced.ReductionRatio); Assert.AreEqual(originalBuildDuration, clone.Reduced.OriginalBuildDuration); Assert.AreEqual(reducedActionTypeCode, clone.Reduced.ActionTypeCode); } }
/// <summary> /// Crée un nouvel élément représentant une action. /// </summary> /// <param name="action">L'action.</param> /// <returns>L'élément créé.</returns> protected override ActionGridItem CreateNewActionItemImpl(KAction action) { if (this.IsViewByReferential()) { return(new ActionGridItem(action, WBSHelper.IndentationFromWBS(action.WBS) + 1)); } else { return(new ActionGridItem(action, WBSHelper.IndentationFromWBS(action.WBS))); } }
public void TestGetCriticalPath3() { // Prédecesseurs multiples var t1 = new KAction() { Label = "T1", WBS = "1", BuildStart = 0, BuildDuration = 2 }; var t2 = new KAction() { Label = "T2", WBS = "2", BuildStart = 0, BuildDuration = 3 }; var t3 = new KAction() { Label = "T3", WBS = "3", BuildStart = 0, BuildDuration = 4 }; var t4 = new KAction() { Label = "T4", WBS = "4", BuildStart = 0, BuildDuration = 2 }; var t5 = new KAction() { Label = "T5", WBS = "5", BuildStart = 0, BuildDuration = 2 }; var actions = new List <KAction>() { t1, t2, t3, t4, t5 }; t3.Predecessors.Add(t1); t3.Predecessors.Add(t2); t4.Predecessors.Add(t3); t5.Predecessors.Add(t3); var collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(actions); manager.FixPredecessorsSuccessorsTimings(); var actual = manager.UpdateCriticalPath().ToList(); var expected = new List <ActionPath>() { actual.First(c => c.Action == t2), actual.First(c => c.Action == t3), actual.First(c => c.Action == t4) }; CollectionAssert.AreEqual(expected, actual); }
public void TestCanAddPredecessor() { var t1 = new KAction() { Label = "T1", WBS = "1" }; var g1 = new KAction() { Label = "G1", WBS = "2" }; var t2 = new KAction() { Label = "T2", WBS = "2.1" }; var t3 = new KAction() { Label = "T3", WBS = "2.2" }; var t4 = new KAction() { Label = "T4", WBS = "3" }; var t5 = new KAction() { Label = "T5", WBS = "4" }; var actions = new List <KAction>() { t1, g1, t2, t3, t4, t5 }; t3.Predecessors.Add(t1); t3.Predecessors.Add(t2); t4.Predecessors.Add(t3); t5.Predecessors.Add(t3); var collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(actions); Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t1, t1)); Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t1, t3)); Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), g1, t3)); Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t4, t1)); Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t5, t1)); Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t2, t1)); }
/// <summary> /// Obtient la fin process d'une action. /// </summary> /// <param name="action">L'action.</param> /// <returns>La fin</returns> protected override long GetBuildFinish(KAction action) { if (_useGanttItemsTimingsOnly) { var first = this.ItemsOfTypeAction.First(i => i.Action == action); return(GanttDates.ToTicks(first.Finish)); } else { return(action.BuildFinish); } }
private void AssertAction(KAction action, int indentation, string wbs) { var item = _collection[_currentAssertIndex] as ActionGridItem; Assert.IsNotNull(item); Assert.AreEqual(action, item.Action); Assert.AreEqual(indentation, item.Indentation); Assert.AreEqual(wbs, item.Action.WBS); _currentAssertIndex++; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { KAction item = (KAction)value; if (item != null && item.Original != null && item.Original.Predecessors.Count != 0) { return(string.Join("\n", item.Original.Predecessors.OrderBy(_ => _.WBS).Select(_ => $"{_.WBS} - {_.Label}").ToArray())); } else { return("-"); } }
public void CloneActionFromInitialToTargetTest() { var catI = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.I }; var catE = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.E }; var catS = new ActionCategoryStandard { ActionTypeCode = KnownActionCategoryTypes.S }; var actionNonPretypee = new KAction() { BuildDuration = 30, }; var actionPretypeeI = new KAction() { BuildDuration = 30, Category = catI }; var actionPretypeeE = new KAction() { BuildDuration = 30, Category = catE }; var actionPretypeeS = new KAction() { BuildDuration = 30, Category = catS }; // En mode initial to target, on n'est pas sensé avoir de partie réduite à la base // Le prétype par la catégorie uniquement s'applique var clone = ScenarioCloneManager.CloneAction(actionNonPretypee, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 30, true, 0, 30, KnownActionCategoryTypes.I); clone = ScenarioCloneManager.CloneAction(actionPretypeeI, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 30, true, 0, 30, KnownActionCategoryTypes.I); clone = ScenarioCloneManager.CloneAction(actionPretypeeE, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 30, true, 0, 30, KnownActionCategoryTypes.E); clone = ScenarioCloneManager.CloneAction(actionPretypeeS, ScenarioCloneManager.ActionCloneBehavior.InitialToTarget); AssertClonedAction(clone, 0, true, 1, 30, KnownActionCategoryTypes.S); }
public void TestGetCriticalPath1() { var g1 = new KAction() { Label = "G1", WBS = "1" }; var t1 = new KAction() { Label = "T1", WBS = "1.1", BuildStart = 0, BuildDuration = 2 }; var t2 = new KAction() { Label = "T2", WBS = "1.2" }; var t21 = new KAction() { Label = "T21", WBS = "1.2.1", BuildStart = 0, BuildDuration = 2 }; var t22 = new KAction() { Label = "T22", WBS = "1.2.2", BuildStart = 0, BuildDuration = 2 }; var actions = new List <KAction>() { g1, t1, t2, t21, t22 }; t22.Predecessors.Add(t1); t21.Predecessors.Add(t22); var collection = new BulkObservableCollection <DataTreeGridItem>(); var manager = new GridActionsManager(collection, null, null); manager.ChangeView(GanttGridView.WBS, null); manager.RegisterInitialActions(actions); manager.FixPredecessorsSuccessorsTimings(); var actual = manager.UpdateCriticalPath().ToList(); //var actual = manager.GetCriticalPathv2().ToList(); var expected = new List <ActionPath>() { actual.First(c => c.Action == t1), actual.First(c => c.Action == t22), actual.First(c => c.Action == t21) }; CollectionAssert.AreEqual(expected, actual); }
private void SetBuildFinish(KAction action, long value) { if (_useGanttItemsTimingsOnly) { foreach (var item in this.ItemsOfTypeAction.Where(i => i.Action == action)) { item.Finish = GanttDates.ToDateTime(value); } } else { action.BuildFinish = value; } }
private Node CreateRecursively(KAction action, IEnumerable <KAction> actions) { var wrappedAction = new Node(action); wrappedAction.Children = new List <Node>(); if (WBSHelper.HasChildren(action, actions)) { wrappedAction.Children = WBSHelper.GetChildren(action, actions) .Select(_ => CreateRecursively(_, actions)) .OrderBy(_ => _.Action.WBSParts[WBSHelper.IndentationFromWBS(_.Action.WBS)]) .ToList(); } return(wrappedAction); }
/// <summary> /// Détermine si l'ancêtre présumée spécifiée est bien l'ancêtre de l'action spécifiée. /// </summary> /// <param name="ancestor">La présumée ancêtre.</param> /// <param name="action">L'action.</param> /// <returns> /// <c>true</c> si l'ancêtre présumée spécifiée est bien l'ancêtre de l'action spécifiée; sinon, <c>false</c>. /// </returns> public static bool IsAncestor(KAction ancestor, KAction action) { var current = action.Original; while (current != null) { if (current == ancestor) { return(true); } current = current.Original; } return(false); }
private static KAction CreateAction(string index, int duration, params KAction[] predecessors) { var t = new KAction { Label = "T" + index, WBS = index, Start = 0, Finish = 1, BuildStart = 0, BuildFinish = duration, }; t.Predecessors.AddRange(predecessors); return(t); }
/// <summary> /// Crée une nouvelle partie réduite et l'active sur l'action. /// </summary> /// <param name="originalAction">L'action d'origine.</param> /// <param name="newAction">L'action dérivée.</param> internal static void ApplyReduced(KAction originalAction, KAction newAction) { string actionTypeCode; if (originalAction.IsReduced && originalAction.Reduced.ActionTypeCode != null) { actionTypeCode = originalAction.Reduced.ActionTypeCode; } else { actionTypeCode = null; } ApplyNewReduced(newAction, actionTypeCode); }
/// <summary> /// Crée une action. /// </summary> /// <param name="duration">La durée de l'action.</param> /// <param name="predecessorIndexes">Les index des prédécesseurs.</param> private void CreateAction(long duration, params int[] predecessorIndexes) { var wbs = (_actions.Count + 1).ToString(); var action = new KAction() { Label = wbs, WBS = wbs, BuildDuration = duration }; foreach (var index in predecessorIndexes) { action.Predecessors.Add(_actions[index]); } _actions.Add(action); }
/// <summary> /// Appelé lorsqu'un prédecesseur a été ajouté. /// </summary> /// <param name="action">L'action successeur.</param> /// <param name="predecessor">Le prédécesseur.</param> protected override void OnPredecessorAdded(KAction action, KAction predecessor) { var items = this.ItemsOfTypeAction.Where(i => i.Action == action).ToArray(); var predecessorItems = this.ItemsOfTypeAction.Where(i => i.Action == predecessor).ToArray(); foreach (var item in items) { if (_currentUpdatingPredecessors != item.Predecessors) { foreach (var pItem in predecessorItems) { AddPredecessorItem(item, pItem); } } } }