/// <summary> /// Возвращает все повреждения базового агрегата, самолета, или задачи созданные в рамках страницы бортжурнала /// </summary> /// <returns></returns> public DirectiveCollection GetDamageItems(BaseComponent parentBaseComponent = null, Aircraft parentAircraft = null, ICommonFilter[] filters = null) { if (parentAircraft == null && parentBaseComponent == null) { throw new ArgumentNullException(); } List <DbQuery> qrs; if (parentBaseComponent != null) { qrs = DirectiveQueries.GetDamageItemSelectQuery(parentBaseComponent, filters, true); } else { qrs = DirectiveQueries.GetAircraftDamageItemSelectQuery(parentAircraft.ItemId, filters, true); } var directives = new DirectiveCollection(); directives.AddRange(_loader.GetObjectListAll <DamageItem>(qrs, true).ToArray()); if (directives.Count == 0) { return(directives); } var links = _newLoader.GetObjectListAll <ItemFileLinkDTO, ItemFileLink>(new List <Filter>() { new Filter("ParentId", directives.Select(i => i.ItemId)), new Filter("ParentTypeId", 3053) }, true); foreach (var directive in directives) { directive.Files.AddRange(links.Where(i => i.ParentId == directive.ItemId)); } 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); }
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> public DirectiveCollection GetDeferredItems(BaseComponent parentBaseComponent = null, Aircraft parentAircraft = null, AircraftFlight parentFlight = null, IEnumerable <ICommonFilter> filters = null) { if (parentAircraft == null && parentBaseComponent == null && parentFlight == null && filters == null) { throw new ArgumentNullException(); } List <DbQuery> qrs; if (parentBaseComponent != null) { qrs = DeferredItemQueries.GetSelectQuery(parentBaseComponent, filters, true); } else if (parentAircraft != null) { qrs = DeferredItemQueries.GetSelectQuery(parentAircraft.ItemId, filters, true); } else if (parentFlight != null) { qrs = DeferredItemQueries.GetSelectQuery(parentFlight, filters, true); } else { qrs = BaseQueries.GetSelectQueryWithWhereAll <DeferredItem>(filters.ToArray(), true); } var directives = new DirectiveCollection(); directives.AddRange(_loader.GetObjectListAll <DeferredItem>(qrs, true).ToArray()); 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); }