public DirectiveCollection GetDirectivesFromAllAircrafts(DirectiveType directiveType, string text, string paragraph) { if (directiveType == null) { directiveType = DirectiveType.AirworthenessDirectives; } var qrs = DirectiveQueries.GetSelectQuery(directiveType, text, paragraph, loadChild: true); var directives = new DirectiveCollection(); directives.AddRange(_loader.GetObjectListAll <Directive>(qrs, true)); if (directives.Count == 0) { return(directives); } var directiveIds = directives.Select(d => d.ItemId).ToList(); var itemsRelations = _itemsRelationsDataAccess.GetRelations(directiveIds, SmartCoreType.Directive.ItemId); if (itemsRelations.Count > 0) { foreach (var directive in directives) { directive.ItemRelations.AddRange(itemsRelations.Where(i => i.FirstItemId == directive.ItemId || i.SecondItemId == directive.ItemId)); } } return(directives); }
/// <summary> /// Возвращает все директивы базового агрегата, самолета, или задачи созданные в рамках страницы бортжурнала /// </summary> /// <returns></returns> private DirectiveCollection GetDirectives(BaseComponent parentBaseComponent, Aircraft parentAircraft, AircraftFlight parentFlight, DirectiveType directiveType) { if (parentAircraft == null && parentBaseComponent == null && parentFlight == null) { throw new ArgumentNullException(); } if (directiveType == null) { directiveType = DirectiveType.AirworthenessDirectives; } List <DbQuery> qrs; if (parentBaseComponent != null) { qrs = DirectiveQueries.GetSelectQuery(parentBaseComponent, directiveType, loadChild: true); } else if (parentAircraft != null) { qrs = DirectiveQueries.GetAircraftDirectivesSelectQuery(parentAircraft.ItemId, directiveType, loadChild: true); } else { qrs = DirectiveQueries.GetSelectQuery(parentFlight, directiveType, loadChild: true); } var directives = new DirectiveCollection(); directives.AddRange(_loader.GetObjectListAll <Directive>(qrs, true)); if (directives.Count == 0) { return(directives); } var directiveIds = directives.Select(d => d.ItemId).ToList(); var itemsRelations = _itemsRelationsDataAccess.GetRelations(directiveIds, SmartCoreType.Directive.ItemId); if (itemsRelations.Count > 0) { foreach (var directive in directives) { directive.ItemRelations.AddRange(itemsRelations.Where(i => i.FirstItemId == directive.ItemId || i.SecondItemId == directive.ItemId)); } } return(directives); }
/// <summary> /// Возвращает все директивы базового агрегата, самолета, или задачи созданные в рамках страницы бортжурнала /// </summary> /// <returns></returns> private DirectiveCollection GetDirectives(BaseComponent parentBaseComponent, Aircraft parentAircraft, AircraftFlight parentFlight, DirectiveType directiveType) { if (parentAircraft == null && parentBaseComponent == null && parentFlight == null) { throw new ArgumentNullException(); } if (directiveType == null) { directiveType = DirectiveType.AirworthenessDirectives; } List <DbQuery> qrs; if (parentBaseComponent != null) { qrs = DirectiveQueries.GetSelectQuery(parentBaseComponent, directiveType, loadChild: true); } else if (parentAircraft != null) { qrs = DirectiveQueries.GetAircraftDirectivesSelectQuery(parentAircraft.ItemId, directiveType, loadChild: true); } else { qrs = DirectiveQueries.GetSelectQuery(parentFlight, directiveType, loadChild: true); } var directives = new DirectiveCollection(); directives.AddRange(_loader.GetObjectListAll <Directive>(qrs, true)); if (directives.Count == 0) { return(directives); } var directiveIds = directives.Select(d => d.ItemId).ToList(); var itemsRelations = _itemsRelationsDataAccess.GetRelations(directiveIds, SmartCoreType.Directive.ItemId); var mpdCompRelations = _itemsRelationsDataAccess.GetCustomRelations(itemsRelations.Select(i => i.FirstItemId).Concat(itemsRelations.Select(i => i.SecondItemId)), SmartCoreType.ComponentDirective.ItemId); if (itemsRelations.Count > 0) { foreach (var directive in directives) { directive.ItemRelations.AddRange(itemsRelations.Where(i => i.FirstItemId == directive.ItemId || i.SecondItemId == directive.ItemId)); var mpdLink = directive.ItemRelations.FirstOrDefault(i => i.FirtsItemTypeId == SmartCoreType.MaintenanceDirective.ItemId || i.SecondItemTypeId == SmartCoreType.MaintenanceDirective.ItemId); if (mpdLink != null) { var mpdId = mpdLink.FirtsItemTypeId == SmartCoreType.MaintenanceDirective.ItemId ? mpdLink.FirstItemId : mpdLink.SecondItemId; var mpdComLink = mpdCompRelations.FirstOrDefault(i => i.FirstItemId == mpdId || i.SecondItemId == mpdId); directive.LinkComp = mpdComLink?.AdditionalInformation?.Component; } } } return(directives); }