Beispiel #1
0
        /// <summary>
        /// Возвращает все директивы базового агрегата, или самолета
        /// </summary>
        /// <returns></returns>
        public List <MaintenanceDirective> GetMaintenanceDirectives(BaseEntityObject parent, IEnumerable <ICommonFilter> filters = null)
        {
            if (parent == null || (!(parent is Aircraft) && !(parent is BaseComponent)))
            {
                throw new ArgumentNullException();
            }

            var qrs = parent is Aircraft
                                                                        ? MaintenanceDirectiveQueries.GetAircraftDirectivesSelectQuery(((Aircraft)parent).ItemId, filters, true)
                                                                        : MaintenanceDirectiveQueries.GetSelectQuery((BaseComponent)parent, filters, true);

            List <ExecutionResultArgs> resultArgses;
            var ds = _casEnvironment.Execute(qrs, out resultArgses);

            if (resultArgses.Count(r => r.Exception != null) > 0)
            {
                throw resultArgses.First(r => r.Exception != null).Exception;
            }
            var directives = BaseQueries.GetObjectList <MaintenanceDirective>(ds, true);

            if (directives.Count == 0)
            {
                return(directives);
            }

            var directiveIds = directives.Select(d => d.ItemId).ToList();

            //Загрузка задач по компонентам привязанных к задачам из MPD
            //Компонент, для которого привязаны задачи должен находится на том ВС что и задачи MPD
            var itemsRelations = _itemsRelationsDataAccess.GetRelations(directiveIds, SmartCoreType.MaintenanceDirective.ItemId);

            if (itemsRelations.Count > 0)
            {
                foreach (var mpd in directives)
                {
                    mpd.ItemRelations.AddRange(itemsRelations.Where(i => i.FirstItemId == mpd.ItemId || i.SecondItemId == mpd.ItemId));
                }
            }

            return(directives);
        }
Beispiel #2
0
        /// <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);
        }