コード例 #1
0
        public List <Core.Domain.IdAndDate> getEquipmentIdAndDateByCustomer(long customerAuto, System.Security.Principal.IPrincipal User)
        {
            List <Core.Domain.IdAndDate> result = new List <Core.Domain.IdAndDate>();

            if (customerAuto == 0)
            {
                return(result);
            }
            List <int> Ids = getEquipmentIdsByCustomer(customerAuto, User);

            using (var _context = new DAL.UndercarriageContext())
            {
                foreach (var EqId in Ids)
                {
                    var inspections = _context.ACTION_TAKEN_HISTORY.Where(m => m.equipmentid_auto == EqId && m.recordStatus == (int)BLL.Core.Domain.RecordStatus.Available && (m.action_type_auto == (int)Core.Domain.ActionType.InsertInspection || m.action_type_auto == (int)Core.Domain.ActionType.UpdateInspection));
                    if (inspections.Count() == 0)
                    {
                        result.Add(new Core.Domain.IdAndDate {
                            Id = EqId, Date = DateTime.MinValue
                        });
                    }
                    else
                    {
                        result.Add(new Core.Domain.IdAndDate {
                            Id = EqId, Date = inspections.OrderByDescending(m => m.event_date).Select(m => m.event_date).FirstOrDefault()
                        });
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        public async Task <List <RecommendedActionsViewModel> > getEquipmentRecommendedActions(int[] EqIds)
        {
            var result = new List <RecommendedActionsViewModel>();

            using (var _context = new DAL.UndercarriageContext())
            {
                var eqs = await _context.TRACK_QUOTE_DETAIL.Where(m => EqIds.Any(k => m.Quote.Inspection.equipmentid_auto == k)).GroupBy(m => m.Quote.Inspection.equipmentid_auto).Select(m => new RecommendedActionsViewModel {
                    EquipmentId = (int)m.Key, RecommendedActions = m.Select(k => new ComponentActionViewModel {
                        Id = k.quote_detail_auto, ActionType = k.op_type_auto, ComponentId = (int)k.ComponentId, Date = k.Quote.due_date ?? DateTime.MinValue, EquipmentId = (int)k.Quote.Inspection.equipmentid_auto, Title = k.Comment
                    }), CompletedActions = m.Select(k => new ComponentActionViewModel {
                        Id = 0, ActionType = k.op_type_auto, ComponentId = (int)k.ComponentId, Date = k.Quote.Inspection.inspection_date, EquipmentId = (int)k.Quote.Inspection.equipmentid_auto, Title = k.Comment
                    })
                }).ToListAsync();

                var _actions = await _context.ACTION_TAKEN_HISTORY.Where(m => EqIds.Any(k => m.equipmentid_auto == k && m.recordStatus == (int)RecordStatus.Available)).Select(m => new ComponentActionViewModel {
                    Id = (int)m.history_id, ActionType = m.action_type_auto, ComponentId = (int)(m.equnit_auto ?? 0), Date = m.event_date, EquipmentId = (int)m.equipmentid_auto, Title = m.comment
                }).ToListAsync();

                foreach (var eq in eqs)
                {
                    result.Add(new RecommendedActionsViewModel
                    {
                        EquipmentId        = eq.EquipmentId,
                        RecommendedActions = eq.RecommendedActions.ToList(),
                        CompletedActions   = eq.RecommendedActions.Join(_actions, p => p.ComponentId, q => q.ComponentId, (recs, acts) => new { recs, acts }).Where(m => m.recs.Date < m.acts.Date).Select(m => m.acts)
                    });
                }
            }
            return(result);
        }
コード例 #3
0
        public List <UserSelectedIds> getEquipmentIdAndDateByCondition(int PageNo, int PageSize, UserSelectedIds SelectedIds, int userId)
        {
            var customerIds = new CustomerManagement().getListOfActiveCustomersForLoggedInUser(userId).Select(m => m.customerId);

            PageNo = PageNo <= 1 ? 0 : PageNo - 1;
            using (var _context = new DAL.UndercarriageContext())
            {
                return(_context.EQUIPMENTs.Join(_context.CRSF, equipment => equipment.crsf_auto, jobsite => jobsite.crsf_auto, (equipment, jobsite) => new UserSelectedIds {
                    CustomerId = (int)jobsite.customer_auto, EquipmentId = (int)equipment.equipmentid_auto, FamilyId = equipment.LU_MMTA.type_auto, JobSiteId = (int)jobsite.crsf_auto, MakeId = equipment.LU_MMTA.make_auto, ModelId = equipment.LU_MMTA.model_auto, LastReadingDate = equipment.last_reading_date ?? DateTime.MinValue
                }).Where(joined => customerIds.Any(cId => joined.CustomerId == cId) && (SelectedIds.CustomerId != 0 ? joined.CustomerId == SelectedIds.CustomerId : true) && (SelectedIds.JobSiteId != 0 ? joined.JobSiteId == SelectedIds.JobSiteId : true) && (SelectedIds.EquipmentId != 0 ? joined.EquipmentId == SelectedIds.EquipmentId : true) && (SelectedIds.MakeId != 0 ? joined.MakeId == SelectedIds.MakeId : true) && (SelectedIds.FamilyId != 0 ? joined.FamilyId == SelectedIds.FamilyId : true) && (SelectedIds.ModelId != 0 ? joined.ModelId == SelectedIds.ModelId : true)).OrderByDescending(m => m.LastReadingDate).Skip(PageNo * PageSize).Take(PageSize).ToList());
            }
        }
コード例 #4
0
ファイル: SearchFavorite.cs プロジェクト: hari81/BLL
 public SearchFavorite(DAL.UndercarriageContext context) : base(context)
 {
 }