コード例 #1
0
        /// <summary>
        /// Rerturns a system if user has access to and system is not installed on any equipment
        /// </summary>
        /// <param name="SystemId"></param>
        /// <returns></returns>
        public SystemForSetupVwMdl GetSelectedSystemForInventorySelection(int SystemId)
        {
            var result = new SystemForSetupVwMdl();

            if (!Initialized)
            {
                return(result);
            }

            var m = _context.LU_Module_Sub.Find(SystemId);

            if (m == null || m.equipmentid_auto != null || m.equipmentid_auto > 0)
            {
                return(result);
            }
            result = new SystemForSetupVwMdl {
                Id = m.Module_sub_auto.LongNullableToInt(), JobsiteId = m.crsf_auto.LongNullableToInt(), Serial = m.Serialno, EquipmentId = m.equipmentid_auto.LongNullableToInt(), Side = Side.Unknown, SystemType = (UCSystemType)m.systemTypeEnumIndex
            };
            var logicalSystem = new UCSystem(new DAL.UndercarriageContext(), SystemId);

            result.Make       = logicalSystem.getMake();
            result.Model      = logicalSystem.getModel();
            result.Family     = logicalSystem.getFamily();
            result.Side       = logicalSystem.side;
            result.SystemType = logicalSystem.GetSystemType();
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Returns a list of all systems in a specific jobsite which user has access to
        /// </summary>
        /// <param name="JobSiteId"></param>
        /// <param name="PageNo"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public List <SystemForSetupVwMdl> getSystemListForSetupInInventory(int JobSiteId, int PageNo, int PageSize)
        {
            PageNo = PageNo <= 1 ? 0 : PageNo - 1;
            var result = new List <SystemForSetupVwMdl>();

            if (!Initialized)
            {
                return(result);
            }
            var _access = new BLL.Core.Domain.UserAccess(new SharedContext(), userTableId);

            if (!_access.hasAccessToJobsite(JobSiteId))
            {
                return(result);
            }
            var jobsites = _access.getAccessibleJobsites().Select(k => k.crsf_auto).ToList();
            var systems  = _context.LU_Module_Sub.Where(m => jobsites.Any(k => m.crsf_auto == k) && (m.equipmentid_auto == null || m.equipmentid_auto == 0)).ToList();

            result = systems.Select(m => new SystemForSetupVwMdl {
                Id = m.Module_sub_auto.LongNullableToInt(), JobsiteId = m.crsf_auto.LongNullableToInt(), Serial = m.Serialno, EquipmentId = m.equipmentid_auto.LongNullableToInt(), Side = Side.Unknown, SystemType = (UCSystemType)m.systemTypeEnumIndex
            }).GroupBy(m => m.Id).Select(m => m.First()).Skip(PageNo * PageSize).Take(PageSize).ToList();
            foreach (var system in result)
            {
                var logicalSystem = new UCSystem(new DAL.UndercarriageContext(), system.Id);
                system.Make       = logicalSystem.getMake();
                system.Model      = logicalSystem.getModel();
                system.Family     = logicalSystem.getFamily();
                system.Side       = logicalSystem.side;
                system.SystemType = logicalSystem.GetSystemType();
            }
            return(result.OrderBy(m => m.Serial).ToList());
        }