diff --git a/common/Tnb.Common.Core/Tnb.Common.Core.csproj b/common/Tnb.Common.Core/Tnb.Common.Core.csproj index f7e011f8..d7c75c81 100644 --- a/common/Tnb.Common.Core/Tnb.Common.Core.csproj +++ b/common/Tnb.Common.Core/Tnb.Common.Core.csproj @@ -6,7 +6,7 @@ enable enable False - $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS1572;CS1573;CS0168;CS1998; + $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;CS1998; diff --git a/common/Tnb.Common/Extension/StringExtensions.cs b/common/Tnb.Common/Extension/StringExtensions.cs index 189a3c6d..02cce18e 100644 --- a/common/Tnb.Common/Extension/StringExtensions.cs +++ b/common/Tnb.Common/Extension/StringExtensions.cs @@ -950,4 +950,284 @@ public static class StringExtensions } #endregion + + #region 转换,来自Abp + /// + /// Converts PascalCase string to camelCase string. + /// + /// String to convert + /// set true to use current culture. Otherwise, invariant culture will be used. + /// set true to if you want to convert 'XYZ' to 'xyz'. + /// camelCase of the string + public static string ToCamelCase(this string str, bool useCurrentCulture = false, bool handleAbbreviations = false) + { + if (string.IsNullOrWhiteSpace(str)) + { + return str; + } + + if (str.Length == 1) + { + return useCurrentCulture ? str.ToLower() : str.ToLowerInvariant(); + } + + if (handleAbbreviations && IsAllUpperCase(str)) + { + return useCurrentCulture ? str.ToLower() : str.ToLowerInvariant(); + } + + return (useCurrentCulture ? char.ToLower(str[0]) : char.ToLowerInvariant(str[0])) + str.Substring(1); + } + + /// + /// Converts given PascalCase/camelCase string to sentence (by splitting words by space). + /// Example: "ThisIsSampleSentence" is converted to "This is a sample sentence". + /// + /// String to convert. + /// set true to use current culture. Otherwise, invariant culture will be used. + public static string ToSentenceCase(this string str, bool useCurrentCulture = false) + { + if (string.IsNullOrWhiteSpace(str)) + { + return str; + } + + return useCurrentCulture + ? Regex.Replace(str, "[a-z][A-Z]", m => m.Value[0] + " " + char.ToLower(m.Value[1])) + : Regex.Replace(str, "[a-z][A-Z]", m => m.Value[0] + " " + char.ToLowerInvariant(m.Value[1])); + } + + /// + /// Converts given PascalCase/camelCase string to kebab-case. + /// + /// String to convert. + /// set true to use current culture. Otherwise, invariant culture will be used. + public static string ToKebabCase(this string str, bool useCurrentCulture = false) + { + if (string.IsNullOrWhiteSpace(str)) + { + return str; + } + + str = str.ToCamelCase(); + + return useCurrentCulture + ? Regex.Replace(str, "[a-z][A-Z]", m => m.Value[0] + "-" + char.ToLower(m.Value[1])) + : Regex.Replace(str, "[a-z][A-Z]", m => m.Value[0] + "-" + char.ToLowerInvariant(m.Value[1])); + } + + /// + /// Converts given PascalCase/camelCase string to snake case. + /// Example: "ThisIsSampleSentence" is converted to "this_is_a_sample_sentence". + /// https://github.com/npgsql/npgsql/blob/dev/src/Npgsql/NameTranslation/NpgsqlSnakeCaseNameTranslator.cs#L51 + /// + /// String to convert. + /// + public static string ToSnakeCase(this string str) + { + if (string.IsNullOrWhiteSpace(str)) + { + return str; + } + + var builder = new StringBuilder(str.Length + Math.Min(2, str.Length / 5)); + var previousCategory = default(UnicodeCategory?); + + for (var currentIndex = 0; currentIndex < str.Length; currentIndex++) + { + var currentChar = str[currentIndex]; + if (currentChar == '_') + { + builder.Append('_'); + previousCategory = null; + continue; + } + + var currentCategory = char.GetUnicodeCategory(currentChar); + switch (currentCategory) + { + case UnicodeCategory.UppercaseLetter: + case UnicodeCategory.TitlecaseLetter: + if (previousCategory == UnicodeCategory.SpaceSeparator || + previousCategory == UnicodeCategory.LowercaseLetter || + previousCategory != UnicodeCategory.DecimalDigitNumber && + previousCategory != null && + currentIndex > 0 && + currentIndex + 1 < str.Length && + char.IsLower(str[currentIndex + 1])) + { + builder.Append('_'); + } + + currentChar = char.ToLower(currentChar); + break; + + case UnicodeCategory.LowercaseLetter: + case UnicodeCategory.DecimalDigitNumber: + if (previousCategory == UnicodeCategory.SpaceSeparator) + { + builder.Append('_'); + } + break; + + default: + if (previousCategory != null) + { + previousCategory = UnicodeCategory.SpaceSeparator; + } + continue; + } + + builder.Append(currentChar); + previousCategory = currentCategory; + } + + return builder.ToString(); + } + + /// + /// Converts camelCase string to PascalCase string. + /// + /// String to convert + /// set true to use current culture. Otherwise, invariant culture will be used. + /// PascalCase of the string + public static string ToPascalCase(this string str, bool useCurrentCulture = false) + { + if (string.IsNullOrWhiteSpace(str)) + { + return str; + } + + if (str.Length == 1) + { + return useCurrentCulture ? str.ToUpper() : str.ToUpperInvariant(); + } + + return (useCurrentCulture ? char.ToUpper(str[0]) : char.ToUpperInvariant(str[0])) + str.Substring(1); + } + + /// + /// Removes first occurrence of the given prefixes from beginning of the given string. + /// + /// The string. + /// one or more prefix. + /// Modified string or the same string if it has not any of given prefixes + public static string RemovePreFix(this string str, params string[] preFixes) + { + return str.RemovePreFix(StringComparison.Ordinal, preFixes); + } + + /// + /// Removes first occurrence of the given prefixes from beginning of the given string. + /// + /// The string. + /// String comparison type + /// one or more prefix. + /// Modified string or the same string if it has not any of given prefixes + public static string RemovePreFix(this string str, StringComparison comparisonType, params string[] preFixes) + { + if (str.IsNullOrEmpty()) + { + return str; + } + + if (preFixes.IsNullOrEmpty()) + { + return str; + } + + foreach (var preFix in preFixes) + { + if (str.StartsWith(preFix, comparisonType)) + { + return str.Right(str.Length - preFix.Length); + } + } + + return str; + } + + /// + /// Removes first occurrence of the given postfixes from end of the given string. + /// + /// The string. + /// one or more postfix. + /// Modified string or the same string if it has not any of given postfixes + public static string RemovePostFix(this string str, params string[] postFixes) + { + return str.RemovePostFix(StringComparison.Ordinal, postFixes); + } + + /// + /// Removes first occurrence of the given postfixes from end of the given string. + /// + /// The string. + /// String comparison type + /// one or more postfix. + /// Modified string or the same string if it has not any of given postfixes + public static string RemovePostFix(this string str, StringComparison comparisonType, params string[] postFixes) + { + if (str.IsNullOrEmpty()) + { + return str; + } + + if (postFixes.IsNullOrEmpty()) + { + return str; + } + + foreach (var postFix in postFixes) + { + if (str.EndsWith(postFix, comparisonType)) + { + return str.Left(str.Length - postFix.Length); + } + } + + return str; + } + + /// + /// Gets a substring of a string from beginning of the string. + /// + /// Thrown if is null + /// Thrown if is bigger that string's length + public static string Left(this string str, int len) + { + if (str.Length < len) + { + throw new ArgumentException("len argument can not be bigger than given string's length!"); + } + + return str.Substring(0, len); + } + /// + /// Gets a substring of a string from end of the string. + /// + /// Thrown if is null + /// Thrown if is bigger that string's length + public static string Right(this string str, int len) + { + if (str.Length < len) + { + throw new ArgumentException("len argument can not be bigger than given string's length!"); + } + + return str.Substring(str.Length - len, len); + } + private static bool IsAllUpperCase(string input) + { + for (int i = 0; i < input.Length; i++) + { + if (Char.IsLetter(input[i]) && !Char.IsUpper(input[i])) + { + return false; + } + } + + return true; + } + + #endregion } \ No newline at end of file diff --git a/common/Tnb.WebSockets/Tnb.WebSockets.csproj b/common/Tnb.WebSockets/Tnb.WebSockets.csproj index 081b83d5..b87a3d57 100644 --- a/common/Tnb.WebSockets/Tnb.WebSockets.csproj +++ b/common/Tnb.WebSockets/Tnb.WebSockets.csproj @@ -7,7 +7,7 @@ enable enable False - $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS1572;CS1573;CS1998; + $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS1572;CS1573;CS1998; diff --git a/extend/Tnb.Extend/Tnb.Extend.csproj b/extend/Tnb.Extend/Tnb.Extend.csproj index e5c49e58..878a7f6d 100644 --- a/extend/Tnb.Extend/Tnb.Extend.csproj +++ b/extend/Tnb.Extend/Tnb.Extend.csproj @@ -6,7 +6,7 @@ enable enable True - $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS1572;CS1573;CS0168;CS4014; + $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;CS4014; diff --git a/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj b/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj index 53b4b389..a01086ce 100644 --- a/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj +++ b/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj @@ -6,6 +6,7 @@ enable enable False + $(NoWarn);CS8625; diff --git a/system/Tnb.Systems.Entitys/Dto/Permission/OrganizeAdministrator/OrganizeAdminIsTratorUpInput.cs b/system/Tnb.Systems.Entitys/Dto/Permission/OrganizeAdministrator/OrganizeAdminIsTratorUpInput.cs index bf2e80b8..2bb1f6e2 100644 --- a/system/Tnb.Systems.Entitys/Dto/Permission/OrganizeAdministrator/OrganizeAdminIsTratorUpInput.cs +++ b/system/Tnb.Systems.Entitys/Dto/Permission/OrganizeAdministrator/OrganizeAdminIsTratorUpInput.cs @@ -7,10 +7,11 @@ namespace JNPF.Systems.Entitys.Dto.OrganizeAdministrator; /// public class OrganizeAdminIsTratorUpInput : OrganizeAdminCrInput { - /// - /// 主键. - /// - public string id { get; set; } + //modified by PhilPan + ///// + ///// 主键. + ///// + //public string id { get; set; } /// /// 权限组织集合. diff --git a/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj b/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj index 3c84db98..1418d2c1 100644 --- a/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj +++ b/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ enable enable False - $(NoWarn);CS8618; + $(NoWarn);CS8603;CS8618; diff --git a/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj b/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj index 4abeef78..fe747c12 100644 --- a/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj +++ b/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj @@ -6,7 +6,7 @@ enable enable False - $(NoWarn)CS8604; + $(NoWarn)CS8604;CS8618; diff --git a/taskschedule/Tnb.TaskScheduler/Listener/SpareTimeListener.cs b/taskschedule/Tnb.TaskScheduler/Listener/SpareTimeListener.cs index 09f0d238..4cd08159 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/SpareTimeListener.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/SpareTimeListener.cs @@ -86,7 +86,8 @@ public class SpareTimeListener : ISpareTimeListener, ISingleton } var taskEntity = await _sqlSugarClient.Queryable().FirstAsync(x => x.Id == executer.Timer.WorkerName); - var nextRunTime = ((DateTimeOffset)SpareTime.GetCronNextOccurrence(taskEntity.ExecuteCycleJson)).DateTime; + //modified by PhilPan + var nextRunTime = SpareTime.GetCronNextOccurrence(taskEntity.ExecuteCycleJson)?.DateTime; await _eventPublisher.PublishAsync(new TaskEventSource("Task:UpdateTask", connectionConfig, new TimeTaskEntity() { diff --git a/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs b/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs index d7bbce5b..ba30ffbf 100644 --- a/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs +++ b/visualdev/Tnb.VisualDev.Engine/CodeGen/CodeGenWay.cs @@ -1269,7 +1269,6 @@ public class CodeGenWay IsRelationForm = isRelationForm, ChildTableStyle = columnDesignModel.childTableStyle, }; - break; default: return new FrontEndGenConfigModel() { @@ -1339,7 +1338,6 @@ public class CodeGenWay ChildTableStyle = columnDesignModel.childTableStyle, IsFixed = isFixed, }; - break; } } diff --git a/visualdev/Tnb.VisualDev.Engine/Model/IndexGridFieldModel.cs b/visualdev/Tnb.VisualDev.Engine/Model/IndexGridFieldModel.cs index bba29120..cfdc7458 100644 --- a/visualdev/Tnb.VisualDev.Engine/Model/IndexGridFieldModel.cs +++ b/visualdev/Tnb.VisualDev.Engine/Model/IndexGridFieldModel.cs @@ -8,10 +8,11 @@ namespace JNPF.VisualDev.Engine; [SuppressSniffer] public class IndexGridFieldModel : IndexEachConfigBase { - /// - /// 对齐. - /// - public string align { get; set; } + //modified by PhilPan + ///// + ///// 对齐. + ///// + //public string align { get; set; } /// /// 固定. diff --git a/visualdev/Tnb.VisualDev.Engine/Model/IndexSearchFieldModel.cs b/visualdev/Tnb.VisualDev.Engine/Model/IndexSearchFieldModel.cs index f2ab0a13..ba618fc0 100644 --- a/visualdev/Tnb.VisualDev.Engine/Model/IndexSearchFieldModel.cs +++ b/visualdev/Tnb.VisualDev.Engine/Model/IndexSearchFieldModel.cs @@ -14,8 +14,9 @@ public class IndexSearchFieldModel : IndexEachConfigBase /// public string value { get; set; } - /// - /// 查询类型. - /// - public int? searchType { get; set; } + //modified by PhilPan + ///// + ///// 查询类型. + ///// + //public int? searchType { get; set; } } diff --git a/workflow/Tnb.WorkFlow/Manager/FlowTaskOtherUtil.cs b/workflow/Tnb.WorkFlow/Manager/FlowTaskOtherUtil.cs index a54f81ad..77a6daeb 100644 --- a/workflow/Tnb.WorkFlow/Manager/FlowTaskOtherUtil.cs +++ b/workflow/Tnb.WorkFlow/Manager/FlowTaskOtherUtil.cs @@ -361,7 +361,8 @@ public class FlowTaskOtherUtil { try { - if (jobj[timeOutConfig.formField] is long) + //modified by PhilPan + if (jobj[timeOutConfig.formField].Type == Newtonsoft.Json.Linq.JTokenType.Integer) { dt = jobj[timeOutConfig.formField].ParseToLong().TimeStampToDateTime(); }