diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasCustomer.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasCustomer.cs
new file mode 100644
index 00000000..698ae11b
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Entity/BasCustomer.cs
@@ -0,0 +1,174 @@
+using System;
+using System.Linq;
+using System.Text;
+using SqlSugar;
+
+namespace Tnb.BasicData.Entities
+{
+ ///
+ ///客户信息
+ ///
+ [SugarTable("bas_customer")]
+ public partial class BasCustomer
+ {
+ public BasCustomer(){
+
+ this.org_id =Convert.ToString("NULL::character varying");
+ this.short_name =Convert.ToString("NULL::character varying");
+ this.full_address =Convert.ToString("NULL::character varying");
+ this.postal_code =Convert.ToString("NULL::character varying");
+ this.country =Convert.ToString("NULL::character varying");
+ this.province =Convert.ToString("NULL::character varying");
+ this.city =Convert.ToString("NULL::character varying");
+ this.district =Convert.ToString("NULL::character varying");
+ this.street =Convert.ToString("NULL::character varying");
+ this.contact_name =Convert.ToString("NULL::character varying");
+ this.contact_phone =Convert.ToString("NULL::character varying");
+ this.contact_mobile =Convert.ToString("NULL::character varying");
+ this.create_id =Convert.ToString("NULL::character varying");
+ this.modify_id =Convert.ToString("NULL::character varying");
+
+ }
+ ///
+ /// Desc:编号
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey=true)]
+ public string id {get;set;}
+
+ ///
+ /// Desc:客户代码
+ /// Default:
+ /// Nullable:False
+ ///
+ public string customer_code {get;set;}
+
+ ///
+ /// Desc:客户名称
+ /// Default:
+ /// Nullable:False
+ ///
+ public string customer_name {get;set;}
+
+ ///
+ /// Desc:所属组织
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? org_id {get;set;}
+
+ ///
+ /// Desc:客户简称
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? short_name {get;set;}
+
+ ///
+ /// Desc:详细地址
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? full_address {get;set;}
+
+ ///
+ /// Desc:邮编
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? postal_code {get;set;}
+
+ ///
+ /// Desc:国家
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? country {get;set;}
+
+ ///
+ /// Desc:省
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? province {get;set;}
+
+ ///
+ /// Desc:市
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? city {get;set;}
+
+ ///
+ /// Desc:区
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? district {get;set;}
+
+ ///
+ /// Desc:街道地址
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? street {get;set;}
+
+ ///
+ /// Desc:联系人名称
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? contact_name {get;set;}
+
+ ///
+ /// Desc:联系人电话
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? contact_phone {get;set;}
+
+ ///
+ /// Desc:联系人手机
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? contact_mobile {get;set;}
+
+ ///
+ /// Desc:创建用户
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? create_id {get;set;}
+
+ ///
+ /// Desc:创建时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? create_time {get;set;}
+
+ ///
+ /// Desc:修改用户
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string? modify_id {get;set;}
+
+ ///
+ /// Desc:修改时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? modify_time {get;set;}
+
+ ///
+ /// Desc:扩展字段
+ /// Default:
+ /// Nullable:True
+ ///
+ public string? extras {get;set;}
+
+ }
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Consts/EquipmentLife.cs b/EquipMgr/Tnb.EquipMgr.Entities/Consts/EquipmentLife.cs
new file mode 100644
index 00000000..7224dfc9
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Consts/EquipmentLife.cs
@@ -0,0 +1,25 @@
+namespace Tnb.EquipMgr
+{
+ ///
+ /// 设备生命周期
+ ///
+ public static class EquipmentLife
+ {
+ ///
+ /// 启用
+ ///
+ public const string ENABLE = "1";
+ ///
+ /// 停用
+ ///
+ public const string DISABLE = "2";
+ ///
+ /// 库存
+ ///
+ public const string STOCK = "3";
+ ///
+ /// 报废
+ ///
+ public const string SCRAP = "4";
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
new file mode 100644
index 00000000..13a649e8
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
@@ -0,0 +1,150 @@
+using SqlSugar;
+using Tnb.Common.Contracts;
+
+namespace Tnb.EquipMgr.Entities
+{
+ ///
+ ///设备点巡检项目
+ ///
+ [SugarTable("eqp_spot_ins_item")]
+ public class EqpSpotInsItem : BaseEntity
+ {
+ public EqpSpotInsItem()
+ {
+ }
+
+ ///
+ /// Desc:创建时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// Desc:修改时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? modify_time { get; set; }
+
+
+ ///
+ /// Desc:判断类型1数值2结果
+ /// Default:
+ /// Nullable:False
+ ///
+ public string judge_type { get; set; }
+
+ ///
+ /// Desc:上限值
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? high_value { get; set; }
+
+ ///
+ /// Desc:是否包含上限值
+ /// Default:
+ /// Nullable:True
+ ///
+ public int? high_value_is_include { get; set; }
+
+ ///
+ /// Desc:下限值
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? low_value { get; set; }
+
+ ///
+ /// Desc:是否包含下限值
+ /// Default:
+ /// Nullable:True
+ ///
+ public int? low_value_is_include { get; set; }
+
+ ///
+ /// Desc:标准值
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? standard_value { get; set; }
+
+ ///
+ /// Desc:单位id
+ /// Default:
+ /// Nullable:False
+ ///
+ public string unit_id { get; set; }
+
+ ///
+ /// Desc:排序
+ /// Default:
+ /// Nullable:False
+ ///
+ public int ordinal { get; set; }
+
+ ///
+ /// Desc:类型 1 点检 2巡检
+ /// Default:
+ /// Nullable:False
+ ///
+ public string type { get; set; }
+
+ ///
+ /// Desc:创建用户
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string create_id { get; set; }
+
+ ///
+ /// Desc:修改用户
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string modify_id { get; set; }
+
+ ///
+ /// Desc:编码
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string code { get; set; }
+
+ ///
+ /// Desc:名称
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string name { get; set; }
+
+ ///
+ /// Desc:判断内容
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string judge_content { get; set; }
+
+ ///
+ /// Desc:点巡检方法
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string inspection_method { get; set; }
+
+ ///
+ /// Desc:备注
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string remark { get; set; }
+
+ ///
+ /// Desc:所属组织
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string org_id { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
index 7ac2a892..3e7c12bc 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
@@ -67,7 +67,7 @@ public partial class EqpSpotInsRecordD : BaseEntity
/// Default:
/// Nullable:True
///
- public double? standard_value { get; set; }
+ public decimal? standard_value { get; set; }
///
/// Desc:单位id
@@ -131,4 +131,11 @@ public partial class EqpSpotInsRecordD : BaseEntity
/// Nullable:True
///
public string remark { get; set; }
+
+ ///
+ /// Desc:点巡检设备模板id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string spot_ins_tem_equip_id {get;set;}
}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordH.cs
index 94a35273..cdcfec28 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordH.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordH.cs
@@ -27,6 +27,7 @@ namespace Tnb.EquipMgr.Entities
///
public DateTime? modify_time { get; set; }
+
///
/// Desc:设备id
/// Default:
@@ -70,18 +71,18 @@ namespace Tnb.EquipMgr.Entities
public DateTime? send_date_time { get; set; }
///
- /// Desc:滞后推送时间
+ /// Desc:计划执行通知提前量
/// Default:
/// Nullable:True
///
- public DateTime? after_send_date_time { get; set; }
+ public int? plan_run_notice { get; set; }
///
- /// Desc:是否滞后推送
+ /// Desc:执行滞后推送时间
/// Default:
/// Nullable:True
///
- public int? is_after_send { get; set; }
+ public int? plan_delay { get; set; }
///
/// Desc:创建用户
@@ -131,5 +132,81 @@ namespace Tnb.EquipMgr.Entities
/// Nullable:True
///
public string send_id { get; set; }
+
+ ///
+ /// Desc:编码
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string code { get; set; }
+
+ ///
+ /// Desc:计划执行通知提前量单位 1 小时 2 天 3 周
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string plan_run_notice_unit { get; set; }
+
+ ///
+ /// Desc:执行滞后推送时间单位 1 小时 2 天 3 周
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string plan_delay_unit { get; set; }
+
+ ///
+ /// Desc:复核岗位id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string repeat_post_info_user_id { get; set; }
+
+ ///
+ /// Desc:责任岗位id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string send_post_info_user_id { get; set; }
+
+ ///
+ /// Desc:是否复核
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string is_repeat { get; set; }
+
+ ///
+ /// Desc:复核时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? repeat_time {get;set;}
+
+ ///
+ /// Desc:复核备注
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string repeat_remark {get;set;}
+
+ ///
+ /// Desc:复核人id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string repeat_user_id {get;set;}
+
+ ///
+ /// Desc:仅用于关联表字段查询用不存储数据
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName="query_info")]
+ public string query_info {get;set;}
+
+ ///
+ /// 附件
+ ///
+ public string attachment { get; set; }
}
}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemEquipD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemEquipD.cs
new file mode 100644
index 00000000..7d0042e5
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsTemEquipD.cs
@@ -0,0 +1,33 @@
+using SqlSugar;
+using Tnb.Common.Contracts;
+
+
+namespace Tnb.EquipMgr.Entities
+{
+ ///
+ ///点巡检设备模板子表
+ ///
+ [SugarTable("eqp_spot_ins_tem_equip_d")]
+ public class EqpSpotInsTemEquipD : BaseEntity
+ {
+ public EqpSpotInsTemEquipD(){
+
+
+ }
+
+ ///
+ /// Desc:设备模板id
+ /// Default:
+ /// Nullable:False
+ ///
+ public string spot_ins_tem_equip_id {get;set;}
+
+ ///
+ /// Desc:点巡检项id
+ /// Default:
+ /// Nullable:False
+ ///
+ public string spot_ins_item_id {get;set;}
+
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/WorklineCommService.cs b/ProductionMgr/Tnb.ProductionMgr/WorklineCommService.cs
index ac7ba7c1..63e4c92e 100644
--- a/ProductionMgr/Tnb.ProductionMgr/WorklineCommService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/WorklineCommService.cs
@@ -1,29 +1,11 @@
-using System.Dynamic;
-using System.Reflection.Emit;
-using Aop.Api.Domain;
-using JNPF.Common.Core.Manager;
-using JNPF.Common.Enums;
-using JNPF.Common.Extension;
-using JNPF.Common.Security;
+using JNPF.Common.Core.Manager;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
-using JNPF.Extensitions.EventBus;
-using JNPF.FriendlyException;
-using JNPF.Logging;
using JNPF.Systems.Interfaces.System;
-using JNPF.VisualDev;
-using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
-using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using Senparc.Weixin.Work.AdvancedAPIs.MailList;
using SqlSugar;
-using Tnb.BasicData;
-using Tnb.BasicData.Entitys.Entity;
-using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
-using Tnb.ProductionMgr.Entities.Dto;
-using Tnb.ProductionMgr.Entities.Enums;
using Tnb.ProductionMgr.Interfaces;
namespace Tnb.ProductionMgr;
diff --git a/apihost/Tnb.API.Entry/Handlers/JwtHandler.cs b/apihost/Tnb.API.Entry/Handlers/JwtHandler.cs
index ac713bd2..f0e9de90 100644
--- a/apihost/Tnb.API.Entry/Handlers/JwtHandler.cs
+++ b/apihost/Tnb.API.Entry/Handlers/JwtHandler.cs
@@ -59,6 +59,7 @@ public class JwtHandler : AppAuthorizeHandler
return true;
// 路由名称
+ if (httpContext.Request.Path.Value == null) return false;
var routeName = httpContext.Request.Path.Value[1..].Replace("/", ":");
if (httpContext.Request.Path.StartsWithSegments("/api"))
routeName = httpContext.Request.Path.Value[5..].Replace("/", ":");
@@ -76,6 +77,7 @@ public class JwtHandler : AppAuthorizeHandler
// 检查授权
//return permissionList.Contains(routeName);
+ await Task.CompletedTask;
return true;
}
}
diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs
index e73e43ed..611eb99d 100644
--- a/apihost/Tnb.API.Entry/Startup.cs
+++ b/apihost/Tnb.API.Entry/Startup.cs
@@ -98,7 +98,7 @@ public class Startup : AppStartup
app.UseInject(string.Empty);
//app.MapWebSocketManager("/api/message/websocket", serviceProvider.GetService());
- app.MapWebSocketManager("/websocket", serviceProvider.GetService());
+ app.MapWebSocketManager("/websocket", serviceProvider.GetRequiredService());
app.UseEndpoints(endpoints =>
{
diff --git a/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj b/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj
index 1e177c15..76aef262 100644
--- a/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj
+++ b/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8618;
diff --git a/app/Tnb.Apps/Tnb.Apps.csproj b/app/Tnb.Apps/Tnb.Apps.csproj
index ff1045f7..b596a93b 100644
--- a/app/Tnb.Apps/Tnb.Apps.csproj
+++ b/app/Tnb.Apps/Tnb.Apps.csproj
@@ -6,6 +6,7 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS1572;CS1573;
diff --git a/common.props b/common.props
index eb6672a5..6734521c 100644
--- a/common.props
+++ b/common.props
@@ -1,7 +1,7 @@
latest
- $(NoWarn);CS1591;CA1307;CS8625;CS8600;CS8601;CS8604;CS8618;
+ $(NoWarn);CS1591;
diff --git a/common/Tnb.CollectiveOAuth/Enums/EnumHelper/EnumExtensions.cs b/common/Tnb.CollectiveOAuth/Enums/EnumHelper/EnumExtensions.cs
index 0fee4d6c..ec0ecded 100644
--- a/common/Tnb.CollectiveOAuth/Enums/EnumHelper/EnumExtensions.cs
+++ b/common/Tnb.CollectiveOAuth/Enums/EnumHelper/EnumExtensions.cs
@@ -112,7 +112,7 @@ public static class EnumExtensions
{
if (field.FieldType.IsEnum)
{
- strValue = ((int)enumType.InvokeMember(field.Name, BindingFlags.GetField, null, null, null)).ToString();
+ strValue = ((int?)enumType.InvokeMember(field.Name, BindingFlags.GetField, null, null, null)).ToString();
object[] arr = field.GetCustomAttributes(typeDescription, true);
if (arr.Length > 0)
{
diff --git a/common/Tnb.CollectiveOAuth/Request/AuthRequests/ElemeAuthRequest.cs b/common/Tnb.CollectiveOAuth/Request/AuthRequests/ElemeAuthRequest.cs
index 6d0c1e8e..cf0ad9a1 100644
--- a/common/Tnb.CollectiveOAuth/Request/AuthRequests/ElemeAuthRequest.cs
+++ b/common/Tnb.CollectiveOAuth/Request/AuthRequests/ElemeAuthRequest.cs
@@ -253,7 +253,9 @@ public class ElemeAuthRequest : DefaultAuthRequest
{
//就是比string往后一直加要好的优化容器
StringBuilder sb = new StringBuilder();
+#pragma warning disable SYSLIB0021 //MD5CryptoServiceProvider已过时
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
+#pragma warning disable SYSLIB0021 //MD5CryptoServiceProvider已过时
{
//将输入字符串转换为字节数组并计算哈希。
byte[] data = md5.ComputeHash(Encoding.UTF8.GetBytes(willMd5Str));
diff --git a/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj b/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj
index 34af77a4..015ae7e0 100644
--- a/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj
+++ b/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;
diff --git a/common/Tnb.CollectiveOAuth/Utils/HttpUtils.cs b/common/Tnb.CollectiveOAuth/Utils/HttpUtils.cs
index 14ce2199..a908e1df 100644
--- a/common/Tnb.CollectiveOAuth/Utils/HttpUtils.cs
+++ b/common/Tnb.CollectiveOAuth/Utils/HttpUtils.cs
@@ -4,6 +4,7 @@ using System.Text;
namespace JNPF.Extras.CollectiveOAuth.Utils;
+#pragma warning disable SYSLIB0014 //WebRequest.Create已过时
public class HttpUtils
{
///
@@ -269,4 +270,5 @@ public class HttpUtils
return result;
}
-}
\ No newline at end of file
+}
+#pragma warning restore SYSLIB0014 //WebRequest.Create已过时
diff --git a/common/Tnb.CollectiveOAuth/Utils/TwitterBase.cs b/common/Tnb.CollectiveOAuth/Utils/TwitterBase.cs
index 007ffa64..5ed2160e 100644
--- a/common/Tnb.CollectiveOAuth/Utils/TwitterBase.cs
+++ b/common/Tnb.CollectiveOAuth/Utils/TwitterBase.cs
@@ -52,7 +52,7 @@ public class TwitterBase
#region IComparer Members
- public int Compare(QueryParameter x, QueryParameter y)
+ public int Compare(QueryParameter? x, QueryParameter? y)
{
if (x.Name == y.Name)
{
diff --git a/common/Tnb.Common.Core/Tnb.Common.Core.csproj b/common/Tnb.Common.Core/Tnb.Common.Core.csproj
index 2c81754d..d7c75c81 100644
--- a/common/Tnb.Common.Core/Tnb.Common.Core.csproj
+++ b/common/Tnb.Common.Core/Tnb.Common.Core.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;CS1998;
diff --git a/common/Tnb.Common/DataValidation/Check.cs b/common/Tnb.Common/DataValidation/Check.cs
new file mode 100644
index 00000000..cc102ead
--- /dev/null
+++ b/common/Tnb.Common/DataValidation/Check.cs
@@ -0,0 +1,350 @@
+using JetBrains.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Tnb.Common;
+
+[DebuggerStepThrough]
+public static class Check
+{
+ public static T NotNull(T value, string parameterName)
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(parameterName);
+ }
+
+ return value;
+ }
+
+ public static T NotNull(
+ T value,
+ string parameterName,
+ string message)
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(parameterName, message);
+ }
+
+ return value;
+ }
+
+ public static string NotNull(
+ string value,
+ string parameterName,
+ int maxLength = int.MaxValue,
+ int minLength = 0)
+ {
+ if (value == null)
+ {
+ throw new ArgumentException($"{parameterName} can not be null!", parameterName);
+ }
+
+ if (value.Length > maxLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
+ }
+
+ if (minLength > 0 && value.Length < minLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
+ }
+
+ return value;
+ }
+
+ public static string NotNullOrWhiteSpace(
+ string value,
+ string parameterName,
+ int maxLength = int.MaxValue,
+ int minLength = 0)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException($"{parameterName} can not be null, empty or white space!", parameterName);
+ }
+
+ if (value.Length > maxLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
+ }
+
+ if (minLength > 0 && value.Length < minLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
+ }
+
+ return value;
+ }
+
+ public static string NotNullOrEmpty(
+ string value,
+ string parameterName,
+ int maxLength = int.MaxValue,
+ int minLength = 0)
+ {
+ if (string.IsNullOrEmpty(value))
+ {
+ throw new ArgumentException($"{parameterName} can not be null or empty!", parameterName);
+ }
+
+ if (value.Length > maxLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
+ }
+
+ if (minLength > 0 && value.Length < minLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
+ }
+
+ return value;
+ }
+
+ public static ICollection NotNullOrEmpty(ICollection value, string parameterName)
+ {
+ if (value == null || value.Count <= 0)
+ {
+ throw new ArgumentException(parameterName + " can not be null or empty!", parameterName);
+ }
+
+ return value;
+ }
+
+ public static Type AssignableTo(
+ Type type,
+ string parameterName)
+ {
+ NotNull(type, parameterName);
+
+ if (!type.IsAssignableTo(typeof(TBaseType)))
+ {
+ throw new ArgumentException($"{parameterName} (type of {type.AssemblyQualifiedName}) should be assignable to the {typeof(TBaseType).FullName}!");
+ }
+
+ return type;
+ }
+
+ public static string Length(
+ [AllowNull] string value,
+ string parameterName,
+ int maxLength,
+ int minLength = 0)
+ {
+ if (minLength > 0)
+ {
+ if (string.IsNullOrEmpty(value))
+ {
+ throw new ArgumentException(parameterName + " can not be null or empty!", parameterName);
+ }
+
+ if (value.Length < minLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or bigger than {minLength}!", parameterName);
+ }
+ }
+
+ if (value != null && value.Length > maxLength)
+ {
+ throw new ArgumentException($"{parameterName} length must be equal to or lower than {maxLength}!", parameterName);
+ }
+
+ return value!;
+ }
+
+ public static short Positive(
+ short value,
+ string parameterName)
+ {
+ if(value == 0)
+ {
+ throw new ArgumentException($"{parameterName} is equal to zero");
+ }
+ else if(value < 0)
+ {
+ throw new ArgumentException($"{parameterName} is less than zero");
+ }
+ return value;
+ }
+
+ public static Int32 Positive(
+ Int32 value,
+ string parameterName)
+ {
+ if (value == 0)
+ {
+ throw new ArgumentException($"{parameterName} is equal to zero");
+ }
+ else if (value < 0)
+ {
+ throw new ArgumentException($"{parameterName} is less than zero");
+ }
+ return value;
+ }
+
+ public static Int64 Positive(
+ Int64 value,
+ string parameterName)
+ {
+ if (value == 0)
+ {
+ throw new ArgumentException($"{parameterName} is equal to zero");
+ }
+ else if (value < 0)
+ {
+ throw new ArgumentException($"{parameterName} is less than zero");
+ }
+ return value;
+ }
+
+ public static float Positive(
+ float value,
+ string parameterName)
+ {
+ if (value == 0)
+ {
+ throw new ArgumentException($"{parameterName} is equal to zero");
+ }
+ else if (value < 0)
+ {
+ throw new ArgumentException($"{parameterName} is less than zero");
+ }
+ return value;
+ }
+
+ public static double Positive(
+ double value,
+ string parameterName)
+ {
+ if (value == 0)
+ {
+ throw new ArgumentException($"{parameterName} is equal to zero");
+ }
+ else if (value < 0)
+ {
+ throw new ArgumentException($"{parameterName} is less than zero");
+ }
+ return value;
+ }
+
+ public static decimal Positive(
+ decimal value,
+ string parameterName)
+ {
+ if (value == 0)
+ {
+ throw new ArgumentException($"{parameterName} is equal to zero");
+ }
+ else if (value < 0)
+ {
+ throw new ArgumentException($"{parameterName} is less than zero");
+ }
+ return value;
+ }
+
+ public static Int16 Range(
+ Int16 value,
+ string parameterName,
+ Int16 minimumValue,
+ Int16 maximumValue = Int16.MaxValue)
+ {
+ if(value < minimumValue || value > maximumValue)
+ {
+ throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
+ }
+
+ return value;
+ }
+ public static Int32 Range(
+ Int32 value,
+ string parameterName,
+ Int32 minimumValue,
+ Int32 maximumValue = Int32.MaxValue)
+ {
+ if (value < minimumValue || value > maximumValue)
+ {
+ throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
+ }
+
+ return value;
+ }
+
+ public static Int64 Range(
+ Int64 value,
+ string parameterName,
+ Int64 minimumValue,
+ Int64 maximumValue = Int64.MaxValue)
+ {
+ if (value < minimumValue || value > maximumValue)
+ {
+ throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
+ }
+
+ return value;
+ }
+
+
+ public static float Range(
+ float value,
+ string parameterName,
+ float minimumValue,
+ float maximumValue = float.MaxValue)
+ {
+ if (value < minimumValue || value > maximumValue)
+ {
+ throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
+ }
+ return value;
+ }
+
+
+ public static double Range(
+ double value,
+ string parameterName,
+ double minimumValue,
+ double maximumValue = double.MaxValue)
+ {
+ if (value < minimumValue || value > maximumValue)
+ {
+ throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
+ }
+
+ return value;
+ }
+
+
+ public static decimal Range(
+ decimal value,
+ string parameterName,
+ decimal minimumValue,
+ decimal maximumValue = decimal.MaxValue)
+ {
+ if (value < minimumValue || value > maximumValue)
+ {
+ throw new ArgumentException($"{parameterName} is out of range min: {minimumValue} - max: {maximumValue}");
+ }
+
+ return value;
+ }
+
+ public static T NotDefaultOrNull(
+ T? value,
+ string parameterName)
+ where T : struct
+ {
+ if (value == null)
+ {
+ throw new ArgumentException($"{parameterName} is null!", parameterName);
+ }
+
+ if (value.Value.Equals(default(T)))
+ {
+ throw new ArgumentException($"{parameterName} has a default value!", parameterName);
+ }
+
+ return value.Value;
+ }
+}
diff --git a/common/Tnb.Common/Extension/BooleanExtensions.cs b/common/Tnb.Common/Extension/BooleanExtensions.cs
index c163c4f9..5feffa27 100644
--- a/common/Tnb.Common/Extension/BooleanExtensions.cs
+++ b/common/Tnb.Common/Extension/BooleanExtensions.cs
@@ -31,7 +31,7 @@ public static class BooleanExtensions
///
private static bool? GetBool(this object data)
{
- switch (data.ToString().Trim().ToLower())
+ switch (data.ToString()?.Trim().ToLower())
{
case "0":
return false;
diff --git a/common/Tnb.Common/Extension/DictionaryExtensions.cs b/common/Tnb.Common/Extension/DictionaryExtensions.cs
index b9b052cd..962810bf 100644
--- a/common/Tnb.Common/Extension/DictionaryExtensions.cs
+++ b/common/Tnb.Common/Extension/DictionaryExtensions.cs
@@ -16,7 +16,7 @@ public static class DictionaryExtensions
/// 要操作的字典.
/// 指定键名.
/// 获取到的值.
- public static TValue GetOrDefault(this IDictionary dictionary, TKey key)
+ public static TValue? GetOrDefault(this IDictionary dictionary, TKey key)
{
return dictionary.TryGetValue(key, out TValue value) ? value : default(TValue);
}
diff --git a/common/Tnb.Common/Extension/EnumExtensions.cs b/common/Tnb.Common/Extension/EnumExtensions.cs
index 8e438b11..15206eee 100644
--- a/common/Tnb.Common/Extension/EnumExtensions.cs
+++ b/common/Tnb.Common/Extension/EnumExtensions.cs
@@ -152,7 +152,7 @@ public static class EnumExtensions
///
public static string GetDescription(this System.Enum value)
{
- return value.GetType().GetMember(value.ToString()).FirstOrDefault()?.GetCustomAttribute()?.Description;
+ return value.GetType().GetMember(value.ToString()).FirstOrDefault()?.GetCustomAttribute()?.Description ?? string.Empty;
}
///
@@ -162,7 +162,7 @@ public static class EnumExtensions
///
public static string GetDescription(this object value)
{
- return value.GetType().GetMember(value.ToString() ?? string.Empty).FirstOrDefault()?.GetCustomAttribute()?.Description;
+ return value.GetType().GetMember(value.ToString() ?? string.Empty).FirstOrDefault()?.GetCustomAttribute()?.Description ?? string.Empty;
}
///
diff --git a/common/Tnb.Common/Extension/Extensions.cs b/common/Tnb.Common/Extension/Extensions.cs
index 0815e1d6..a46b4e1d 100644
--- a/common/Tnb.Common/Extension/Extensions.cs
+++ b/common/Tnb.Common/Extension/Extensions.cs
@@ -219,7 +219,7 @@ public static partial class Extensions
///
private static bool? GetBool(this object data)
{
- switch (data.ToString().Trim().ToLower())
+ switch (data.ToString()?.Trim().ToLower())
{
case "0":
return false;
@@ -466,7 +466,7 @@ public static partial class Extensions
{
try
{
- return obj == null ? string.Empty : obj.ToString();
+ return obj == null ? string.Empty : obj.ToString()!;
}
catch
{
@@ -489,7 +489,7 @@ public static partial class Extensions
return string.Join(",", list);
}
- return obj.ToString();
+ return obj.ToString()!;
}
catch
{
@@ -608,7 +608,7 @@ public static partial class Extensions
/// 是否为空.
///
/// 值.
- public static bool IsEmpty(this string value)
+ public static bool IsEmpty(this string? value)
{
return string.IsNullOrWhiteSpace(value);
}
@@ -678,7 +678,7 @@ public static partial class Extensions
///
public static string ObjToString(this object thisValue)
{
- if (thisValue != null) return thisValue.ToString().Trim();
+ if (thisValue != null) return thisValue.ToString()!.Trim();
return string.Empty;
}
diff --git a/common/Tnb.Common/Extension/RandomExtensions.cs b/common/Tnb.Common/Extension/RandomExtensions.cs
index 2e1a62f5..b8466442 100644
--- a/common/Tnb.Common/Extension/RandomExtensions.cs
+++ b/common/Tnb.Common/Extension/RandomExtensions.cs
@@ -38,7 +38,7 @@ public static class RandomExtensions
Array array = System.Enum.GetValues(type);
int index = random.Next(array.GetLowerBound(0), array.GetUpperBound(0) + 1);
- return (T)array.GetValue(index);
+ return (T)array.GetValue(index)!;
}
///
@@ -67,7 +67,7 @@ public static class RandomExtensions
public static T NextItem(this Random random, T[] items)
{
if (items == null || items.Length == 0)
- return default(T);
+ return default(T)!;
return items[random.Next(items.Length)];
}
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.Common/Net/UserAgent.cs b/common/Tnb.Common/Net/UserAgent.cs
index cd578d03..3407035a 100644
--- a/common/Tnb.Common/Net/UserAgent.cs
+++ b/common/Tnb.Common/Net/UserAgent.cs
@@ -111,10 +111,10 @@ public class UserAgent : IUserAgent
private DeviceInfo _device;
private OSInfo _os;
- private bool? _isBot;
+ //private bool? _isBot;
private bool? _isMobileDevice;
private bool? _isTablet;
- private bool? _isPdfConverter;
+ //private bool? _isPdfConverter;
static UserAgent()
{
@@ -142,7 +142,7 @@ public class UserAgent : IUserAgent
}
}
- return _rawValue;
+ return _rawValue ?? "";
}
set
@@ -151,10 +151,10 @@ public class UserAgent : IUserAgent
_userAgent = null;
_device = null;
_os = null;
- _isBot = null;
+ //_isBot = null;
_isMobileDevice = null;
_isTablet = null;
- _isPdfConverter = null;
+ //_isPdfConverter = null;
}
}
diff --git a/common/Tnb.Common/Security/CodeGenExportDataHelper.cs b/common/Tnb.Common/Security/CodeGenExportDataHelper.cs
index 61b8e36a..11141240 100644
--- a/common/Tnb.Common/Security/CodeGenExportDataHelper.cs
+++ b/common/Tnb.Common/Security/CodeGenExportDataHelper.cs
@@ -54,7 +54,7 @@ public static class CodeGenExportDataHelper
var len = rowChildDatas.Select(x => x.Value.Count()).OrderByDescending(x => x).FirstOrDefault();
- if (len != null && len > 0)
+ if (len > 0)
{
for (int i = 0; i < len; i++)
{
diff --git a/common/Tnb.Common/Security/CodeGenHelper.cs b/common/Tnb.Common/Security/CodeGenHelper.cs
index e06dad23..5bf8591d 100644
--- a/common/Tnb.Common/Security/CodeGenHelper.cs
+++ b/common/Tnb.Common/Security/CodeGenHelper.cs
@@ -190,7 +190,7 @@ public static class CodeGenHelper
field = entityInfo.Columns.Find(it => it.PropertyName.Equals(sort.ToUpperCase()))?.DbColumnName;
break;
}
- return string.IsNullOrEmpty(field) ? null : field;
+ return string.IsNullOrEmpty(field) ? "" : field;
}
///
diff --git a/common/Tnb.Common/Security/ComparisonHelper.cs b/common/Tnb.Common/Security/ComparisonHelper.cs
index 8248657c..0b540ac0 100644
--- a/common/Tnb.Common/Security/ComparisonHelper.cs
+++ b/common/Tnb.Common/Security/ComparisonHelper.cs
@@ -63,7 +63,7 @@ public static class ComparisonHelper
///
///
///
- public int Compare(T x, T y)
+ public int Compare(T? x, T? y)
{
return _comparer.Compare(_keySelector(x), _keySelector(y));
}
diff --git a/common/Tnb.Common/Security/EqualityHelper.cs b/common/Tnb.Common/Security/EqualityHelper.cs
index 4d33b45b..2dc3b6b4 100644
--- a/common/Tnb.Common/Security/EqualityHelper.cs
+++ b/common/Tnb.Common/Security/EqualityHelper.cs
@@ -1,4 +1,5 @@
-using JNPF.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
+using JNPF.DependencyInjection;
namespace JNPF.Common.Security;
@@ -49,14 +50,14 @@ public static class EqualityHelper
: this(keySelector, EqualityComparer.Default)
{ }
- public bool Equals(T x, T y)
+ public bool Equals(T? x, T? y)
{
return _comparer.Equals(_keySelector(x), _keySelector(y));
}
- public int GetHashCode(T obj)
+ public int GetHashCode([DisallowNull] T obj)
{
- return _comparer.GetHashCode(_keySelector(obj));
+ return _comparer.GetHashCode(_keySelector(obj)!);
}
}
}
diff --git a/common/Tnb.Common/Security/ExcelExportHelper.cs b/common/Tnb.Common/Security/ExcelExportHelper.cs
index 3b975fde..0a34dfe4 100644
--- a/common/Tnb.Common/Security/ExcelExportHelper.cs
+++ b/common/Tnb.Common/Security/ExcelExportHelper.cs
@@ -1,6 +1,7 @@
using System.Drawing;
using System.Reflection;
using System.Text;
+using JNPF.Common.Helper;
using JNPF.Common.Models.NPOI;
using JNPF.DependencyInjection;
using NPOI.HPSF;
@@ -8,9 +9,13 @@ using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
+using Spire.Doc;
+using static Microsoft.AspNetCore.Razor.Language.TagHelperMetadata;
namespace JNPF.Common.Security;
+#pragma warning disable CS0618, CA2200 //再次引发捕获到的异常会更改堆栈信息
+
///
/// Excel导出操作类
/// 版 本:V3.2.0
@@ -740,7 +745,7 @@ public class ExcelExportHelper
}
catch (Exception ex)
{
- throw;
+ throw ex;
}
}
@@ -1039,7 +1044,7 @@ public class ExcelExportHelper
}
catch (Exception ex)
{
- throw;
+ throw ex;
}
}
@@ -1168,4 +1173,5 @@ public class ExcelExportHelper
}
#endregion
-}
\ No newline at end of file
+}
+#pragma warning restore CS0618, CA2200 //再次引发捕获到的异常会更改堆栈信息
diff --git a/common/Tnb.Common/Security/ExcelImportHelper.cs b/common/Tnb.Common/Security/ExcelImportHelper.cs
index bd7e2883..1d1deff8 100644
--- a/common/Tnb.Common/Security/ExcelImportHelper.cs
+++ b/common/Tnb.Common/Security/ExcelImportHelper.cs
@@ -108,7 +108,7 @@ namespace JNPF.Common.Helper
//}
//else
//{
- dataRow[j] = cell.ToString().Trim();
+ dataRow[j] = cell.ToString()?.Trim();
//}
}
}
diff --git a/common/Tnb.Common/Security/FileHelper.cs b/common/Tnb.Common/Security/FileHelper.cs
index 35b377ef..55d4b8d8 100644
--- a/common/Tnb.Common/Security/FileHelper.cs
+++ b/common/Tnb.Common/Security/FileHelper.cs
@@ -494,7 +494,9 @@ public class FileHelper
}
catch (Exception ex)
{
+#pragma warning disable CA2200 //再次引发捕获到的异常会更改堆栈信息
throw ex;
+#pragma warning disable CA2200 //再次引发捕获到的异常会更改堆栈信息
}
finally
{
@@ -505,6 +507,7 @@ public class FileHelper
#endregion
+#pragma warning disable CA1416 // 验证平台兼容性
#region 生成高清晰缩略图
///
@@ -669,6 +672,7 @@ public class FileHelper
}
#endregion
+#pragma warning restore CA1416 // 验证平台兼容性
#region 将文件路径转为内存流
@@ -712,7 +716,8 @@ public class FileHelper
if (selectFiles.Count > 0)
{
- return selectFiles.FirstOrDefault().FullName;
+ //modified by PhilPan
+ return selectFiles.First().FullName;
}
return Path.Combine(folderPath, $@"{prefix}_{DateTime.Now.ParseToUnixTime()}.log");
@@ -737,7 +742,7 @@ public class FileHelper
Microsoft.AspNetCore.Http.HttpContext? httpContext = App.HttpContext;
httpContext.Response.ContentType = "application/octet-stream";
httpContext.Response.Headers.Add("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, Encoding.UTF8));
- httpContext.Response.Headers.Add("Content-Length", buff.Length.ToString());
+ httpContext.Response.Headers.Add("Content-Length", buff?.Length.ToString());
httpContext.Response.Body.WriteAsync(buff);
httpContext.Response.Body.Flush();
httpContext.Response.Body.Close();
diff --git a/common/Tnb.Common/Security/JsonHelper.cs b/common/Tnb.Common/Security/JsonHelper.cs
index cbb2b901..0128eecc 100644
--- a/common/Tnb.Common/Security/JsonHelper.cs
+++ b/common/Tnb.Common/Security/JsonHelper.cs
@@ -46,7 +46,7 @@ public static class JsonHelper
///
public static T ToObject(this string json)
{
- return _ = _jsonSerializer.Deserialize(json) ?? default(T);
+ return _jsonSerializer.Deserialize(json);
}
///
@@ -58,7 +58,7 @@ public static class JsonHelper
///
public static T ToObject(this string json, object jsonSerializerOptions = default)
{
- return _ = _jsonSerializer.Deserialize(json, jsonSerializerOptions) ?? default(T);
+ return _jsonSerializer.Deserialize(json, jsonSerializerOptions);
}
///
@@ -69,7 +69,7 @@ public static class JsonHelper
///
public static T ToObject(this object json)
{
- return _ = ToJsonString(json).ToObject() ?? default(T);
+ return ToJsonString(json).ToObject();
}
///
@@ -81,7 +81,7 @@ public static class JsonHelper
///
public static T ToObject(this object json, object jsonSerializerOptions = default)
{
- return _ = ToJsonString(json, jsonSerializerOptions).ToObject(jsonSerializerOptions) ?? default(T);
+ return ToJsonString(json, jsonSerializerOptions).ToObject(jsonSerializerOptions);
}
///
@@ -92,7 +92,7 @@ public static class JsonHelper
///
public static List ToList(this string json)
{
- return _ = _jsonSerializer.Deserialize>(json) ?? null;
+ return _jsonSerializer.Deserialize>(json);
}
///
@@ -104,7 +104,7 @@ public static class JsonHelper
///
public static List ToList(this string json, object jsonSerializerOptions = default)
{
- return _ = _jsonSerializer.Deserialize>(json, jsonSerializerOptions) ?? null;
+ return _jsonSerializer.Deserialize>(json, jsonSerializerOptions);
}
///
diff --git a/common/Tnb.Common/Security/MachineHelper.cs b/common/Tnb.Common/Security/MachineHelper.cs
index 43597cb2..e435e49b 100644
--- a/common/Tnb.Common/Security/MachineHelper.cs
+++ b/common/Tnb.Common/Security/MachineHelper.cs
@@ -217,6 +217,7 @@ public static class MachineHelper
}
#endregion
+#pragma warning disable CA1416 // 验证平台兼容性
#region Windows
///
@@ -364,4 +365,6 @@ public static class MachineHelper
}
#endregion
+#pragma warning restore CA1416 // 验证平台兼容性
+
}
\ No newline at end of file
diff --git a/common/Tnb.Common/Security/SuperQueryHelper.cs b/common/Tnb.Common/Security/SuperQueryHelper.cs
index eaa6f636..e42973c6 100644
--- a/common/Tnb.Common/Security/SuperQueryHelper.cs
+++ b/common/Tnb.Common/Security/SuperQueryHelper.cs
@@ -60,7 +60,7 @@ public class SuperQueryHelper
{
case JnpfKeyConst.COMINPUT:
case JnpfKeyConst.TEXTAREA:
- item.fieldValue = item.fieldValue?.ToString().Replace("\r\n", string.Empty);
+ item.fieldValue = item.fieldValue?.ToString()?.Replace("\r\n", string.Empty);
switch (item.symbol)
{
case "==": // 等于
@@ -549,8 +549,9 @@ public class SuperQueryHelper
queryOr.mainWhere = true;
queryList.Add(queryOr);
}
+ //modified by PhilPan
+ continue;
}
- continue;
switch (item.symbol)
{
case ">=": // 大于等于
diff --git a/common/Tnb.Common/Tnb.Common.csproj b/common/Tnb.Common/Tnb.Common.csproj
index 4d8a9838..b5e6e13b 100644
--- a/common/Tnb.Common/Tnb.Common.csproj
+++ b/common/Tnb.Common/Tnb.Common.csproj
@@ -7,6 +7,7 @@
enable
False
False
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8618;CS8619;CS8625;CS1572;CS1573;
diff --git a/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj b/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj
index e71e8896..197c66e6 100644
--- a/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj
+++ b/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj
@@ -18,7 +18,7 @@
-
+
diff --git a/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj b/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj
index ab91d29c..42576ee7 100644
--- a/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj
+++ b/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj
@@ -7,6 +7,7 @@
enable
enable
False
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;CS0618;
diff --git a/common/Tnb.WebSockets/Tnb.WebSockets.csproj b/common/Tnb.WebSockets/Tnb.WebSockets.csproj
index 39088182..b87a3d57 100644
--- a/common/Tnb.WebSockets/Tnb.WebSockets.csproj
+++ b/common/Tnb.WebSockets/Tnb.WebSockets.csproj
@@ -7,6 +7,7 @@
enable
enable
False
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS1572;CS1573;CS1998;
diff --git a/extend/Tnb.Extend.Entitys/Tnb.Extend.Entitys.csproj b/extend/Tnb.Extend.Entitys/Tnb.Extend.Entitys.csproj
index 1e177c15..76aef262 100644
--- a/extend/Tnb.Extend.Entitys/Tnb.Extend.Entitys.csproj
+++ b/extend/Tnb.Extend.Entitys/Tnb.Extend.Entitys.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8618;
diff --git a/extend/Tnb.Extend/OrderService.cs b/extend/Tnb.Extend/OrderService.cs
index 39923c73..25117549 100644
--- a/extend/Tnb.Extend/OrderService.cs
+++ b/extend/Tnb.Extend/OrderService.cs
@@ -44,12 +44,14 @@ public class OrderService : IDynamicApiController, ITransient
ISqlSugarRepository repository,
IUserManager userManager,
IUsersService usersService,
- ICacheManager cacheManager)
+ ICacheManager cacheManager,
+ IFileManager fileManager)
{
_repository = repository;
_userManager = userManager;
_usersService = usersService;
_cacheManager = cacheManager;
+ _fileManager = fileManager;
}
#region GET
diff --git a/extend/Tnb.Extend/Tnb.Extend.csproj b/extend/Tnb.Extend/Tnb.Extend.csproj
index d7a0cd78..878a7f6d 100644
--- a/extend/Tnb.Extend/Tnb.Extend.csproj
+++ b/extend/Tnb.Extend/Tnb.Extend.csproj
@@ -6,6 +6,7 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;CS4014;
diff --git a/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj b/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj
index 1e177c15..76aef262 100644
--- a/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj
+++ b/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8618;
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/message/Tnb.Message/Tnb.Message.csproj b/message/Tnb.Message/Tnb.Message.csproj
index 0567e028..1894305e 100644
--- a/message/Tnb.Message/Tnb.Message.csproj
+++ b/message/Tnb.Message/Tnb.Message.csproj
@@ -6,6 +6,7 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS1572;CS1573;CS0168;
diff --git a/system/Tnb.OAuth/Tnb.OAuth.csproj b/system/Tnb.OAuth/Tnb.OAuth.csproj
index 927c3a91..1640baae 100644
--- a/system/Tnb.OAuth/Tnb.OAuth.csproj
+++ b/system/Tnb.OAuth/Tnb.OAuth.csproj
@@ -1,4 +1,4 @@
-
+
@@ -6,6 +6,7 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;
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/Entity/Permission/AuthorizeEntity.cs b/system/Tnb.Systems.Entitys/Entity/Permission/AuthorizeEntity.cs
index 2aa025f7..e3d66bdf 100644
--- a/system/Tnb.Systems.Entitys/Entity/Permission/AuthorizeEntity.cs
+++ b/system/Tnb.Systems.Entitys/Entity/Permission/AuthorizeEntity.cs
@@ -44,11 +44,11 @@ public class AuthorizeEntity : CEntityBase
///
///
///
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
- if (obj is AuthorizeEntity)
+ if (obj is AuthorizeEntity authorizeEntity)
{
- AuthorizeEntity authorizeEntity = obj as AuthorizeEntity;
+ //AuthorizeEntity authorizeEntity = obj as AuthorizeEntity;
return ItemType == authorizeEntity.ItemType && ItemId == authorizeEntity.ItemId && ObjectId == authorizeEntity.ObjectId && ObjectType == authorizeEntity.ObjectType;
}
diff --git a/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj b/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj
index 43253c86..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,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8603;CS8618;
diff --git a/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj b/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj
index 2d9293a0..42ab777d 100644
--- a/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj
+++ b/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8625;
diff --git a/system/Tnb.Systems/System/DataBaseService.cs b/system/Tnb.Systems/System/DataBaseService.cs
index 592ef1c1..da72766c 100644
--- a/system/Tnb.Systems/System/DataBaseService.cs
+++ b/system/Tnb.Systems/System/DataBaseService.cs
@@ -386,51 +386,39 @@ public class DataBaseService : IDynamicApiController, ITransient
sugarClient = _dataBaseManager.ChangeDataBase(link);
}
- string CustomFormatName(string s)
+ var entityName = string.Join("", input.TableName.Split('_').Select(a => a.ToPascalCase()));
+ foreach (var item in sugarClient.DbMaintenance.GetTableInfoList().Where(t => t.Name == input.TableName))
{
- var pos = 0;
- if ((pos = s.IndexOf("_", StringComparison.Ordinal)) > -1)
- {
- var separatorStrings = Regex.Split(s, @"_", RegexOptions.Compiled);
- if (separatorStrings.Length > 2)
- {
- var sb = new StringBuilder();
- foreach (var item in separatorStrings)
- {
- sb.Append(item.ToUpperCase());
- }
- return sb.ToString();
- }
- else
- {
- var first = s.AsSpan().Slice(0, pos).ToString().ToUpperCase();
- var second = s.AsSpan().Slice(pos + 1).ToString().ToUpperCase();
- return $"{first}{second}";
- }
- }
- else
- {
- return s.ToUpperCase();
- }
- }
-
- foreach (var item in sugarClient!.DbMaintenance.GetTableInfoList().Where(t => t.Name == input.TableName))
- {
- string entityName = CustomFormatName(item.Name);/*实体名首字母大写*/
+ //string entityName = CustomFormatName(item.Name);/*实体名首字母大写*/
sugarClient.MappingTables.Add(entityName, item.Name);
- foreach (var col in sugarClient.DbMaintenance.GetColumnInfosByTableName(item.Name))
- {
- //var colName = CustomFormatName(col.DbColumnName);
- sugarClient.MappingColumns.Add(col.DbColumnName /*类的属性首字母大写*/, col.DbColumnName, entityName);
- }
+ //foreach (var col in sugarClient.DbMaintenance.GetColumnInfosByTableName(item.Name))
+ //{
+ // //var colName = CustomFormatName(col.DbColumnName);
+ // sugarClient.MappingColumns.Add(col.DbColumnName /*类的属性首字母大写*/, col.DbColumnName, entityName);
+ //}
}
+ var prefix = input.TableName.Split('_')[0];
+ Dictionary nsMapper = new()
+ {
+ {"bas", "Tnb.BasicData.Entities" },
+ {"prd", "Tnb.ProductionMgr.Entities" },
+ {"wms", "Tnb.WarehouseMgr.Entities" },
+ {"eqp", "Tnb.EquipMgr.Entities" },
+ {"tool", "Tnb.EquipMgr.Entities" },
+ {"qc", "Tnb.QcMgr.Entities" },
+ };
sugarClient.DbFirst.Where(input.TableName)
- .FormatFileName(CustomFormatName)
+ .SettingConstructorTemplate(a =>
+ {
+ return a;
+ })
+ //.IsCreateDefaultValue(true)
.IsCreateAttribute()
- .CreateClassFile(dir, "DbModels");
+ .StringNullable()
+ .CreateClassFile(dir, nsMapper.ContainsKey(prefix) ? nsMapper[prefix] : "Tnb.Entities");
var previewContent = "";
- var codeFile = Path.Combine(dir, $"{CustomFormatName(input.TableName)}.cs");
+ var codeFile = Path.Combine(dir, $"{entityName}.cs");
if (File.Exists(codeFile))
{
using (var sr = File.OpenText(codeFile))
diff --git a/system/Tnb.Systems/System/ModuleDataAuthorizeSchemeService.cs b/system/Tnb.Systems/System/ModuleDataAuthorizeSchemeService.cs
index 2ff51eba..b38d1292 100644
--- a/system/Tnb.Systems/System/ModuleDataAuthorizeSchemeService.cs
+++ b/system/Tnb.Systems/System/ModuleDataAuthorizeSchemeService.cs
@@ -143,7 +143,7 @@ public class ModuleDataAuthorizeSchemeService : IModuleDataAuthorizeSchemeServic
/// 功能主键.
///
[NonAction]
- public async Task> GetList(string moduleId)
+ public async Task> GetList(string? moduleId)
{
return await _repository.AsQueryable().Where(x => x.DeleteMark == null && x.ModuleId == moduleId).OrderBy(a => a.SortCode).OrderBy(a => a.CreatorTime, OrderByType.Desc).OrderBy(a => a.LastModifyTime, OrderByType.Desc).ToListAsync();
}
diff --git a/system/Tnb.Systems/Tnb.Systems.csproj b/system/Tnb.Systems/Tnb.Systems.csproj
index 328587e7..35ba2198 100644
--- a/system/Tnb.Systems/Tnb.Systems.csproj
+++ b/system/Tnb.Systems/Tnb.Systems.csproj
@@ -1,4 +1,4 @@
-
+
@@ -6,6 +6,7 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8619;CS8625;CS8629;CS1572;CS1573;CS0168;CS4014;CS1998;
diff --git a/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj b/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj
index f0f0d51f..fe747c12 100644
--- a/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj
+++ b/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn)CS8604;CS8618;
diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
index b124ee33..e4da44d1 100644
--- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
+++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
@@ -1,11 +1,186 @@
+using JNPF.Common.Security;
+using JNPF.Logging;
+using Microsoft.AspNetCore.Components;
+using SqlSugar;
+using Tnb.EquipMgr.Entities;
+
namespace JNPF.TaskScheduler.Listener
{
+ ///
+ /// 生成点巡检计划
+ ///
public class GenerateSpotInspectionPlanTimeWorker : ISpareTimeWorker
{
- [SpareTime("0 45 14 * * ? *", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
+ private ISqlSugarRepository _repository => App.GetService>();
+ // public GenerateSpotInspectionPlanTimeWorker(ISqlSugarRepository repository)
+ // {
+ // _repository = repository;
+ // }
+
+ [SpareTime("0 0 0 * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
{
- Console.WriteLine("hello world");
+ Log.Information("----------------------开始生成点巡检计划----------------------");
+
+ try
+ {
+ List eqpSpotInsTemEquipHsByOne = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "1");
+ List eqpSpotInsTemEquipHsByCirculate = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "2");
+ List tobeCreateList = new List();
+ List tobeCreateTemplets = new List();
+ var db = _repository.AsSugarClient();
+
+ foreach (var item in eqpSpotInsTemEquipHsByOne)
+ {
+ if (item.start_time.AddHours((double)item.plan_cycle).ToString("yyyy-MM-dd HH:mm") == DateTime.Now.ToString("yyyy-MM-dd HH:mm"))
+ {
+ tobeCreateTemplets.Add(item);
+ }
+ }
+
+ if (eqpSpotInsTemEquipHsByCirculate != null && eqpSpotInsTemEquipHsByCirculate.Count > 0)
+ {
+ //查询最后一条数据加上周期是否等于现在等于表示周期到了 已废除
+ // List ids = eqpSpotInsTemEquipHsByCirculate.Select(x => x.id).ToList();
+ // List lastPlans = db.Queryable()
+ // .GroupBy(a => new { a.spot_ins_tem_equip_id })
+ // .Where(a => ids.Contains(a.spot_ins_tem_equip_id))
+ // .Select(a => new SpotInsRecordLastDTO()
+ // {
+ // spot_ins_tem_equip_id = a.spot_ins_tem_equip_id,
+ // create_time = SqlFunc.AggregateMax(a.create_time.Value)
+ // }).ToList();
+ //
+ // foreach (var item in eqpSpotInsTemEquipHsByCirculate)
+ // {
+ // var lastPlan = lastPlans.FirstOrDefault(x => x.spot_ins_tem_equip_id == item.id);
+ // if (lastPlan == null || lastPlan.create_time == null || lastPlan.create_time.AddHours((double)item.plan_cycle).ToString("yyyy-MM-dd HH") == DateTime.Now.ToString("yyyy-MM-dd HH"))
+ // {
+ // tobeCreateTemplets.Add(item);
+ // }
+ // }
+
+ //整除表示一个周期到了
+ foreach (var item in eqpSpotInsTemEquipHsByCirculate)
+ {
+ TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm")).Ticks);
+ TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(item.start_time.ToString("yyyy-MM-dd HH:mm")).Ticks);
+ TimeSpan ts3 = ts1.Subtract(ts2).Duration();
+ if (ts3.TotalMinutes * 10 / 60 % (10 * (double)item.plan_cycle)==0)
+ {
+ tobeCreateTemplets.Add(item);
+ }
+ }
+ }
+
+ if (tobeCreateTemplets != null && tobeCreateTemplets.Count > 0)
+ {
+ List equipments = db.Queryable().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToList();
+ int index = 1;
+ foreach (var item in tobeCreateTemplets)
+ {
+ //只有启用设备才生成计划
+ if (equipments.FirstOrDefault(x => x.id == item.equip_id) == null)
+ continue;
+
+ string code = $"{DateTime.Now.ToString("yyyyMMddHHmm")+(index++).ToString().PadLeft(3,'0')}";
+ tobeCreateList.Add(new EqpSpotInsRecordH()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ code = code,
+ // equip_type_id = item.equip_type_id,
+ equip_id = item.equip_id,
+ spot_ins_tem_equip_id = item.id,
+ plan_run_notice = item.plan_run_notice,
+ plan_run_notice_unit = item.plan_run_notice_unit,
+ plan_delay = item.plan_delay,
+ plan_delay_unit = item.plan_delay_unit,
+ send_post_info_user_id = item.send_post_info_user_id,
+ is_repeat = item.is_repeat,
+ repeat_post_info_user_id = item.repeat_post_info_user_id,
+ is_send = item.is_send,
+ create_time = DateTime.Now,
+ });
+ }
+ }
+
+
+ if (tobeCreateList != null && tobeCreateList.Count > 0)
+ {
+ List templetIDs = tobeCreateList.Select(x => x.spot_ins_tem_equip_id).ToList();
+ List spotInsTemEquipDs = db.Queryable().Where(x => templetIDs.Contains(x.spot_ins_tem_equip_id)).ToList();
+ List spotInsItemIDs = spotInsTemEquipDs.Select(x => x.spot_ins_item_id).ToList();
+ List spotCheckItems = db.Queryable().Where(x => spotInsItemIDs.Contains(x.id)).ToList();
+
+
+ foreach (var tobeCreatePlan in tobeCreateList)
+ {
+ List spotInsRecordDs = new List();
+ List spotInsItems = spotInsTemEquipDs
+ .Where(x => x.spot_ins_tem_equip_id == tobeCreatePlan.spot_ins_tem_equip_id)
+ .Select(x => x.spot_ins_item_id).ToList();
+ List tobeCreateItems = spotCheckItems.Where(x => spotInsItems.Contains(x.id)).ToList();
+ foreach (var tobeCreateItem in tobeCreateItems)
+ {
+ spotInsRecordDs.Add(new EqpSpotInsRecordD()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ spot_ins_record_id = tobeCreatePlan.id,
+ spot_ins_tem_equip_id = tobeCreatePlan.spot_ins_tem_equip_id,
+ spot_ins_item_id = tobeCreateItem.id,
+ code = tobeCreateItem.code,
+ name = tobeCreateItem.name,
+ judge_type = tobeCreateItem.judge_type,
+ low_value = tobeCreateItem.low_value,
+ high_value = tobeCreateItem.high_value,
+ low_value_is_include = tobeCreateItem.low_value_is_include,
+ high_value_is_include = tobeCreateItem.high_value_is_include,
+ standard_value = tobeCreateItem.standard_value,
+ unit_id = tobeCreateItem.unit_id,
+ inspection_method = tobeCreateItem.inspection_method,
+ judge_content = tobeCreateItem.judge_content,
+ remark = tobeCreateItem.remark
+ });
+ }
+
+ var dbResult = db.Ado.UseTran(() =>
+ {
+ if (tobeCreateList != null && tobeCreateList.Count > 0)
+ {
+ db.Insertable(tobeCreateList).ExecuteCommand();
+ }
+
+ if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
+ {
+ db.Insertable(spotInsRecordDs).ExecuteCommand();
+ }
+ });
+ if (!dbResult.IsSuccess)
+ {
+ Console.WriteLine(dbResult.ErrorMessage);
+ Log.Error(dbResult.ErrorMessage);
+ }
+ Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ Log.Error(e.Message);
+ }
+
+
+ Log.Information("----------------------结束生成点巡检计划----------------------");
+ }
+
+ ///
+ /// 最后一个点巡检记录
+ ///
+ private class SpotInsRecordLastDTO
+ {
+ public string spot_ins_tem_equip_id { get; set; }
+ public DateTime create_time { get; set; }
}
}
}
\ No newline at end of file
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/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs
index fb492e0f..93739262 100644
--- a/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs
+++ b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs
@@ -324,11 +324,12 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
Action? action = null;
ContentModel? comtentModel = input.ExecuteContent.ToObject();
input.ExecuteCycleJson = comtentModel.cron;
+ TaskMethodInfo? taskMethod = null;
switch (input.ExecuteType)
{
case "3":
// 查询符合条件的任务方法
- TaskMethodInfo? taskMethod = GetTaskMethods()?.Result.FirstOrDefault(m => m.id == comtentModel.localHostTaskId);
+ taskMethod = GetTaskMethods()?.Result.FirstOrDefault(m => m.id == comtentModel.localHostTaskId);
if (taskMethod == null) break;
// 创建任务对象
@@ -354,20 +355,20 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
{
interval = (starTime.ParseToDateTime() - DateTime.Now).TotalMilliseconds.ParseToInt();
}
- SpareTime.DoOnce(interval, action, "Once_" + input.Id);
- SpareTime.Do(
- () =>
- {
- var isRun = comtentModel.endTime.IsNullOrEmpty() ? DateTime.Now >= starTime : DateTime.Now >= starTime && DateTime.Now < endTime;
- if (isRun)
- {
- return SpareTime.GetCronNextOccurrence(comtentModel.cron);
- }
- else
- {
- return null;
- }
- },
+
+ if (taskMethod.StartNow) //modifyby zhoukeda 20230516
+ {
+ SpareTime.DoOnce(interval, action, "Once_" + input.Id);
+ }
+
+ Func nextHandle = null;
+ var isRun = comtentModel.endTime.IsNullOrEmpty() ? DateTime.Now >= starTime : DateTime.Now >= starTime && DateTime.Now < endTime;
+ if (isRun)
+ {
+ nextHandle = ()=>SpareTime.GetCronNextOccurrence(comtentModel.cron);
+ }
+ SpareTime.Do(nextHandle
+ ,
action, input.Id, comtentModel.ConnectionConfig.ToJsonString(), true, executeType: SpareTimeExecuteTypes.Parallel, cancelInNoneNextTime: false);
}
diff --git a/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj b/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj
index f2dfa7fb..85fb18db 100644
--- a/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj
+++ b/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj
@@ -6,12 +6,18 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS1572;CS1573;
+
+
+
+
+
\ No newline at end of file
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/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj b/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj
index 50f2e5c3..1d9eedd5 100644
--- a/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj
+++ b/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj
@@ -1,4 +1,4 @@
-
+
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS8629;CS1572;CS1573;CS0168;
diff --git a/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs b/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs
index f05956df..5a5f52d8 100644
--- a/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs
+++ b/visualdev/Tnb.VisualDev.Entitys/Dto/VisualDevModelData/VisualDevModelListQueryInput.cs
@@ -8,10 +8,11 @@ namespace JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
///
public class VisualDevModelListQueryInput : PageInputBase
{
- ///
- /// 菜单ID.
- ///
- public string menuId { get; set; }
+ //modified by PhilPan
+ /////
+ ///// 菜单ID.
+ /////
+ //public string menuId { get; set; }
///
/// 选择导出数据key.
diff --git a/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj b/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj
index 1e177c15..76aef262 100644
--- a/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj
+++ b/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8618;
diff --git a/visualdev/Tnb.VisualDev/RunService.cs b/visualdev/Tnb.VisualDev/RunService.cs
index fd1b9b98..498e1ba3 100644
--- a/visualdev/Tnb.VisualDev/RunService.cs
+++ b/visualdev/Tnb.VisualDev/RunService.cs
@@ -57,10 +57,10 @@ public class RunService : IRunService, ITransient
///
private readonly IBillRullService _billRuleService;
- ///
- /// 缓存管理.
- ///
- private readonly ICacheManager _cacheManager;
+ /////
+ ///// 缓存管理.
+ /////
+ //private readonly ICacheManager _cacheManager;
///
/// 用户管理.
diff --git a/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj b/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj
index 10a3c287..e6e5b41b 100644
--- a/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj
+++ b/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj
@@ -6,6 +6,7 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS8629;CS1572;CS1573;CS0168;
diff --git a/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs b/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs
index 13a2b694..64407b37 100644
--- a/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs
+++ b/visualdev/Tnb.VisualDev/VisualDevModelDataService.cs
@@ -872,7 +872,7 @@ namespace JNPF.VisualDev
var len = rowChildDatas.Select(x => x.Value.Count()).OrderByDescending(x => x).FirstOrDefault();
- if (len != null && len > 0)
+ if (len > 0)
{
for (int i = 0; i < len; i++)
{
diff --git a/visualdev/Tnb.VisualDev/VisualDevService.cs b/visualdev/Tnb.VisualDev/VisualDevService.cs
index 94151705..7bf72960 100644
--- a/visualdev/Tnb.VisualDev/VisualDevService.cs
+++ b/visualdev/Tnb.VisualDev/VisualDevService.cs
@@ -1281,7 +1281,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
foreach (DbTableAndFieldModel? item in addTableList)
{
bool res = await _changeDataBase.Create(link, item, item.FieldList);
- if (!res) throw null;
+ if (!res) Oops.Oh(ErrorCode.COM1008); // throw null;
}
if (await _visualDevRepository.IsAnyAsync(x => x.Id.Equals(vEntity.Id)))
diff --git a/visualdev/Tnb.VisualDev/VisualdevModelAppService.cs b/visualdev/Tnb.VisualDev/VisualdevModelAppService.cs
index 1a1d04d7..04233a29 100644
--- a/visualdev/Tnb.VisualDev/VisualdevModelAppService.cs
+++ b/visualdev/Tnb.VisualDev/VisualdevModelAppService.cs
@@ -409,7 +409,7 @@ public class VisualdevModelAppService : IDynamicApiController, ITransient
var len = rowChildDatas.Select(x => x.Value.Count()).OrderByDescending(x => x).FirstOrDefault();
- if (len != null && len > 0)
+ if (len > 0)
{
for (int i = 0; i < len; i++)
{
diff --git a/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj b/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj
index 358cdc7b..938c5f8a 100644
--- a/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj
+++ b/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8618;
diff --git a/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj b/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj
index 23d1885c..04a146bb 100644
--- a/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj
+++ b/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj
@@ -6,6 +6,7 @@
enable
enable
False
+ $(NoWarn);CS8625;
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();
}
diff --git a/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj b/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj
index 3f246622..261223a1 100644
--- a/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj
+++ b/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj
@@ -6,6 +6,7 @@
enable
enable
True
+ $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8619;CS8620;CS8625;CS8629;CS1572;CS1573;CS0168;CS4014;CS1998;