MIke 2 жил өмнө
parent
commit
c4c8ebbe4d

+ 7 - 7
Service/ConnectService.cs

@@ -38,31 +38,31 @@ namespace WingDeviceService.Service
 
                 if (string.IsNullOrWhiteSpace(request.DeviceUniqueCode))
                 {
-                    throw new RpcException((int)CustomerRpcCode.DeviceUniqueCodeEmpty, "DeviceUniqueCode empty error", "DeviceUniqueCode empty error");
+                    ThrowCustomerException(CustomerRpcCode.DeviceUniqueCodeEmpty, "DeviceUniqueCode empty error");
                 }
                 if (string.IsNullOrWhiteSpace(request.DeviceModel))
                 {
-                    throw new RpcException((int)CustomerRpcCode.DeviceModelEmpty, "DeviceModel empty error", "DeviceModel empty error");
+                    ThrowCustomerException(CustomerRpcCode.DeviceModelEmpty, "DeviceModel empty error");
                 }
                 if (string.IsNullOrWhiteSpace(request.DeviceType))
                 {
-                    throw new RpcException((int)CustomerRpcCode.DeviceTypeEmpty, "DeviceType empty error", "DeviceType empty error");
+                    ThrowCustomerException(CustomerRpcCode.DeviceTypeEmpty, "DeviceType empty error");
                 }
                 if (string.IsNullOrWhiteSpace(request.SoftwareVersion))
                 {
-                    throw new RpcException((int)CustomerRpcCode.SoftwareVersionEmpty, "SoftwareVersion empty error", "SoftwareVersion empty error");
+                    ThrowCustomerException(CustomerRpcCode.SoftwareVersionEmpty, "SoftwareVersion empty error");
                 }
                 if (string.IsNullOrWhiteSpace(request.SystemVersion))
                 {
-                    throw new RpcException((int)CustomerRpcCode.SystemVersionEmpty, "SystemVersion empty error", "SystemVersion empty error");
+                    ThrowCustomerException(CustomerRpcCode.SystemVersionEmpty, "SystemVersion empty error");
                 }
                 if (string.IsNullOrWhiteSpace(request.CPUModel))
                 {
-                    throw new RpcException((int)CustomerRpcCode.CPUModelEmpty, "CPUModel empty error", "CPUModel empty error");
+                    ThrowCustomerException(CustomerRpcCode.CPUModelEmpty, "CPUModel empty error");
                 }
                 if (string.IsNullOrWhiteSpace(request.SystemLanguage))
                 {
-                    throw new RpcException((int)CustomerRpcCode.SystemVersionEmpty, "SystemLanguage empty error", "SystemLanguage empty error");
+                    ThrowCustomerException(CustomerRpcCode.SystemVersionEmpty, "SystemLanguage empty error");
                 }
 
                 #endregion

+ 7 - 7
Service/DeviceService.cs

@@ -136,7 +136,7 @@ namespace WingDeviceService.Service
             //验证
             if (string.IsNullOrWhiteSpace(request.DeviceCode))
             {
-                throw new RpcException((int)CustomerRpcCode.DeviceCodeEmpty, "DeviceCode empty error", "DeviceCode empty error");
+                ThrowCustomerException(CustomerRpcCode.DeviceCodeEmpty, "DeviceCode empty error");
             }
             var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(request.DeviceCode);
             if (deviceDb == null || deviceDb.DeviceCode != request.DeviceCode)
@@ -189,7 +189,7 @@ namespace WingDeviceService.Service
             //验证
             if (string.IsNullOrWhiteSpace(request.ShortCode))
             {
-                throw new RpcException((int)CustomerRpcCode.ShortCodeEmpty, "ShortCode empty error", "ShortCode empty error");
+                ThrowCustomerException(CustomerRpcCode.ShortCodeEmpty, "ShortCode empty error");
             }
             var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByShortCodeAsync(request.ShortCode);
             if (deviceDb == null || deviceDb.ShortCode != request.ShortCode)
@@ -265,12 +265,12 @@ namespace WingDeviceService.Service
             //验证
             if (string.IsNullOrWhiteSpace(request.DeviceCode) || string.IsNullOrWhiteSpace(request.OrganizationCode))
             {
-                throw new RpcException((int)CustomerRpcCode.DeviceCodeOrOrganizationCodeEmpty, "DeviceCode Or OrganizationCode empty error", "DeviceCode Or OrganizationCode empty error");
+                ThrowCustomerException(CustomerRpcCode.DeviceCodeOrOrganizationCodeEmpty, "DeviceCode Or OrganizationCode empty error");
             }
             var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(request.DeviceCode);
             if (deviceDb == null || deviceDb.OrganizationCode != request.OrganizationCode || deviceDb.DepartmentCode != request.DepartmentCode)
             {
-                throw new RpcException((int)CustomerRpcCode.DeviceNotExist, "DeviceInfo not exist error", "DeviceInfo not exist error");
+                ThrowCustomerException(CustomerRpcCode.DeviceNotExist, "DeviceInfo not exist error");
             }
             //根据设备code和机构code查询相关数据,查到则删除关联
             if (!string.IsNullOrEmpty(deviceDb.DepartmentCode))
@@ -377,7 +377,7 @@ namespace WingDeviceService.Service
             var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByShortCodeAsync(request.ShortCode);
             if (deviceDb == null)
             {
-                throw new RpcException((int)CustomerRpcCode.DeviceNotExist, "Not find device", "Not find device");
+                ThrowCustomerException(CustomerRpcCode.DeviceNotExist, "Not find device");
             }
             if (userInfoDO.BindDevices != null && userInfoDO.BindDevices.Contains(deviceDb.DeviceCode))
             {
@@ -444,11 +444,11 @@ namespace WingDeviceService.Service
             var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(request.DeviceCode);
             if (deviceDb == null)
             {
-                throw new RpcException((int)CustomerRpcCode.DeviceNotExist, "Not find device", "Not find device");
+                ThrowCustomerException(CustomerRpcCode.DeviceNotExist, "Not find device");
             }
             if (string.IsNullOrWhiteSpace(request.Name))
             {
-                throw new RpcException((int)CustomerRpcCode.DeviceNameEmpty, "Device name cannot be empty", "Device name cannot be empty");
+                ThrowCustomerException(CustomerRpcCode.DeviceNameEmpty, "Device name cannot be empty");
             }
             deviceDb.Name = request.Name;
             if (!string.IsNullOrWhiteSpace(request.HeadPicUrl))