private void SaveItemRelations(WorkItemsRelationTypeUI relationTypeUI, IBindedItem currentItem) { foreach (var itemRelation in currentItem.ItemRelations) { itemRelation.RelationTypeId = ItemRelationHelper.ConvertUIItemRelationToBLItem(relationTypeUI, currentItem.IsFirst); GlobalObjects.NewKeeper.Save(itemRelation); } }
private bool RelateditemContainsLinkOnCurrentItem(IBindedItem thisItem, IBindedItem anotherItem) { return (anotherItem.ItemRelations.Any( itemsRelation => itemsRelation.FirstItemId == anotherItem.ItemId && itemsRelation.FirtsItemTypeId == thisItem.SmartCoreObjectType.ItemId || itemsRelation.SecondItemId == anotherItem.ItemId && itemsRelation.SecondItemTypeId == thisItem.SmartCoreObjectType.ItemId)); }
public static bool?IsAffect(this IBindedItem bindedItem) { if (bindedItem.ItemRelations.Count == 0) { return(null); } if (!bindedItem.IsFirst.HasValue) { return(null); } if (bindedItem.IsFirst == true && bindedItem.WorkItemsRelationType == WorkItemsRelationType.CalculationAffect) { return(true); } if (bindedItem.IsFirst == false && bindedItem.WorkItemsRelationType == WorkItemsRelationType.CalculationDepend) { return(true); } return(false); }
private void LookupComboboxMaintenanceDirectiveSelectedIndexChanged(object sender, EventArgs e) { if (lookupComboboxMaintenanceDirective.SelectedItem != null) { var bindedItem = (MaintenanceDirective)lookupComboboxMaintenanceDirective.SelectedItem; var itemRelations = GlobalObjects.ItemsRelationsDataAccess.GetRelations(bindedItem.ItemId, bindedItem.SmartCoreObjectType.ItemId); if (_lastBindedMpd == null) { _lastBindedMpd = bindedItem; } comboBoxMpdTaskType.SelectedItem = bindedItem.WorkType; bindedItem.ItemRelations.Clear(); if (itemRelations.Count > 0) { //TODO:(Evgenii Babak) фикс очень кривой нужно вычислять WorkItemsRelationType с помощью метода расширения для коллекции relation - ов bindedItem.ItemRelations.AddRange(itemRelations); if (bindedItem.ItemRelations.IsAllRelationWith(SmartCoreType.ComponentDirective)) { comboBoxRelationType.SelectedValue = ItemRelationHelper.ConvertBLItemRelationToUIITem(bindedItem.WorkItemsRelationType, !(bindedItem.IsFirst.HasValue && bindedItem.IsFirst.Value)); } else { ItemRelationHelper.ShowDialogIfItemHaveLinkWithAnotherItem($"MPD {bindedItem.MPDNumber}", "AD", "Component"); } } else { var selectedItem = (WorkItemsRelationTypeUI)comboBoxRelationType.SelectedValue; SetControlsEnable(selectedItem == WorkItemsRelationTypeUI.ThisItemAffectOnAnother); } } else { SetControlsEnable(true); } }
public IList <IDirective> GetBindedItemsFor(int aircraftId, IBindedItem bindedItem) { var resultCollection = new List <IDirective>(); if (bindedItem.ItemRelations.Count == 0) { return(resultCollection); } if (bindedItem.IsFirst == null) { bindedItem.NormalizeItemRelations(); } var direrctiveList = bindedItem.IsFirst == true ? bindedItem.ItemRelations.Select(i => new { ItemId = i.SecondItemId, TypeId = i.SecondItemTypeId }) : bindedItem.ItemRelations.Select(i => new { ItemId = i.FirstItemId, TypeId = i.FirtsItemTypeId }); var groupedDirective = direrctiveList.GroupBy(g => g.TypeId); foreach (var grouping in groupedDirective) { if (grouping.Key == SmartCoreType.ComponentDirective.ItemId) { resultCollection.AddRange(_componentCore.GetAircraftComponentDirectives(aircraftId, grouping.Select(g => g.ItemId).ToList()).Cast <IDirective>()); } else if (grouping.Key == SmartCoreType.Directive.ItemId) { resultCollection.AddRange(_directiveCore.GetDirectivesList(aircraftId, DirectiveType.All, grouping.Select(g => g.ItemId).ToList()).Cast <IDirective>()); } else { resultCollection.AddRange(_maintenanceCore.GetMaintenanceDirectiveList(grouping.Select(g => g.ItemId).ToList(), aircraftId).Cast <IDirective>()); } } return(resultCollection); }
public static bool IsAllRelationWith(this IEnumerable <ItemsRelation> relationsCollection, IBindedItem withItem) { return(relationsCollection.All(i => i.FirstItemId == withItem.ItemId && i.FirtsItemTypeId == withItem.SmartCoreObjectType.ItemId || i.SecondItemId == withItem.ItemId && i.SecondItemTypeId == withItem.SmartCoreObjectType.ItemId)); }
public static IEnumerable <ItemsRelation> GetRelationsWith(this IEnumerable <ItemsRelation> relationsCollection, IBindedItem withItem) { if (relationsCollection == null || withItem == null) { throw new ArgumentNullException("Input parameters can not be null"); } return(relationsCollection.Where(i => i.FirstItemId == withItem.ItemId && i.FirtsItemTypeId == withItem.SmartCoreObjectType.ItemId || i.SecondItemId == withItem.ItemId && i.SecondItemTypeId == withItem.SmartCoreObjectType.ItemId)); }