Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public ActionStatus Validate()
        {
            ActionLog += "Starting validation ..." + Environment.NewLine;
            if (Status == ActionStatus.Started)
            {
                if (_Logicalsystem == null || _Logicalsystem.Id == 0 || _Logicalsystem.DALSystem == null)
                {
                    ActionLog += "System not found!";
                    Message    = "System not found! Installing component on the system failed";
                    Status     = ActionStatus.Invalid;
                    return(Status);
                }

                if (_Logicalequipment.Id == 0 || _Logicalequipment.DALEquipment == null)
                {
                    ActionLog += "Equipment not found!";
                    Message    = "Equipment not found! Installing component on the system failed";
                    Status     = ActionStatus.Invalid;
                    return(Status);
                }
                var systemType = _Logicalsystem.GetSystemType();
                if (systemType == UCSystemType.Unknown)
                {
                    ActionLog += "System Type is not defined!";
                    Message    = "System Type is not defined! Link or Idler should be installed first";
                    Status     = ActionStatus.Invalid;
                    return(Status);
                }
                var  keq         = _Logicalequipment.getSystemsInstallationStatus();
                bool systemExist = false;
                if (Params.side == Side.Left)
                {
                    if ((systemType == UCSystemType.Frame && keq.LeftFrame) || (systemType == UCSystemType.Chain && keq.LeftChain))
                    {
                        systemExist = true;
                    }
                }
                else if (Params.side == Side.Right)
                {
                    if ((systemType == UCSystemType.Frame && keq.RightFrame) || (systemType == UCSystemType.Chain && keq.RightChain))
                    {
                        systemExist = true;
                    }
                }
                else
                {
                    ActionLog += "Side is not valid!";
                    Message    = "Side is not valid!";
                    Status     = ActionStatus.Invalid;
                    return(Status);
                }
                if (systemExist)
                {
                    ActionLog += "A system with the same type is already installed on this equipment!";
                    Message    = "Installation failed! system already exist.";
                    Status     = ActionStatus.Invalid;
                    return(Status);
                }
                ActionLog += "Validation completed." + Environment.NewLine;
                Message    = "Operation is valid.";
                Status     = ActionStatus.Valid;
            }
            return(Status);
        }