public HttpResponseMessage GetConfig([FromBody] ControllerPingDto pingDto)
 {
     return(Request.ExecuteProtectedAndWrapResult <ControllerPingDto, ControllerConfigModel>(
                dto => { CheckUserAgent(Request); return PartService.GetControllerConfig(dto); },
                ModelState, pingDto
                ));
 }
 public HttpResponseMessage Ping([FromBody] ControllerPingDto controllerPingDto)
 {
     return(Request.ExecuteProtectedAndWrapResult <ControllerPingDto, IndicatorMapModel>(
                dto => { CheckUserAgent(Request); return BuildService.HandlePing(dto); },
                ModelState, controllerPingDto
                ));
 }
        public IndicatorMapModel HandlePing(ControllerPingDto pingDto)
        {
            BuildSessionManager buildSession = GetBuildSessionByMac(pingDto.Mac);

            if (buildSession == null)
            {
                throw new NotFoundException("build session");
            }

            if (!buildSession.IndicatorMaps.ContainsKey(pingDto.Mac))
            {
                return(new IndicatorMapModel());
            }
            //throw new NotFoundException("indicator map");

            return(buildSession.IndicatorMaps[pingDto.Mac]);
        }
示例#4
0
        public ControllerConfigModel GetControllerConfig(ControllerPingDto pingDto)
        {
            ConcretePartModel part = ConcretePartRepo.GetPartByMac(pingDto.Mac);

            if (part == null)
            {
                throw new NotFoundException("concrete part with specified mac");
            }

            List <int> indicators = part.Part.ConnectionHelpers.Select(helper => helper.IndicatorPinNumber).ToList();
            List <int> readers    = part.Part.ConnectionHelpers.Aggregate(
                new List <int>(),
                (acc, helper) => acc.Append(helper.ReaderPinNumber).Append(helper.ReaderPinNumberOther).ToList()
                ).ToList();

            return(new ControllerConfigModel(indicators, readers));
        }