/// <summary>
        /// 录入deviceinfo信息
        /// </summary>
        /// <param name="deviceInfo"></param>
        /// <returns></returns>
        public ActionResult EnteringDeviceInfo(DeviceInfo deviceInfo)
        {
            var res = new JsonResult();

            try
            {
                DeviceInfo getAddDeviceInfo = deviceInfoService.Add(deviceInfo);
                res.Data = new { state = getAddDeviceInfo.Id };
            }
            catch (Exception e)
            {
                res.Data = new { state = false };
            }

            return(res);
        }
Пример #2
0
        public List <IMessageHandler> CreateHandlers(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction)
        {
            string emulatorName = context.Request.Path.Value.Replace($"/ws/{DeviceType}/", "");
            var    emulator     = emulatorService.FindEmulator <IDs4Emulator>(XOutput.Emulation.DeviceTypes.SonyDualShock4, emulatorName);
            var    device       = emulator.CreateDs4Device();
            DeviceDisconnectedEvent disconnectedEvent = (sender, args) => closeFunction();

            device.Closed += disconnectedEvent;
            var ip = context.Request.HttpContext.Connection.RemoteIpAddress?.ToString();

            deviceInfoService.Add(new NetworkDeviceInfo
            {
                Device     = device,
                IPAddress  = ip,
                DeviceType = XOutput.Emulation.DeviceTypes.SonyDualShock4,
                Emulator   = emulator.Name,
            });
            return(new List <IMessageHandler>
            {
                new DebugMessageHandler(),
                new Ds4FeedbackMessageHandler(device, sendFunction.GetTyped <Ds4FeedbackMessage>()),
                new Ds4InputMessageHandler(device, disconnectedEvent),
            });
        }
Пример #3
0
        // GET: Device

        /// <summary>
        /// 添加设备信息
        /// </summary>
        /// <param name="deviceInfo"></param>
        /// <returns></returns>
        public ActionResult Add(DeviceInfo deviceInfo)
        {
            var deviceId = DeviceInfoService.GetEntities(u => (u.DeviceId == deviceInfo.DeviceId && u.IsDeleted == false)).FirstOrDefault();

            if (deviceId == null)
            {
                deviceInfo.SubTime = DateTime.Now;
                int id = DeviceInfoService.Add(deviceInfo).Id;
                DeviceParameterInfo deviceParameterInfo = new DeviceParameterInfo
                {
                    DeviceInfoId = id,
                    StatusFlag   = Glove.IOT.Model.Enum.StatusFlagEnum.未连接.ToString(),
                    SubTime      = DateTime.Now,
                };
                DeviceParameterInfoService.Add(deviceParameterInfo);
                //写操作日志
                OperationLogService.Add("添加设备", "设备管理", LoginInfo, deviceInfo.DeviceId, "");
                return(Content("Ok"));
            }
            else
            {
                return(Content("fail"));
            }
        }