/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary> /// <param name="isNew"></param> public override void Valid(Boolean isNew) { // 如果没有脏数据,则不需要进行任何处理 if (!HasDirty) { return; } if (Name.IsNullOrEmpty()) { throw new ArgumentNullException(__.Name, _.Name.DisplayName + "不能为空!"); } var len = _.CpuID.Length; if (CpuID != null && len > 0 && CpuID.Length > len) { CpuID = CpuID.Substring(0, len); } len = _.Uuid.Length; if (Uuid != null && len > 0 && Uuid.Length > len) { Uuid = Uuid.Substring(0, len); } len = _.MachineGuid.Length; if (MachineGuid != null && len > 0 && MachineGuid.Length > len) { MachineGuid = MachineGuid.Substring(0, len); } len = _.MACs.Length; if (MACs != null && len > 0 && MACs.Length > len) { MACs = MACs.Substring(0, len); } len = _.DiskID.Length; if (DiskID != null && len > 0 && DiskID.Length > len) { DiskID = DiskID.Substring(0, len); } len = _.OS.Length; if (OS != null && len > 0 && OS.Length > len) { OS = OS.Substring(0, len); } if (Period == 0) { Period = 60; } }
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary> /// <param name="isNew"></param> public override void Valid(Boolean isNew) { // 如果没有脏数据,则不需要进行任何处理 if (!HasDirty) { return; } if (Name.IsNullOrEmpty()) { throw new ArgumentNullException(__.Name, _.Name.DisplayName + "不能为空!"); } var len = _.MACs.Length; if (MACs != null && len > 0 && MACs.Length > len) { MACs = MACs.Substring(0, len); } len = _.COMs.Length; if (COMs != null && len > 0 && COMs.Length > len) { COMs = COMs.Substring(0, len); } len = _.Uuid.Length; if (Uuid != null && len > 0 && Uuid.Length > len) { Uuid = Uuid.Substring(0, len); } len = _.MachineGuid.Length; if (MachineGuid != null && len > 0 && MachineGuid.Length > len) { MachineGuid = MachineGuid.Substring(0, len); } }