diff --git a/COMCMS.Common/COMCMS.Common.csproj b/COMCMS.Common/COMCMS.Common.csproj index 9ae3e53..64c5fa5 100644 --- a/COMCMS.Common/COMCMS.Common.csproj +++ b/COMCMS.Common/COMCMS.Common.csproj @@ -6,7 +6,7 @@ - + diff --git a/COMCMS.Common/Utils.cs b/COMCMS.Common/Utils.cs index 630a9d4..c730f45 100644 --- a/COMCMS.Common/Utils.cs +++ b/COMCMS.Common/Utils.cs @@ -9,6 +9,9 @@ using System.Net; using System.IO; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Json; +using System.Net.NetworkInformation; +using System.Linq; +using System.Net.Sockets; namespace COMCMS.Common { @@ -1067,6 +1070,24 @@ namespace COMCMS.Common } #endregion + private static String[] _Excludes = new[] { "Loopback", "VMware", "VBox", "Virtual", "Teredo", "Microsoft", "VPN", "VNIC", "IEEE" }; + /// 获取所有网卡MAC地址 + /// + public static IEnumerable GetMacs() + { + foreach (var item in NetworkInterface.GetAllNetworkInterfaces()) + { + if (_Excludes.Any(e => item.Description.Contains(e))) continue; + if (item.Speed < 1_000_000) continue; + + var addrs = item.GetIPProperties().UnicastAddresses.Where(e => e.Address.AddressFamily == AddressFamily.InterNetwork).ToArray(); + if (addrs.All(e => IPAddress.IsLoopback(e.Address))) continue; + + var mac = item.GetPhysicalAddress()?.GetAddressBytes(); + if (mac != null && mac.Length == 6) yield return mac; + } + } + } #region 常用扩展方法 diff --git a/COMCMS.Core/COMCMS.Core.csproj b/COMCMS.Core/COMCMS.Core.csproj index 9175279..a2c8c0a 100644 --- a/COMCMS.Core/COMCMS.Core.csproj +++ b/COMCMS.Core/COMCMS.Core.csproj @@ -5,7 +5,7 @@ - + diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs index 50ed2ff..325aac9 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs @@ -71,12 +71,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers return Json(tip); } - if (model.FilePath.StartsWith("/")) + if (!model.FilePath.StartsWith("/")) { tip.Message = "栏目路径请以/开头!"; return Json(tip); } - if (!model.FilePath.EndsWith("/")) + if (model.FilePath.EndsWith("/")) { tip.Message = "栏目路径结尾不用加上/"; return Json(tip); diff --git a/COMCMS.Web/COMCMS.Web.csproj b/COMCMS.Web/COMCMS.Web.csproj index c4152d6..5d346e0 100644 --- a/COMCMS.Web/COMCMS.Web.csproj +++ b/COMCMS.Web/COMCMS.Web.csproj @@ -5,17 +5,17 @@ - - + + - - - + + + - - - - + + + + diff --git a/COMCMS.Web/Controllers/HomeController.cs b/COMCMS.Web/Controllers/HomeController.cs index 253e8f3..48a6e4e 100644 --- a/COMCMS.Web/Controllers/HomeController.cs +++ b/COMCMS.Web/Controllers/HomeController.cs @@ -65,7 +65,16 @@ namespace COMCMS.Web.Controllers #region 测试拼音 public IActionResult Test3() { - return Content(PinYinHelper.GetPinyin("关于 我们about us") + "|" + PinYinHelper.GetFirstPinyin("关于 我们") + "||" + "/sd/dsd/sd/sd/sd/sd".Count(x => x == '/')); + var mac = Utils.GetMacs().ToList(); + string re = ""; + foreach (var item in mac) + { + if (string.IsNullOrEmpty(re)) + re = item.ToHex(); + else + re += "-" + item.ToHex(); + } + return Content(re); } #endregion diff --git a/XCoder/XCoder(代码生成器).csproj b/XCoder/XCoder(代码生成器).csproj index 4f04deb..17fce69 100644 --- a/XCoder/XCoder(代码生成器).csproj +++ b/XCoder/XCoder(代码生成器).csproj @@ -30,8 +30,8 @@ 4 - - ..\packages\NewLife.Core.8.1.2019.510\lib\net45\NewLife.Core.dll + + ..\packages\NewLife.Core.8.3.2019.822\lib\net45\NewLife.Core.dll @@ -46,8 +46,8 @@ - - ..\packages\NewLife.XCode.9.11.2019.510\lib\net45\XCode.dll + + ..\packages\NewLife.XCode.9.14.2019.822\lib\net45\XCode.dll diff --git a/XCoder/packages.config b/XCoder/packages.config index 11eea0e..fc025bc 100644 --- a/XCoder/packages.config +++ b/XCoder/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file