Example #1
0
        /// <summary>
        ///     处理获取设备类型
        /// </summary>
        /// <returns></returns>
        public static async Task <XResponseMessage> ProcessDeviceTypeGet()
        {
            try
            {
                var deviceTypeList = _redis.GetVals <DeviceTypeDto>("deviceType", DataType.Protobuf);
                var deviceTypes    = deviceTypeList.Count > 0 ? deviceTypeList: await _devcieTypeService.GetAllAsny();

                var types = deviceTypes.Select(t => new DeviceTypeModel()
                {
                    Serialnum       = t.Serialnum,
                    Name            = t.Name,
                    ParentSerialnum = t.ParentSerialnum,
                    PhotoUrl        = t.PhotoUrl,
                    Introduce       = t.Introduce
                });
                return(ResultHelper.CreateMessage("", ErrorType.NoError, types));
            }
            catch (Exception ex)
            {
                return(ResultHelper.CreateMessage("", ErrorType.InternalError, null, ex));
            }
        }