| | |
| | | } |
| | | return content; } |
| | | |
| | | [HttpPost, Route("GetBaseRouterInfo"), AllowAnonymous] |
| | | public WebResponseContent GetBaseRouterInfo() |
| | | { |
| | | try |
| | | { |
| | | #region 鑾峰彇璺敱绫诲瀷 |
| | | List<object> routerTypes = new List<object>(); |
| | | Type routerType = typeof(RouterInOutType); |
| | | List<int> routerIndexs = Enum.GetValues(typeof(RouterInOutType)).Cast<int>().ToList(); |
| | | int routerIndex = 0; |
| | | foreach (var item in routerIndexs) |
| | | { |
| | | FieldInfo? fieldInfo = routerType.GetField(((RouterInOutType)item).ToString()); |
| | | DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); |
| | | if (description != null) |
| | | { |
| | | routerTypes.Add(new { key = item.ToString(), value = description.Description }); |
| | | } |
| | | else |
| | | { |
| | | routerTypes.Add(new { key = item.ToString(), value = item.ToString() }); |
| | | } |
| | | routerIndex++; |
| | | } |
| | | #endregion |
| | | //[HttpPost, Route("GetBaseRouterInfo"), AllowAnonymous] |
| | | //public WebResponseContent GetBaseRouterInfo() |
| | | //{ |
| | | // try |
| | | // { |
| | | // #region 鑾峰彇璺敱绫诲瀷 |
| | | // List<object> routerTypes = new List<object>(); |
| | | // Type routerType = typeof(RouterInOutType); |
| | | // List<int> routerIndexs = Enum.GetValues(typeof(RouterInOutType)).Cast<int>().ToList(); |
| | | // int routerIndex = 0; |
| | | // foreach (var item in routerIndexs) |
| | | // { |
| | | // FieldInfo? fieldInfo = routerType.GetField(((RouterInOutType)item).ToString()); |
| | | // DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); |
| | | // if (description != null) |
| | | // { |
| | | // routerTypes.Add(new { key = item.ToString(), value = description.Description }); |
| | | // } |
| | | // else |
| | | // { |
| | | // routerTypes.Add(new { key = item.ToString(), value = item.ToString() }); |
| | | // } |
| | | // routerIndex++; |
| | | // } |
| | | // #endregion |
| | | |
| | | #region 鑾峰彇璁惧缂栧彿 |
| | | object deviceCodes = _deviceProtocolRepository.QueryData(x => true).GroupBy(x => x.DeviceChildCode).Select(x => new { key = x.Key, value = x.Key }).ToList(); |
| | | // #region 鑾峰彇璁惧缂栧彿 |
| | | // object deviceCodes = _deviceProtocolRepository.QueryData(x => true).GroupBy(x => x.DeviceChildCode).Select(x => new { key = x.Key, value = x.Key }).ToList(); |
| | | |
| | | object areaInfos = Enum.GetNames(typeof(AreaInfo)).Select(x => new { key = x, value = x }).ToList(); |
| | | // object areaInfos = Enum.GetNames(typeof(AreaInfo)).Select(x => new { key = x, value = x }).ToList(); |
| | | |
| | | |
| | | #endregion |
| | | // #endregion |
| | | |
| | | return WebResponseContent.Instance.OK(data: new { routerTypes, deviceCodes, areaInfos }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | // return WebResponseContent.Instance.OK(data: new { routerTypes, deviceCodes, areaInfos }); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | |
| | | } |
| | | //} |
| | | |
| | | [HttpPost, Route("AddRouters"), AllowAnonymous] |
| | | public WebResponseContent AddRouters([FromBody] List<RoutersAddDTO> routersAddDTOs, int routerType) |