示例#1
0
        public List <MaintenanceDirective> GetMaintenanceDirectives(string text)
        {
            var qrs = MaintenanceDirectiveQueries.GetSelectQuery(text, 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);
        }
示例#2
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);
        }