Compare commits

..

776 Commits

Author SHA1 Message Date
Kimdiego2098
a64ab7df4e 更新版本号 2023-11-24 14:48:53 +08:00
Kimdiego2098
82cd64cb50 10功能码写入时 修改需判断的crc长度 2023-11-24 14:48:28 +08:00
Kimdiego2098
065bfb8694 修复 modbusTcpDtu 初始化 空指针错误 2023-11-24 09:44:47 +08:00
Kimdiego2098
6db335cf87 OPCUA插件afterStop方法重写时需执行父类方法 2023-11-23 20:51:08 +08:00
Kimdiego2098
155f4670e9 调整网关状态页面 2023-11-23 20:49:35 +08:00
Kimdiego2098
50522b571a 修改内存缓存mapster选项 2023-11-23 15:22:39 +08:00
Kimdiego2098
8e138863ce 添加kafka的SecurityProtocol与SaslMechanism参数说明 2023-11-22 21:29:08 +08:00
Kimdiego2098
7d8dfe628d 修复上个提交导致的excel导入产生空指针错误 2023-11-22 20:52:58 +08:00
Kimdiego2098
8baed5b306 excel导入导出设备表时,去除多余的字段 2023-11-22 16:09:41 +08:00
Kimdiego2098
41a5ffd214 socktClient重载toString 2023-11-22 15:28:04 +08:00
Kimdiego2098
c6aec3a1af 更新版本号 2023-11-22 14:06:52 +08:00
Kimdiego2098
22e30f7a62 代码文件编码更改 2023-11-22 14:02:41 +08:00
Kimdiego2098
57711b8ab5 修复变量上传属性在编辑页面不显示的问题 2023-11-22 13:35:44 +08:00
Kimdiego2098
90ff1259ea 修复变量上传属性在编辑页面不显示的问题 2023-11-22 13:30:42 +08:00
Kimdiego2098
d88fc5ccd7 去除不存在的菜单 2023-11-21 18:19:14 +08:00
Kimdiego2098
5aaca2aa9c 调整循环延时时间限值 2023-11-21 16:27:11 +08:00
Kimdiego2098
8b9ca56e17 调试mqtt依赖 2023-11-21 15:07:07 +08:00
Kimdiego2098
e4f3772e6d 去除上传间隔1s限制 2023-11-21 11:46:33 +08:00
Kimdiego2098
d58ec81d20 整理代码 2023-11-21 11:41:44 +08:00
Kimdiego2098
415aae44b6 更新依赖 2023-11-21 08:44:47 +08:00
Kimdiego2098
a533286658 更新版本号 2023-11-20 23:05:12 +08:00
Kimdiego2098
e59f91cd82 去除treeview 2023-11-20 23:04:54 +08:00
Kimdiego2098
5f8b85d8a4 去除treeview显示 2023-11-20 22:53:34 +08:00
Kimdiego2098
47c7b88436 更新版本号 2023-11-20 22:47:18 +08:00
Kimdiego2098
90006782f2 mqttserver/client插件支持websocket通道,直接对接前端 2023-11-20 22:42:08 +08:00
Kimdiego2098
c3d49cbe70 mqttserver/client插件支持websocket通道,直接对接前端 2023-11-20 22:33:26 +08:00
Kimdiego2098
112323a360 modbusTcpServer最大连接数设为3w 2023-11-20 19:46:07 +08:00
Kimdiego2098
9d08c90fda 更新依赖 2023-11-20 17:35:42 +08:00
Kimdiego2098
602d24deec 添加admin-解决方案 2023-11-20 15:38:33 +08:00
Kimdiego2098
a2b9f66785 修复设备curd服务aop失效的问题 2023-11-19 23:30:11 +08:00
Kimdiego2098
7cbf289b50 更新版本号 2023-11-19 22:32:53 +08:00
Kimdiego2098
4097da79a5 modbus server 添加是否立即写入内存的选项 2023-11-19 22:32:13 +08:00
Kimdiego2098
91b7ae554f 默认开启多标签 2023-11-19 22:31:47 +08:00
Kimdiego2098
3121aa2542 添加历史报警插件 2023-11-19 22:19:05 +08:00
Kimdiego2098
4bf895e6e1 修复4.0代码 s7协议未设置适配器导致初始化/读写失败的问题 2023-11-19 21:49:32 +08:00
Kimdiego2098
0c5489e920 增加上传插件 缓存基类 2023-11-19 15:20:01 +08:00
Kimdiego2098
d63c3aaa80 获取插件继承属性时,去除不重写特性的属性 2023-11-19 14:15:58 +08:00
Kimdiego2098
4f188ea6cc 整理文件 2023-11-18 23:04:51 +08:00
Kimdiego2098
acb17018ae 整理文件 2023-11-18 23:04:25 +08:00
Kimdiego2098
2affe2988d 整理文件 2023-11-18 23:03:24 +08:00
Kimdiego2098
4174dd2206 整理文件 2023-11-18 23:03:02 +08:00
Kimdiego2098
e1c492f238 整理文件 2023-11-18 23:02:28 +08:00
Kimdiego2098
fb08e34fa3 整理文件 2023-11-18 23:01:56 +08:00
Kimdiego2098
a1793a0afe 去除不必要的文件 2023-11-18 22:52:26 +08:00
Kimdiego2098
4da9763b49 去除不必要的文件 2023-11-18 22:50:03 +08:00
Kimdiego2098
81e0918bd0 迁移4.0 2023-11-18 22:45:24 +08:00
Kimdiego2098
c1e064f06d 迁移4.0 2023-11-18 22:43:36 +08:00
Kimdiego2098
1c52be8b47 添加停止线程等待时间 2023-11-16 22:32:22 +08:00
Kimdiego2098
bcd82055ca s7握手失败后,手动关闭连接 2023-11-11 10:26:05 +08:00
Kimdiego2098
c47d95d170 fix:修复线程阻塞检测触发重启时,后台变量列表不再刷新的问题! 2023-11-10 09:00:50 +08:00
Kimdiego2098
3e62f1ad51 历史数据上传成功后,才上传缓存数据 2023-11-09 18:55:56 +08:00
Kimdiego2098
8dcae973ef update 2023-11-08 16:19:46 +08:00
Kimdiego2098
4cf35f7294 发布3.0.1版本 2023-11-03 11:32:13 +08:00
Kimdiego2098
94c77d151b update touchsocket 2023-11-03 11:27:12 +08:00
Kimdiego2098
7f600e2b4b update touchsocket 2023-11-03 11:19:26 +08:00
Kimdiego2098
c809d0ba87 不存在插件时,报错内容优化 2023-11-01 14:51:08 +08:00
Kimdiego2098
50f038ec89 update webapiClient 2023-11-01 14:21:53 +08:00
Kimdiego2098
9199a255a2 调整Timeout属性为int数据类型 2023-10-31 23:49:46 +08:00
Kimdiego2098
d324537b47 更新发布版3.0.0.28 2023-10-31 17:47:07 +08:00
Kimdiego2098
d0c05685f7 更新OPCUAClient,订阅模式适配 分组 2023-10-31 10:55:50 +08:00
Kimdiego2098
1063c930b5 update 2023-10-31 00:24:00 +08:00
Kimdiego2098
79cbd44366 tcpservice停止时执行shutdown方法,修复demo发布不显示页面的问题 2023-10-30 21:31:30 +08:00
Kimdiego2098
7fdac1c5cb 添加部分Pro内容 2023-10-29 19:39:38 +08:00
Kimdiego2098
0c0cf72ebb 添加部分Pro内容 2023-10-29 19:34:17 +08:00
Kimdiego2098
8e2fe175ed 更新文档 2023-10-28 22:06:58 +08:00
Kimdiego2098
d1cff037c9 发布3.0.0.27版本;
优化设备线程启停逻辑
添加winform(blazor) demo
部分页面显示内容优化
2023-10-28 22:03:52 +08:00
Kimdiego2098
fc88a2fafa 发布3.0.0.27版本;
优化设备线程启停逻辑
添加winform(blazor) demo
部分页面显示内容优化
2023-10-28 22:00:35 +08:00
Kimdiego2098
45fcceb056 优化设备线程启停逻辑 2023-10-28 21:58:09 +08:00
Kimdiego2098
7043477038 添加部分Pro内容 2023-10-28 21:21:03 +08:00
Kimdiego2098
7dd685cf54 添加winform(blazor) demo 2023-10-28 15:20:12 +08:00
Kimdiego2098
5f5e4969c0 调整pro类库 2023-10-28 10:54:26 +08:00
Diego2098
8a53fd19e9 设备状态页面显示优化 2023-10-27 20:19:26 +08:00
Diego2098
baf4714c36 状态显示:已退出自动更新 2023-10-27 20:18:57 +08:00
Kimdiego2098
7ba9ac7a5b 报文显示限长500 2023-10-27 14:53:19 +08:00
Kimdiego2098
85b8f26e8e tcpserver 报文输出 添加 ip端口 提示 2023-10-27 14:41:35 +08:00
Kimdiego2098
594a0f1410 update the tcpserver class and add log output for start and stop 2023-10-27 14:24:26 +08:00
Kimdiego2098
d317d757d7 优化线程上下文转换 2023-10-26 19:16:24 +08:00
Kimdiego2098
fdf0ba6318 添加ConfigureAwait 2023-10-26 18:06:33 +08:00
Kimdiego2098
15bf7de5fa 优化设备导出逻辑 2023-10-26 15:15:43 +08:00
Kimdiego2098
d3402b058e 优化设备导出逻辑 2023-10-26 15:10:26 +08:00
Kimdiego2098
e7dfdd4031 3.0.0.25 2023-10-26 13:21:40 +08:00
Kimdiego2098
b2dd7b6364 Merge branch 'master' of https://gitee.com/dotnetchina/ThingsGateway 2023-10-26 13:20:54 +08:00
Kimdiego2098
9bd6d9abbf 3.0.0.25 2023-10-26 13:20:31 +08:00
Kimdiego2098
cd14428fea update 2023-10-26 13:19:18 +08:00
Kimdiego2098
19d9f03c2b s7添加错误返回码提示,组包处理 2023-10-26 13:05:06 +08:00
Kimdiego2098
0d57e72bbf 增加硬件信息 相关json配置 2023-10-26 10:54:48 +08:00
Kimdiego2098
329516a61b 更新nuget依赖 2023-10-26 09:37:01 +08:00
Kimdiego2098
d566869589 硬件信息页面添加刷新条件 2023-10-26 09:20:25 +08:00
Kimdiego2098
9cb8d8e6c7 更新文档 2023-10-25 00:53:27 +08:00
Kimdiego2098
9de3c57e5d update touchsocket 2023-10-25 00:53:17 +08:00
Kimdiego2098
f32ff92b0b <Version>3.0.0.24</Version> 2023-10-24 23:48:20 +08:00
Kimdiego2098
88d71e271e 更改S7协议 设备属性,注意删除了DstTSAP,改为较直观的 机架号/槽位号 2023-10-24 23:47:35 +08:00
Kimdiego2098
fd9c14612a 添加属性识别 16进制写入 2023-10-24 23:46:50 +08:00
Kimdiego2098
e26e5a160f 添加nuget依赖包 2023-10-24 20:50:39 +08:00
Kimdiego2098
b836bfed22 更新nuget包 2023-10-24 00:37:46 +08:00
Kimdiego2098
a4b598c6d0 调整解决方案文件夹 2023-10-24 00:13:03 +08:00
Kimdiego2098
c9ab755839 暂时屏蔽mqttserver 遗留消息错误 2023-10-23 20:51:11 +08:00
Kimdiego2098
9920edba53 调整编码 2023-10-23 20:47:00 +08:00
Kimdiego2098
12bd7280d1 调整mqttlog 2023-10-23 20:46:17 +08:00
Kimdiego2098
d30ea7f63b 调整mqttlog 2023-10-23 20:43:58 +08:00
Kimdiego2098
ebd3390db6 添加部分兼容方法 2023-10-22 02:42:16 +08:00
Kimdiego2098
9a374a9ebc 添加部分兼容方法 2023-10-22 02:26:18 +08:00
Kimdiego2098
b1bc22cb08 update touchsocket 2023-10-22 02:26:04 +08:00
Kimdiego2098
4930d53890 调整代码格式 2023-10-21 19:15:26 +08:00
Kimdiego2098
c31327b5bc update touchsocket 2023-10-21 19:08:21 +08:00
Kimdiego2098
3f2aa1f1e1 调整代码格式 2023-10-21 19:03:15 +08:00
Kimdiego2098
6e78c00a96 调整代码格式 2023-10-21 19:02:58 +08:00
Kimdiego2098
c27dde085e 3.0.0.23 2023-10-20 21:38:22 +08:00
Kimdiego2098
d26cc308c0 优化SQLDB实时表模式,插入/更新 2023-10-20 21:38:07 +08:00
Kimdiego2098
fb1efdf290 sqlsugar提示默认中文 2023-10-20 21:37:42 +08:00
Kimdiego2098
3c99f2a472 update touchsocket 2023-10-20 21:03:29 +08:00
Kimdiego2098
affe9a44e0 优化 ModbusServer 内存占用 2023-10-20 01:53:48 +08:00
Kimdiego2098
43730fa519 3.0.0.21 2023-10-20 01:19:18 +08:00
Kimdiego2098
d39aa22b09 优化OPCUAServer,取消注册,提供多url写入 2023-10-20 01:19:05 +08:00
Kimdiego2098
e232a6b6ea 更新赞助名单 2023-10-19 21:15:35 +08:00
Kimdiego2098
71ebb36fe9 更新文档 2023-10-19 20:36:28 +08:00
Kimdiego2098
78a0b86327 更新版本:3.0.0.20 2023-10-19 20:27:31 +08:00
Kimdiego2098
2636c16a97 优化modbusServer内存管理 2023-10-19 20:24:39 +08:00
Kimdiego2098
fd77c0242d update touchsocket 2023-10-19 20:23:43 +08:00
Kimdiego2098
e74819a900 update toucksocket 2023-10-18 21:51:49 +08:00
Kimdiego2098
9b7f696c9b 更新文档 2023-10-18 20:42:10 +08:00
Kimdiego2098
0230d614e7 发布驱动包 2023-10-18 18:04:37 +08:00
Diego2098
252d99ad78 !12 【轻量级 PR】:修正心跳事件中的参数
Merge pull request !12 from youthalan/N/A
2023-10-18 06:59:17 +00:00
youthalan
1ffc200350 修正心跳事件中的参数
Signed-off-by: youthalan <youthalan@126.com>
2023-10-18 06:58:03 +00:00
Kimdiego2098
807d89b2b2 更新版本号 2023-10-18 13:13:03 +08:00
Kimdiego2098
4013afa1f1 初始化 采集/上传线程时 直接返回线程控制 2023-10-18 13:11:59 +08:00
Kimdiego2098
a580927ceb 更新OPCUAClient类库 2023-10-18 13:09:25 +08:00
Kimdiego2098
bf2cf52034 更新OPCUAClient类库 2023-10-18 12:45:26 +08:00
Kimdiego2098
81bb8b7c31 更新OPCUAClient类库 2023-10-18 12:44:58 +08:00
Kimdiego2098
a825007fb5 更新版本号与nuget发布 2023-10-18 12:39:42 +08:00
Kimdiego2098
988124d96a 更新OPCUAClient类库 2023-10-18 12:38:20 +08:00
Diego2098
f0de815296 !11 补充OPCClient类库事件的缺失文件
Merge pull request !11 from youthalan/N/A
2023-10-18 04:34:34 +00:00
youthalan
0e2d58c887 补充OPCClient类库事件的缺失文件
Signed-off-by: youthalan <youthalan@126.com>
2023-10-18 04:32:39 +00:00
Diego2098
b155382626 !10 添加连接或断开事件
Merge pull request !10 from youthalan/N/A
2023-10-18 04:20:22 +00:00
youthalan
f362d740af 修改OPCUAClient类添加连接或断开事件,修改注入时不需要带参数
Signed-off-by: youthalan <youthalan@126.com>
2023-10-18 03:48:05 +00:00
Kimdiego2098
4a85e31a4f update 3.0.0.16 2023-10-18 00:38:36 +08:00
Kimdiego2098
302c270ad5 opcuaClient浏览空间 添加是否显示子变量的选项 2023-10-18 00:36:44 +08:00
Kimdiego2098
3c1517d0f3 更改日志输出内容 2023-10-18 00:15:07 +08:00
Kimdiego2098
f9fb222044 update 3.0.0.15 2023-10-18 00:07:24 +08:00
Kimdiego2098
e8edc02ba3 增加不支持单文件发布的说明 2023-10-17 23:47:24 +08:00
Kimdiego2098
95a44e3053 update tdengineDB plugin 2023-10-17 23:43:48 +08:00
Kimdiego2098
74a9fe9a87 update touchsocket 2023-10-17 23:12:19 +08:00
Kimdiego2098
4d03f9ea1a TD时序库插件,创建时间更改为主键 2023-10-17 23:08:09 +08:00
Kimdiego2098
67c96ca991 update touchsocket 2023-10-17 23:06:21 +08:00
Kimdiego2098
88fb793c68 更新nuget包 2023-10-17 21:00:50 +08:00
Kimdiego2098
d6d02d8cc5 update SQLDB 2023-10-16 20:50:10 +08:00
Kimdiego2098
c5a3f8e2e3 update touchsocket and other 2023-10-16 20:36:51 +08:00
Kimdiego2098
27e8653a1a 3.0.0.13 2023-10-16 17:44:09 +08:00
Kimdiego2098
863beda82c 增加关系库存储插件; 2023-10-16 17:40:17 +08:00
Kimdiego2098
bac84c3ecd 增加时序库存储插件; 2023-10-16 17:40:13 +08:00
Kimdiego2098
2fca2ad9f8 更新pro用户列表 2023-10-16 17:39:14 +08:00
Kimdiego2098
dd75286fe0 3.0.0.12 2023-10-16 08:47:39 +08:00
Kimdiego2098
7f91792cf1 opcuaclient添加是否加载服务端数据类型的选项 2023-10-16 08:46:46 +08:00
Kimdiego2098
0e0ccad311 fix:tcpservice dispose err 2023-10-16 08:46:32 +08:00
Diego2098
0691f72e67 !9 增加可选择安全订阅
Merge pull request !9 from youthalan/N/A
2023-10-16 00:33:19 +00:00
youthalan
7e38a51720 增加可选择安全订阅,以加快订阅速度
Signed-off-by: youthalan <youthalan@126.com>
2023-10-16 00:26:59 +00:00
Kimdiego2098
34ca8243a3 更新3.0.0.11 2023-10-15 20:26:18 +08:00
Diego2098
112fea7632 读取数据类型方法改为批量 2023-10-15 20:21:23 +08:00
Kimdiego2098
378763e4ee 同步Pro版本 2023-10-13 20:14:35 +08:00
Kimdiego2098
517bd0394d update touchsocket 2023-10-13 19:16:12 +08:00
Kimdiego2098
70adb97fb5 update nuget 2023-10-13 16:14:42 +08:00
Kimdiego2098
623d44cabe update 3.0.0.7 2023-10-13 11:54:27 +08:00
Kimdiego2098
0d479ca00b 添加三菱mc 3e帧二进制通讯协议文档 2023-10-13 11:51:51 +08:00
Kimdiego2098
8bc49ef437 update demo 2023-10-12 18:52:44 +08:00
Kimdiego2098
f83fcec786 参数名称修改 2023-10-12 14:57:58 +08:00
Kimdiego2098
93690ce40d fix:mqtt保留消息未更新/更新错误 2023-10-12 14:57:36 +08:00
Kimdiego2098
f82c5f2f27 3.0.0.6 2023-10-11 16:35:10 +08:00
Kimdiego2098
a83c1c3899 update nuget 2023-10-11 16:28:18 +08:00
Kimdiego2098
91d6aed109 调整代码执行顺序 2023-10-11 16:19:34 +08:00
Kimdiego2098
db8f8fe51d update ManageGateway 2023-10-11 10:59:33 +08:00
Kimdiego2098
4596004b17 update ManageGateway 2023-10-11 10:41:09 +08:00
Kimdiego2098
d5540906cb update 3.0.0.5 2023-10-10 21:09:34 +08:00
Kimdiego2098
90796a979d fix:modbusRtu写入返回报文缓存逻辑修复 2023-10-10 21:08:42 +08:00
Kimdiego2098
2190a87772 update touchsocket 2023-10-10 20:03:40 +08:00
Kimdiego2098
c5953b83f8 update touchsocket 2023-10-10 20:02:15 +08:00
Kimdiego2098
24bc60abf0 fix:signalR razor dispose接口 2023-10-09 18:11:23 +08:00
Kimdiego2098
31eee6b009 update uaparser 2023-10-09 10:56:22 +08:00
Kimdiego2098
c5da565a8f 添加MqttRpcDemo 2023-10-07 12:04:17 +08:00
Kimdiego2098
947cd712e1 添加清理日志任务配置参数 2023-10-06 18:28:06 +08:00
Kimdiego2098
edc208f96b update 3.0.0.2 2023-10-05 15:32:50 +08:00
Diego2098
1fb0296ee7 update Directory.Build.props 2023-10-05 15:21:51 +08:00
Kimdiego2098
6488d3df87 修复重启共享通道中的单个设备时,导致通道内其他设备变量异常 2023-10-05 00:34:12 +08:00
Kimdiego2098
56189d78e0 update opcuaclient 2023-10-04 17:12:47 +08:00
Kimdiego2098
bff18127b8 update opcuaclient 2023-10-04 16:59:15 +08:00
Kimdiego2098
363206e0ba update nuget 2023-10-04 02:04:09 +08:00
Kimdiego2098
fd3e378501 update 3.0.0.1 2023-10-04 01:42:27 +08:00
Kimdiego2098
4ba2fe4c9d 实时报警列表线程同步 2023-10-04 01:27:03 +08:00
Kimdiego2098
2c499626ad modbusRtu 适配器 过滤干扰头部数据 2023-10-04 01:26:44 +08:00
Kimdiego2098
2b581a03c3 更新种子数据 2023-10-04 01:24:34 +08:00
Kimdiego2098
450c15210a update windowsService bat 2023-10-03 19:11:42 +08:00
Kimdiego2098
65fed8cc93 update demo 2023-10-03 18:54:01 +08:00
Kimdiego2098
4b64771ea2 rpc调用提示优化 2023-10-03 18:20:39 +08:00
Kimdiego2098
f39977a6ff fix:rpc 特殊方法分类错误 2023-10-03 17:05:49 +08:00
Kimdiego2098
933b535caa update demo 2023-10-02 22:37:50 +08:00
Kimdiego2098
8abc5d2f20 update driverDebugPage 2023-10-02 18:34:55 +08:00
Kimdiego2098
d8783cd994 update opcuaClient 2023-10-02 18:30:58 +08:00
Diego2098
d5d087feb5 add s7 wstring addressSign 2023-10-01 16:54:42 +08:00
Diego2098
6ba3399df7 add s7 wstring addressSign 2023-10-01 16:49:07 +08:00
Diego2098
65124b3aa8 更新demo 2023-10-01 13:33:25 +08:00
Kimdiego2098
98597f4726 update demo csproj 2023-10-01 00:33:33 +08:00
Kimdiego2098
e7981f0d8e add EncodingMapper 2023-10-01 00:25:04 +08:00
Kimdiego2098
cf654427c3 更新文档 2023-09-30 23:28:50 +08:00
Kimdiego2098
ff2f628282 默认不启用远程更新 2023-09-30 23:23:44 +08:00
Kimdiego2098
ae818ca265 更新readme 2023-09-30 23:09:48 +08:00
Kimdiego2098
0f2aed458e 同步3.0.0版本代码 2023-09-30 23:05:53 +08:00
Kimdiego2098
d486c44ff6 更新文档 2023-09-26 20:03:58 +08:00
Kimdiego2098
ca7b9980bf 2.1.0.15 2023-09-20 11:50:06 +08:00
Kimdiego2098
3c71e6a8e3 2.1.0.15 2023-09-20 11:47:10 +08:00
Kimdiego2098
542442864c 添加kafka/mq/iotsharp的间隔上传 2023-09-20 11:46:17 +08:00
Diego2098
5edb64fa85 fix:上传设备选择驱动时没有正确刷新 2023-09-18 00:10:02 +08:00
Kimdiego2098
8dc1c898a3 2.1.0.14 2023-09-15 14:02:15 +08:00
Kimdiego2098
1ed35726b0 ExpressionEvaluator改为多实例 2023-09-15 14:01:54 +08:00
Kimdiego2098
27fae9ebaa 2.1.0.13 2023-09-15 13:23:59 +08:00
Kimdiego2098
b103f25c94 add dispose() 2023-09-15 13:23:39 +08:00
Kimdiego2098
abff450274 2.1.0.12 2023-09-15 13:20:29 +08:00
Kimdiego2098
c260736a11 更新多个依赖包版本 2023-09-15 13:19:04 +08:00
Kimdiego2098
166ac2307a 修复因重复注册cancellationToken.Register导致的内存暴涨! 2023-09-15 13:17:36 +08:00
Kimdiego2098
b21a4e1a4d CancellationToken代替CancellationTokenSource传入 2023-09-15 13:16:56 +08:00
Kimdiego2098
f7dc943fa3 2.1.0.11 2023-09-11 09:35:24 +08:00
Kimdiego2098
bfbd2693ec feat:ManageGatewayWorker part 2023-09-11 09:31:26 +08:00
Kimdiego2098
819e71c993 feat:ManageGatewayWorker part 2023-09-11 09:09:48 +08:00
Kimdiego2098
9fd0b489a2 feat:ManageGatewayWorker part 2023-09-11 09:09:03 +08:00
Kimdiego2098
f5fe9f8dae TGAPPInfp更名APPInfo 2023-09-11 08:57:13 +08:00
Kimdiego2098
f9ffc18145 Merge branch 'master' of https://gitee.com/dotnetchina/ThingsGateway 2023-09-11 08:54:01 +08:00
Kimdiego2098
08db5b983a feat:ManageGatewayWorker part 2023-09-11 08:53:52 +08:00
Diego2098
5b3b4c8c50 !7 修复无法修改变量值问题
Merge pull request !7 from 如阳如木/master
2023-09-07 10:14:45 +00:00
如阳如木
73f914ffc4 删除&& LastSetValue?.ToString() != data?.ToString()
Signed-off-by: 如阳如木 <970143933@qq.com>
2023-09-07 08:42:49 +00:00
Kimdiego2098
d6bdd73ed6 ManageGatewayConfig.json 2023-09-06 17:29:58 +08:00
Kimdiego2098
7370ee7349 fix:_mqttServer null error 2023-09-06 17:27:36 +08:00
Kimdiego2098
4574596bac 2.1.0.10 2023-09-06 17:16:28 +08:00
Kimdiego2098
4d16855e36 从数据库取原属性 2023-09-06 17:14:24 +08:00
Kimdiego2098
13a0d4d282 更改变量 最近一次值 为 上次值 2023-09-06 16:44:58 +08:00
Kimdiego2098
b9cd06b829 更改 变量最近一次值 为 上次值 2023-09-06 16:44:42 +08:00
Kimdiego2098
5b460e8fa2 2.1.0.9 2023-09-06 16:30:50 +08:00
Kimdiego2098
41087edf17 fix:串口断连/拔出/断电等情况,重新连接 2023-09-06 16:29:48 +08:00
Kimdiego2098
2afcc38e38 feat:ManageGatewayWorker part 2023-09-06 16:15:38 +08:00
Kimdiego2098
e59ccce25f feat:ManageGatewayWorker part 2023-09-06 16:10:29 +08:00
Kimdiego2098
d7425890e8 feat:ManageGatewayWorker part 2023-09-05 23:59:18 +08:00
Kimdiego2098
a989a837fb feat:ManageGatewayWorker part 2023-09-05 23:37:02 +08:00
Kimdiego2098
db1221da50 feat:ManageGatewayWorker part 2023-09-05 23:33:02 +08:00
Kimdiego2098
cf794569ed 2.1.0.8 2023-09-05 09:19:58 +08:00
Kimdiego2098
51e5bbab0d fix:PeriodicTimer dispose 2023-09-05 09:17:26 +08:00
Kimdiego2098
2c197ed2b2 2.1.0.7 2023-09-05 09:06:39 +08:00
Kimdiego2098
d8fc6665b3 fix:error!the stream dispose 2023-09-05 09:04:34 +08:00
Kimdiego2098
c671a79822 Revert "fix:error!the stearm dispose"
This reverts commit a6d99fe227.
2023-09-05 09:03:49 +08:00
Kimdiego2098
9d93ce4c41 feat:mqttBroker part 2023-09-05 08:58:49 +08:00
Kimdiego2098
a6d99fe227 fix:error!the stearm dispose 2023-09-05 08:57:42 +08:00
Diego2098
923b8bca31 feat:mqttBroker part 2023-09-04 22:34:31 +08:00
Diego2098
e2c30d1c88 fix:uploadDeivce复制多个,ID重复问题 2023-09-04 22:11:50 +08:00
Diego2098
b6d9f2a04e 刷新后选择行清空 2023-09-04 22:09:26 +08:00
Diego2098
57306ea664 fix:采集设备线程初始化时更新活跃时间 2023-09-04 20:13:49 +08:00
Diego2098
cd7f3fd02f fix:特殊情况下无法获取程序集文件修改日期,所以去除 页脚-编译时间显示 2023-09-04 19:49:17 +08:00
Kimdiego2098
0482e077a8 fix:sqlsugar json支持类型改为bigstring 2023-09-04 17:09:38 +08:00
Kimdiego2098
5f986a45ca 更新文档 2023-09-04 15:03:03 +08:00
Kimdiego2098
ca7b49c0d5 恢复Sqlite默认数据库 2023-09-02 19:17:32 +08:00
Kimdiego2098
52dd555e6c fix: page取消注入瞬时服务,改为App.GetService 2023-09-02 19:13:57 +08:00
Kimdiego2098
579b1a59f9 feat:mqttBroker part 2023-09-02 13:55:21 +08:00
Kimdiego2098
5299c5c4be 更新文档 2023-08-31 09:17:59 +08:00
Kimdiego2098
f7756bccef 更新 变量管理-上传设备筛选功能 2023-08-31 08:58:30 +08:00
Kimdiego2098
a6b874d160 2.1.0.6 2023-08-30 17:19:18 +08:00
Kimdiego2098
3e5fb3ddcf add windows service create/delete bat 2023-08-30 17:18:35 +08:00
Kimdiego2098
5e6bcb12d3 update statusPage; 2023-08-30 14:12:50 +08:00
Kimdiego2098
14303f1429 默认检测重连频率为10分钟 2023-08-29 17:56:59 +08:00
Kimdiego2098
96711ba022 2.1.0.5 2023-08-29 17:44:28 +08:00
Kimdiego2098
cbfc0fdbdc 添加报文日志入库选项 2023-08-29 17:42:56 +08:00
Kimdiego2098
6e81886c0e 添加 页脚 编译时间显示 2023-08-29 17:01:46 +08:00
Kimdiego2098
2d976bc132 调整导入excel错误提示 2023-08-29 16:45:54 +08:00
Kimdiego2098
57f6a476af update opcdaclient null error 2023-08-29 15:24:29 +08:00
Kimdiego2098
8491ed296e update GetBoolValue 2023-08-29 12:40:21 +08:00
Kimdiego2098
cd1288afdc 调整种子文件,增加Pro版本种子文件录入 2023-08-29 09:42:54 +08:00
Kimdiego2098
ec6c830cb0 更新2.1.0.4 2023-08-28 19:31:00 +08:00
Kimdiego2098
2f86ccc4bf 修复串口基类 缓存包 失效错误;完善modbusrtu长度校验 2023-08-28 19:25:22 +08:00
Kimdiego2098
8ca445aec0 更新touchsocket版本,更新2.1.0.3 2023-08-28 18:12:18 +08:00
Kimdiego2098
1e1f27c8a5 修复浏览大量节点空间时,BrowseNext方法参数releaseContinuationPoints改为false 2023-08-28 17:44:02 +08:00
Kimdiego2098
2b84bde367 修复调试界面-opcuaclient浏览节点展开逻辑错误 2023-08-28 10:51:35 +08:00
Kimdiego2098
b52e58551d 更新小版本2.1.0.2 2023-08-27 17:17:37 +08:00
Kimdiego2098
9aceed00bf 更新dlt645地址说明 2023-08-27 17:16:59 +08:00
Kimdiego2098
58814f7f74 添加日志查询 时间区间条件 2023-08-27 16:58:45 +08:00
Kimdiego2098
6a70ef9f31 2.1.0.1 2023-08-27 16:31:03 +08:00
Kimdiego2098
82cc4ca500 dlt645添加数据标识校验 2023-08-27 16:30:32 +08:00
Kimdiego2098
4567fa04ed 更新dlt645,添加地址/控制码的校验规则 2023-08-27 16:15:51 +08:00
Kimdiego2098
8b98b5d818 更新touchsocket 2023-08-27 15:59:57 +08:00
Kimdiego2098
176d0351af 更新 Opc.Ua Version="1.4.372.56" 2023-08-27 14:33:24 +08:00
Kimdiego2098
d63dc3384b opcda/ua浏览地址空间 初始只加载首层节点 2023-08-27 14:14:47 +08:00
Kimdiego2098
1ccd704e30 opcuaclient浏览地址空间 初始只加载首层节点 2023-08-27 13:06:03 +08:00
Diego2098
f5d23dbe79 update MqttNetLogger 2023-08-26 21:38:14 +08:00
Diego2098
75bfe53ac3 update MqttNetLogger 2023-08-26 20:40:23 +08:00
Diego2098
3308f916dd 添加在线/离线方法参数 2023-08-26 17:18:47 +08:00
Diego2098
e7140279ca 更新opcuaclient 2023-08-26 15:38:22 +08:00
Diego2098
1034719f5e 更新opcuaclient,添加checkDomain属性,去除多余代码,更新SelectEndpoint方法 2023-08-26 15:33:03 +08:00
Kimdiego2098
2c00043a7f 更新文档 2023-08-25 19:49:02 +08:00
Kimdiego2098
65c695d9ce 更新版本2.1.0 2023-08-25 19:45:28 +08:00
Kimdiego2098
57253fe46a 更新解决方案 2023-08-25 19:38:47 +08:00
Kimdiego2098
4e5c443440 更新DLT645文档 2023-08-25 19:33:33 +08:00
Kimdiego2098
0b3b73d8ec 添加DLT645_2007协议插件 2023-08-25 19:33:08 +08:00
Kimdiego2098
921eabc134 调整Test位置 2023-08-25 19:32:27 +08:00
Kimdiego2098
0faa428751 调整非主从协议的状态判断策略;OPCUA去除主动连接 2023-08-25 17:23:00 +08:00
Kimdiego2098
f71a2fdd63 crc校验优化 2023-08-22 17:01:10 +08:00
Kimdiego2098
4eb9ed8aba OPCUAClient添加是否使用SourceTime的选项 2023-08-22 16:15:34 +08:00
Kimdiego2098
d7b549abb8 更新文档 2023-08-22 12:21:45 +08:00
Kimdiego2098
95d723c578 2.0.9.3 2023-08-22 11:31:36 +08:00
Kimdiego2098
2fcd853e86 去除mqtt throw an _MqttConnectingFailedException_.报错信息 2023-08-22 11:26:22 +08:00
Kimdiego2098
07eef7c812 更新批量写入方法,注意rpc入口参数变化,mqtt等RPC接口参数变化 2023-08-22 11:23:03 +08:00
Kimdiego2098
b01e0757fa 修正部分代码格式 2023-08-21 19:59:07 +08:00
Kimdiego2098
32844a20c6 2.0.9.2 2023-08-19 12:08:49 +08:00
Kimdiego2098
5b6532c601 xml 2023-08-19 11:06:05 +08:00
Kimdiego2098
2c5b4b4027 修复TcpClient重复释放导致锁异常 2023-08-19 11:05:29 +08:00
Kimdiego2098
72d7ecf195 mas1.0.2默认中文 2023-08-18 18:36:30 +08:00
Kimdiego2098
2cfa6b4306 更新masa1.0.2 2023-08-18 13:59:17 +08:00
Kimdiego2098
6f6ffde0ab 2.0.9.1 2023-08-18 13:33:45 +08:00
Kimdiego2098
1694739a16 修改锁为EasyLock 2023-08-18 12:07:01 +08:00
Kimdiego2098
95d1e8bfca 代码文件编码统一utf-8 2023-08-18 09:57:03 +08:00
Kimdiego2098
60dec08e3c 更换DEMO Include为PackageReference 2023-08-17 15:30:35 +08:00
Kimdiego2098
a99d71be93 底层驱动添加netstandard输出 2023-08-17 15:24:07 +08:00
Kimdiego2098
f1331b6a0c 2.0.8 2023-08-17 10:58:48 +08:00
Kimdiego2098
10d66b642b 调整readme,方便copy账密 2023-08-17 10:28:47 +08:00
Kimdiego2098
cd2310e4a8 优化变量地址输入分割方法;s7读写字符串添加默认编码 2023-08-17 09:50:10 +08:00
Kimdiego2098
1b399cf6b0 优化s7读写字符串,更改特殊方法为读写共用 2023-08-16 17:20:20 +08:00
Kimdiego2098
877445bc0a 修复写入返回结果时的解析,0XFF为成功 2023-08-16 15:56:25 +08:00
Kimdiego2098
9a5b345bde 修复s7字符串打包读取 2023-08-16 15:47:37 +08:00
Kimdiego2098
fc9e8ea7b3 修复s7字符串读取 2023-08-16 15:35:15 +08:00
Kimdiego2098
32be6fcfc1 主动释放锁 2023-08-16 14:56:47 +08:00
Kimdiego2098
49847236c2 OPCUA死区不再固定传入 2023-08-16 14:21:19 +08:00
Kimdiego2098
d8424443e6 fix: 优化JsonUtils中的获取type语句顺序 2023-08-16 08:59:18 +08:00
Kimdiego2098
f3b571ec3f OPC系列增加导出excel/导入系统双选项 2023-08-15 17:38:40 +08:00
Kimdiego2098
99318bb5d7 OPCUA采集设备写入字符串,不再需要传入双引号 2023-08-15 14:15:39 +08:00
Kimdiego2098
1aa154c9aa 历史数据/报警 线程初始化时不再阻塞 2023-08-15 12:12:00 +08:00
Kimdiego2098
c65d8a445b 更改ItemGroup Condition条件 2023-08-14 17:36:59 +08:00
Kimdiego2098
80f4f85570 传播token;
更新admin解决方案
2023-08-14 16:43:30 +08:00
Kimdiego2098
5beee43a6b 优化适配器解析代码 2023-08-14 14:21:00 +08:00
Kimdiego2098
8d6ae203a0 2.0.6 2023-08-13 16:57:12 +08:00
Kimdiego2098
4353479a5c OPCUACClient订阅初始化添加trycatch 2023-08-13 16:29:59 +08:00
Kimdiego2098
34d7687f9e Merge branch 'master' of https://gitee.com/dotnetchina/ThingsGateway 2023-08-13 15:53:33 +08:00
Kimdiego2098
b1dc3cf4af 更新opcuaclient,初始读取server类型改为动态读取 2023-08-13 15:50:47 +08:00
Diego2098
6a58b95933 更新nuget包 2023-08-12 12:09:50 +08:00
Kimdiego2098
d3badfd02b 修复批量令牌强退失效 2023-08-11 15:15:50 +08:00
Kimdiego2098
0098be057b 中间变量导入时添加标识 2023-08-11 14:15:22 +08:00
Kimdiego2098
6f972aa515 2.0.5 2023-08-10 18:23:40 +08:00
Kimdiego2098
7407ba6313 去除不需要的模板 2023-08-10 16:28:52 +08:00
Kimdiego2098
1c79de207b 修改详情模板 2023-08-10 11:23:18 +08:00
Kimdiego2098
257c79db92 添加自定义详情模板 2023-08-10 10:35:19 +08:00
Kimdiego2098
9d1934a308 底层修改:如果连接端口断开,停止等待返回 2023-08-10 10:35:01 +08:00
Kimdiego2098
d70f959902 上传DTO添加 单位 参数 2023-08-10 09:09:09 +08:00
Kimdiego2098
e4d810222f 调整调试页面 2023-08-09 23:45:53 +08:00
Kimdiego2098
bc1af4ae07 添加单文件发布配置 2023-08-09 15:12:55 +08:00
Kimdiego2098
6e688ef43f 去除页面多余引号 2023-08-09 13:45:27 +08:00
Kimdiego2098
f0fe1b23dc 更新2.0.4 2023-08-09 13:00:10 +08:00
Kimdiego2098
aaf2006401 更新opcua写入 2023-08-09 12:43:05 +08:00
Kimdiego2098
b821e26935 更新opcua调试页面 2023-08-09 12:01:23 +08:00
Kimdiego2098
7ae4287157 更新opcua 2023-08-09 11:47:04 +08:00
Kimdiego2098
c6fcc38a65 修复中间变量导入错误 2023-08-09 09:00:49 +08:00
Kimdiego2098
ab2d5c8853 修正错误注释 2023-08-08 18:09:23 +08:00
Kimdiego2098
5e557ff0bc opcua添加初始化连接错误重试 2023-08-08 18:04:24 +08:00
Kimdiego2098
918ca449a1 更新readme 2023-08-08 16:14:06 +08:00
Kimdiego2098
8e73368008 优化大量设备线程重启的耗时 2023-08-08 14:02:00 +08:00
Kimdiego2098
f3c1faf672 2.0.3 2023-08-08 12:59:14 +08:00
Kimdiego2098
d6df04dd6a 底层部分方法更改 2023-08-08 12:31:42 +08:00
Kimdiego2098
b1b9e51ab6 报警/历史值查询时区转换 2023-08-08 09:05:15 +08:00
Kimdiego2098
e49d4770ac 时间最小最大值时不再转换时区 2023-08-08 08:39:20 +08:00
Kimdiego2098
8fa1075511 Merge branch 'master' of https://gitee.com/dotnetchina/ThingsGateway 2023-08-08 08:28:37 +08:00
Kimdiego2098
9a70169b94 默认不启用单用户登录 2023-08-08 08:28:27 +08:00
Diego2098
fefb928237 更新文档 2023-08-07 22:31:51 +08:00
Diego2098
ad7e700d0d 去除DateTimeOffset类型 2023-08-07 22:30:38 +08:00
Kimdiego2098
1699c69147 更新文档 2023-08-07 17:38:53 +08:00
Kimdiego2098
1695f7cece 更新readme 2023-08-07 17:34:32 +08:00
Kimdiego2098
052c27f907 更新文件 2023-08-07 17:24:28 +08:00
Kimdiego2098
dc46c32b30 更新文件 2023-08-07 17:16:53 +08:00
Kimdiego2098
fa63349bb2 更新文件 2023-08-07 16:56:45 +08:00
Kimdiego2098
ffe26448a6 更新文件 2023-08-07 16:33:36 +08:00
Kimdiego2098
4af51e8a84 更新文件 2023-08-07 16:30:23 +08:00
Kimdiego2098
1e453cf5a5 更新文件 2023-08-07 15:46:30 +08:00
Kimdiego2098
591282b87d 更新文件 2023-08-07 15:36:49 +08:00
Kimdiego2098
e87528d520 去除多余解决方案配置 2023-08-07 15:31:22 +08:00
Kimdiego2098
d79eb0411d 添加发布脚本 2023-08-07 15:23:53 +08:00
Kimdiego2098
ac1e0a4cf7 更新readme 2023-08-07 15:18:42 +08:00
Kimdiego2098
9525eab130 更新readme 2023-08-07 15:13:21 +08:00
Kimdiego2098
89b317496c 更新文档 2023-08-07 15:10:42 +08:00
Kimdiego2098
13be91e78b 2.0.0 2023-08-07 15:09:53 +08:00
Kimdiego2098
f68c1437f3 调试更新Blazor代码时不再跳转登录界面 2023-07-25 22:00:27 +08:00
Kimdiego2098
4c64c969bb 取消不必要的错误日志 2023-07-25 20:50:33 +08:00
Kimdiego2098
b4bf3b5138 变量值更新错误提示; 2023-07-25 20:48:17 +08:00
Kimdiego2098
083bc4b400 优化大批量excel变量表导入效率 2023-07-25 18:26:48 +08:00
Kimdiego2098
e8683c5bcc 删除不必要延时 2023-07-25 16:52:56 +08:00
Kimdiego2098
80e0d1de91 发布1.7.6 2023-07-25 14:22:11 +08:00
Kimdiego2098
dbe841037e 优化导入excel效率 2023-07-25 14:21:17 +08:00
Kimdiego2098
bdd537c33c 添加上传插件获取采集设备属性值的快捷方法 2023-07-23 13:44:37 +08:00
Kimdiego2098
c0c3846094 Merge branch 'master' of https://gitee.com/dotnetchina/ThingsGateway 2023-07-23 09:59:11 +08:00
Kimdiego2098
9e8710e7d2 线程完成时不再需要全局数据移除,有可能会导致偶发全局数据丢失 2023-07-23 09:58:43 +08:00
Kimdiego2098
475553fdf6 线程完成时不要需要全局数据移除,有可能会导致偶发全局数据丢失 2023-07-23 09:57:03 +08:00
Kimdiego2098
9d570f5b45 更新icon包版本 2023-07-23 00:03:46 +08:00
Kimdiego2098
af7fafd34f 更新icon包版本 2023-07-22 23:59:03 +08:00
Kimdiego2098
d43130f4fc 修改插件日志为自定义日志 2023-07-22 23:34:09 +08:00
Kimdiego2098
7500194620 更新文档 2023-07-22 20:48:29 +08:00
Kimdiego2098
eb27c29144 发布1.7.4 2023-07-22 20:47:26 +08:00
Kimdiego2098
43260b3e24 修正错误名称 2023-07-22 20:32:34 +08:00
Kimdiego2098
f80713f0aa 添加上传插件最后错误原因 2023-07-22 20:10:45 +08:00
Kimdiego2098
0c4bdc7ad1 修复上传设备暂停按钮失效 2023-07-22 19:56:56 +08:00
Kimdiego2098
811cff7bd0 OPCUAServer 数组维度不再写any;rpc写入添加延时 2023-07-22 17:02:44 +08:00
Kimdiego2098
30269aa75c 更改假死检测间隔5分钟 2023-07-22 11:05:56 +08:00
Kimdiego2098
e345ef7083 添加OPCUAServer线程间隔配置项,优化最后一次错误提示 2023-07-22 11:03:56 +08:00
Kimdiego2098
f559c9b8f7 支持OPCUAServer数组类型,添加缓存文件存在判断 2023-07-21 21:28:39 +08:00
Kimdiego2098
f4af0916b2 去除OPCUA写入数组维度校验 2023-07-20 17:37:49 +08:00
Kimdiego2098
f15f14f28d 更新文档 2023-07-20 12:48:13 +08:00
Kimdiego2098
834f44f58d kafka尝试自动加载c库 2023-07-20 12:40:59 +08:00
Kimdiego2098
b36f45dcf4 修复中间变量Rpc写入 2023-07-20 10:55:37 +08:00
Kimdiego2098
11ba21c9a8 ModbusServer添加自定义循环间隔,修复中间变量写入 2023-07-20 10:55:17 +08:00
Kimdiego2098
b045557ce1 更新文档 2023-07-19 18:02:31 +08:00
Kimdiego2098
0dd251a3f6 更新文档 2023-07-19 15:43:28 +08:00
Kimdiego2098
793acb1725 更改左侧菜单为手风琴效果 2023-07-19 15:00:40 +08:00
Kimdiego2098
921243e8bd 更新文档 2023-07-19 14:34:27 +08:00
Kimdiego2098
bd9d7a90d9 修改OPCUAClient心跳频率默认3s 2023-07-18 14:49:27 +08:00
Kimdiego2098
cc444a4cea 更改OPCUAClient心跳频率为30000 2023-07-18 14:15:02 +08:00
Kimdiego2098
38ca1fa168 更新1.7.3版本 2023-07-18 12:16:33 +08:00
Kimdiego2098
7a552b87ec 更新masa 稳定版以及其他包 2023-07-18 12:11:37 +08:00
Kimdiego2098
36923d3190 修复添加订阅时,值死区过滤逻辑 2023-07-18 11:13:21 +08:00
Kimdiego2098
a9d3017123 修复异步锁上下文切换导致OPCUA 心跳事件出错 2023-07-18 09:58:01 +08:00
Kimdiego2098
313acd4976 修复OPCUAClient调试界面重复输出订阅值 2023-07-18 08:51:27 +08:00
Kimdiego2098
a4c91bb268 修改OPCUAClient的心跳频率配置项 2023-07-18 08:48:18 +08:00
Kimdiego2098
f9b566984b 添加重启锁 2023-07-17 21:40:47 +08:00
2248356998 qq.com
8dd261854d Merge branch 'master' of https://gitee.com/diego2098/thingsgateway-docs 2023-07-17 20:59:53 +08:00
2248356998 qq.com
7351e62d87 更新opcua心跳状态日志 2023-07-17 20:59:32 +08:00
Diego2098
0593ae720b 更新文档 2023-07-16 20:46:16 +08:00
Diego2098
a0a7b08e08 更新授权名单 2023-07-16 20:31:56 +08:00
2248356998 qq.com
9a3bc6b8b3 更新文档 2023-07-16 18:27:22 +08:00
2248356998 qq.com
5acae17f71 更新文档 2023-07-16 18:12:55 +08:00
2248356998 qq.com
f1e5b76ef2 更新文档 2023-07-16 18:07:31 +08:00
2248356998 qq.com
53c628fde9 更新文档 2023-07-16 17:49:33 +08:00
2248356998 qq.com
baca0a70c0 更新文档 2023-07-16 17:48:22 +08:00
2248356998 qq.com
3e8d0af404 更新文档 2023-07-16 17:41:52 +08:00
2248356998 qq.com
cf9a91d9d5 更新文档 2023-07-16 17:35:04 +08:00
2248356998 qq.com
02b9e282c6 更新文档地址 2023-07-16 17:32:49 +08:00
2248356998 qq.com
9ce87f235f 迁移文档 2023-07-16 17:28:26 +08:00
2248356998 qq.com
e329bea1b2 冗余设备删除后会导致后台出错 2023-07-16 11:36:45 +08:00
2248356998 qq.com
8086e7b54d 更新readme 2023-07-16 10:28:43 +08:00
2248356998 qq.com
f7a875606e 删除无用属性 2023-07-16 09:40:00 +08:00
2248356998 qq.com
196eaf85f4 修复1.7.0版本修改导致的mqttrpc映射错误 2023-07-15 22:56:28 +08:00
2248356998 qq.com
876a55668e 增加 上传插件的列表分割大小,因为某些情况下传输字节太大会导致失败 2023-07-15 22:42:34 +08:00
2248356998 qq.com
05bd21bdd5 导入提示的当前行显示未初始 2023-07-15 22:35:12 +08:00
2248356998 qq.com
fb51a08cc6 格式化整理 2023-07-15 22:32:54 +08:00
2248356998 qq.com
dd83d7f4d3 插件报文截取前200字符,防止页面渲染过多 2023-07-15 20:04:14 +08:00
2248356998 qq.com
842a56f7ce kafka插件增加超时选项 2023-07-15 17:27:35 +08:00
2248356998 qq.com
9246a6e797 历史服务修复变量在线状态显示错误 2023-07-15 15:46:39 +08:00
2248356998 qq.com
8ad693f717 发布1.7.2版本 2023-07-15 11:10:29 +08:00
2248356998 qq.com
f4c2ee7cc4 优化OPCUA错误提示 2023-07-14 17:33:11 +08:00
2248356998 qq.com
6043441faa OPCUA在取消订阅时应该走读取方法 2023-07-14 17:22:19 +08:00
2248356998 qq.com
4a065c3710 优化导入excel提示 2023-07-14 16:23:42 +08:00
2248356998 qq.com
0ef800bdd7 优化导入excel提示 2023-07-14 16:23:35 +08:00
2248356998 qq.com
56eaa1910d kafka 插件释放时取消事件注册 2023-07-14 14:35:40 +08:00
2248356998 qq.com
201788e286 更改属性说明 2023-07-14 12:23:46 +08:00
2248356998 qq.com
506e0f144f 添加kafka插件null传播 2023-07-14 10:41:04 +08:00
2248356998 qq.com
72f68bfdd9 opcda JValue转object 2023-07-14 10:14:05 +08:00
2248356998 qq.com
2f9869b11d opcua读取值JValue转为object 2023-07-14 10:04:05 +08:00
2248356998 qq.com
8ffcf6498c RabbitMQ,IotSharp添加离线缓存 2023-07-13 19:54:12 +08:00
2248356998 qq.com
d224ae1923 Variable Value数据类型改为object 2023-07-13 18:18:53 +08:00
2248356998 qq.com
fed2063a19 中间变量页种子ID重复 2023-07-13 17:47:22 +08:00
2248356998 qq.com
db2810cdd7 复制设备没有及时刷新缓存 2023-07-13 17:38:45 +08:00
2248356998 qq.com
4f1a6781ef 发布1.7.1 2023-07-13 11:19:17 +08:00
2248356998 qq.com
beffa5d5a4 代码格式化 2023-07-13 11:18:36 +08:00
2248356998 qq.com
7a20f1de07 OPCDA增加数组支持,增加写入动态类型支持 2023-07-13 11:16:31 +08:00
2248356998 qq.com
cd25cf726b 优化OPCUA数组类型转换 2023-07-13 09:02:36 +08:00
2248356998 qq.com
d6b1bc3842 修复blazor界面null错误 2023-07-12 22:12:11 +08:00
2248356998 qq.com
a4385fb9bb 更新ReadMe 2023-07-12 21:33:05 +08:00
2248356998 qq.com
7045f2b8ea 删除重复文件 2023-07-12 21:30:41 +08:00
2248356998 qq.com
07ca1a4de8 更新nuget包 2023-07-12 21:21:50 +08:00
2248356998 qq.com
24f289e692 V1.7.0发布
1、增加采集通道冗余
2、优化多个界面
3、导出导入功能优化
4、增加中间变量
5、OPCUAClient支持动态类型
6、离线缓存多处覆盖,包含上传插件/历史报警/时序库
7、增加通用调试界面,增加s7调试
8、其他优化
2023-07-12 21:16:38 +08:00
2248356998 qq.com
01bcdaae2d 修复AppDataTable清空MForm模型导致筛选列清空的问题 2023-07-10 13:18:14 +08:00
2248356998 qq.com
55890008d1 修复写入s7协议 bit值 偏移错误(以byte数据块为准) 2023-07-08 17:01:44 +08:00
2248356998 qq.com
5ab9b01879 修复读取s7协议 bit值 偏移错误(以byte数据块为准) 2023-07-08 11:44:57 +08:00
2248356998 qq.com
e4abb333b3 默认添加kafka插件 种子数据 2023-07-07 17:13:00 +08:00
2248356998 qq.com
09f476c745 修复布尔量解析时反转字节导致结果值不符的错误 2023-07-06 14:05:09 +08:00
2248356998 qq.com
8806e68dce null传播 2023-07-03 14:13:00 +08:00
2248356998 qq.com
2ef1e25cd8 添加x86架构 2023-07-03 10:48:52 +08:00
2248356998 qq.com
10e7f202aa 补充插件实例内容 2023-07-02 19:50:09 +08:00
2248356998 qq.com
ccd7000c09 blazor组件初始化并行执行,导致sugar单例DB出现线程偶发错误,暂增加copyNew()解决 2023-06-29 16:42:19 +08:00
2248356998 qq.com
8ee7b798cf blazor组件初始化并行执行,导致sugar单例DB出现线程偶发错误,暂增加copyNew()解决 2023-06-29 16:36:03 +08:00
2248356998 qq.com
7733cf5bf0 sqlsugar偶发线程故障,添加copyNew方法 2023-06-28 18:54:45 +08:00
2248356998 qq.com
a05ce86dd7 登录跳转uri优化 2023-06-28 15:47:35 +08:00
2248356998 qq.com
91f51c32e8 更新开源说明 2023-06-28 10:48:33 +08:00
2248356998 qq.com
f910202bba update openapiUser datatableUI 2023-06-26 19:51:02 +08:00
2248356998 qq.com
6d77194a8f css脚本结果不采用 System.Text.Json.JsonSerializer 2023-06-26 19:44:17 +08:00
2248356998 qq.com
9deb89c15f OPCUAClient修复当变量为string类型时的数值过滤失败导致添加订阅失效 2023-06-26 19:43:00 +08:00
2248356998 qq.com
4b62a092b4 停用采集设备时,变量获取运行态出错 2023-06-26 16:43:48 +08:00
2248356998 qq.com
81c8f626f9 登录后跳转原url 2023-06-26 14:46:24 +08:00
2248356998 qq.com
3e846c42fb cookie授权验证失败时返回登录界面 2023-06-26 14:36:41 +08:00
Diego2098
63ad7fd766 更新nuget类库 2023-06-25 18:59:09 +08:00
2248356998 qq.com
9ff1e9aa34 添加报警事件None枚举 2023-06-20 13:10:58 +08:00
2248356998 qq.com
8d162b6f3d 修复cpu核心等于1时报错,修正登录错误提示 2023-06-20 09:09:08 +08:00
Diego2098
9844d10bef 修复modbusServer 初始化错误 2023-06-17 18:14:13 +08:00
2248356998 qq.com
b908fa8489 sugar添加取消令箭 2023-06-15 17:38:36 +08:00
2248356998 qq.com
15a10643a7 增加变量运行态 CollectVariableRuntime 所在设备属性 2023-06-15 16:50:08 +08:00
2248356998 qq.com
299617aca1 parallel.foreach无序体验不好,退回为foreach 2023-06-14 11:04:09 +08:00
2248356998 qq.com
45647d697a update 1.6.1 version 2023-06-13 22:39:47 +08:00
2248356998 qq.com
48f5105d38 update nuget package 2023-06-13 22:39:25 +08:00
2248356998 qq.com
fe1c741d68 update driver messagesui 2023-06-13 22:26:19 +08:00
2248356998 qq.com
fa42cc1f00 并行关闭线程 2023-06-12 14:41:08 +08:00
2248356998 qq.com
42cf5e7a81 添加mqtt/kafka上传内容显示 2023-06-12 14:40:53 +08:00
2248356998 qq.com
47905e1aa1 优化大量变量excel上传的验证过程 2023-06-12 11:35:27 +08:00
2248356998 qq.com
9a8e907df3 更新文档站点地址 2023-06-11 18:37:50 +08:00
2248356998 qq.com
106fe85582 删除docs 2023-06-11 18:22:15 +08:00
2248356998 qq.com
4b3571bd57 更新1.6.0版本 2023-06-11 17:58:57 +08:00
2248356998 qq.com
96b537401a 缓存最大默认2000 2023-06-11 17:56:34 +08:00
2248356998 qq.com
721c9eb057 添加离线缓存大小限制配置 2023-06-11 17:55:03 +08:00
2248356998 qq.com
51701bf6d6 上传插件线程等待时间改为10ms 2023-06-11 17:47:16 +08:00
2248356998 qq.com
dbde68bd56 导入变量优化 2023-06-11 17:46:23 +08:00
2248356998 qq.com
ad2c9f585a 添加mqttClient离线缓存 2023-06-11 17:45:46 +08:00
2248356998 qq.com
562093c468 添加kafka离线缓存 2023-06-11 17:45:27 +08:00
Diego2098
b0295584a3 !6 部分配置会导致SqlServer自动建库失败
Merge pull request !6 from samisgod/master
2023-06-10 06:55:34 +00:00
samisgod
208c54de98 fix db init for SqlServer 2023-06-10 14:51:29 +08:00
2248356998 qq.com
63e2d941a1 增加pwa 2023-06-09 17:53:41 +08:00
2248356998 qq.com
3956838e9c 修复停用验证码时登录失败显示null报错 2023-06-09 17:09:17 +08:00
2248356998 qq.com
abeee58bb0 统一文件编码 2023-06-09 15:04:54 +08:00
2248356998 qq.com
d5b1b49722 update solution folder 2023-06-09 14:30:53 +08:00
2248356998 qq.com
564ed03ff8 upload deviceStatusPage 2023-06-09 10:32:11 +08:00
2248356998 qq.com
70db4c76b4 update deviceStatusPage 2023-06-09 09:49:03 +08:00
2248356998 qq.com
d059f7975b remove dotNET China declaration 2023-06-09 09:10:30 +08:00
2248356998 qq.com
4e74e6dc2d add dotNET China declaration 2023-06-09 09:02:17 +08:00
Diego2098
b6deb96658 重启线程时增加运行状态界面空传播防止报错 2023-06-08 21:35:07 +08:00
2248356998 qq.com
3839e966be add upload plugin code description 2023-06-08 17:47:53 +08:00
2248356998 qq.com
3dd035849c 迁移导入变量功能到驱动调试内 2023-06-08 15:11:58 +08:00
2248356998 qq.com
3d6532b5d6 plugin unload test,but failed 2023-06-08 10:52:39 +08:00
2248356998 qq.com
bf7c175ee7 更改默认api文档为Knife4j 2023-06-07 20:34:31 +08:00
2248356998 qq.com
f84af35ed6 缓存键增加Type-TypeHandle句柄 2023-06-07 18:42:58 +08:00
2248356998 qq.com
99063b3eb1 修改OPCUA证书路径,增加默认接收不收信任证书与其选项;
OPCDA整理;
2023-06-07 18:03:57 +08:00
2248356998 qq.com
3bec18f28d 重启线程WebApi修改 2023-06-07 11:32:18 +08:00
2248356998 qq.com
15de7a7894 添加注释提示 2023-06-07 11:28:11 +08:00
2248356998 qq.com
e20e04e677 GC策略更改,大量变量实例手动清空以快速内存释放 2023-06-07 11:19:24 +08:00
2248356998 qq.com
5fc6ae2835 上传1.5.1 2023-06-06 19:37:04 +08:00
2248356998 qq.com
7d281b8c96 Merge branch 'master' of https://gitee.com/diego2098/ThingsGateway 2023-06-05 08:33:50 +08:00
Diego2098
4880b801a7 S7-TCP连接修复死锁 2023-06-02 22:20:21 +08:00
2248356998 qq.com
74e354456a 增加KINGVIEW 配置 2023-05-29 01:32:37 +08:00
2248356998 qq.com
af2e03aa36 超管用户名称不可更改 2023-05-26 00:14:05 +08:00
2248356998 qq.com
d8fa660ab6 初步添加OPCUAClient调试界面;更新依赖 2023-05-25 23:41:11 +08:00
2248356998 qq.com
1a62d48297 OPCUA安全策略添加全部选项 2023-05-25 00:59:21 +08:00
2248356998 qq.com
7ba01be13d OPCUA安全策略添加全部选项 2023-05-25 00:58:47 +08:00
2248356998 qq.com
1a83d64db7 添加OPCDAClient调试页面 2023-05-25 00:11:00 +08:00
2248356998 qq.com
5b53014c40 修改程序根目录为文件所在目录 2023-05-24 14:37:45 +08:00
2248356998 qq.com
83685340af 默认添加服务守护支持 2023-05-24 14:32:21 +08:00
2248356998 qq.com
31e0cc4dec ModbusServer添加自定义数据类型;修复发布时静态文件路径错误 2023-05-24 12:31:20 +08:00
2248356998 qq.com
56b87fc1f5 Add copyright notices 2023-05-23 23:54:28 +08:00
2248356998 qq.com
6b956a2dd7 update TGTcpClient 2023-05-23 22:42:48 +08:00
2248356998 qq.com
1937623d7d 添加Modbus系列插件调试页面;添加Modbus组包解析缓存超时时间; 2023-05-23 20:50:44 +08:00
2248356998 qq.com
3b60b10945 update HardwareInfoService 2023-05-23 12:04:04 +08:00
2248356998 qq.com
7173acd350 nuget更新 2023-05-23 11:59:28 +08:00
2248356998 qq.com
6310d87338 硬件界面添加限值防报错 2023-05-23 11:46:19 +08:00
2248356998 qq.com
49a1ed7c18 初步添加插件驱动调试页面 2023-05-22 18:50:30 +08:00
2248356998 qq.com
d426e280d9 初步添加插件驱动调试页面 2023-05-22 18:41:09 +08:00
2248356998 qq.com
6154fb29f1 Razor文件格式化清理 2023-05-22 18:40:50 +08:00
2248356998 qq.com
97d48ef9d6 删除调试代码... 2023-05-22 17:09:21 +08:00
2248356998 qq.com
88992625c4 更改变量读取间隔限制最低为10ms 2023-05-22 15:17:22 +08:00
2248356998 qq.com
bc6eb44218 明确System.Management版本 2023-05-22 14:51:02 +08:00
2248356998 qq.com
cf9ccd799d 硬件信息获取添加异常拦截 2023-05-22 14:33:30 +08:00
2248356998 qq.com
ffa0e4e771 update adapter 2023-05-22 12:42:31 +08:00
2248356998 qq.com
60fa9c196c 代码清理 2023-05-21 22:39:33 +08:00
2248356998 qq.com
df860d22fb 优化opcua质量戳提示;添加数据转换基础方法;TCP等待返回时默认断开连接立即返回 2023-05-21 10:51:56 +08:00
2248356998 qq.com
cb46ff326c modbus 组包优化 2023-05-20 21:41:16 +08:00
2248356998 qq.com
f277a853ef 类型更换 2023-05-20 17:13:14 +08:00
2248356998 qq.com
9ae34f67c3 可指定OPCUA节点数据类型 2023-05-20 15:40:17 +08:00
2248356998 qq.com
c9223218cc 更新文档 2023-05-20 13:52:23 +08:00
2248356998 qq.com
c0dd645aba 添加自定义OPCUAServer数据类型 2023-05-20 12:34:06 +08:00
2248356998 qq.com
2e948eb5b6 导入规则优化,主动抛出名称重复错误 2023-05-19 22:55:53 +08:00
2248356998 qq.com
c3276889cf 更改插件时开启刷新设备属性 2023-05-19 22:26:37 +08:00
2248356998 qq.com
a76ca8282d 判断OPCUAServer状态时增加tryCatch 2023-05-19 21:27:20 +08:00
2248356998 qq.com
8ce6b8362f 判断OPCUAServer状态时增加tryCatch 2023-05-19 21:24:56 +08:00
2248356998 qq.com
842fb12f05 优化tcp拆包组包 2023-05-19 20:28:51 +08:00
2248356998 qq.com
d63e1511af 快捷方式null错误 2023-05-19 16:33:57 +08:00
2248356998 qq.com
278783b8e0 更新依赖包 2023-05-19 16:23:21 +08:00
2248356998 qq.com
d24e3c922d UDP通讯优化 2023-05-19 16:21:42 +08:00
2248356998 qq.com
1d02cd2283 添加链路锁 2023-05-19 14:27:47 +08:00
2248356998 qq.com
8edeb82a87 分包数量显示错误 2023-05-19 10:13:48 +08:00
2248356998 qq.com
146e9279de Modbus读写锁更新 2023-05-19 10:05:54 +08:00
2248356998 qq.com
47105f50a9 Modbus读写锁更新 2023-05-19 09:53:56 +08:00
2248356998 qq.com
16c9c80f37 删除sqlsugar旧版本代码,会导致sqlite不兼容 2023-05-19 09:15:32 +08:00
2248356998 qq.com
8e7e4bc95a 适配mysql;修复写入表达式转换;优化web页面写入体验 2023-05-18 23:38:40 +08:00
2248356998 qq.com
0aa3d2f930 数据库初始化修复 2023-05-18 22:24:27 +08:00
2248356998 qq.com
ce77755a1e 数据库连接自动释放 2023-05-18 21:06:06 +08:00
2248356998 qq.com
0f31f20c87 编辑页面添加 变量 允许远程写入选项 2023-05-18 21:03:44 +08:00
2248356998 qq.com
ee6da2aaa5 修复枚举类型在mysql中类型出错的问题 2023-05-18 20:58:14 +08:00
Diego2098
a35f087cd9 修改文件大小限制 2023-05-17 22:29:59 +08:00
Diego2098
6e029b44dd 更新设备读写锁 2023-05-17 22:05:31 +08:00
2248356998 qq.com
973c0cff34 touchSocket修复UDP在windows下重置连接的问题;更新nuget 2023-05-17 16:54:33 +08:00
2248356998 qq.com
2027eea6ac 代码格式清理 2023-05-17 16:49:25 +08:00
2248356998 qq.com
2f43692f33 修复CancellationTokenSource未释放导致Linux下偶发内存问题 2023-05-17 16:44:52 +08:00
2248356998 qq.com
6d24992f88 OPCUAServer节点数据类型增加在读取表达式转换后的判断 2023-05-16 09:05:58 +08:00
Diego2098
b4388a58d6 ModbusClient添加帧前时间 2023-05-15 22:45:55 +08:00
2248356998 qq.com
158aa05fac 修复using作用域导致获取的服务可能被释放的问题 2023-05-15 19:21:35 +08:00
2248356998 qq.com
f2731bf55e nuget更新 2023-05-15 18:55:27 +08:00
2248356998 qq.com
7304e99fce mqttClient同步间隔上传的实体类 2023-05-12 18:22:06 +08:00
2248356998 qq.com
02700b83eb update mqttClient 2023-05-12 16:40:55 +08:00
2248356998 qq.com
676b25acf9 MqttClient增加间隔上传选项;更改线程循环间隔说明定义 2023-05-12 16:31:57 +08:00
Diego2098
556359ea2d update readme 2023-05-10 21:18:43 +08:00
Diego2098
b72923e0f5 增加api控制采集启停等方法 2023-05-10 21:17:34 +08:00
Diego2098
115ac9f75e 提交kafka插件 2023-05-10 21:17:09 +08:00
2248356998 qq.com
32e36f6708 update readme 2023-05-10 17:49:52 +08:00
2248356998 qq.com
d949b7a4f9 共享链路写入变量修复;Nuget更新 2023-05-10 16:33:59 +08:00
2248356998 qq.com
eae1171ff5 更新文档 2023-05-09 17:51:55 +08:00
2248356998 qq.com
76a1b75a51 更新文档 2023-05-09 17:47:22 +08:00
2248356998 qq.com
8882c0daea OPCUAClient/Server 修改证书有效期为100年 2023-05-09 14:37:18 +08:00
2248356998 qq.com
07ebc16d59 添加控制台logo 2023-05-08 18:10:07 +08:00
2248356998 qq.com
0ceb109964 Code Cleanup 2023-05-08 18:03:32 +08:00
2248356998 qq.com
118b0d0038 add GetSciptValue 2023-05-08 17:45:13 +08:00
2248356998 qq.com
5e87067792 modbus rtu 粘包优化 2023-05-08 15:59:35 +08:00
2248356998 qq.com
c946a252e8 modbus rtu报文粘包优化;共享链路切换延时;上传插件添加报文界面 2023-05-08 15:57:33 +08:00
2248356998 qq.com
f9ad2ba1dd plc read with CancellationToken 2023-05-08 13:33:01 +08:00
2248356998 qq.com
0d0ecd33bd 粘包优化 2023-05-08 10:55:16 +08:00
2248356998 qq.com
e4b98fd05b Rpc条件bug修复 2023-05-07 18:06:27 +08:00
2248356998 qq.com
95a5933303 OPCUAServer修复匿名登录 2023-05-07 18:06:09 +08:00
2248356998 qq.com
da3b55fa64 更新文档 2023-05-07 16:56:41 +08:00
2248356998 qq.com
fbbabfb90e 属性顺序调整 2023-05-05 09:46:11 +08:00
2248356998 qq.com
f13da6830d 更新文档 2023-05-04 22:58:36 +08:00
2248356998 qq.com
f560a8e2f8 update CollectDeviceThread 2023-05-04 10:58:45 +08:00
2248356998 qq.com
56f1139c2f 更新文档 2023-05-02 22:11:55 +08:00
2248356998 qq.com
773bdfc1e2 更新1.5.0 2023-05-02 22:06:09 +08:00
2248356998 qq.com
f449666628 1、共享链路支持;
2、设备报文查看;
3、采集线程重构;
2023-05-02 21:58:11 +08:00
2248356998 qq.com
3f282de0ab mqtt重连锁优化 2023-04-27 11:19:32 +08:00
2248356998 qq.com
440dd8d22f 添加常用转换 2023-04-24 17:54:00 +08:00
2248356998 qq.com
dcff9de2f7 masa更新 2023-04-24 11:16:28 +08:00
2248356998 qq.com
a192866543 更新包 2023-04-24 09:26:47 +08:00
Diego2098
10081416de 报警后台服务去除多余接口
Signed-off-by: Diego2098 <2248356998@qq.com>
2023-04-19 00:48:13 +00:00
2248356998 qq.com
e2bed618f9 添加docker文件 2023-04-17 17:39:12 +08:00
2248356998 qq.com
03ab1f3823 单文件发布 2023-04-17 15:13:40 +08:00
2248356998 qq.com
ac8aeb63d9 update SqlSugarConfig 2023-04-17 11:58:41 +08:00
2248356998 qq.com
2e16d822fa 删除其他信息 2023-04-17 11:05:38 +08:00
2248356998 qq.com
e407d873fa 验证码更新修复 2023-04-17 09:05:44 +08:00
2248356998 qq.com
fd712a1dbe 1、字段null约束修改
2、ModbusServer绑定端口优化
2023-04-16 15:02:09 +08:00
2248356998 qq.com
e9028b40ce 更新readme 2023-04-16 13:34:29 +08:00
2248356998 qq.com
c9da3dee7c 更新1.4.0
注意Excel导入已不适用以前版本
1、去除动态更新插件
2、改用MiniExcel,支持动态导入,excel配置更简单
3、优化多处界面与后台逻辑,部分方法规范更名
4、修复外网地址获取错误等
2023-04-15 20:48:56 +08:00
2248356998 qq.com
c8c224e202 修复报警文本逻辑 2023-04-11 13:40:13 +08:00
2248356998 qq.com
f34559daaf 1,修复控制台报错(echarts.js问题,已删除)2,多处Dispose修正 2023-04-07 08:48:34 +08:00
2248356998 qq.com
9fefbf4c27 过滤 2023-04-06 14:46:24 +08:00
2248356998 qq.com
1af9fd73ea 历史数据库选择为sqlite时查询转换日期错误 2023-04-05 18:04:33 +08:00
2248356998 qq.com
75ef394eff 启用开发环境web详细日志,调整App.Razor位置,添加网页ico 2023-04-05 17:14:26 +08:00
2248356998 qq.com
ec6cc2c63e update console/file datetime format 2023-04-05 15:49:00 +08:00
2248356998 qq.com
06bc2e192b 更新readme 2023-04-04 18:41:56 +08:00
2248356998 qq.com
78701ec7c1 😀版本1.3.1 2023-04-04 17:55:52 +08:00
2248356998 qq.com
c925fab7e4 网关软件时间统一UTC 2023-04-04 17:55:15 +08:00
2248356998 qq.com
42fd72c164 update iotSharpClient 2023-04-04 11:07:05 +08:00
2248356998 qq.com
7fd160e1a2 😀 更新1.3.0 2023-04-04 10:15:34 +08:00
2248356998 qq.com
97a0d940eb update iotSharpClient 2023-04-04 09:25:16 +08:00
2248356998 qq.com
efaa099d81 update iotSharpClient 2023-04-04 09:23:22 +08:00
2248356998 qq.com
47864a804b IosSharpClient Rpc优化 2023-04-04 09:22:22 +08:00
2248356998 qq.com
91136c0e43 IotSharp Rpc方法完善 2023-04-04 09:19:48 +08:00
2248356998 qq.com
28c3b1bd61 添加写入多个变量的api方法 2023-04-04 09:18:58 +08:00
2248356998 qq.com
551352bc40 update IotSharpClient 2023-04-03 20:16:38 +08:00
2248356998 qq.com
e73c24c925 更新种子 2023-04-03 19:34:12 +08:00
2248356998 qq.com
7ec4c286cc 添加IotSharp插件 2023-04-03 19:30:52 +08:00
2248356998 qq.com
6705e2ec4b 分页显示令牌 2023-04-03 15:29:35 +08:00
2248356998 qq.com
6f0373063b 后台启动时Furion RootServices NULL值 2023-04-03 15:19:59 +08:00
2248356998 qq.com
f64eef60b5 修复不存在采集设备时,初始化报警/历史服务bug 2023-04-03 14:12:56 +08:00
2248356998 qq.com
89546bf86b 弹窗消息在SignalR订阅方法中需InvokeAsync 2023-04-03 13:35:14 +08:00
2248356998 qq.com
793678feca 修复规范化结果包装2次导致登录返回结果不正确的问题 2023-04-03 12:45:19 +08:00
2248356998 qq.com
923cc3019a 更新演示地址 2023-04-03 10:47:49 +08:00
2248356998 qq.com
10eb98a5f6 readme 2023-04-02 18:12:18 +08:00
2248356998 qq.com
bd9e89d8dd readme 2023-04-02 18:08:56 +08:00
2248356998 qq.com
1926b4ce73 更新readme 2023-04-02 18:05:54 +08:00
2248356998 qq.com
4ef3062d74 更新readme 2023-04-02 18:05:28 +08:00
2248356998 qq.com
abb6e0f60f 更新包 2023-04-02 17:10:32 +08:00
2248356998 qq.com
f204d8d84e 添加注释 2023-04-02 16:59:46 +08:00
2248356998 qq.com
fa301656f1 调整依赖,添加关系图 2023-04-01 17:28:35 +08:00
2248356998 qq.com
7e1221028f 调整依赖,更新版本1.2.1 2023-04-01 15:45:02 +08:00
2248356998 qq.com
41308cb2dd 整理 2023-04-01 13:57:57 +08:00
2248356998 qq.com
130600521c 😀 OPCUAServer支持历史查询数据 2023-03-31 18:32:55 +08:00
2248356998 qq.com
cd57548a48 添加ThingsGateway.Foundation注释 2023-03-31 16:25:33 +08:00
2248356998 qq.com
efacc99f76 硬件信息获取添加延时 2023-03-30 20:51:08 +08:00
2248356998 qq.com
f0d236e172 脚本显示优化 2023-03-30 19:51:38 +08:00
2248356998 qq.com
a8118bd8c6 更新文档 2023-03-30 19:39:35 +08:00
2248356998 qq.com
0e58f2ef53 mqtt/mq上传 添加上传实体自定义脚本 2023-03-30 19:07:18 +08:00
2248356998 qq.com
f4b22b3a0c 表达式整理 2023-03-30 16:23:03 +08:00
2248356998 qq.com
df5bd281c7 更新版本 2023-03-30 14:12:39 +08:00
2248356998 qq.com
a3f23837ce 更新文档 2023-03-30 14:11:16 +08:00
2248356998 qq.com
612d989b97 readme 2023-03-30 14:06:03 +08:00
2248356998 qq.com
42c01ee9a2 更新readme,nuget 2023-03-30 14:05:00 +08:00
2248356998 qq.com
14074db591 删除多余代码 2023-03-30 13:53:57 +08:00
2248356998 qq.com
43dfdd7942 opcua 写入添加用户名日志 2023-03-30 13:32:32 +08:00
2248356998 qq.com
f397b97ccf 去除ua数据类型验证 2023-03-30 13:20:26 +08:00
2248356998 qq.com
95f8716144 更新readme 2023-03-30 13:13:44 +08:00
2248356998 qq.com
17ba472b2e 类命名错误更改 2023-03-30 13:11:46 +08:00
2248356998 qq.com
42d82571ab 发布文件添加 2023-03-30 13:11:43 +08:00
2248356998 qq.com
9119a28141 添加OPCUAServer插件,修复个别bug 2023-03-30 13:10:31 +08:00
Diego2098
a32263d838 1、OPCUAClient修复客户端证书未自动生成
2、修复异步方法错误使用
2023-03-30 00:15:13 +08:00
2248356998 qq.com
208ae2bb88 添加部分代码注释 2023-03-29 16:22:01 +08:00
2248356998 qq.com
4d85462a85 驱动支持主机名称 2023-03-29 11:07:21 +08:00
2248356998 qq.com
f601aa9ca0 修复初始化失败导致的一系列问题 2023-03-29 10:53:42 +08:00
2248356998 qq.com
8aee3ad455 上传插件间隔时间修正 2023-03-28 16:40:00 +08:00
2248356998 qq.com
6a2a1e9561 历史变量enable失效 2023-03-28 16:38:29 +08:00
2248356998 qq.com
5f8786c9dc 历史报表时间格式改为yyyy-MM-dd HH:mm:ss ffffff 2023-03-28 16:31:53 +08:00
2248356998 qq.com
73f1d3eead 采集设备状态判断错误 2023-03-28 16:21:30 +08:00
2248356998 qq.com
2bf21bb3c3 采集设备状态判断错误 2023-03-28 15:55:01 +08:00
2248356998 qq.com
f80f0dbb11 修复历史保存值 频繁时出现值相同的问题 2023-03-28 15:14:30 +08:00
2248356998 qq.com
37518c70c4 opc 活动时间修正 2023-03-28 14:15:14 +08:00
2248356998 qq.com
e5951b5bef 添加写入采集时间的接口,而不是固定DateTime.Now 2023-03-28 14:03:11 +08:00
2248356998 qq.com
ab320bd90b 更新tcpclient 2023-03-28 13:52:33 +08:00
2248356998 qq.com
7bd36b5371 修复linux 分隔符错误问题 2023-03-28 11:48:16 +08:00
2248356998 qq.com
b882b0f2bc 更改插件文件不存在时的日志信息 2023-03-28 10:21:39 +08:00
2248356998 qq.com
38d7ae73cc 更改项目引用结构 2023-03-28 10:21:23 +08:00
2248356998 qq.com
4527c6ee5d swagger文档 2023-03-27 19:01:04 +08:00
Iot边缘设备
85829e70c1 !5 添加部署文档
* 添加部署文档
2023-03-27 10:22:30 +00:00
2248356998 qq.com
256c08d82a 属性/字段缓存获取只包含public 2023-03-27 14:49:09 +08:00
2248356998 qq.com
c2ce03c047 更新masa-1.0.0-preview.10 2023-03-27 14:27:15 +08:00
2248356998 qq.com
f2af19e198 优化变量上传属性页 2023-03-27 12:00:10 +08:00
2248356998 qq.com
930b7c092d 采集设备活动时间应正常刷新 2023-03-27 10:51:54 +08:00
2248356998 qq.com
00757c69c6 添加设备复制功能 2023-03-27 10:42:02 +08:00
2248356998 qq.com
55f267d0fc update code collation 2023-03-27 08:49:10 +08:00
2248356998 qq.com
6b96aff6e8 update code collation 2023-03-26 19:48:08 +08:00
2248356998 qq.com
32b773a8fa 更新nuget包 2023-03-26 18:52:16 +08:00
2248356998 qq.com
03089adad6 发行1.10版本 2023-03-26 18:10:12 +08:00
2248356998 qq.com
4a1fe746ab 实时数据界面优化 2023-03-26 17:39:05 +08:00
2248356998 qq.com
aa52c05d2c 1、采用异步AutoResetEvent,修复多个设备下采集太慢的问题
2、弃用IntelligentConcurrentQueue(touchsocket集成类)
2023-03-26 17:32:29 +08:00
2248356998 qq.com
26407a43e7 1、优化设备状态页,减少signalr刷新所需包大小
2、日志前置等级添加
2023-03-24 18:32:10 +08:00
2248356998 qq.com
a02934bf19 修复导出表格时,null值报错 2023-03-23 22:09:53 +08:00
2248356998 qq.com
09c65fba09 导入错误时,忽略大于10行的错误信息显示 2023-03-23 20:01:19 +08:00
2248356998 qq.com
4305c727d0 更新readme 2023-03-22 15:29:35 +08:00
2248356998 qq.com
188339897f 优化log等级、json配置注解 2023-03-22 15:26:42 +08:00
2248356998 qq.com
4ecff9a707 OPCUA写入测试 2023-03-22 14:06:32 +08:00
2248356998 qq.com
355aed49c6 设备运行状态页面改为扩展 2023-03-22 13:46:23 +08:00
2248356998 qq.com
4717b6b0f0 更新文档 2023-03-22 10:44:44 +08:00
Diego2098
45ebe9048d rbmq插件优化 2023-03-21 23:38:00 +08:00
Diego2098
b2170c49a3 分包失败提示 2023-03-21 23:28:30 +08:00
Diego2098
dc2f4d6115 设备组列宽调整,补充上传设备组 2023-03-21 23:10:59 +08:00
Diego2098
1eb132440f 1、更新DataTypeEnum
2、OPCUA写入时需实际数据类型
2023-03-21 22:47:10 +08:00
Diego2098
a464bbc37a 更新Tests 2023-03-21 22:46:12 +08:00
2248356998 qq.com
ed995697c2 表格无数据时,修改默认宽度 2023-03-21 18:17:18 +08:00
2248356998 qq.com
163cd84c7b S7nuget版本 2023-03-21 15:44:50 +08:00
2248356998 qq.com
293d7cc292 masa nuget版本更改 2023-03-21 14:31:36 +08:00
2248356998 qq.com
5de1b4e74c GC策略修改 2023-03-21 14:07:17 +08:00
2248356998 qq.com
7b474975da 更新文档 2023-03-21 14:03:49 +08:00
2248356998 qq.com
beab51516b 更新文档 2023-03-21 13:56:14 +08:00
2248356998 qq.com
fe8685a50c 修改s7属性注释 2023-03-21 13:51:05 +08:00
2248356998 qq.com
f9af5d0885 更新readme 2023-03-21 13:49:10 +08:00
2248356998 qq.com
e8136a9720 更新S7协议插件 2023-03-21 13:45:58 +08:00
2248356998 qq.com
531e5d4556 修改S7特殊方法 2023-03-21 13:41:32 +08:00
2248356998 qq.com
e66255963a 修改s7 2023-03-21 13:38:43 +08:00
2248356998 qq.com
246aac8ee4 添加西门子S7协议插件 2023-03-21 13:37:17 +08:00
2248356998 qq.com
23cfeff685 版本恢复 2023-03-21 11:45:18 +08:00
2248356998 qq.com
a5e7e0d126 更新nuget,暂缓链路复用功能 2023-03-20 13:34:59 +08:00
2248356998 qq.com
5bebc30ba0 默认不开启转储 2023-03-20 09:22:11 +08:00
2248356998 qq.com
0e7057f5b9 更新opcda文档 2023-03-19 23:18:24 +08:00
2248356998 qq.com
7c6c365ba4 格式清理 2023-03-19 23:12:58 +08:00
2248356998 qq.com
424c9bb0c5 修复null值报错 2023-03-19 23:02:08 +08:00
2248356998 qq.com
9d0f26594c 添加设备组,变量按设备组别搜索 2023-03-19 22:56:02 +08:00
2248356998 qq.com
99c17de079 更新readme,opcda核心库提示 2023-03-19 20:40:54 +08:00
2248356998 qq.com
b1e3dd0af6 尝试修复中文在mac上乱码 2023-03-19 17:29:01 +08:00
2248356998 qq.com
261cb89530 修正中文在mac上乱码 2023-03-19 16:45:14 +08:00
2248356998 qq.com
ff6773ba37 删除未知文件 2023-03-19 16:35:24 +08:00
2248356998 qq.com
bdfbbfcbbd Merge branch 'master' of https://gitee.com/diego2098/ThingsGateway 2023-03-19 16:34:26 +08:00
2248356998 qq.com
0c4cd56758 添加设备组功能 2023-03-19 16:34:15 +08:00
士心
4a36658321 !4 修复MacOS环境下,数据库报错的问题
* 修复macos环境下,数据库报错
2023-03-19 08:28:54 +00:00
2248356998 qq.com
7aae938685 准备更新设备组/变量组功能 2023-03-19 11:49:06 +08:00
2248356998 qq.com
3723401e7a 更新ReadMe 2023-03-18 17:56:18 +08:00
2248356998 qq.com
70631366a9 1、最后校验失败时应该提示日志
2、暂停时设备状态修正
2023-03-18 17:49:08 +08:00
2248356998 qq.com
0e40bbda3e 更新文档 2023-03-18 16:47:29 +08:00
2248356998 qq.com
e9aa475398 ByteBlock实际长度 2023-03-18 16:45:39 +08:00
2248356998 qq.com
8d2a811184 修正串口描述类ToString 2023-03-18 16:32:15 +08:00
2248356998 qq.com
dd7f5b6700 更新文档 2023-03-18 16:23:23 +08:00
2248356998 qq.com
a4f6277737 更新nuget 2023-03-18 16:16:27 +08:00
2248356998 qq.com
c2bfaacbb7 更新readme 2023-03-18 16:15:14 +08:00
2248356998 qq.com
a17cbfa2d4 添加ModbusRtu种子数据 2023-03-18 16:14:37 +08:00
2248356998 qq.com
fb9a101555 添加ModbusRtu插件 2023-03-18 16:14:25 +08:00
2248356998 qq.com
e319cf0200 添加串口基础类 2023-03-18 16:14:08 +08:00
2248356998 qq.com
0a8395ef6a 更新文档 2023-03-17 18:19:14 +08:00
2248356998 qq.com
38df5e01be 更新文档 2023-03-17 17:52:04 +08:00
2248356998 qq.com
ebd891a868 种子数据更改 2023-03-17 17:51:58 +08:00
2248356998 qq.com
4ab2395cbe 采集检测间隔修改 2023-03-17 17:40:34 +08:00
2248356998 qq.com
5f1f989fc9 上传插件添加循环间隔属性 2023-03-17 17:30:06 +08:00
2248356998 qq.com
44b709eee3 添加rbmq插件种子数据 2023-03-17 16:30:02 +08:00
2248356998 qq.com
d0d7726597 rbmq插件文件夹更名 2023-03-17 16:16:23 +08:00
2248356998 qq.com
054c342aeb 优化内存queue,修复mqtt插件可能超出字节限制的情况 2023-03-17 16:04:24 +08:00
2248356998 qq.com
c79c33baf7 添加rbmq插件 2023-03-17 16:03:44 +08:00
2248356998 qq.com
23b00e35b2 设备禁用时,变量绑定的设备对应选项会显示禁用(灰色) 2023-03-17 11:29:14 +08:00
2248356998 qq.com
fe51079266 更新readme 2023-03-16 17:33:25 +08:00
2248356998 qq.com
0791b0bbee 选择插件时自动更新属性 2023-03-16 17:33:17 +08:00
2248356998 qq.com
dbf04c8eeb 更新赞助名单 2023-03-16 11:35:58 +08:00
2248356998 qq.com
6204256df8 限流服务默认不开启 2023-03-16 09:47:20 +08:00
2248356998 qq.com
93cc8c2327 增加简易定时看板 2023-03-15 16:01:54 +08:00
2248356998 qq.com
68a2e5bbbc 更新历史配置说明 2023-03-15 09:11:33 +08:00
Diego2098
72792153f2 !3 update handbook/docs/05、网关配置/5.5、其他配置.mdx.
Merge pull request !3 from zhubanghao/N/A
2023-03-14 13:39:16 +00:00
zhubanghao
88b6ef1897 update handbook/docs/05、网关配置/5.5、其他配置.mdx.
Signed-off-by: zhubanghao <58813184@qq.com>
2023-03-14 13:05:33 +00:00
275 changed files with 4248 additions and 5310 deletions

View File

@@ -1,20 +0,0 @@
<Project>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
<Version>4.0.0.8</Version>
<LangVersion>latest</LangVersion>
<Authors>Diego</Authors>
<Product>ThingsGateway</Product>
<Copyright>© 2023-present Diego</Copyright>
<RepositoryUrl>https://gitee.com/diego2098/ThingsGateway</RepositoryUrl>
<SignAssembly>True</SignAssembly>
<DelaySign>False</DelaySign>
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
</PropertyGroup>
</Project>

View File

@@ -82,7 +82,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决方案项", "{97B23D8B-C6C0-4746-A21F-C7B49354B284}"
ProjectSection(SolutionItems) = preProject
..\.gitignore = ..\.gitignore
Directory.Build.props = Directory.Build.props
..\README.md = ..\README.md
EndProjectSection
EndProject

View File

@@ -1,7 +1,17 @@
<Project>
<Import Project="$(SolutionDir)\Directory.Build.props" />
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
<Version>4.0.0.5</Version>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>Diego</Authors>
<Product>ThingsGateway</Product>
<Copyright>© 2023-present Diego</Copyright>
<RepositoryUrl>https://gitee.com/diego2098/ThingsGateway</RepositoryUrl>
<SignAssembly>True</SignAssembly>
<DelaySign>False</DelaySign>
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
</PropertyGroup>

View File

@@ -27,12 +27,12 @@ namespace ThingsGateway.Admin.ApiController;
[Route("Swagger")]
public class SwaggerController : IDynamicApiController, IScoped
{
private readonly IConfigService _configService;
private readonly ConfigService _configService;
/// <summary>
/// <inheritdoc cref="SwaggerController"/>
/// </summary>
/// <param name="sysConfigService"></param>
public SwaggerController(IConfigService sysConfigService)
public SwaggerController(ConfigService sysConfigService)
{
_configService = sysConfigService;
}

View File

@@ -79,7 +79,7 @@
Swagger登录授权服务
</summary>
</member>
<member name="M:ThingsGateway.Admin.ApiController.SwaggerController.#ctor(ThingsGateway.Admin.Application.IConfigService)">
<member name="M:ThingsGateway.Admin.ApiController.SwaggerController.#ctor(ThingsGateway.Admin.Application.ConfigService)">
<summary>
<inheritdoc cref="T:ThingsGateway.Admin.ApiController.SwaggerController"/>
</summary>

View File

@@ -96,7 +96,7 @@ public class OperDispatchProxy : AspectDispatchProxy, IDispatchProxy
/// <exception cref="NotImplementedException"></exception>
public override async Task InvokeAsync(MethodInfo method, object[] args)
{
var desc = method.GetActualCustomAttribute<OperDescAttribute>(Target, true);
var desc = method.GetActualCustomAttribute<OperDescAttribute>(Target);
if (desc == null)
{
var task = method.Invoke(Target, args) as Task;
@@ -134,7 +134,7 @@ public class OperDispatchProxy : AspectDispatchProxy, IDispatchProxy
/// <exception cref="NotImplementedException"></exception>
public override async Task<T> InvokeAsyncT<T>(MethodInfo method, object[] args)
{
var desc = method.GetActualCustomAttribute<OperDescAttribute>(Target, true);
var desc = method.GetActualCustomAttribute<OperDescAttribute>(Target);
if (desc == null)
{
var taskT = method.Invoke(Target, args) as Task<T>;

View File

@@ -83,7 +83,7 @@ public class OpenApiSessionService : DbRepository<OpenApiUser>, IOpenApiSessionS
var verificatInfos = await _verificatService.GetVerificatIdAsync(it.Id);
if (verificatInfos != null)
{
GetVerificatInfos(ref verificatInfos);//获取剩余时间
OpenApiSessionService.GetVerificatInfos(ref verificatInfos);//获取剩余时间
it.VerificatCount = verificatInfos.Count;//令牌数量
it.VerificatSignList = verificatInfos;//令牌列表
}

View File

@@ -73,7 +73,7 @@ public class SessionService : DbRepository<SysUser>, ISessionService
var verificatInfos = await _verificatService.GetVerificatIdAsync(it.Id);
if (verificatInfos != null)
{
GetVerificatInfos(ref verificatInfos);//获取剩余时间
SessionService.GetVerificatInfos(ref verificatInfos);//获取剩余时间
it.VerificatCount = verificatInfos.Count;//令牌数量
it.VerificatSignList = verificatInfos;//令牌列表

View File

@@ -10,8 +10,6 @@
//------------------------------------------------------------------------------
#endregion
using System.Text.RegularExpressions;
using ThingsGateway.Foundation.Extension.String;
namespace ThingsGateway.Admin.Application;
@@ -36,8 +34,7 @@ public class SeedDataUtil
if (!string.IsNullOrEmpty(dataString))//如果有内容
{
//字段没有数据的替换成null
dataString = Regex.Replace(dataString, "\\\"[^\"]+?\\\": \\\"\\\"", match => match.Value.Replace("\"\"", "null"));
//dataString = dataString.Replace("\"\"", "null");
dataString = dataString.Replace("\"\"", "null");
//将json字符串转为实体这里extjson可以正常转换为字符串
var seedDataRecord = Newtonsoft.Json.JsonConvert.DeserializeObject<SeedDataRecords<T>>(dataString);

View File

@@ -37,7 +37,7 @@ namespace ThingsGateway.Admin.Blazor
{
try
{
var data = await _serviceScope.ServiceProvider.GetService<IUserCenterService>().GetLoginDefaultRazorAsync(UserManager.UserId);
var data = await _serviceScope.ServiceProvider.GetService<UserCenterService>().GetLoginDefaultRazorAsync(UserManager.UserId);
var sameLevelMenus = await _serviceScope.ServiceProvider.GetService<IResourceService>().GetaMenuAndSpaListAsync();
if (NavigationManager.ToAbsoluteUri(NavigationManager.Uri).AbsolutePath == "/Login" || NavigationManager.ToAbsoluteUri(NavigationManager.Uri).AbsolutePath == "/")
NavigationManager.NavigateTo(sameLevelMenus.FirstOrDefault(a => a.Id == data)?.Component ?? "index", true);

View File

@@ -39,26 +39,26 @@ public partial class Config
}
private async Task AddCallAsync(ConfigAddInput input)
{
await _serviceScope.ServiceProvider.GetService<IConfigService>().AddAsync(input);
await _serviceScope.ServiceProvider.GetService<ConfigService>().AddAsync(input);
}
private async Task DeleteCallAsync(IEnumerable<SysConfig> sysConfigs)
{
await _serviceScope.ServiceProvider.GetService<IConfigService>().DeleteAsync(sysConfigs.Select(a => a.Id).ToArray());
await _serviceScope.ServiceProvider.GetService<ConfigService>().DeleteAsync(sysConfigs.Select(a => a.Id).ToArray());
}
private async Task EditCallAsync(ConfigEditInput sysConfigs)
{
await _serviceScope.ServiceProvider.GetService<IConfigService>().EditAsync(sysConfigs);
await _serviceScope.ServiceProvider.GetService<ConfigService>().EditAsync(sysConfigs);
}
private async Task OnSaveAsync()
{
await _serviceScope.ServiceProvider.GetService<IConfigService>().EditBatchAsync(_sysConfig);
await _serviceScope.ServiceProvider.GetService<ConfigService>().EditBatchAsync(_sysConfig);
await _mainLayout.StateHasChangedAsync();
await PopupService.EnqueueSnackbarAsync("成功", AlertTypes.Success);
}
private async Task<ISqlSugarPagedList<SysConfig>> QueryCallAsync(ConfigPageInput input)
{
return await _serviceScope.ServiceProvider.GetService<IConfigService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<ConfigService>().PageAsync(input);
}
}

View File

@@ -45,23 +45,23 @@ public partial class Menu
private async Task AddCallAsync(MenuAddInput input)
{
input.ParentId = _search.ParentId;
await _serviceScope.ServiceProvider.GetService<IMenuService>().AddAsync(input);
await _serviceScope.ServiceProvider.GetService<MenuService>().AddAsync(input);
await NavChangeAsync();
}
private async Task ButtonAddCallAsync(ButtonAddInput input)
{
input.ParentId = _buttonParentId;
await _serviceScope.ServiceProvider.GetService<IButtonService>().AddAsync(input);
await _serviceScope.ServiceProvider.GetService<ButtonService>().AddAsync(input);
}
private async Task ButtonDeleteCallAsync(IEnumerable<SysResource> input)
{
await _serviceScope.ServiceProvider.GetService<IButtonService>().DeleteAsync(input.Select(a => a.Id).ToArray());
await _serviceScope.ServiceProvider.GetService<ButtonService>().DeleteAsync(input.Select(a => a.Id).ToArray());
}
private async Task ButtonEditCallAsync(ButtonEditInput input)
{
await _serviceScope.ServiceProvider.GetService<IButtonService>().EditAsync(input);
await _serviceScope.ServiceProvider.GetService<ButtonService>().EditAsync(input);
}
@@ -85,7 +85,7 @@ public partial class Menu
private async Task<ISqlSugarPagedList<SysResource>> ButtonQueryCallAsync(ButtonPageInput input)
{
input.ParentId = _buttonParentId;
var data = await _serviceScope.ServiceProvider.GetService<IButtonService>().PageAsync(input);
var data = await _serviceScope.ServiceProvider.GetService<ButtonService>().PageAsync(input);
return data;
}
@@ -96,13 +96,13 @@ public partial class Menu
private async Task DeleteCallAsync(IEnumerable<SysResource> input)
{
await _serviceScope.ServiceProvider.GetService<IMenuService>().DeleteAsync(input.Select(a => a.Id).ToArray());
await _serviceScope.ServiceProvider.GetService<MenuService>().DeleteAsync(input.Select(a => a.Id).ToArray());
await NavChangeAsync();
}
private async Task EditCallAsync(MenuEditInput input)
{
await _serviceScope.ServiceProvider.GetService<IMenuService>().EditAsync(input);
await _serviceScope.ServiceProvider.GetService<MenuService>().EditAsync(input);
await NavChangeAsync();
}
@@ -123,7 +123,7 @@ public partial class Menu
}
private async Task<ISqlSugarPagedList<SysResource>> QueryCallAsync(MenuPageInput input)
{
var data = await _serviceScope.ServiceProvider.GetService<IMenuService>().TreeAsync(input);
var data = await _serviceScope.ServiceProvider.GetService<MenuService>().TreeAsync(input);
return data.ToPagedList(input);
}

View File

@@ -32,13 +32,13 @@ public partial class OpenApiSession
var confirm = await PopupService.OpenConfirmDialogAsync("警告", "确定 ?");
if (confirm)
{
await _serviceScope.ServiceProvider.GetService<IOpenApiSessionService>().ExitSessionAsync(id);
await _serviceScope.ServiceProvider.GetService<OpenApiSessionService>().ExitSessionAsync(id);
}
}
private async Task<ISqlSugarPagedList<OpenApiSessionOutput>> SessionQueryCallAsync(OpenApiSessionPageInput input)
{
return await _serviceScope.ServiceProvider.GetService<IOpenApiSessionService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<OpenApiSessionService>().PageAsync(input);
}
private async Task ShowVerificatListAsync(List<VerificatInfo> verificatInfos)
@@ -56,7 +56,7 @@ public partial class OpenApiSession
VerificatIds = verificats.Select(it => it.Id).ToList(),
Id = verificats.First().UserId
};
await _serviceScope.ServiceProvider.GetService<IOpenApiSessionService>().ExitVerificatAsync(send);
await _serviceScope.ServiceProvider.GetService<OpenApiSessionService>().ExitVerificatAsync(send);
_verificatInfos.RemoveWhere(it => send.VerificatIds.Contains(it.Id));
}

View File

@@ -32,17 +32,17 @@ public partial class OpenApiUserR
private async Task AddCallAsync(OpenApiUserAddInput input)
{
await _serviceScope.ServiceProvider.GetService<IOpenApiUserService>().AddAsync(input);
await _serviceScope.ServiceProvider.GetService<OpenApiUserService>().AddAsync(input);
}
private async Task DeleteCallAsync(IEnumerable<OpenApiUser> users)
{
await _serviceScope.ServiceProvider.GetService<IOpenApiUserService>().DeleteAsync(users.Select(a => a.Id).ToArray());
await _serviceScope.ServiceProvider.GetService<OpenApiUserService>().DeleteAsync(users.Select(a => a.Id).ToArray());
}
private async Task EditCallAsync(OpenApiUserEditInput users)
{
await _serviceScope.ServiceProvider.GetService<IOpenApiUserService>().EditAsync(users);
await _serviceScope.ServiceProvider.GetService<OpenApiUserService>().EditAsync(users);
}
private List<OpenApiPermissionTreeSelector> GetRouters()
@@ -58,7 +58,7 @@ public partial class OpenApiUserR
OpenApiUserGrantPermissionInput userGrantRoleInput = new();
userGrantRoleInput.Id = _choiceUserId;
userGrantRoleInput.PermissionList = _rolesChoice.Select(it => it.ApiRoute).ToList();
await _serviceScope.ServiceProvider.GetService<IOpenApiUserService>().GrantRoleAsync(userGrantRoleInput);
await _serviceScope.ServiceProvider.GetService<OpenApiUserService>().GrantRoleAsync(userGrantRoleInput);
_isShowRoles = false;
await _datatable?.QueryClickAsync();
}
@@ -70,7 +70,7 @@ public partial class OpenApiUserR
}
private async Task<ISqlSugarPagedList<OpenApiUser>> QueryCallAsync(OpenApiUserPageInput input)
{
return await _serviceScope.ServiceProvider.GetService<IOpenApiUserService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<OpenApiUserService>().PageAsync(input);
}
private async Task UserStatusChangeAsync(OpenApiUser context, bool enable)
@@ -78,9 +78,9 @@ public partial class OpenApiUserR
try
{
if (enable)
await _serviceScope.ServiceProvider.GetService<IOpenApiUserService>().EnableUserAsync(context.Id);
await _serviceScope.ServiceProvider.GetService<OpenApiUserService>().EnableUserAsync(context.Id);
else
await _serviceScope.ServiceProvider.GetService<IOpenApiUserService>().DisableUserAsync(context.Id);
await _serviceScope.ServiceProvider.GetService<OpenApiUserService>().DisableUserAsync(context.Id);
}
finally
{

View File

@@ -47,7 +47,7 @@ public partial class Oplog
var confirm = await PopupService.OpenConfirmDialogAsync("删除", "确定 ?");
if (confirm)
{
await _serviceScope.ServiceProvider.GetService<IOperateLogService>().DeleteAsync(_categoryFilters.Select(it => it.Value).ToArray());
await _serviceScope.ServiceProvider.GetService<OperateLogService>().DeleteAsync(_categoryFilters.Select(it => it.Value).ToArray());
await _datatable?.QueryClickAsync();
}
}
@@ -68,6 +68,6 @@ public partial class Oplog
input.Account = _search.Account;
input.Category = _search.Category;
input.ExeStatus = _search.ExeStatus;
return await _serviceScope.ServiceProvider.GetService<IOperateLogService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<OperateLogService>().PageAsync(input);
}
}

View File

@@ -41,17 +41,17 @@ public partial class Role
private async Task AddCallAsync(RoleAddInput input)
{
await _serviceScope.ServiceProvider.GetService<IRoleService>().AddAsync(input);
await _serviceScope.ServiceProvider.GetService<RoleService>().AddAsync(input);
}
private async Task DeleteCallAsync(IEnumerable<SysRole> sysRoles)
{
await _serviceScope.ServiceProvider.GetService<IRoleService>().DeleteAsync(sysRoles.Select(a => a.Id).ToArray());
await _serviceScope.ServiceProvider.GetService<RoleService>().DeleteAsync(sysRoles.Select(a => a.Id).ToArray());
await _mainLayout.StateHasChangedAsync();
}
private async Task EditCallAsync(RoleEditInput input)
{
await _serviceScope.ServiceProvider.GetService<IRoleService>().EditAsync(input);
await _serviceScope.ServiceProvider.GetService<RoleService>().EditAsync(input);
await _mainLayout.StateHasChangedAsync();
}
private async Task OnRoleHasResuorcesSaveAsync(ModalActionEventArgs args)
@@ -62,7 +62,7 @@ public partial class Role
var data = new List<SysResource>();
userGrantRoleInput.Id = _choiceRoleId;
userGrantRoleInput.GrantInfoList = _roleHasResuorces;
await _serviceScope.ServiceProvider.GetService<IRoleService>().GrantResourceAsync(userGrantRoleInput);
await _serviceScope.ServiceProvider.GetService<RoleService>().GrantResourceAsync(userGrantRoleInput);
_isShowResuorces = false;
}
catch (Exception ex)
@@ -79,7 +79,7 @@ public partial class Role
GrantUserInput userGrantRoleInput = new();
userGrantRoleInput.Id = _choiceRoleId;
userGrantRoleInput.GrantInfoList = _usersChoice.Select(it => it.Id).ToList();
await _serviceScope.ServiceProvider.GetService<IRoleService>().GrantUserAsync(userGrantRoleInput);
await _serviceScope.ServiceProvider.GetService<RoleService>().GrantUserAsync(userGrantRoleInput);
_isShowUsers = false;
}
catch (Exception ex)
@@ -92,19 +92,19 @@ public partial class Role
private async Task<ISqlSugarPagedList<SysRole>> QueryCallAsync(RolePageInput input)
{
return await _serviceScope.ServiceProvider.GetService<IRoleService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<RoleService>().PageAsync(input);
}
private async Task ResuorceInitAsync()
{
_resTreeSelectors = (await _serviceScope.ServiceProvider.GetService<ResourceService>().GetRoleGrantResourceMenusAsync());
_roleHasResuorces = (await _serviceScope.ServiceProvider.GetService<IRoleService>().OwnResourceAsync(_choiceRoleId))?.GrantInfoList;
_roleHasResuorces = (await _serviceScope.ServiceProvider.GetService<RoleService>().OwnResourceAsync(_choiceRoleId))?.GrantInfoList;
}
private async Task<List<UserSelectorOutput>> UserInitAsync()
{
_allUsers = await _serviceScope.ServiceProvider.GetService<ISysUserService>().UserSelectorAsync(_searchKey);
var data = await _serviceScope.ServiceProvider.GetService<IRoleService>().OwnUserAsync(_choiceRoleId);
_allUsers = await _serviceScope.ServiceProvider.GetService<SysUserService>().UserSelectorAsync(_searchKey);
var data = await _serviceScope.ServiceProvider.GetService<RoleService>().OwnUserAsync(_choiceRoleId);
_usersChoice = _allUsers.Where(a => data.Contains(a.Id)).ToList();
return _allUsers;
}

View File

@@ -37,14 +37,14 @@ public partial class Session
var confirm = await PopupService.OpenConfirmDialogAsync("警告", "确定 ?");
if (confirm)
{
await _serviceScope.ServiceProvider.GetService<ISessionService>().ExitSessionAsync(id);
await _serviceScope.ServiceProvider.GetService<SessionService>().ExitSessionAsync(id);
}
}
private async Task<ISqlSugarPagedList<SessionOutput>> SessionQueryCallAsync(SessionPageInput input)
{
return await _serviceScope.ServiceProvider.GetService<ISessionService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<SessionService>().PageAsync(input);
}
private async Task ShowVerificatListAsync(List<VerificatInfo> verificatInfos)
@@ -62,7 +62,7 @@ public partial class Session
VerificatIds = verificats.Select(it => it.Id).ToList(),
Id = verificats.First().UserId
};
await _serviceScope.ServiceProvider.GetService<ISessionService>().ExitVerificatAsync(send);
await _serviceScope.ServiceProvider.GetService<SessionService>().ExitVerificatAsync(send);
_verificatInfos.RemoveWhere(it => send.VerificatIds.Contains(it.Id));
}

View File

@@ -28,23 +28,23 @@ public partial class Spa
private async Task AddCallAsync(SpaAddInput input)
{
await _serviceScope.ServiceProvider.GetService<ISpaService>().AddAsync(input);
await _serviceScope.ServiceProvider.GetService<SpaService>().AddAsync(input);
await _mainLayout.StateHasChangedAsync();
}
private async Task DeleteCallAsync(IEnumerable<SysResource> input)
{
await _serviceScope.ServiceProvider.GetService<ISpaService>().DeleteAsync(input.Select(a => a.Id).ToArray());
await _serviceScope.ServiceProvider.GetService<SpaService>().DeleteAsync(input.Select(a => a.Id).ToArray());
await _mainLayout.StateHasChangedAsync();
}
private async Task EditCallAsync(SpaEditInput input)
{
await _serviceScope.ServiceProvider.GetService<ISpaService>().EditAsync(input);
await _serviceScope.ServiceProvider.GetService<SpaService>().EditAsync(input);
await _mainLayout.StateHasChangedAsync();
}
private async Task<ISqlSugarPagedList<SysResource>> QueryCallAsync(SpaPageInput input)
{
return await _serviceScope.ServiceProvider.GetService<ISpaService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<SpaService>().PageAsync(input);
}
}

View File

@@ -35,17 +35,17 @@ public partial class User
private async Task AddCallAsync(UserAddInput input)
{
await _serviceScope.ServiceProvider.GetService<ISysUserService>().AddAsync(input);
await _serviceScope.ServiceProvider.GetService<SysUserService>().AddAsync(input);
}
private async Task DeleteCallAsync(IEnumerable<SysUser> users)
{
await _serviceScope.ServiceProvider.GetService<ISysUserService>().DeleteAsync(users.Select(a => a.Id).ToArray());
await _serviceScope.ServiceProvider.GetService<SysUserService>().DeleteAsync(users.Select(a => a.Id).ToArray());
await _mainLayout.StateHasChangedAsync();
}
private async Task EditCallAsync(UserEditInput users)
{
await _serviceScope.ServiceProvider.GetService<ISysUserService>().EditAsync(users);
await _serviceScope.ServiceProvider.GetService<SysUserService>().EditAsync(users);
await _mainLayout.StateHasChangedAsync();
}
@@ -56,7 +56,7 @@ public partial class User
UserGrantRoleInput userGrantRoleInput = new();
userGrantRoleInput.Id = _choiceUserId;
userGrantRoleInput.RoleIdList = _rolesChoice.Select(it => it.Id).ToList();
await _serviceScope.ServiceProvider.GetService<ISysUserService>().GrantRoleAsync(userGrantRoleInput);
await _serviceScope.ServiceProvider.GetService<SysUserService>().GrantRoleAsync(userGrantRoleInput);
_isShowRoles = false;
}
catch (Exception ex)
@@ -68,20 +68,20 @@ public partial class User
}
private async Task<ISqlSugarPagedList<SysUser>> QueryCallAsync(UserPageInput input)
{
return await _serviceScope.ServiceProvider.GetService<ISysUserService>().PageAsync(input);
return await _serviceScope.ServiceProvider.GetService<SysUserService>().PageAsync(input);
}
private async Task ResetPasswordAsync(SysUser sysUser)
{
await _serviceScope.ServiceProvider.GetService<ISysUserService>().ResetPasswordAsync(sysUser.Id);
await _serviceScope.ServiceProvider.GetService<SysUserService>().ResetPasswordAsync(sysUser.Id);
await PopupService.EnqueueSnackbarAsync(new("成功", AlertTypes.Success));
await _mainLayout.StateHasChangedAsync();
}
private async Task RoleInitAsync()
{
_allRoles = await _serviceScope.ServiceProvider.GetService<IRoleService>().RoleSelectorAsync();
var data = await _serviceScope.ServiceProvider.GetService<IRoleService>().GetRoleIdListByUserIdAsync(_choiceUserId);
_allRoles = await _serviceScope.ServiceProvider.GetService<RoleService>().RoleSelectorAsync();
var data = await _serviceScope.ServiceProvider.GetService<RoleService>().GetRoleIdListByUserIdAsync(_choiceUserId);
_rolesChoice = _allRoles.Where(a => data.Contains(a.Id)).ToList();
}
private async Task UserStatusChangeAsync(SysUser context, bool enable)
@@ -89,9 +89,9 @@ public partial class User
try
{
if (enable)
await _serviceScope.ServiceProvider.GetService<ISysUserService>().EnableUserAsync(context.Id);
await _serviceScope.ServiceProvider.GetService<SysUserService>().EnableUserAsync(context.Id);
else
await _serviceScope.ServiceProvider.GetService<ISysUserService>().DisableUserAsync(context.Id);
await _serviceScope.ServiceProvider.GetService<SysUserService>().DisableUserAsync(context.Id);
}
finally
{

View File

@@ -44,14 +44,14 @@ public partial class UserCenter
async Task OnDefaultRazorSaveAsync()
{
await _serviceScope.ServiceProvider.GetService<IUserCenterService>().UpdateUserDefaultRazorAsync(UserManager.UserId, _defaultMenuId);
await _serviceScope.ServiceProvider.GetService<UserCenterService>().UpdateUserDefaultRazorAsync(UserManager.UserId, _defaultMenuId);
await _mainLayout.StateHasChangedAsync();
await PopupService.EnqueueSnackbarAsync("成功", AlertTypes.Success);
}
async Task OnShortcutSaveAsync()
{
await _serviceScope.ServiceProvider.GetService<IUserCenterService>().UpdateWorkbenchAsync(_menusChoice);
await _serviceScope.ServiceProvider.GetService<UserCenterService>().UpdateWorkbenchAsync(_menusChoice);
await _mainLayout.StateHasChangedAsync();
await PopupService.EnqueueSnackbarAsync("成功", AlertTypes.Success);
}
@@ -62,7 +62,7 @@ public partial class UserCenter
{
//验证成功,操作业务
_passwordInfoInput.Id = UserResoures.CurrentUser.Id;
await _serviceScope.ServiceProvider.GetService<IUserCenterService>().EditPasswordAsync(_passwordInfoInput);
await _serviceScope.ServiceProvider.GetService<UserCenterService>().EditPasswordAsync(_passwordInfoInput);
await _mainLayout.StateHasChangedAsync();
await PopupService.EnqueueSnackbarAsync("成功,将重新登录", AlertTypes.Success);
await Task.Delay(2000);
@@ -72,7 +72,7 @@ public partial class UserCenter
async Task OnUpdateUserInfoAsync()
{
await _serviceScope.ServiceProvider.GetService<IUserCenterService>().UpdateUserInfoAsync(_updateInfoInput);
await _serviceScope.ServiceProvider.GetService<UserCenterService>().UpdateUserInfoAsync(_updateInfoInput);
await _mainLayout.StateHasChangedAsync();
await PopupService.EnqueueSnackbarAsync("成功", AlertTypes.Success);
}

View File

@@ -56,7 +56,7 @@ public partial class Vislog
var confirm = await PopupService.OpenConfirmDialogAsync("删除", "确定 ?");
if (confirm)
{
await _serviceScope.ServiceProvider.GetService<IVisitLogService>().DeleteAsync(_categoryFilters.Select(it => it.Value).ToArray());
await _serviceScope.ServiceProvider.GetService<VisitLogService>().DeleteAsync(_categoryFilters.Select(it => it.Value).ToArray());
await _datatable?.QueryClickAsync();
}
}
@@ -74,7 +74,7 @@ public partial class Vislog
private async Task<ISqlSugarPagedList<SysVisitLog>> QueryCallAsync(VisitLogPageInput input)
{
var data = await _serviceScope.ServiceProvider.GetService<IVisitLogService>().PageAsync(input);
var data = await _serviceScope.ServiceProvider.GetService<VisitLogService>().PageAsync(input);
return data;
}
}

View File

@@ -107,8 +107,8 @@ public partial class Login
{
await PopupService.EnqueueSnackbarAsync(new("登录成功", AlertTypes.Success));
await Task.Delay(500);
var userId = await _serviceScope.ServiceProvider.GetService<ISysUserService>().GetIdByAccountAsync(_loginModel.Account);
var data = await _serviceScope.ServiceProvider.GetService<IUserCenterService>().GetLoginDefaultRazorAsync(userId);
var userId = await _serviceScope.ServiceProvider.GetService<SysUserService>().GetIdByAccountAsync(_loginModel.Account);
var data = await _serviceScope.ServiceProvider.GetService<UserCenterService>().GetLoginDefaultRazorAsync(userId);
var sameLevelMenus = await _serviceScope.ServiceProvider.GetService<ResourceService>().GetaMenuAndSpaListAsync();
if (_NavigationManager.ToAbsoluteUri(_NavigationManager.Uri).AbsolutePath == "/Login" || _NavigationManager.ToAbsoluteUri(_NavigationManager.Uri).AbsolutePath == "/")
await _ajaxService.GotoAsync(sameLevelMenus.FirstOrDefault(a => a.Id == data)?.Component ?? "index");

View File

@@ -16,7 +16,7 @@ using ThingsGateway.Foundation.Extension.String;
namespace ThingsGateway.Admin.Blazor;
public partial class MainLayout : IDisposable
public partial class MainLayout
{
private List<SysResource> _breadcrumbSysResources = new();
private string _configCopyRight = "";
@@ -43,23 +43,16 @@ public partial class MainLayout : IDisposable
private IServiceScopeFactory _serviceScopeFactory { get; set; }
[Inject]
private UserResoures _userResoures { get; set; }
public void Dispose()
{
_serviceScope.Dispose();
}
/// <summary>
/// 页面刷新
/// </summary>
/// <returns></returns>
public async Task StateHasChangedAsync()
{
var configService = _serviceScope.ServiceProvider.GetService<IConfigService>();
_configCopyRight = (await configService.GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_COPYRIGHT)).ConfigValue;
_configTitle = (await configService.GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_TITLE)).ConfigValue;
_configCopyRightUrl = (await configService.GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_COPYRIGHT_URL)).ConfigValue;
_configPageTab = (await configService.GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_PAGETAB)).ConfigValue.ToBool(true);
_configCopyRight = (await _serviceScope.ServiceProvider.GetService<IConfigService>().GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_COPYRIGHT)).ConfigValue;
_configTitle = (await _serviceScope.ServiceProvider.GetService<IConfigService>().GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_TITLE)).ConfigValue;
_configCopyRightUrl = (await _serviceScope.ServiceProvider.GetService<IConfigService>().GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_COPYRIGHT_URL)).ConfigValue;
_configPageTab = (await _serviceScope.ServiceProvider.GetService<IConfigService>().GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_PAGETAB)).ConfigValue.ToBool(true);
await _userResoures.InitUserAsync();
await _userResoures.InitMenuAsync();

View File

@@ -24,6 +24,7 @@ public class Startup : AppStartup
public void ConfigureServices(IServiceCollection services)
{
services.ThingsGatewayComponentsConfigureServices();
services.AddScoped<UserResoures>();
}

View File

@@ -3,7 +3,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
<PackageReference Include="Masa.Blazor.SomethingSkia" Version="1.2.2" />
</ItemGroup>

View File

@@ -35,7 +35,6 @@ public class Startup : AppStartup
{
WorkerId = 4// 取值范围0~63
});
services.ThingsGatewayCoreConfigureServices();
services.AddComponent<LoggingConsoleComponent>();//启动控制台日志格式化组件
ThingsGateway.Core.TypeExtensions.DefaultFuncs.Add(a => a.GetCustomAttribute<SqlSugar.SugarColumn>()?.ColumnDescription);

View File

@@ -5,10 +5,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Furion.Pure" Version="4.9.1.11" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.11" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.11" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.126" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.5" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.123" />
<PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup>

View File

@@ -56,7 +56,6 @@ public abstract class BaseComponentBase : ComponentBase, IDisposable
/// </summary>
public virtual void Dispose()
{
_serviceScope.Dispose();
}
/// <summary>

View File

@@ -19,7 +19,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace ThingsGateway.Components;
public static class ServiceExtensions
public static class ConfigureService
{
/// <inheritdoc/>
public static void ThingsGatewayComponentsConfigureServices(this IServiceCollection services)
@@ -65,7 +65,9 @@ public static class ServiceExtensions
{ nameof(MTimeline), new Dictionary<string, object>() { { nameof(MTimeline.Dense), true } } },
{ nameof(MToolbar), new Dictionary<string, object>() { { nameof(MToolbar.Dense), true } } },
{ "MTreeview", new Dictionary<string, object>() { { "Dense", true } } },
{ "PImageCaptcha", new Dictionary<string, object>() { { "Dense", true } } }
{ nameof(PImageCaptcha), new Dictionary<string, object>() { { nameof(PImageCaptcha.Dense), true } } }
};
options.ConfigureTheme(theme =>
@@ -96,7 +98,6 @@ public static class ServiceExtensions
services.AddScoped<InitTimezone>();
services.AddScoped<AjaxService>();
services.AddScoped<CookieStorage>();
services.AddScoped<IDefaultTimezoneOffsetAccessor, DefaultTimezoneOffsetAccessor>();
}
}

View File

@@ -1,8 +0,0 @@

namespace ThingsGateway.Components
{
public interface IDefaultTimezoneOffsetAccessor
{
TimeSpan GetTimezoneOffsetResult();
}
}

View File

@@ -10,6 +10,9 @@
//------------------------------------------------------------------------------
#endregion
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace ThingsGateway.Components;
/// <summary>
@@ -40,11 +43,17 @@ public class InitTimezone : IDisposable
/// <param name="jsRuntime"></param>
/// <param name="storage"></param>
/// <param name="serviceProvider"></param>
public InitTimezone(IJSRuntime jsRuntime, CookieStorage storage, IDefaultTimezoneOffsetAccessor defaultTimezoneOffsetAccessor)
public InitTimezone(IJSRuntime jsRuntime, CookieStorage storage, IServiceProvider serviceProvider)
{
IHttpContextAccessor httpContextAccessor = serviceProvider.GetService<IHttpContextAccessor>();
_jsRuntime = jsRuntime;
_storage = storage;
_timezoneOffset = defaultTimezoneOffsetAccessor.GetTimezoneOffsetResult();
var httpContext = httpContextAccessor?.HttpContext;
if (httpContext is not null)
{
var timezoneOffsetResult = httpContext.Request.Cookies[_timezoneOffsetKey];
_timezoneOffset = TimeSpan.FromMinutes(Convert.ToDouble(timezoneOffsetResult));
}
}
/// <summary>
/// 获取Web客户端时差

View File

@@ -3,6 +3,7 @@
<ItemGroup>
<PackageReference Include="Masa.Blazor" Version="1.2.2" />
<PackageReference Include="Masa.Blazor.SomethingSkia" Version="1.2.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -10,6 +10,8 @@
//------------------------------------------------------------------------------
#endregion
using Furion.DependencyInjection;
using Mapster;
using Microsoft.Extensions.Caching.Memory;
@@ -21,9 +23,8 @@ namespace ThingsGateway.Core;
/// <summary>
/// 系统内存缓存
/// </summary>
public class MemoryCache
public class MemoryCache : ISingleton
{
public static MemoryCache Instance { get; private set; } = new();
private const string intervalStr = "---___---";
private readonly Microsoft.Extensions.Caching.Memory.MemoryCache _memoryCache = new(new MemoryCacheOptions());
private readonly Microsoft.Extensions.Caching.Memory.MemoryCache _prefixmemoryCache = new(new MemoryCacheOptions());

View File

@@ -10,6 +10,8 @@
//------------------------------------------------------------------------------
#endregion
using Furion;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
@@ -88,7 +90,7 @@ public static class TypeExtensions
public static string GetDescription(this Type modelType, string name, Func<MemberInfo, string> func = null)
{
var cacheKey = $"{nameof(GetDescription)}-{CultureInfo.CurrentUICulture.Name}-{modelType.FullName}-{name}-{modelType.TypeHandle.Value}";
var str = MemoryCache.Instance.GetOrCreate(cacheKey, entry =>
var str = App.GetService<MemoryCache>().GetOrCreate(cacheKey, entry =>
{
string dn = default;
{

View File

@@ -10,15 +10,20 @@
//------------------------------------------------------------------------------
#endregion
using Furion;
using Microsoft.Extensions.DependencyInjection;
namespace ThingsGateway.Core;
public static class ServiceExtensions
/// <summary>
/// Startup
/// </summary>
[AppStartup(9999)]
public class Startup : AppStartup
{
/// <inheritdoc/>
public static void ThingsGatewayCoreConfigureServices(this IServiceCollection services)
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(a => MemoryCache.Instance);
}
}

View File

@@ -1,11 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Furion.Pure" Version="4.9.1.5" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@@ -1,7 +1,14 @@
<Project>
<Import Project="$(SolutionDir)\Directory.Build.props" />
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
<Version>4.0.0.5</Version>
<LangVersion>latest</LangVersion>
<Authors>Diego</Authors>
<Product>ThingsGateway</Product>
<Copyright>© 2023-present Diego</Copyright>
<RepositoryUrl>https://gitee.com/diego2098/ThingsGateway</RepositoryUrl>
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
</PropertyGroup>

View File

@@ -12,8 +12,6 @@
using Photino.Blazor;
using ThingsGateway.Core;
namespace ThingsGateway.Foundation.Demo;
internal class Program
@@ -25,10 +23,11 @@ internal class Program
var appBuilder = PhotinoBlazorAppBuilder.CreateDefault(args);
Serve.RunNative();
appBuilder.RootComponents.Add<App>("#app");
appBuilder.Services.ThingsGatewayComponentsConfigureServices();
appBuilder.Services.ThingsGatewayCoreConfigureServices();
var app = appBuilder.Build();
app.MainWindow.SetTitle("ThingsGateway.Foundation.Demo");
app.MainWindow.SetIconFile("wwwroot/favicon.ico");

View File

@@ -12,9 +12,6 @@
using Microsoft.AspNetCore.Components;
using ThingsGateway.Components;
namespace ThingsGateway.Foundation.Demo;
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
/// <summary>

View File

@@ -18,10 +18,10 @@
<MCard Flat Class="pa-2 my-1" Style="width:100%">
<div class="mb-4">通道配置</div>
<MRow Justify="JustifyTypes.Start" Align="AlignTypes.Center">
<MTextField Style="max-width:100px" Class="ma-1" Outlined Label=@(_serialPortOption.Description(x => x.PortName)) Dense HideDetails="@("auto")" @bind-Value=@_serialPortOption.PortName />
<MTextField Style="max-width:100px" Class="ma-1" Outlined Label=@(_serialPortOption.Description(x => x.BaudRate)) Dense HideDetails="@("auto")" @bind-Value=@_serialPortOption.BaudRate />
<MTextField Style="max-width:100px" Class="ma-1" Outlined Label=@(_serialPortOption.Description(x => x.DataBits)) Dense HideDetails="@("auto")" @bind-Value=@_serialPortOption.DataBits />
<MSelect Class="ma-1 " Style="max-width:200px" Outlined @bind-Value="_serialPortOption.Parity" Label="@(_serialPortOption.Description(x => x.Parity))"
<MTextField Style="max-width:100px" Class="ma-1" Outlined Label=@(_serialProperty.Description(x => x.PortName)) Dense HideDetails="@("auto")" @bind-Value=@_serialProperty.PortName />
<MTextField Style="max-width:100px" Class="ma-1" Outlined Label=@(_serialProperty.Description(x => x.BaudRate)) Dense HideDetails="@("auto")" @bind-Value=@_serialProperty.BaudRate />
<MTextField Style="max-width:100px" Class="ma-1" Outlined Label=@(_serialProperty.Description(x => x.DataBits)) Dense HideDetails="@("auto")" @bind-Value=@_serialProperty.DataBits />
<MSelect Class="ma-1 " Style="max-width:200px" Outlined @bind-Value="_serialProperty.Parity" Label="@(_serialProperty.Description(x => x.Parity))"
Items=@(typeof(Parity).GetEnumList())
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
ItemText=@((u) =>u.Description)
@@ -29,7 +29,7 @@
HideDetails=@("auto") Height="30"
Dense>
</MSelect>
<MSelect Class="ma-1 " Style="max-width:200px" Outlined @bind-Value="_serialPortOption.StopBits" Label="@(_serialPortOption.Description(x => x.StopBits))"
<MSelect Class="ma-1 " Style="max-width:200px" Outlined @bind-Value="_serialProperty.StopBits" Label="@(_serialProperty.Description(x => x.StopBits))"
Items=@(typeof(StopBits).GetEnumList())
MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
ItemText=@((u) =>u.Description)

View File

@@ -13,39 +13,39 @@
namespace ThingsGateway.Foundation.Demo;
/// <inheritdoc/>
public partial class SerialPortClientPage : IDisposable
public partial class SerialSessionPage : IDisposable
{
/// <summary>
/// 日志输出
/// </summary>
public Action<LogLevel, object, string, Exception> LogAction;
private readonly SerialPortOption _serialPortOption = new();
private readonly SerialProperty _serialProperty = new();
private TouchSocketConfig _config;
private SerialPortClient _serialPortClient { get; set; } = new();
private SerialSession _serialSession { get; set; } = new();
/// <summary>
/// <inheritdoc/>
/// </summary>
public void Dispose()
{
_serialPortClient.SafeDispose();
_serialSession.SafeDispose();
}
/// <summary>
/// 获取对象
/// </summary>
/// <returns></returns>
public SerialPortClient GetSerialPortClient()
public SerialSession GetSerialSession()
{
_config ??= new TouchSocketConfig();
var LogMessage = new LoggerGroup() { LogLevel = LogLevel.Trace };
LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = LogLevel.Trace });
_config.ConfigureContainer(a => a.RegisterSingleton<ILog>(LogMessage));
_config.SetSerialPortOption(_serialPortOption);
_config.SetSerialProperty(_serialProperty);
//载入配置
_serialPortClient.Setup(_config);
return _serialPortClient;
_serialSession.Setup(_config);
return _serialSession;
}
internal void StateHasChangedAsync()
{
@@ -63,7 +63,7 @@ public partial class SerialPortClientPage : IDisposable
var LogMessage = new LoggerGroup() { LogLevel = LogLevel.Trace };
LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = LogLevel.Trace });
_config.ConfigureContainer(a => a.RegisterSingleton<ILog>(LogMessage));
_serialPortClient.Setup(_config);
_serialSession.Setup(_config);
}
base.OnAfterRender(firstRender);
}
@@ -80,8 +80,8 @@ public partial class SerialPortClientPage : IDisposable
{
try
{
_serialPortClient.Close();
await GetSerialPortClient().ConnectAsync();
_serialSession.Close();
await GetSerialSession().ConnectAsync();
}
catch (Exception ex)
{
@@ -93,7 +93,7 @@ public partial class SerialPortClientPage : IDisposable
{
try
{
_serialPortClient.Close();
_serialSession.Close();
}
catch (Exception ex)
{

View File

@@ -16,6 +16,6 @@ global using System.Threading.Tasks;
global using ThingsGateway.Components;
global using ThingsGateway.Foundation.Core;
global using ThingsGateway.Foundation.SerialPorts;
global using ThingsGateway.Foundation.Serial;
global using ThingsGateway.Foundation.Sockets;

View File

@@ -19,7 +19,7 @@
@using Masa.Blazor;
@namespace ThingsGateway.Foundation.Demo
<SerialPortClientPage @ref=_serialPortClientPage></SerialPortClientPage>
<SerialSessionPage @ref=_serialSessionPage></SerialSessionPage>
<MCard Flat Class="pa-2 my-1" Style="width:100%">
<div class="mb-4">驱动配置</div>

View File

@@ -17,9 +17,9 @@ namespace ThingsGateway.Foundation.Demo;
public partial class DLT645_2007DebugPage
{
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private SerialPortClientPage _serialPortClientPage;
private SerialSessionPage _serialSessionPage;
private DriverDebugUIPage _driverDebugUIPage;
private ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007 _plc;
/// <summary>
@@ -37,15 +37,15 @@ public partial class DLT645_2007DebugPage
//链路基础配置项
var config = new TouchSocketConfig();
config
.SetSerialPortOption(new SerialPortOption() //串口链路才需要
.SetSerialProperty(new SerialProperty() //串口链路才需要
{
PortName = "COM1"
});
var serialPortClient = new SerialPortClient();//链路对象
serialPortClient.Setup(config);
var serialSession = new SerialSession();//链路对象
serialSession.Setup(config);
//创建协议对象,构造函数需要传入对应链路对象
DLT645_2007 plc = new(serialPortClient)//传入链路
DLT645_2007 plc = new(serialSession)//传入链路
{
//协议配置
DataFormat = DataFormat.ABCD,
@@ -69,9 +69,9 @@ public partial class DLT645_2007DebugPage
""", "csharp"));
if (_serialPortClientPage != null)
_serialPortClientPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007(_serialPortClientPage.GetSerialPortClient());
if (_serialSessionPage != null)
_serialSessionPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007(_serialSessionPage.GetSerialSession());
_driverDebugUIPage.Plc = _plc;
//初始化

View File

@@ -17,7 +17,7 @@ namespace ThingsGateway.Foundation.Demo;
public partial class DLT645_2007OverTcpDebugPage
{
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private TcpClientPage _tcpClientPage;
private DriverDebugUIPage _driverDebugUIPage;

View File

@@ -19,7 +19,7 @@
@using Masa.Blazor;
@namespace ThingsGateway.Foundation.Demo
<SerialPortClientPage @ref=_serialPortClientPage></SerialPortClientPage>
<SerialSessionPage @ref=_serialSessionPage></SerialSessionPage>
<MCard Flat Class="pa-2 my-1" Style="width:100%">
<div class="mb-4">驱动配置</div>

View File

@@ -19,9 +19,9 @@ namespace ThingsGateway.Foundation.Demo;
public partial class ModbusRtuDebugPage
{
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private SerialPortClientPage _serialPortClientPage;
private SerialSessionPage _serialSessionPage;
private readonly List<(string Code, string Language)> _sections = new();
private DriverDebugUIPage _driverDebugUIPage;
@@ -41,15 +41,15 @@ public partial class ModbusRtuDebugPage
//链路基础配置项
var config = new TouchSocketConfig();
config
.SetSerialPortOption(new SerialPortOption() //串口链路才需要
.SetSerialProperty(new SerialProperty() //串口链路才需要
{
PortName = "COM1"
});
var serialPortClient = new SerialPortClient();//链路对象
serialPortClient.Setup(config);
var serialSession = new SerialSession();//链路对象
serialSession.Setup(config);
//创建协议对象,构造函数需要传入对应链路对象
ModbusRtu plc = new(serialPortClient)//传入链路
ModbusRtu plc = new(serialSession)//传入链路
{
//协议配置
DataFormat = DataFormat.ABCD,
@@ -72,9 +72,9 @@ public partial class ModbusRtuDebugPage
""", "csharp"));
if (_serialPortClientPage != null)
_serialPortClientPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu(_serialPortClientPage.GetSerialPortClient());
if (_serialSessionPage != null)
_serialSessionPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu(_serialSessionPage.GetSerialSession());
_driverDebugUIPage.Plc = _plc;
//载入配置
StateHasChanged();

View File

@@ -19,7 +19,7 @@ namespace ThingsGateway.Foundation.Demo;
public partial class ModbusRtuOverTcpDebugPage
{
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private TcpClientPage _tcpClientPage;
private DriverDebugUIPage _driverDebugUIPage;

View File

@@ -17,7 +17,7 @@ namespace ThingsGateway.Foundation.Demo;
public partial class ModbusRtuOverUdpDebugPage
{
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private UdpSessionPage _udpSessionPage;
private DriverDebugUIPage _driverDebugUIPage;

View File

@@ -19,7 +19,7 @@
@using Masa.Blazor;
@namespace ThingsGateway.Foundation.Demo
<SerialPortClientPage @ref=_serialPortClientPage></SerialPortClientPage>
<SerialSessionPage @ref=_serialSessionPage></SerialSessionPage>
<MCard Flat Class="pa-2 my-1" Style="width:100%">
<div class="mb-4">驱动配置</div>

View File

@@ -17,9 +17,9 @@ namespace ThingsGateway.Foundation.Demo;
public partial class ModbusSerialServerDebugPage
{
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private SerialPortClientPage _serialPortClientPage;
private SerialSessionPage _serialSessionPage;
private DriverDebugUIPage _driverDebugUIPage;
private ThingsGateway.Foundation.Adapter.Modbus.ModbusSerialServer _plc;
@@ -39,15 +39,15 @@ public partial class ModbusSerialServerDebugPage
//链路基础配置项
var config = new TouchSocketConfig();
config
.SetSerialPortOption(new SerialPortOption() //串口链路才需要
.SetSerialProperty(new SerialProperty() //串口链路才需要
{
PortName = "COM1"
});
var serialPortClient = new SerialPortClient();//链路对象
serialPortClient.Setup(config);
var serialSession = new SerialSession();//链路对象
serialSession.Setup(config);
//创建协议对象,构造函数需要传入对应链路对象
ModbusSerialServer plc = new(serialPortClient)//传入链路
ModbusSerialServer plc = new(serialSession)//传入链路
{
//协议配置
DataFormat = DataFormat.ABCD,
@@ -70,9 +70,9 @@ public partial class ModbusSerialServerDebugPage
""", "csharp"));
if (_serialPortClientPage != null)
_serialPortClientPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusSerialServer(_serialPortClientPage.GetSerialPortClient());
if (_serialSessionPage != null)
_serialSessionPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusSerialServer(_serialSessionPage.GetSerialSession());
_driverDebugUIPage.Plc = _plc;
//载入配置
StateHasChanged();

View File

@@ -21,7 +21,7 @@ public partial class ModbusTcpDebugPage
private ThingsGateway.Foundation.Adapter.Modbus.ModbusTcp _plc;
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private TcpClientPage _tcpClientPage;
/// <summary>

View File

@@ -40,9 +40,7 @@
Dense>
</MSelect>
<MCheckbox Class="ma-1" Style="max-width:200px" Label=@(_plc.Description(x => x.IsRtu)) Dense HideDetails="@("auto")" @bind-Value=@_plc.IsRtu></MCheckbox>
<MCheckbox Class="ma-1" Style="max-width:200px" Label=@(_plc.Description(x => x.IsCheckMessageId)) Dense HideDetails="@("auto")" @bind-Value=@_plc.IsCheckMessageId></MCheckbox>
<MCheckbox Class="ma-1" Style="max-width:200px" Label=@(_plc.Description(x => x.Crc16CheckEnable)) Dense HideDetails="@("auto")" @bind-Value=@_plc.Crc16CheckEnable></MCheckbox>
}
</MRow>

View File

@@ -13,9 +13,9 @@
namespace ThingsGateway.Foundation.Demo;
/// <summary>
/// ModbusDtuDebugPage
/// ModbusTcpDtuDebugPage
/// </summary>
public partial class ModbusDtuDebugPage
public partial class ModbusTcpDtuDebugPage
{
/// <summary>
/// TcpServerPage
@@ -23,7 +23,7 @@ public partial class ModbusDtuDebugPage
private TcpServerPage _tcpServerPage;
private DriverDebugUIPage _driverDebugUIPage;
private ThingsGateway.Foundation.Adapter.Modbus.ModbusDtu _plc;
private ThingsGateway.Foundation.Adapter.Modbus.ModbusTcpDtu _plc;
/// <summary>
/// <inheritdoc/>
@@ -70,7 +70,7 @@ public partial class ModbusDtuDebugPage
if (_tcpServerPage != null)
_tcpServerPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusDtu(_tcpServerPage.GetTcpServer());
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusTcpDtu(_tcpServerPage.GetTcpServer());
_driverDebugUIPage.Plc = _plc;
//载入配置
StateHasChanged();

View File

@@ -17,7 +17,7 @@ namespace ThingsGateway.Foundation.Demo;
public partial class ModbusUdpDebugPage
{
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private UdpSessionPage _udpSessionPage;
private DriverDebugUIPage _driverDebugUIPage;

View File

@@ -23,7 +23,7 @@
@using ThingsGateway.Foundation.Core;
@using ThingsGateway.Foundation.Adapter.OPCDA.Da;
@using ThingsGateway.Foundation.Extension;
@using ThingsGateway.Foundation.SerialPorts;
@using ThingsGateway.Foundation.Serial;
@using Masa.Blazor

View File

@@ -20,6 +20,8 @@ using Microsoft.JSInterop;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using ThingsGateway.Foundation.Adapter.OPCDA;
using ThingsGateway.Foundation.Adapter.OPCDA.Da;
@@ -43,7 +45,6 @@ public partial class OPCDAClientDebugPage : IDisposable
{
_plc.SafeDispose();
opcDAClientPage.SafeDispose();
base.Dispose();
}
/// <inheritdoc/>
@@ -104,7 +105,7 @@ public partial class OPCDAClientDebugPage : IDisposable
await PopupService.EnqueueSnackbarAsync("无可用变量", AlertTypes.Warning);
return;
}
await _serviceScope.ServiceProvider.GetService<ICollectDeviceService>().AddAsync(data?.Item1);
await _serviceScope.ServiceProvider.GetService<CollectDeviceService>().AddAsync(data?.Item1);
await _serviceScope.ServiceProvider.GetService<VariableService>().AddBatchAsync(data?.Item2);
await PopupService.EnqueueSnackbarAsync("成功", AlertTypes.Success);
}
@@ -150,7 +151,7 @@ public partial class OPCDAClientDebugPage : IDisposable
/// <returns></returns>
public async Task DownDeviceExportAsync(CollectDevice data)
{
using var memoryStream = await _serviceScope.ServiceProvider.GetService<ICollectDeviceService>().ExportFileAsync(new List<CollectDevice>() { data });
using var memoryStream = await _serviceScope.ServiceProvider.GetService<CollectDeviceService>().ExportFileAsync(new List<CollectDevice>() { data });
using var streamRef = new DotNetStreamReference(stream: memoryStream);
JSObjectReference ??= await JSRuntime.LoadModuleAsync("js/downloadFileFromStream");
await JSObjectReference.InvokeVoidAsync("downloadFileFromStream", $"设备导出{DateTimeExtensions.CurrentDateTime.ToFileDateTimeFormat()}.xlsx", streamRef);

View File

@@ -25,7 +25,7 @@
@using ThingsGateway.Foundation.Core;
@using ThingsGateway.Foundation.Adapter.OPCUA;
@using ThingsGateway.Foundation.Extension;
@using ThingsGateway.Foundation.SerialPorts;
@using ThingsGateway.Foundation.Serial;
@using Masa.Blazor

View File

@@ -96,7 +96,7 @@ public partial class OPCUAClientDebugPage
await PopupService.EnqueueSnackbarAsync("无可用变量", AlertTypes.Warning);
return;
}
await _serviceScope.ServiceProvider.GetService<ICollectDeviceService>().AddAsync(data.Item1);
await _serviceScope.ServiceProvider.GetService<CollectDeviceService>().AddAsync(data.Item1);
await _serviceScope.ServiceProvider.GetService<VariableService>().AddBatchAsync(data.Item2);
await PopupService.EnqueueSnackbarAsync("成功", AlertTypes.Success);
}
@@ -141,7 +141,7 @@ public partial class OPCUAClientDebugPage
/// <returns></returns>
public async Task DownDeviceExportAsync(CollectDevice data)
{
using var memoryStream = await _serviceScope.ServiceProvider.GetService<ICollectDeviceService>().ExportFileAsync(new List<CollectDevice>() { data });
using var memoryStream = await _serviceScope.ServiceProvider.GetService<CollectDeviceService>().ExportFileAsync(new List<CollectDevice>() { data });
using var streamRef = new DotNetStreamReference(stream: memoryStream);
JSObjectReference ??= await JSRuntime.LoadModuleAsync("js/downloadFileFromStream");
await JSObjectReference.InvokeVoidAsync("downloadFileFromStream", $"设备导出{DateTimeExtensions.CurrentDateTime.ToFileDateTimeFormat()}.xlsx", streamRef);

View File

@@ -20,7 +20,7 @@
@using ThingsGateway.Foundation.Adapter.Siemens;
@using ThingsGateway.Foundation.Core;
@using ThingsGateway.Foundation.Extension;
@using ThingsGateway.Foundation.SerialPorts;
@using ThingsGateway.Foundation.Serial;
@using Masa.Blazor

View File

@@ -21,7 +21,7 @@ public partial class SiemensDebugPage
private ThingsGateway.Foundation.Adapter.Siemens.SiemensS7PLC _plc;
/// <summary>
/// SerialPortClientPage
/// SerialSessionPage
/// </summary>
private TcpClientPage _tcpClientPage;
/// <summary>

View File

@@ -10,6 +10,8 @@
//------------------------------------------------------------------------------
#endregion
using System.Collections.Generic;
namespace ThingsGateway.Foundation.Demo;
public partial class MainLayout
@@ -103,16 +105,16 @@ public partial class MainLayout
"Title": "OPCUAClient"
}
]
},
{
"Title": "Mqtt",
"Children": [
{
"Href": "/MqttClient",
"Title": "MqttClient"
}
]
}
//{
// "Title": "Mqtt",
// "Children": [
// {
// "Href": "/MqttClient",
// "Title": "MqttClient"
// }
// ]
//}
]

View File

@@ -25,5 +25,5 @@
@using System.Net.Http.Json
@using System.IO;
@using System.Text.Json;
@using ThingsGateway.Foundation.SerialPorts;
@using ThingsGateway.Foundation.Serial;
@using ThingsGateway.Foundation.Sockets;

View File

@@ -14,9 +14,9 @@ using Microsoft.AspNetCore.Components.WebView.WindowsForms;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics;
using System.Threading.Tasks;
using ThingsGateway.Components;
using ThingsGateway.Core;
namespace ThingsGateway.Foundation.Demo.Winform
{
@@ -26,12 +26,14 @@ namespace ThingsGateway.Foundation.Demo.Winform
{
InitializeComponent();
IServiceCollection services = new ServiceCollection();
IServiceCollection services = null;
services.AddWindowsFormsBlazorWebView();
services.ThingsGatewayComponentsConfigureServices();
services.ThingsGatewayCoreConfigureServices();
Serve.RunNative(a =>
{
services = a;
services.AddWindowsFormsBlazorWebView();
services.ThingsGatewayComponentsConfigureServices();
});
blazorWebView1.HostPage = "wwwroot/index.html";
blazorWebView1.Services = services.BuildServiceProvider();

View File

@@ -7,7 +7,6 @@
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<None Remove="favicon.ico" />
</ItemGroup>

View File

@@ -1,14 +1,20 @@
<Project>
<Import Project="$(SolutionDir)\Directory.Build.props" />
<!--如果编译net45报错无支持用一下方法添加net45包-->
<!--VS顶部菜单栏 -> 视图 -> 其他 -> 程序包控制台
Install-Package Microsoft.NETFramework.ReferenceAssemblies.net45
-->
<PropertyGroup>
<Version>4.0.0.5</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net45;netstandard2.0;net6.0;net8.0;</TargetFrameworks>
<Description>
ThingsGateway.Foundation是工业设备通讯类库归属于ThingsGateway边缘网关项目说明文档https://diego2098.gitee.io/thingsgateway-docs/
</Description>
<Authors>Diego</Authors>
<Product>ThingsGateway</Product>
<Copyright>© 2023-present Diego</Copyright>
<RepositoryUrl>https://gitee.com/diego2098/ThingsGateway</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSource>true</EmbedUntrackedSource>
<EmbedAllSources>true</EmbedAllSources>
@@ -20,11 +26,17 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://diego2098.gitee.io/thingsgateway-docs/</PackageProjectUrl>
<PackageTags>ThingsGateway;Diego;dotNET China;Blazor;设备采集;边缘网关</PackageTags>
<SignAssembly>True</SignAssembly>
<DelaySign>False</DelaySign>
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
<PackageOutputPath>..\..\nupkgs</PackageOutputPath>
<AssemblyOriginatorKeyFile>..\..\..\snks/ThingsGateway.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

View File

@@ -16,13 +16,13 @@ namespace ThingsGateway.Foundation.Adapter.DLT645;
/// <summary>
/// DLT645_2007
/// </summary>
public class DLT645_2007 : ReadWriteDevicesSerialPortClientBase, IDLT645_2007
public class DLT645_2007 : ReadWriteDevicesSerialSessionBase, IDLT645_2007
{
/// <summary>
/// DLT645_2007
/// </summary>
/// <param name="serialPortClient"></param>
public DLT645_2007(SerialPortClient serialPortClient) : base(serialPortClient)
/// <param name="serialSession"></param>
public DLT645_2007(SerialSession serialSession) : base(serialSession)
{
ThingsGatewayBitConverter = new DLT645_2007BitConverter(EndianType.Big);
RegisterByteLength = 2;
@@ -62,7 +62,7 @@ public class DLT645_2007 : ReadWriteDevicesSerialPortClientBase, IDLT645_2007
{
EnableFEHead = EnableFEHead
};
SerialPortClient.SetDataHandlingAdapter(dataHandleAdapter);
SerialSession.SetDataHandlingAdapter(dataHandleAdapter);
}
@@ -106,7 +106,7 @@ public class DLT645_2007 : ReadWriteDevicesSerialPortClientBase, IDLT645_2007
public override OperResult Write(string address, bool[] value, CancellationToken cancellationToken = default) => Write(address, value.ToString(), cancellationToken);
/// <inheritdoc/>
public override Task<OperResult> WriteAsync(string address, byte[] value, CancellationToken cancellationToken = default) => Task.FromResult(new OperResult());
public override Task<OperResult> WriteAsync(string address, byte[] value, CancellationToken cancellationToken = default) => throw new NotImplementedException();
/// <inheritdoc/>
public override Task<OperResult> WriteAsync(string address, uint value, CancellationToken cancellationToken = default) => WriteAsync(address, value.ToString(), cancellationToken);
/// <inheritdoc/>
@@ -125,7 +125,7 @@ public class DLT645_2007 : ReadWriteDevicesSerialPortClientBase, IDLT645_2007
public override Task<OperResult> WriteAsync(string address, int value, CancellationToken cancellationToken = default) => WriteAsync(address, value.ToString(), cancellationToken);
/// <inheritdoc/>
public override Task<OperResult> WriteAsync(string address, bool[] value, CancellationToken cancellationToken = default) => Task.FromResult(new OperResult());
public override Task<OperResult> WriteAsync(string address, bool[] value, CancellationToken cancellationToken = default) => throw new NotImplementedException();
#region

View File

@@ -106,7 +106,7 @@ public class DLT645_2007OverTcp : ReadWriteDevicesTcpClientBase, IDLT645_2007
public override OperResult Write(string address, bool[] value, CancellationToken cancellationToken = default) => Write(address, value.ToString(), cancellationToken);
/// <inheritdoc/>
public override Task<OperResult> WriteAsync(string address, byte[] value, CancellationToken cancellationToken = default) => Task.FromResult(new OperResult());
public override Task<OperResult> WriteAsync(string address, byte[] value, CancellationToken cancellationToken = default) => throw new NotImplementedException();
/// <inheritdoc/>
public override Task<OperResult> WriteAsync(string address, uint value, CancellationToken cancellationToken = default) => WriteAsync(address, value.ToString(), cancellationToken);
/// <inheritdoc/>
@@ -125,7 +125,7 @@ public class DLT645_2007OverTcp : ReadWriteDevicesTcpClientBase, IDLT645_2007
public override Task<OperResult> WriteAsync(string address, int value, CancellationToken cancellationToken = default) => WriteAsync(address, value.ToString(), cancellationToken);
/// <inheritdoc/>
public override Task<OperResult> WriteAsync(string address, bool[] value, CancellationToken cancellationToken = default) => Task.FromResult(new OperResult());
public override Task<OperResult> WriteAsync(string address, bool[] value, CancellationToken cancellationToken = default) => throw new NotImplementedException();
#region

View File

@@ -17,5 +17,5 @@ global using System.Threading;
global using System.Threading.Tasks;
global using ThingsGateway.Foundation.Core;
global using ThingsGateway.Foundation.SerialPorts;
global using ThingsGateway.Foundation.Serial;
global using ThingsGateway.Foundation.Sockets;

View File

@@ -17,5 +17,5 @@ global using System.Threading;
global using System.Threading.Tasks;
global using ThingsGateway.Foundation.Core;
global using ThingsGateway.Foundation.SerialPorts;
global using ThingsGateway.Foundation.Serial;
global using ThingsGateway.Foundation.Sockets;

View File

@@ -14,14 +14,14 @@ using System.ComponentModel;
namespace ThingsGateway.Foundation.Adapter.Modbus;
/// <inheritdoc/>
public class ModbusDtu : ReadWriteDevicesTcpServerBase
public class ModbusTcpDtu : ReadWriteDevicesTcpServerBase
{
/// <inheritdoc/>
public ModbusDtu(TcpService tcpService) : base(tcpService)
public ModbusTcpDtu(TcpService tcpService) : base(tcpService)
{
ThingsGatewayBitConverter = new ThingsGatewayBitConverter(EndianType.Big);
RegisterByteLength = 2;
ModbusDtuPlugin modbusTcpSalvePlugin = new ModbusDtuPlugin();
ModbusTcpDtuPlugin modbusTcpSalvePlugin = new ModbusTcpDtuPlugin();
tcpService.Config.ConfigurePlugins(a =>
{
a.Add(modbusTcpSalvePlugin);
@@ -35,18 +35,6 @@ public class ModbusDtu : ReadWriteDevicesTcpServerBase
[Description("检测事务标识符")]
public bool IsCheckMessageId { get; set; }
/// <summary>
/// 是否Rtu格式
/// </summary>
[Description("是否Rtu格式")]
public bool IsRtu { get; set; }
/// <summary>
/// Crc校验
/// </summary>
[Description("Crc校验")]
public bool Crc16CheckEnable { get; set; } = true;
/// <summary>
/// 站号
/// </summary>
@@ -104,49 +92,23 @@ public class ModbusDtu : ReadWriteDevicesTcpServerBase
{
if (socketClient != default)
{
if (!IsRtu)
ModbusTcpDataHandleAdapter dataHandleAdapter = new()
{
IsCheckMessageId = IsCheckMessageId,
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
};
socketClient.SetDataHandlingAdapter(dataHandleAdapter);
}
else
{
foreach (var item in TcpService.GetClients())
{
ModbusTcpDataHandleAdapter dataHandleAdapter = new()
{
IsCheckMessageId = IsCheckMessageId,
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
};
socketClient.SetDataHandlingAdapter(dataHandleAdapter);
}
else
{
ModbusRtuDataHandleAdapter dataHandleAdapter = new()
{
Crc16CheckEnable = Crc16CheckEnable,
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
};
socketClient.SetDataHandlingAdapter(dataHandleAdapter);
}
}
else
{
//只适配第一个
var item = TcpService.GetClients().FirstOrDefault();
if (item != null)
{
if (!IsRtu)
{
ModbusTcpDataHandleAdapter dataHandleAdapter = new()
{
IsCheckMessageId = IsCheckMessageId,
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
};
item.SetDataHandlingAdapter(dataHandleAdapter);
}
else
{
ModbusRtuDataHandleAdapter dataHandleAdapter = new()
{
Crc16CheckEnable = Crc16CheckEnable,
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
};
item.SetDataHandlingAdapter(dataHandleAdapter);
}
item.SetDataHandlingAdapter(dataHandleAdapter);
}
}
}
@@ -225,7 +187,7 @@ public class ModbusDtu : ReadWriteDevicesTcpServerBase
if (TcpService.TryGetSocketClient($"ID={id}", out var client))
{
SetDataAdapter(client);
return SendThenReturn<MessageBase>(command, cancellationToken, client);
return SendThenReturn<ModbusTcpMessage>(command, cancellationToken, client);
}
else
{
@@ -238,7 +200,7 @@ public class ModbusDtu : ReadWriteDevicesTcpServerBase
if (TcpService.TryGetSocketClient($"ID={id}", out var client))
{
SetDataAdapter(client);
return await SendThenReturnAsync<MessageBase>(command, cancellationToken, client);
return await SendThenReturnAsync<ModbusTcpMessage>(command, cancellationToken, client);
}
else if (TcpService.SocketClients.Count == 1)
{
@@ -246,13 +208,13 @@ public class ModbusDtu : ReadWriteDevicesTcpServerBase
if (client1 != null)
{
SetDataAdapter(client1);
return await SendThenReturnAsync<MessageBase>(command, cancellationToken, client1);
return await SendThenReturnAsync<ModbusTcpMessage>(command, cancellationToken, client1);
}
}
return new OperResult<byte[]>("客户端未连接");
}
internal class ModbusDtuPlugin : PluginBase, ITcpReceivingPlugin
internal class ModbusTcpDtuPlugin : PluginBase, ITcpReceivingPlugin
{
public async Task OnTcpReceiving(ITcpClientBase client, ByteBlockEventArgs e)
{

View File

@@ -16,13 +16,13 @@ namespace ThingsGateway.Foundation.Adapter.Modbus;
/// <summary>
/// ModbusRtu
/// </summary>
public class ModbusRtu : ReadWriteDevicesSerialPortClientBase
public class ModbusRtu : ReadWriteDevicesSerialSessionBase
{
/// <summary>
/// ModbusRtu
/// </summary>
/// <param name="serialPortClient"></param>
public ModbusRtu(SerialPortClient serialPortClient) : base(serialPortClient)
/// <param name="serialSession"></param>
public ModbusRtu(SerialSession serialSession) : base(serialSession)
{
ThingsGatewayBitConverter = new ThingsGatewayBitConverter(EndianType.Big);
RegisterByteLength = 2;
@@ -93,7 +93,7 @@ public class ModbusRtu : ReadWriteDevicesSerialPortClientBase
Crc16CheckEnable = Crc16CheckEnable,
CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout)
};
SerialPortClient.SetDataHandlingAdapter(dataHandleAdapter);
SerialSession.SetDataHandlingAdapter(dataHandleAdapter);
}
/// <inheritdoc/>

View File

@@ -19,7 +19,7 @@ namespace ThingsGateway.Foundation.Adapter.Modbus;
/// </summary>
internal class ModbusTcpDataHandleAdapter : ReadWriteDevicesSingleStreamDataHandleAdapter<ModbusTcpMessage>
{
private readonly IncrementCount _incrementCount = new(ushort.MaxValue);
private readonly IncrementCount easyIncrementCount = new(ushort.MaxValue);
/// <summary>
/// 检测事务标识符
@@ -39,7 +39,7 @@ internal class ModbusTcpDataHandleAdapter : ReadWriteDevicesSingleStreamDataHand
/// <inheritdoc/>
public override byte[] PackCommand(byte[] command)
{
return ModbusHelper.AddModbusTcpHead(command, (ushort)_incrementCount.GetCurrentValue());
return ModbusHelper.AddModbusTcpHead(command, (ushort)easyIncrementCount.GetCurrentValue());
}
/// <inheritdoc/>

View File

@@ -18,7 +18,7 @@ namespace ThingsGateway.Foundation.Adapter.Modbus;
/// </summary>
internal class ModbusUdpDataHandleAdapter : ReadWriteDevicesUdpDataHandleAdapter<ModbusTcpMessage>
{
private readonly IncrementCount _incrementCount = new(ushort.MaxValue);
private readonly IncrementCount easyIncrementCount = new(ushort.MaxValue);
/// <summary>
/// 检测事务标识符
@@ -38,7 +38,7 @@ internal class ModbusUdpDataHandleAdapter : ReadWriteDevicesUdpDataHandleAdapter
/// <inheritdoc/>
public override byte[] PackCommand(byte[] command)
{
return ModbusHelper.AddModbusTcpHead(command, (ushort)_incrementCount.GetCurrentValue());
return ModbusHelper.AddModbusTcpHead(command, (ushort)easyIncrementCount.GetCurrentValue());
}
/// <inheritdoc/>

View File

@@ -16,10 +16,10 @@ namespace ThingsGateway.Foundation.Adapter.Modbus;
/// <summary>
/// <inheritdoc/>
/// </summary>
public class ModbusSerialServer : ReadWriteDevicesSerialPortClientBase, IModbusServer
public class ModbusSerialServer : ReadWriteDevicesSerialSessionBase, IModbusServer
{
/// <inheritdoc/>
public ModbusSerialServer(SerialPortClient serialPortClient) : base(serialPortClient)
public ModbusSerialServer(SerialSession serialSession) : base(serialSession)
{
ThingsGatewayBitConverter = new ThingsGatewayBitConverter(EndianType.Big);
RegisterByteLength = 2;
@@ -130,7 +130,7 @@ public class ModbusSerialServer : ReadWriteDevicesSerialPortClientBase, IModbusS
{
ModbusSerialServerDataHandleAdapter dataHandleAdapter = new();
dataHandleAdapter.CacheTimeout = TimeSpan.FromMilliseconds(CacheTimeout);
SerialPortClient.SetDataHandlingAdapter(dataHandleAdapter);
SerialSession.SetDataHandlingAdapter(dataHandleAdapter);
}
@@ -165,7 +165,7 @@ public class ModbusSerialServer : ReadWriteDevicesSerialPortClientBase, IModbusS
}
/// <inheritdoc/>
protected override async Task Received(SerialPortClient client, ReceivedDataEventArgs e)
protected override async Task Received(SerialSession client, ReceivedDataEventArgs e)
{
try
{

View File

@@ -253,11 +253,11 @@
ModbusRtu
</summary>
</member>
<member name="M:ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu.#ctor(ThingsGateway.Foundation.SerialPorts.SerialPortClient)">
<member name="M:ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu.#ctor(ThingsGateway.Foundation.Serial.SerialSession)">
<summary>
ModbusRtu
</summary>
<param name="serialPortClient"></param>
<param name="serialSession"></param>
</member>
<member name="P:ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu.Crc16CheckEnable">
<summary>

View File

@@ -143,7 +143,7 @@ public interface IReadWrite : IDisposable
/// <param name="cancellationToken">取消令箭</param>
/// <param name="senderClient">传入改参数时,将新建等待线程</param>
/// <returns></returns>
T SendThenReturn<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>;
T SendThenReturn<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>, new();
/// <summary>
/// 异步发送并返回结果
@@ -153,7 +153,7 @@ public interface IReadWrite : IDisposable
/// <param name="cancellationToken">取消令箭</param>
/// <param name="senderClient">传入改参数时,将新建等待线程</param>
/// <returns></returns>
Task<T> SendThenReturnAsync<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>;
Task<T> SendThenReturnAsync<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>, new();
/// <summary>
/// 发送获取数据

View File

@@ -148,7 +148,7 @@ public abstract class ReadWriteDevicesBase : IReadWrite
public abstract void Send(byte[] command, string id = default);
/// <inheritdoc/>
public virtual T SendThenReturn<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>
public virtual T SendThenReturn<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>, new()
{
var item = command;
if (FrameTime != 0)
@@ -157,7 +157,7 @@ public abstract class ReadWriteDevicesBase : IReadWrite
return (T)result.RequestInfo;
}
/// <inheritdoc/>
public virtual async Task<T> SendThenReturnAsync<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>
public virtual async Task<T> SendThenReturnAsync<T>(byte[] command, CancellationToken cancellationToken, ISenderClient senderClient = default) where T : OperResult<byte[]>, new()
{
var item = command;
await Task.Delay(FrameTime, cancellationToken);

View File

@@ -10,34 +10,33 @@
//------------------------------------------------------------------------------
#endregion
namespace ThingsGateway.Foundation.Core;
/// <summary>
/// 串口读写设备
/// </summary>
public abstract class ReadWriteDevicesSerialPortClientBase : ReadWriteDevicesBase
public abstract class ReadWriteDevicesSerialSessionBase : ReadWriteDevicesBase
{
/// <summary>
/// <inheritdoc cref="ReadWriteDevicesSerialPortClientBase"/>
/// <inheritdoc cref="ReadWriteDevicesSerialSessionBase"/>
/// </summary>
/// <param name="serialPortClient"></param>
public ReadWriteDevicesSerialPortClientBase(SerialPortClient serialPortClient)
/// <param name="serialSession"></param>
public ReadWriteDevicesSerialSessionBase(SerialSession serialSession)
{
SerialPortClient = serialPortClient;
WaitingClientEx = SerialPortClient.CreateWaitingClient(new() { });
SerialPortClient.Received -= Received;
SerialPortClient.Connecting -= Connecting;
SerialPortClient.Connected -= Connected;
SerialPortClient.Disconnecting -= Disconnecting;
SerialPortClient.Disconnected -= Disconnected;
SerialPortClient.Connecting += Connecting;
SerialPortClient.Connected += Connected;
SerialPortClient.Disconnecting += Disconnecting;
SerialPortClient.Disconnected += Disconnected;
SerialPortClient.Received += Received;
SerialSession = serialSession;
WaitingClientEx = SerialSession.CreateWaitingClient(new() { });
SerialSession.Received -= Received;
SerialSession.Connecting -= Connecting;
SerialSession.Connected -= Connected;
SerialSession.Disconnecting -= Disconnecting;
SerialSession.Disconnected -= Disconnected;
SerialSession.Connecting += Connecting;
SerialSession.Connected += Connected;
SerialSession.Disconnecting += Disconnecting;
SerialSession.Disconnected += Disconnected;
SerialSession.Received += Received;
Logger = SerialPortClient.Logger;
Logger = SerialSession.Logger;
}
/// <summary>
/// 接收解析
@@ -45,88 +44,88 @@ public abstract class ReadWriteDevicesSerialPortClientBase : ReadWriteDevicesBas
/// <param name="client"></param>
/// <param name="e"></param>
/// <returns></returns>
protected virtual Task Received(SerialPortClient client, ReceivedDataEventArgs e)
protected virtual Task Received(SerialSession client, ReceivedDataEventArgs e)
{
return EasyTask.CompletedTask;
}
/// <inheritdoc/>
public override ChannelEnum ChannelEnum => ChannelEnum.SerialPortClient;
public override ChannelEnum ChannelEnum => ChannelEnum.SerialSession;
/// <summary>
/// 串口管理对象
/// </summary>
public SerialPortClient SerialPortClient { get; }
public SerialSession SerialSession { get; }
/// <summary>
/// 默认WaitingClientEx
/// </summary>
public virtual IWaitingClient<SerialPortClient> WaitingClientEx { get; }
public virtual IWaitingClient<SerialSession> WaitingClientEx { get; }
/// <inheritdoc/>
public override bool IsConnected()
{
return SerialPortClient?.CanSend == true;
return SerialSession?.CanSend == true;
}
/// <inheritdoc/>
public override void Connect(CancellationToken cancellationToken)
{
SerialPortClient.Connect();
SerialSession.Connect();
}
/// <inheritdoc/>
public override Task ConnectAsync(CancellationToken cancellationToken)
{
return SerialPortClient.ConnectAsync();
return SerialSession.ConnectAsync();
}
/// <inheritdoc/>
public override void Disconnect()
{
if (CascadeDisposal && IsConnected())
SerialPortClient.Close();
SerialSession.Close();
}
/// <inheritdoc/>
public override void Dispose()
{
Disconnect();
SerialPortClient.Received -= Received;
SerialPortClient.Connecting -= Connecting;
SerialPortClient.Connected -= Connected;
SerialPortClient.Disconnecting -= Disconnecting;
SerialPortClient.Disconnected -= Disconnected;
if (CascadeDisposal && !SerialPortClient.DisposedValue)
SerialPortClient.SafeDispose();
SerialSession.Received -= Received;
SerialSession.Connecting -= Connecting;
SerialSession.Connected -= Connected;
SerialSession.Disconnecting -= Disconnecting;
SerialSession.Disconnected -= Disconnected;
if (CascadeDisposal && !SerialSession.DisposedValue)
SerialSession.SafeDispose();
}
/// <inheritdoc/>
public override string ToString()
{
return SerialPortClient.ToString();
return SerialSession.SerialProperty.ToString();
}
private async Task Connected(ISerialPortClient client, ConnectedEventArgs e)
private async Task Connected(ISerialSession client, ConnectedEventArgs e)
{
Logger?.Debug(client.ToString() + "连接成功");
Logger?.Debug(client.SerialProperty.ToString() + "连接成功");
SetDataAdapter();
await EasyTask.CompletedTask;
}
private async Task Connecting(ISerialPortClient client, SerialConnectingEventArgs e)
private async Task Connecting(ISerialSession client, SerialConnectingEventArgs e)
{
Logger?.Debug(client.ToString() + "正在连接");
Logger?.Debug(client.SerialProperty.ToString() + "正在连接");
await EasyTask.CompletedTask;
}
private async Task Disconnected(ISerialPortClient client, DisconnectEventArgs e)
private async Task Disconnected(ISerialSessionBase client, DisconnectEventArgs e)
{
Logger?.Debug(client.ToString() + "断开连接-" + e.Message);
Logger?.Debug(client.SerialProperty.ToString() + "断开连接-" + e.Message);
await EasyTask.CompletedTask;
}
private async Task Disconnecting(ISerialPortClient client, DisconnectEventArgs e)
private async Task Disconnecting(ISerialSessionBase client, DisconnectEventArgs e)
{
Logger?.Debug(client.ToString() + "正在主动断开连接-" + e.Message);
Logger?.Debug(client.SerialProperty.ToString() + "正在主动断开连接-" + e.Message);
await EasyTask.CompletedTask;
}
@@ -151,6 +150,6 @@ public abstract class ReadWriteDevicesSerialPortClientBase : ReadWriteDevicesBas
/// <inheritdoc/>
public override void Send(byte[] command, string id = default)
{
SerialPortClient.Send(command);
SerialSession.Send(command);
}
}

View File

@@ -53,7 +53,8 @@ public abstract class ReadWriteDevicesTcpServerBase : ReadWriteDevicesBase
/// <inheritdoc/>
public override Task ConnectAsync(CancellationToken cancellationToken)
{
return TcpService.StartAsync();
Connect(cancellationToken);
return EasyTask.CompletedTask;
}
/// <inheritdoc/>

View File

@@ -48,7 +48,7 @@ public abstract class ReadWriteDevicesUdpSessionBase : ReadWriteDevicesBase
/// <inheritdoc/>
public override Task ConnectAsync(CancellationToken cancellationToken)
{
return UdpSession.StartAsync();
return Task.FromResult(UdpSession.Start());
}
/// <inheritdoc/>
@@ -69,7 +69,7 @@ public abstract class ReadWriteDevicesUdpSessionBase : ReadWriteDevicesBase
/// <inheritdoc/>
public override string ToString()
{
return UdpSession.RemoteIPHost?.ToString();
return UdpSession.RemoteIPHost.ToString();
}
/// <inheritdoc/>

View File

@@ -29,7 +29,6 @@ public abstract class ReadWriteDevicesSingleStreamDataHandleAdapter<TRequest> :
public ReadWriteDevicesSingleStreamDataHandleAdapter()
{
Request = GetInstance();
CacheTimeoutEnable = true;
}
/// <inheritdoc/>
public override bool CanSendRequestInfo => false;

View File

@@ -53,7 +53,7 @@ public abstract class ReadWriteDevicesUdpDataHandleAdapter<TRequest> : UdpDataHa
/// <inheritdoc/>
public override string ToString()
{
return (Owner as UdpSession)?.RemoteIPHost?.ToString();
return (Owner as UdpSession)?.RemoteIPHost.ToString();
}
/// <summary>
@@ -83,11 +83,11 @@ public abstract class ReadWriteDevicesUdpDataHandleAdapter<TRequest> : UdpDataHa
var allBytes = byteBlock.ToArray(0, byteBlock.Len);
Logger?.Trace($"{FoundationConst.LogMessageHeader}{ToString()}- 接收:{(IsHexData ? allBytes.ToHexString(' ') : Encoding.UTF8.GetString(allBytes))}");
//if (Request?.SendBytes == null)
//{
// GoReceived(remoteEndPoint, byteBlock, null);
// return;
//}
if (Request?.SendBytes == null)
{
GoReceived(remoteEndPoint, byteBlock, null);
return;
}
byte[] header = new byte[] { };
if (Request.HeadBytesLength > 0)
{

View File

@@ -22,7 +22,7 @@ public enum ChannelEnum
/// <inheritdoc/>
TcpClient = 1,
/// <inheritdoc/>
SerialPortClient = 2,
SerialSession = 2,
/// <inheritdoc/>
UdpSession = 4,
/// <inheritdoc/>

View File

@@ -421,74 +421,6 @@ public static class StringExtensions
{
return value.IsNullOrEmpty() ? defaultValue : ushort.TryParse(value, out var n) ? n : defaultValue;
}
/// <summary>
/// ToDouble
/// </summary>
/// <returns></returns>
public static double ToDouble(this object value, double defaultValue = 0)
{
if (value is Double d)
{
return Double.IsNaN(d) ? defaultValue : (Double)d;
}
var str = value?.ToString();
if (str.IsNullOrEmpty())
{
return (double)defaultValue;
}
else
{
if (value is bool boolValue)
{
return boolValue ? 1 : 0;
}
return (double)(double.TryParse(str, out var n) ? n : defaultValue);
}
}
/// <summary>
/// ToDecimal
/// </summary>
/// <returns></returns>
public static decimal ToDecimal(this object value, int defaultValue = 0)
{
if (value is Double d)
{
return Double.IsNaN(d) ? defaultValue : (Decimal)d;
}
var str = value?.ToString();
if (str.IsNullOrEmpty())
{
return defaultValue;
}
else
{
if (value is bool boolValue)
{
return boolValue ? 1 : 0;
}
return Decimal.TryParse(str, out var n) ? n : defaultValue;
}
}
/// <summary>
/// ToInt
/// </summary>
/// <returns></returns>
public static int ToInt(this object value, int defaultValue = 0)
{
if (value == null || value.ToString().IsNullOrEmpty())
{
return defaultValue;
}
else
{
if (value is bool boolValue)
{
return boolValue ? 1 : 0;
}
return int.TryParse(value.ToString(), out int n) ? n : defaultValue;
}
}
/// <summary>
/// 用 正则表达式 判断字符是不是汉字

View File

@@ -0,0 +1,48 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using System.IO.Ports;
namespace ThingsGateway.Foundation.Serial;
/// <summary>
/// Connecting
/// </summary>
/// <typeparam name="TClient"></typeparam>
/// <param name="client"></param>
/// <param name="e"></param>
public delegate Task SerialConnectingEventHandler<TClient>(TClient client, SerialConnectingEventArgs e);
/// <summary>
/// 客户端连接事件。
/// </summary>
public class SerialConnectingEventArgs : MsgPermitEventArgs
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="serialPort"></param>
public SerialConnectingEventArgs(SerialPort serialPort)
{
this.SerialPort = serialPort;
this.IsPermitOperation = true;
}
/// <summary>
/// 客户端Id。该Id的赋值仅在服务器适用。
/// </summary>
public string Id { get; set; }
/// <summary>
/// 新初始化的通信器
/// </summary>
public SerialPort SerialPort { get; private set; }
}

View File

@@ -1,4 +1,4 @@
#region copyright
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
@@ -10,12 +10,15 @@
//------------------------------------------------------------------------------
#endregion
namespace ThingsGateway.Components;
namespace ThingsGateway.Foundation.Serial;
public class DefaultTimezoneOffsetAccessor : IDefaultTimezoneOffsetAccessor
/// <summary>
/// 字节事件
/// </summary>
public class SerialReceivedEventArgs : TouchSocketEventArgs
{
public TimeSpan GetTimezoneOffsetResult()
{
return TimeSpan.FromHours(8);
}
}
/// <summary>
/// 数据块
/// </summary>
public ByteBlock UserToken { get; set; }
}

View File

@@ -0,0 +1,38 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
namespace ThingsGateway.Foundation.Serial;
/// <summary>
/// 串口附加属性
/// </summary>
public static class SerialConfigExtension
{
/// <summary>
/// 串口属性
/// </summary>
public static readonly DependencyProperty<SerialProperty> SerialProperty =
DependencyProperty<SerialProperty>.Register("SerialProperty", new());
/// <summary>
/// 设置串口
/// </summary>
/// <param name="config"></param>
/// <param name="value"></param>
/// <returns></returns>
public static TouchSocketConfig SetSerialProperty(this TouchSocketConfig config, SerialProperty value)
{
config.SetValue(SerialProperty, value);
return config;
}
}

View File

@@ -0,0 +1,58 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using System.IO.Ports;
namespace ThingsGateway.Foundation.Serial;
/// <summary>
/// SocketExtension
/// </summary>
public static class SerialPortExtensions
{
/// <summary>
/// 会使用同步锁,保证所有数据上缓存区。
/// </summary>
/// <param name="serialPort"></param>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
public static void AbsoluteSend(this SerialPort serialPort, byte[] buffer, int offset, int length)
{
lock (serialPort)
{
serialPort.Write(buffer, offset, length);
}
}
/// <summary>
/// 尝试关闭<see cref="SerialPort"/>。不会抛出异常。
/// </summary>
/// <param name="serialPort"></param>
public static void TryClose(this SerialPort serialPort)
{
lock (serialPort)
{
try
{
if (serialPort.IsOpen)
{
serialPort.Close();
}
}
catch
{
}
}
}
}

View File

@@ -0,0 +1,36 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
namespace ThingsGateway.Foundation.Serial;
/// <summary>
/// <inheritdoc cref="ISerialSessionBase"/>
/// </summary>
public interface ISerialSession : ISerialSessionBase, IClientSender, IPluginObject, ISetupConfigObject
{
/// <summary>
/// 成功打开串口
/// </summary>
ConnectedEventHandler<ISerialSession> Connected { get; set; }
/// <summary>
/// 准备连接串口的时候
/// </summary>
SerialConnectingEventHandler<ISerialSession> Connecting { get; set; }
/// <summary>
/// 连接串口
/// </summary>
/// <exception cref="Exception"></exception>
ISerialSession Connect();
}

View File

@@ -0,0 +1,66 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using System.IO.Ports;
namespace ThingsGateway.Foundation.Serial;
/// <summary>
/// 串口连接接口。
/// </summary>
public interface ISerialSessionBase : ISenderClient, IClient, ISender, IDefaultSender, IPluginObject, IRequsetInfoSender, IConfigObject, IOnlineClient
{
/// <summary>
/// 是否允许自由调用<see cref="SetDataHandlingAdapter"/>进行赋值。
/// </summary>
bool CanSetDataHandlingAdapter { get; }
/// <summary>
/// 数据处理适配器
/// </summary>
SingleStreamDataHandlingAdapter DataHandlingAdapter { get; }
/// <summary>
/// 断开连接
/// </summary>
DisconnectEventHandler<ISerialSessionBase> Disconnected { get; set; }
/// <summary>
/// 即将断开连接(仅主动断开时有效)。
/// <para>
/// </para>
/// </summary>
DisconnectEventHandler<ISerialSessionBase> Disconnecting { get; set; }
/// <summary>
/// 主通信器
/// </summary>
SerialPort MainSerialPort { get; }
/// <summary>
/// 串口描述
/// </summary>
SerialProperty SerialProperty { get; }
/// <summary>
/// 关闭客户端。
/// </summary>
/// <param name="msg"></param>
/// <exception cref="Exception"></exception>
void Close(string msg = TouchSocketCoreUtility.Empty);
/// <summary>
/// 设置数据处理适配器
/// </summary>
/// <param name="adapter"></param>
void SetDataHandlingAdapter(SingleStreamDataHandlingAdapter adapter);
}

View File

@@ -0,0 +1,388 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using System.IO.Ports;
namespace ThingsGateway.Foundation.Serial;
internal sealed class InternalSerialCore : SerialCore
{
}
/// <summary>
/// Serial核心
/// </summary>
public class SerialCore : IDisposable, ISender
{
/// <summary>
/// 最小缓存尺寸
/// </summary>
public int MinBufferSize { get; set; } = 1024 * 10;
/// <summary>
/// 最大缓存尺寸
/// </summary>
public int MaxBufferSize { get; set; } = 1024 * 1024 * 10;
#region
/// <summary>
/// 同步根
/// </summary>
public readonly object SyncRoot = new object();
private long m_bufferRate;
private bool m_online => m_serialPort?.IsOpen == true;
private int m_receiveBufferSize = 1024 * 10;
private ValueCounter m_receiveCounter;
private int m_sendBufferSize = 1024 * 10;
private ValueCounter m_sendCounter;
private readonly EasyLock m_semaphoreForSend = new EasyLock();
private SerialPort m_serialPort;
#endregion
/// <summary>
/// Tcp核心
/// </summary>
public SerialCore()
{
this.m_receiveCounter = new ValueCounter
{
Period = TimeSpan.FromSeconds(1),
OnPeriod = this.OnReceivePeriod
};
this.m_sendCounter = new ValueCounter
{
Period = TimeSpan.FromSeconds(1),
OnPeriod = this.OnSendPeriod
};
}
/// <summary>
/// 析构函数
/// </summary>
~SerialCore()
{
this.SafeDispose();
}
/// <inheritdoc/>
public bool CanSend => this.m_online;
/// <summary>
/// 当中断Tcp的时候。当为<see langword="true"/>时,意味着是调用<see cref="Close(string)"/>。当为<see langword="false"/>时,则是其他中断。
/// </summary>
public Action<SerialCore, bool, string> OnBreakOut { get; set; }
/// <summary>
/// 当发生异常的时候
/// </summary>
public Action<SerialCore, Exception> OnException { get; set; }
/// <summary>
/// 在线状态
/// </summary>
public bool Online { get => this.m_online; }
/// <summary>
/// UserToken
/// </summary>
public ByteBlock UserToken { get; set; }
/// <summary>
/// 当收到数据的时候
/// </summary>
public Action<SerialCore, ByteBlock> OnReceived { get; set; }
/// <summary>
/// 接收缓存池,运行时的值会根据流速自动调整
/// </summary>
public int ReceiveBufferSize
{
get => this.m_receiveBufferSize;
}
/// <summary>
/// 接收计数器
/// </summary>
public ValueCounter ReceiveCounter { get => this.m_receiveCounter; }
/// <summary>
/// 发送缓存池,运行时的值会根据流速自动调整
/// </summary>
public int SendBufferSize
{
get => this.m_sendBufferSize;
}
/// <summary>
/// 发送计数器
/// </summary>
public ValueCounter SendCounter { get => this.m_sendCounter; }
/// <summary>
/// SerialPort
/// </summary>
public SerialPort MainSerialPort { get => this.m_serialPort; }
/// <summary>
/// 开始以Iocp方式接收
/// </summary>
public virtual void BeginIocpReceive()
{
var byteBlock = BytePool.Default.GetByteBlock(this.ReceiveBufferSize);
this.UserToken = byteBlock;
byteBlock.SetLength(0);
if (this.m_serialPort.BytesToRead > 0)
{
this.m_bufferRate += 2;
this.ProcessReceived();
}
m_serialPort.DataReceived += MainSerialPort_DataReceived;
}
private void MainSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
this.m_bufferRate = 1;
this.ProcessReceived();
}
catch (Exception ex)
{
this.PrivateBreakOut(false, ex.ToString());
}
}
/// <summary>
/// 请求关闭
/// </summary>
/// <param name="msg"></param>
public virtual void Close(string msg)
{
this.PrivateBreakOut(true, msg);
}
/// <summary>
/// 释放对象
/// </summary>
public void Dispose()
{
GC.SuppressFinalize(this);
UserToken.SafeDispose();
}
/// <summary>
/// 重置环境,并设置新的<see cref="m_serialPort"/>。
/// </summary>
/// <param name="socket"></param>
public virtual void Reset(SerialPort socket)
{
if (socket is null)
{
throw new ArgumentNullException(nameof(socket));
}
if (!socket.IsOpen)
{
throw new Exception("新的SerialPort必须在连接状态。");
}
this.Reset();
this.m_serialPort = socket;
}
/// <summary>
/// 重置环境。
/// </summary>
public virtual void Reset()
{
this.m_receiveCounter.Reset();
this.m_sendCounter.Reset();
this.m_serialPort = null;
this.OnReceived = null;
this.OnBreakOut = null;
this.UserToken = null;
this.m_bufferRate = 1;
this.m_receiveBufferSize = this.MinBufferSize;
this.m_sendBufferSize = this.MinBufferSize;
}
/// <summary>
/// 判断,当不在连接状态时触发异常。
/// </summary>
/// <exception cref="NotConnectedException"></exception>
protected void ThrowIfNotConnected()
{
if (!this.m_online)
{
throw new NotConnectedException();
}
}
/// <summary>
/// 发送数据。
/// <para>
/// 内部会根据是否启用Ssl进行直接发送还是Ssl发送。
/// </para>
/// </summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
public virtual void Send(byte[] buffer, int offset, int length)
{
this.ThrowIfNotConnected();
try
{
this.m_semaphoreForSend.Wait();
this.m_serialPort.Write(buffer, offset, length);
this.m_sendCounter.Increment(length);
}
finally
{
this.m_semaphoreForSend.Release();
}
}
/// <summary>
/// 异步发送数据。
/// </summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public virtual async Task SendAsync(byte[] buffer, int offset, int length)
{
this.ThrowIfNotConnected();
try
{
await this.m_semaphoreForSend.WaitAsync();
this.m_serialPort.Write(buffer, offset, length);
this.m_sendCounter.Increment(length);
}
finally
{
this.m_semaphoreForSend.Release();
}
}
/// <summary>
/// 当中断Tcp时。
/// </summary>
/// <param name="manual">当为<see langword="true"/>时,意味着是调用<see cref="Close(string)"/>。当为<see langword="false"/>时,则是其他中断。</param>
/// <param name="msg"></param>
protected virtual void BreakOut(bool manual, string msg)
{
this.OnBreakOut?.Invoke(this, manual, msg);
}
/// <summary>
/// 当发生异常的时候
/// </summary>
/// <param name="ex"></param>
protected virtual void Exception(Exception ex)
{
this.OnException?.Invoke(this, ex);
}
/// <summary>
/// 当收到数据的时候
/// </summary>
/// <param name="byteBlock"></param>
protected virtual void Received(ByteBlock byteBlock)
{
this.OnReceived?.Invoke(this, byteBlock);
}
private void HandleBuffer(ByteBlock byteBlock)
{
try
{
this.m_receiveCounter.Increment(byteBlock.Length);
this.Received(byteBlock);
}
catch (Exception ex)
{
this.Exception(ex);
}
finally
{
byteBlock.Dispose();
}
}
private void OnReceivePeriod(long value)
{
this.m_receiveBufferSize = Math.Max(TouchSocketUtility.HitBufferLength(value), this.MinBufferSize);
if (this.MainSerialPort != null && !MainSerialPort.IsOpen)
{
this.MainSerialPort.ReadBufferSize = this.m_receiveBufferSize;
}
}
private void OnSendPeriod(long value)
{
this.m_sendBufferSize = Math.Max(TouchSocketUtility.HitBufferLength(value), this.MinBufferSize);
if (this.MainSerialPort != null && !MainSerialPort.IsOpen)
{
this.MainSerialPort.WriteBufferSize = this.m_sendBufferSize;
}
}
private void PrivateBreakOut(bool manual, string msg)
{
lock (this.SyncRoot)
{
if (this.m_online)
{
this.BreakOut(manual, msg);
}
}
}
private void ProcessReceived()
{
if (!this.m_online)
{
UserToken?.SafeDispose();
return;
}
if (m_serialPort.BytesToRead > 0)
{
var byteBlock = UserToken;
byte[] buffer = BytePool.Default.Rent(m_serialPort.BytesToRead);
int num = m_serialPort.Read(buffer, 0, m_serialPort.BytesToRead);
byteBlock.Write(buffer, 0, num);
byteBlock.SetLength(num);
this.HandleBuffer(byteBlock);
try
{
var newByteBlock = BytePool.Default.GetByteBlock((int)Math.Min(this.ReceiveBufferSize * this.m_bufferRate, this.MaxBufferSize));
newByteBlock.SetLength(0);
UserToken = newByteBlock;
if (m_serialPort.BytesToRead > 0)
{
this.m_bufferRate += 2;
this.ProcessReceived();
}
}
catch (Exception ex)
{
this.PrivateBreakOut(false, ex.ToString());
}
}
}
}

View File

@@ -0,0 +1,53 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using System.ComponentModel;
using System.IO.Ports;
namespace ThingsGateway.Foundation.Serial;
/// <summary>
/// 串口属性
/// </summary>
public class SerialProperty
{
/// <summary>
/// COM
/// </summary>
[Description("COM口")]
public string PortName { get; set; } = "COM1";
/// <summary>
/// 波特率
/// </summary>
[Description("波特率")]
public int BaudRate { get; set; } = 9600;
/// <summary>
/// 数据位
/// </summary>
[Description("数据位")]
public int DataBits { get; set; } = 8;
/// <summary>
/// 校验位
/// </summary>
[Description("校验位")]
public Parity Parity { get; set; } = Parity.None;
/// <summary>
/// 停止位
/// </summary>
[Description("停止位")]
public StopBits StopBits { get; set; } = StopBits.One;
/// <inheritdoc/>
public override string ToString()
{
return $"{PortName}[{BaudRate},{DataBits},{StopBits},{Parity}]";
}
}

View File

@@ -0,0 +1,749 @@
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using System.IO.Ports;
namespace ThingsGateway.Foundation.Serial;
/// <inheritdoc cref="SerialSessionBase"/>
public class SerialSession : SerialSessionBase
{
/// <summary>
/// 接收到数据
/// </summary>
public ReceivedEventHandler<SerialSession> Received { get; set; }
/// <inheritdoc/>
protected override Task ReceivedData(ReceivedDataEventArgs e)
{
if (this.Received != null)
{
return this.Received.Invoke(this, e);
}
return base.ReceivedData(e);
}
}
/// <summary>
/// 串口管理
/// </summary>
public class SerialSessionBase : SetupConfigObject, ISerialSession
{
static readonly Protocol SerialPort = new("SerialSession");
/// <summary>
/// 构造函数
/// </summary>
public SerialSessionBase()
{
this.Protocol = SerialPort;
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
public override string ToString()
{
return SerialProperty?.ToString();
}
#region
private DelaySender m_delaySender;
private bool m_online => MainSerialPort?.IsOpen == true;
private readonly EasyLock m_semaphore = new();
private readonly InternalSerialCore m_serialCore = new();
#endregion
#region
/// <inheritdoc/>
public ConnectedEventHandler<ISerialSession> Connected { get; set; }
/// <inheritdoc/>
public SerialConnectingEventHandler<ISerialSession> Connecting { get; set; }
/// <inheritdoc/>
public DisconnectEventHandler<ISerialSessionBase> Disconnected { get; set; }
/// <inheritdoc/>
public DisconnectEventHandler<ISerialSessionBase> Disconnecting { get; set; }
private async Task PrivateOnConnected(ConnectedEventArgs o)
{
await this.OnConnected(o);
}
/// <summary>
/// 已经建立连接
/// </summary>
/// <param name="e"></param>
protected virtual async Task OnConnected(ConnectedEventArgs e)
{
try
{
if (this.Connected != null)
{
await this.Connected.Invoke(this, e);
if (e.Handled)
{
return;
}
}
await this.PluginsManager.RaiseAsync(nameof(ITcpConnectedPlugin.OnTcpConnected), this, e);
}
catch (Exception ex)
{
this.Logger.Log(LogLevel.Error, this, $"在事件{nameof(this.Connected)}中发生错误。", ex);
}
}
private async Task PrivateOnConnecting(SerialConnectingEventArgs e)
{
if (this.CanSetDataHandlingAdapter)
{
this.SetDataHandlingAdapter(this.Config.GetValue(TouchSocketConfigExtension.TcpDataHandlingAdapterProperty).Invoke());
}
await this.OnConnecting(e);
}
/// <summary>
/// 准备连接的时候,此时并未建立连接
/// </summary>
/// <param name="e"></param>
protected virtual async Task OnConnecting(SerialConnectingEventArgs e)
{
try
{
if (this.Connecting != null)
{
await this.Connecting.Invoke(this, e);
if (e.Handled)
{
return;
}
}
await this.PluginsManager.RaiseAsync(nameof(ITcpConnectingPlugin.OnTcpConnecting), this, e);
}
catch (Exception ex)
{
this.Logger.Log(LogLevel.Error, this, $"在事件{nameof(this.OnConnecting)}中发生错误。", ex);
}
}
private async Task PrivateOnDisconnected(object obj)
{
this.m_receiver?.TryInputReceive(default, default);
await this.OnDisconnected((DisconnectEventArgs)obj);
}
/// <summary>
/// 断开连接。在客户端未设置连接状态时,不会触发
/// </summary>
/// <param name="e"></param>
protected virtual async Task OnDisconnected(DisconnectEventArgs e)
{
try
{
if (this.Disconnected != null)
{
await this.Disconnected.Invoke(this, e).ConfigureAwait(false);
if (e.Handled)
{
return;
}
}
await this.PluginsManager.RaiseAsync(nameof(ITcpDisconnectedPlugin.OnTcpDisconnected), this, e).ConfigureAwait(false);
}
catch (Exception ex)
{
this.Logger.Log(LogLevel.Error, this, $"在事件{nameof(this.Disconnected)}中发生错误。", ex);
}
}
private async Task PrivateOnDisconnecting(object obj)
{
await this.OnDisconnecting((DisconnectEventArgs)obj);
}
/// <summary>
/// 即将断开连接(仅主动断开时有效)。
/// </summary>
/// <param name="e"></param>
protected virtual async Task OnDisconnecting(DisconnectEventArgs e)
{
try
{
if (this.Disconnecting != null)
{
await this.Disconnecting.Invoke(this, e).ConfigureAwait(false);
if (e.Handled)
{
return;
}
}
await this.PluginsManager.RaiseAsync(nameof(ITcpDisconnectingPlugin.OnTcpDisconnecting), this, e).ConfigureAwait(false);
}
catch (Exception ex)
{
this.Logger.Log(LogLevel.Error, this, $"在事件{nameof(this.Disconnecting)}中发生错误。", ex);
}
}
#endregion
#region
/// <inheritdoc/>
public DateTime LastReceivedTime => this.GetSerialCore().ReceiveCounter.LastIncrement;
/// <inheritdoc/>
public DateTime LastSendTime => this.GetSerialCore().SendCounter.LastIncrement;
/// <inheritdoc/>
public virtual bool CanSetDataHandlingAdapter => true;
/// <inheritdoc/>
public SingleStreamDataHandlingAdapter DataHandlingAdapter { get; private set; }
/// <inheritdoc/>
public SerialProperty SerialProperty { get; private set; }
/// <inheritdoc/>
public SerialPort MainSerialPort { get; private set; }
/// <inheritdoc/>
public bool Online { get => this.m_online; }
/// <inheritdoc/>
public bool CanSend => this.m_online;
/// <inheritdoc/>
public Protocol Protocol { get; set; }
#endregion
#region
/// <inheritdoc/>
public virtual void Close(string msg = TouchSocketCoreUtility.Empty)
{
lock (this.GetSerialCore())
{
if (this.m_online)
{
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, msg));
this.MainSerialPort.TryClose();
this.BreakOut(true, msg);
}
}
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
lock (this.GetSerialCore())
{
if (this.m_online)
{
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, $"{nameof(Dispose)}主动断开"));
this.BreakOut(true, $"{nameof(Dispose)}主动断开");
}
}
base.Dispose(disposing);
}
#endregion
#region Connect
/// <summary>
/// 打开串口
/// </summary>
protected void Open()
{
try
{
ThrowIfDisposed();
this.m_semaphore.Wait();
if (this.m_online)
{
return;
}
if (this.DisposedValue)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
if (this.Config == null)
{
throw new ArgumentNullException(nameof(this.Config), "配置文件不能为空。");
}
var serialProperty = this.Config.GetValue(SerialConfigExtension.SerialProperty) ?? throw new ArgumentNullException("串口配置不能为空。");
this.MainSerialPort.SafeDispose();
var serialPort = CreateSerial(serialProperty);
this.PrivateOnConnecting(new(serialPort)).ConfigureAwait(false).GetAwaiter().GetResult();
serialPort.Open();
this.SetSerialPort(serialPort);
this.BeginReceive();
this.PrivateOnConnected(new()).ConfigureAwait(false).GetAwaiter().GetResult();
}
finally
{
this.m_semaphore.Release();
}
}
private void BeginReceive()
{
this.GetSerialCore().BeginIocpReceive();
}
/// <inheritdoc/>
public virtual ISerialSession Connect()
{
this.Open();
return this;
}
/// <inheritdoc/>
public async Task<ISerialSession> ConnectAsync()
{
return await Task.Run(() =>
{
return this.Connect();
});
}
#endregion Connect
#region Receiver
private Receiver m_receiver;
/// <inheritdoc/>
public IReceiver CreateReceiver()
{
return this.m_receiver ??= new Receiver(this);
}
/// <inheritdoc/>
public void ClearReceiver()
{
this.m_receiver = null;
}
#endregion
private void SerialCoreBreakOut(SerialCore core, bool manual, string msg)
{
this.BreakOut(manual, msg);
}
/// <summary>
/// BreakOut。
/// </summary>
/// <param name="manual"></param>
/// <param name="msg"></param>
protected void BreakOut(bool manual, string msg)
{
lock (this.GetSerialCore())
{
if (this.m_online)
{
this.MainSerialPort.SafeDispose();
this.m_delaySender.SafeDispose();
this.DataHandlingAdapter.SafeDispose();
Task.Factory.StartNew(this.PrivateOnDisconnected, new DisconnectEventArgs(manual, msg));
}
}
}
private SerialCore GetSerialCore()
{
this.ThrowIfDisposed();
return this.m_serialCore ?? throw new ObjectDisposedException(this.GetType().Name);
}
/// <inheritdoc/>
public virtual void SetDataHandlingAdapter(SingleStreamDataHandlingAdapter adapter)
{
if (!this.CanSetDataHandlingAdapter)
{
throw new Exception($"不允许自由调用{nameof(SetDataHandlingAdapter)}进行赋值。");
}
this.SetAdapter(adapter);
}
private void PrivateHandleReceivedData(ByteBlock byteBlock, IRequestInfo requestInfo)
{
if (this.m_receiver != null)
{
if (this.m_receiver.TryInputReceive(byteBlock, requestInfo))
{
return;
}
}
this.ReceivedData(new ReceivedDataEventArgs(byteBlock, requestInfo)).GetFalseAwaitResult();
}
/// <summary>
/// 当收到适配器处理的数据时。
/// </summary>
/// <param name="e"></param>
/// <returns>如果返回<see langword="true"/>则表示数据已被处理,且不会再向下传递。</returns>
protected virtual Task ReceivedData(ReceivedDataEventArgs e)
{
return this.PluginsManager.RaiseAsync(nameof(ITcpReceivedPlugin.OnTcpReceived), this, e);
}
/// <summary>
/// 当即将发送时,如果覆盖父类方法,则不会触发插件。
/// </summary>
/// <param name="buffer">数据缓存区</param>
/// <param name="offset">偏移</param>
/// <param name="length">长度</param>
/// <returns>返回值表示是否允许发送</returns>
protected virtual async Task<bool> SendingData(byte[] buffer, int offset, int length)
{
if (this.PluginsManager.GetPluginCount(nameof(ITcpSendingPlugin.OnTcpSending)) > 0)
{
var args = new SendingEventArgs(buffer, offset, length);
await this.PluginsManager.RaiseAsync(nameof(ITcpSendingPlugin.OnTcpSending), this, args).ConfigureAwait(false);
return args.IsPermitOperation;
}
return true;
}
/// <inheritdoc/>
protected override void LoadConfig(TouchSocketConfig config)
{
this.SerialProperty = config.GetValue(SerialConfigExtension.SerialProperty);
this.Logger ??= this.Container.Resolve<ILog>();
}
/// <summary>
/// 设置适配器,该方法不会检验<see cref="CanSetDataHandlingAdapter"/>的值。
/// </summary>
/// <param name="adapter"></param>
protected void SetAdapter(SingleStreamDataHandlingAdapter adapter)
{
this.ThrowIfDisposed();
if (adapter is null)
{
throw new ArgumentNullException(nameof(adapter));
}
if (this.Config != null)
{
adapter.Config(this.Config);
}
adapter.Logger = this.Logger;
adapter.OnLoaded(this);
adapter.ReceivedCallBack = this.PrivateHandleReceivedData;
adapter.SendCallBack = this.DefaultSend;
adapter.SendAsyncCallBack = this.DefaultSendAsync;
this.DataHandlingAdapter = adapter;
}
private static SerialPort CreateSerial(SerialProperty serialProperty)
{
SerialPort serialPort = new(serialProperty.PortName, serialProperty.BaudRate, serialProperty.Parity, serialProperty.DataBits, serialProperty.StopBits)
{
DtrEnable = true,
RtsEnable = true
};
return serialPort;
}
#region
#region
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="requestInfo"></param>
/// <exception cref="NotConnectedException"></exception>
/// <exception cref="OverlengthException"></exception>
/// <exception cref="Exception"></exception>
public void Send(IRequestInfo requestInfo)
{
if (this.DisposedValue)
{
return;
}
if (this.DataHandlingAdapter == null)
{
throw new ArgumentNullException(nameof(this.DataHandlingAdapter), TouchSocketResource.NullDataAdapter.GetDescription());
}
if (!this.DataHandlingAdapter.CanSendRequestInfo)
{
throw new NotSupportedException($"当前适配器不支持对象发送。");
}
this.DataHandlingAdapter.SendInput(requestInfo);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="buffer"><inheritdoc/></param>
/// <param name="offset"><inheritdoc/></param>
/// <param name="length"><inheritdoc/></param>
/// <exception cref="NotConnectedException"><inheritdoc/></exception>
/// <exception cref="OverlengthException"><inheritdoc/></exception>
/// <exception cref="Exception"><inheritdoc/></exception>
public virtual void Send(byte[] buffer, int offset, int length)
{
if (this.DataHandlingAdapter == null)
{
throw new ArgumentNullException(nameof(this.DataHandlingAdapter), TouchSocketResource.NullDataAdapter.GetDescription());
}
this.DataHandlingAdapter.SendInput(buffer, offset, length);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="transferBytes"><inheritdoc/></param>
/// <exception cref="NotConnectedException"><inheritdoc/></exception>
/// <exception cref="OverlengthException"><inheritdoc/></exception>
/// <exception cref="Exception"><inheritdoc/></exception>
public virtual void Send(IList<ArraySegment<byte>> transferBytes)
{
if (this.DataHandlingAdapter == null)
{
throw new ArgumentNullException(nameof(this.DataHandlingAdapter), TouchSocketResource.NullDataAdapter.GetDescription());
}
if (this.DataHandlingAdapter.CanSplicingSend)
{
this.DataHandlingAdapter.SendInput(transferBytes);
}
else
{
var length = 0;
foreach (var item in transferBytes)
{
length += item.Count;
}
using (var byteBlock = new ByteBlock(length))
{
foreach (var item in transferBytes)
{
byteBlock.Write(item.Array, item.Offset, item.Count);
}
this.DataHandlingAdapter.SendInput(byteBlock.Buffer, 0, byteBlock.Len);
}
}
}
#endregion
#region
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
/// <exception cref="NotConnectedException"></exception>
/// <exception cref="OverlengthException"></exception>
/// <exception cref="Exception"></exception>
public virtual Task SendAsync(byte[] buffer, int offset, int length)
{
this.ThrowIfDisposed();
if (this.DataHandlingAdapter == null)
{
throw new ArgumentNullException(nameof(this.DataHandlingAdapter), TouchSocketResource.NullDataAdapter.GetDescription());
}
return this.DataHandlingAdapter.SendInputAsync(buffer, offset, length);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="requestInfo"></param>
/// <exception cref="NotConnectedException"></exception>
/// <exception cref="OverlengthException"></exception>
/// <exception cref="Exception"></exception>
public virtual Task SendAsync(IRequestInfo requestInfo)
{
this.ThrowIfDisposed();
if (this.DataHandlingAdapter == null)
{
throw new ArgumentNullException(nameof(this.DataHandlingAdapter), TouchSocketResource.NullDataAdapter.GetDescription());
}
if (!this.DataHandlingAdapter.CanSendRequestInfo)
{
throw new NotSupportedException($"当前适配器不支持对象发送。");
}
return this.DataHandlingAdapter.SendInputAsync(requestInfo);
}
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="transferBytes"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public virtual Task SendAsync(IList<ArraySegment<byte>> transferBytes)
{
this.ThrowIfDisposed();
if (this.DataHandlingAdapter == null)
{
throw new ArgumentNullException(nameof(this.DataHandlingAdapter), TouchSocketResource.NullDataAdapter.GetDescription());
}
if (this.DataHandlingAdapter.CanSplicingSend)
{
return this.DataHandlingAdapter.SendInputAsync(transferBytes);
}
else
{
var length = 0;
foreach (var item in transferBytes)
{
length += item.Count;
}
using (var byteBlock = new ByteBlock(length))
{
foreach (var item in transferBytes)
{
byteBlock.Write(item.Array, item.Offset, item.Count);
}
return this.DataHandlingAdapter.SendInputAsync(byteBlock.Buffer, 0, byteBlock.Len);
}
}
}
#endregion
/// <inheritdoc/>
public void DefaultSend(byte[] buffer, int offset, int length)
{
if (this.SendingData(buffer, offset, length).GetFalseAwaitResult())
{
if (this.m_delaySender != null)
{
this.m_delaySender.Send(new QueueDataBytes(buffer, offset, length));
return;
}
this.GetSerialCore().Send(buffer, offset, length);
}
}
/// <inheritdoc/>
public async Task DefaultSendAsync(byte[] buffer, int offset, int length)
{
if (await this.SendingData(buffer, offset, length))
{
await this.GetSerialCore().SendAsync(buffer, offset, length);
}
}
#endregion
#region
private void SetSerialPort(SerialPort serialPort)
{
if (serialPort == null)
{
return;
}
this.MainSerialPort = serialPort;
this.SerialProperty ??= new();
this.SerialProperty.Parity = serialPort.Parity;
this.SerialProperty.PortName = serialPort.PortName;
this.SerialProperty.StopBits = serialPort.StopBits;
this.SerialProperty.DataBits = serialPort.DataBits;
this.SerialProperty.BaudRate = serialPort.BaudRate;
var delaySenderOption = this.Config.GetValue(TouchSocketConfigExtension.DelaySenderProperty);
if (delaySenderOption != null)
{
this.m_delaySender = new DelaySender(delaySenderOption, this.MainSerialPort.AbsoluteSend);
}
this.m_serialCore.Reset(serialPort);
this.m_serialCore.OnReceived = this.HandleReceived;
this.m_serialCore.OnBreakOut = this.SerialCoreBreakOut;
if (this.Config.GetValue(TouchSocketConfigExtension.MinBufferSizeProperty) is int minValue)
{
this.m_serialCore.MinBufferSize = minValue;
}
if (this.Config.GetValue(TouchSocketConfigExtension.MaxBufferSizeProperty) is int maxValue)
{
this.m_serialCore.MaxBufferSize = maxValue;
}
}
private void HandleReceived(SerialCore core, ByteBlock byteBlock)
{
try
{
if (this.DisposedValue)
{
return;
}
if (this.ReceivingData(byteBlock).GetFalseAwaitResult())
{
return;
}
if (this.DataHandlingAdapter == null)
{
this.Logger.Error(this, TouchSocketResource.NullDataAdapter.GetDescription());
return;
}
this.DataHandlingAdapter.ReceivedInput(byteBlock);
}
catch (Exception ex)
{
this.Logger.Log(LogLevel.Error, this, "在处理数据时发生错误", ex);
}
}
/// <summary>
/// 当收到原始数据
/// </summary>
/// <param name="byteBlock"></param>
/// <returns>如果返回<see langword="true"/>则表示数据已被处理,且不会再向下传递。</returns>
protected virtual Task<bool> ReceivingData(ByteBlock byteBlock)
{
if (this.PluginsManager.GetPluginCount(nameof(ITcpReceivingPlugin.OnTcpReceiving)) > 0)
{
return this.PluginsManager.RaiseAsync(nameof(ITcpReceivingPlugin.OnTcpReceiving), this, new ByteBlockEventArgs(byteBlock));
}
return Task.FromResult(false);
}
#endregion
}

View File

@@ -20,5 +20,6 @@ global using System.Threading.Tasks;
global using ThingsGateway.Foundation.Core;
global using ThingsGateway.Foundation.Http;
global using ThingsGateway.Foundation.Rpc;
global using ThingsGateway.Foundation.SerialPorts;
global using ThingsGateway.Foundation.Serial;
global using ThingsGateway.Foundation.Sockets;

View File

@@ -2,6 +2,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net45'">

View File

@@ -15,7 +15,7 @@ namespace ThingsGateway.Foundation.Core
/// <summary>
/// 具有设置配置的对象接口
/// </summary>
public interface ISetupConfigObject : IConfigObject, IPluginObject, IResolverObject
public interface ISetupConfigObject : IConfigObject, IPluginObject
{
/// <summary>
/// 配置设置项
@@ -23,12 +23,5 @@ namespace ThingsGateway.Foundation.Core
/// <param name="config"></param>
/// <exception cref="Exception"></exception>
void Setup(TouchSocketConfig config);
/// <summary>
/// 异步配置设置项
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
Task SetupAsync(TouchSocketConfig config);
}
}

View File

@@ -23,10 +23,10 @@ namespace ThingsGateway.Foundation.Core
public override TouchSocketConfig Config => this.m_config;
/// <inheritdoc/>
public IResolver Resolver { get; private set; }
public IContainer Container { get; private set; }
/// <inheritdoc/>
public IPluginManager PluginManager { get; private set; }
public IPluginsManager PluginsManager { get; private set; }
/// <inheritdoc/>
public void Setup(TouchSocketConfig config)
@@ -40,27 +40,11 @@ namespace ThingsGateway.Foundation.Core
this.BuildConfig(config);
this.PluginManager?.Raise(nameof(ILoadingConfigPlugin.OnLoadingConfig), this, new ConfigEventArgs(config));
this.PluginsManager?.Raise(nameof(ILoadingConfigPlugin.OnLoadingConfig), this, new ConfigEventArgs(config));
this.LoadConfig(this.Config);
this.PluginManager?.Raise(nameof(ILoadedConfigPlugin.OnLoadedConfig), this, new ConfigEventArgs(config));
this.PluginsManager?.Raise(nameof(ILoadedConfigPlugin.OnLoadedConfig), this, new ConfigEventArgs(config));
}
/// <inheritdoc/>
public async Task SetupAsync(TouchSocketConfig config)
{
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
this.ThrowIfDisposed();
this.BuildConfig(config);
await this.PluginManager.RaiseAsync(nameof(ILoadingConfigPlugin.OnLoadingConfig), this, new ConfigEventArgs(config)).ConfigureFalseAwait();
this.LoadConfig(config);
//return EasyTask.CompletedTask;
await this.PluginManager.RaiseAsync(nameof(ILoadedConfigPlugin.OnLoadedConfig), this, new ConfigEventArgs(config)).ConfigureFalseAwait();
}
/// <summary>
/// 加载配置
/// </summary>
@@ -72,48 +56,47 @@ namespace ThingsGateway.Foundation.Core
private void BuildConfig(TouchSocketConfig config)
{
this.m_config = config ?? throw new ArgumentNullException(nameof(config));
this.m_config = config;
if (!config.TryGetValue(TouchSocketCoreConfigExtension.ResolverProperty, out var resolver))
if (!config.TryGetValue(TouchSocketCoreConfigExtension.ContainerProperty, out var container))
{
if (!config.TryGetValue(TouchSocketCoreConfigExtension.RegistratorProperty, out var registrator))
{
registrator = new Container();
}
if (!registrator.IsRegistered(typeof(ILog)))
{
registrator.RegisterSingleton<ILog>(new LoggerGroup());
}
if (config.GetValue(TouchSocketCoreConfigExtension.ConfigureContainerProperty) is Action<IRegistrator> actionContainer)
{
actionContainer.Invoke(registrator);
}
resolver = registrator.BuildResolver();
container = new Container();
}
IPluginManager pluginManager;
if ((!this.Config.GetValue(TouchSocketCoreConfigExtension.NewPluginManagerProperty)) && resolver.IsRegistered<IPluginManager>())
if (!container.IsRegistered(typeof(ILog)))
{
pluginManager = resolver.Resolve<IPluginManager>();
container.RegisterSingleton<ILog, LoggerGroup>();
}
if (!(config.GetValue(TouchSocketCoreConfigExtension.PluginsManagerProperty) is IPluginsManager pluginsManager))
{
pluginsManager = new PluginsManager(container);
}
if (container.IsRegistered(typeof(IPluginsManager)))
{
pluginsManager = container.Resolve<IPluginsManager>();
}
else
{
pluginManager = new PluginManager(resolver);
container.RegisterSingleton<IPluginsManager>(pluginsManager);
}
if (this.Config.GetValue(TouchSocketCoreConfigExtension.ConfigurePluginsProperty) is Action<IPluginManager> actionPluginManager)
if (config.GetValue(TouchSocketCoreConfigExtension.ConfigureContainerProperty) is Action<IContainer> actionContainer)
{
pluginManager.Enable = true;
actionPluginManager.Invoke(pluginManager);
actionContainer.Invoke(container);
}
this.Logger ??= resolver.Resolve<ILog>();
if (config.GetValue(TouchSocketCoreConfigExtension.ConfigurePluginsProperty) is Action<IPluginsManager> actionPluginsManager)
{
pluginsManager.Enable = true;
actionPluginsManager.Invoke(pluginsManager);
}
this.PluginManager = pluginManager;
this.Resolver = resolver;
this.Logger ??= container.Resolve<ILog>();
this.Container = container;
this.PluginsManager = pluginsManager;
}
}
}

View File

@@ -35,14 +35,14 @@ namespace ThingsGateway.Foundation.Core
/// <summary>
/// 配置插件。
/// </summary>
public static readonly DependencyProperty<Action<IPluginManager>> ConfigurePluginsProperty =
DependencyProperty<Action<IPluginManager>>.Register("ConfigurePlugins", null);
public static readonly DependencyProperty<Action<IPluginsManager>> ConfigurePluginsProperty =
DependencyProperty<Action<IPluginsManager>>.Register("ConfigurePlugins", null);
/// <summary>
/// 是否使用新插件管理器。
/// 容器
/// </summary>
public static readonly DependencyProperty<bool> NewPluginManagerProperty =
DependencyProperty<bool>.Register("NewPluginManager", false);
public static readonly DependencyProperty<IPluginsManager> PluginsManagerProperty =
DependencyProperty<IPluginsManager>.Register("PluginsManager", null);
/// <summary>
/// 配置插件。
@@ -50,7 +50,7 @@ namespace ThingsGateway.Foundation.Core
/// <param name="config"></param>
/// <param name="value"></param>
/// <returns></returns>
public static TouchSocketConfig ConfigurePlugins(this TouchSocketConfig config, Action<IPluginManager> value)
public static TouchSocketConfig ConfigurePlugins(this TouchSocketConfig config, Action<IPluginsManager> value)
{
if (config.TryGetValue(ConfigurePluginsProperty, out var action))
{
@@ -64,19 +64,15 @@ namespace ThingsGateway.Foundation.Core
return config;
}
/// <summary>
/// 使用新的插件管理器
/// <para>
/// 一般的,当在容器<see cref="IContainer"/>中注入<see cref="IPluginManager"/>时。会使用容器中的<see cref="IPluginManager"/>。
/// 但是有时候,我们希望个别配置能够独立使用插件管理器。所以可以使用此配置。
/// </para>
/// 使用插件
/// </summary>
/// <param name="config"></param>
/// <param name="value"></param>
/// <returns></returns>
public static TouchSocketConfig UseNewPluginManager(this TouchSocketConfig config)
public static TouchSocketConfig SetPluginsManager(this TouchSocketConfig config, IPluginsManager value)
{
config.SetValue(NewPluginManagerProperty, true);
config.SetValue(PluginsManagerProperty, value);
return config;
}
@@ -87,21 +83,14 @@ namespace ThingsGateway.Foundation.Core
/// <summary>
/// 配置容器注入。
/// </summary>
public static readonly DependencyProperty<Action<IRegistrator>> ConfigureContainerProperty =
DependencyProperty<Action<IRegistrator>>.Register("ConfigureContainer", null);
public static readonly DependencyProperty<Action<IContainer>> ConfigureContainerProperty =
DependencyProperty<Action<IContainer>>.Register("ConfigureContainer", null);
/// <summary>
/// 容器注册
/// 容器
/// </summary>
public static readonly DependencyProperty<IRegistrator> RegistratorProperty =
DependencyProperty<IRegistrator>.Register("Registrator", null);
/// <summary>
/// 容器提供者
/// </summary>
public static readonly DependencyProperty<IResolver> ResolverProperty =
DependencyProperty<IResolver>.Register("Resolver", null);
public static readonly DependencyProperty<IContainer> ContainerProperty =
DependencyProperty<IContainer>.Register("Container", null);
/// <summary>
/// 配置容器注入。
@@ -109,7 +98,7 @@ namespace ThingsGateway.Foundation.Core
/// <param name="config"></param>
/// <param name="value"></param>
/// <returns></returns>
public static TouchSocketConfig ConfigureContainer(this TouchSocketConfig config, Action<IRegistrator> value)
public static TouchSocketConfig ConfigureContainer(this TouchSocketConfig config, Action<IContainer> value)
{
if (config.TryGetValue(ConfigureContainerProperty, out var action))
{
@@ -123,28 +112,15 @@ namespace ThingsGateway.Foundation.Core
return config;
}
/// <summary>
/// 设置<see cref="IResolver"/>
/// 设置容器。
/// </summary>
/// <param name="config"></param>
/// <param name="value"></param>
/// <returns></returns>
public static TouchSocketConfig SetResolver(this TouchSocketConfig config, IResolver value)
public static TouchSocketConfig SetContainer(this TouchSocketConfig config, IContainer value)
{
config.SetValue(ResolverProperty, value);
return config;
}
/// <summary>
/// 设置<see cref="IRegistrator"/>
/// </summary>
/// <param name="config"></param>
/// <param name="value"></param>
/// <returns></returns>
public static TouchSocketConfig SetRegistrator(this TouchSocketConfig config, IRegistrator value)
{
config.SetValue(RegistratorProperty, value);
config.SetValue(ContainerProperty, value);
return config;
}

View File

@@ -1,735 +0,0 @@
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在XREF结尾的命名空间的代码归作者本人若汝棋茗所有
// 源代码使用协议遵循本仓库的开源协议及附加协议若本仓库没有设置则按MIT开源协议授权
// CSDN博客https://blog.csdn.net/qq_40374647
// 哔哩哔哩视频https://space.bilibili.com/94253567
// Gitee源代码仓库https://gitee.com/RRQM_Home
// Github源代码仓库https://github.com/RRQM
// API首页http://rrqm_home.gitee.io/touchsocket/
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// 此代码版权除特别声明或在XREF结尾的命名空间的代码归作者本人若汝棋茗所有
// 源代码使用协议遵循本仓库的开源协议及附加协议若本仓库没有设置则按MIT开源协议授权
// CSDN博客https://blog.csdn.net/qq_40374647
// 哔哩哔哩视频https://space.bilibili.com/94253567
// Gitee源代码仓库https://gitee.com/RRQM_Home
// Github源代码仓库https://github.com/RRQM
// API首页http://rrqm_home.gitee.io/touchsocket/
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
using System.Data;
using System.Reflection;
namespace ThingsGateway.Foundation.Core
{
/// <summary>
/// ContainerExtension
/// </summary>
public static class ContainerExtension
{
#region RegisterSingleton
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTo"></typeparam>
/// <param name="registrator"></param>
/// <param name="instance"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom, TTo>(this IRegistrator registrator, TTo instance)
where TFrom : class
where TTo : class, TFrom
{
RegisterSingleton(registrator, typeof(TFrom), instance);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="instance"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, object instance)
{
if (instance is null)
{
throw new ArgumentNullException(nameof(instance));
}
RegisterSingleton(registrator, instance.GetType(), instance);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, Type fromType)
{
if (fromType is null)
{
throw new ArgumentNullException(nameof(fromType));
}
RegisterSingleton(registrator, fromType, fromType);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTo"></typeparam>
/// <param name="registrator"></param>
/// <param name="key"></param>
/// <param name="instance"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom, TTo>(this IRegistrator registrator, string key, TTo instance)
where TFrom : class
where TTo : class, TFrom
{
RegisterSingleton(registrator, typeof(TFrom), instance, key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="instance"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, Type fromType, object instance, string key)
{
registrator.Register(new DependencyDescriptor(fromType, instance), key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="instance"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, Type fromType, object instance)
{
registrator.Register(new DependencyDescriptor(fromType, instance));
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <param name="registrator"></param>
/// <param name="instance"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom>(this IRegistrator registrator, object instance, string key)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), instance), key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <param name="registrator"></param>
/// <param name="instance"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom>(this IRegistrator registrator, object instance)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), instance));
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="instance"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, object instance, string key)
{
registrator.Register(new DependencyDescriptor(instance.GetType(), instance), key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <param name="registrator"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom>(this IRegistrator registrator)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), typeof(TFrom), Lifetime.Singleton));
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <param name="registrator"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom>(this IRegistrator registrator, string key)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), typeof(TFrom), Lifetime.Singleton), key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="toType"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, Type fromType, Type toType)
{
registrator.Register(new DependencyDescriptor(fromType, toType, Lifetime.Singleton));
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="toType"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, Type fromType, Type toType, string key)
{
registrator.Register(new DependencyDescriptor(fromType, toType, Lifetime.Singleton), key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="func"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom>(this IRegistrator registrator, Func<IResolver, object> func)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), Lifetime.Singleton)
{
ImplementationFactory = func
});
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="func"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom>(this IRegistrator registrator, Func<IResolver, object> func, string key)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), Lifetime.Singleton)
{
ImplementationFactory = func
}, key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="func"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, Type fromType, Func<IResolver, object> func)
{
registrator.Register(new DependencyDescriptor(fromType, Lifetime.Singleton)
{
ImplementationFactory = func
});
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="func"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton(this IRegistrator registrator, Type fromType, Func<IResolver, object> func, string key)
{
registrator.Register(new DependencyDescriptor(fromType, Lifetime.Singleton)
{
ImplementationFactory = func
}, key);
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTO"></typeparam>
/// <param name="registrator"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom, TTO>(this IRegistrator registrator)
where TFrom : class
where TTO : class, TFrom
{
RegisterSingleton(registrator, typeof(TFrom), typeof(TTO));
return registrator;
}
/// <summary>
/// 注册单例
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTO"></typeparam>
/// <param name="registrator"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterSingleton<TFrom, TTO>(this IRegistrator registrator, string key)
where TFrom : class
where TTO : class, TFrom
{
RegisterSingleton(registrator, typeof(TFrom), typeof(TTO), key);
return registrator;
}
#endregion RegisterSingleton
#region Transient
/// <summary>
/// 注册临时映射
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTO"></typeparam>
/// <param name="registrator"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient<TFrom, TTO>(this IRegistrator registrator)
where TFrom : class
where TTO : class, TFrom
{
RegisterTransient(registrator, typeof(TFrom), typeof(TTO));
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <param name="registrator"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient<TFrom>(this IRegistrator registrator)
where TFrom : class
{
RegisterTransient(registrator, typeof(TFrom), typeof(TFrom));
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <param name="registrator"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient<TFrom>(this IRegistrator registrator, string key)
where TFrom : class
{
RegisterTransient(registrator, typeof(TFrom), typeof(TFrom), key);
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTO"></typeparam>
/// <param name="registrator"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient<TFrom, TTO>(this IRegistrator registrator, string key)
where TFrom : class
where TTO : class, TFrom
{
RegisterTransient(registrator, typeof(TFrom), typeof(TTO), key);
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient(this IRegistrator registrator, Type fromType)
{
RegisterTransient(registrator, fromType, fromType);
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient(this IRegistrator registrator, Type fromType, string key)
{
RegisterTransient(registrator, fromType, fromType, key);
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="toType"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient(this IRegistrator registrator, Type fromType, Type toType)
{
registrator.Register(new DependencyDescriptor(fromType, toType, Lifetime.Transient));
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="toType"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient(this IRegistrator registrator, Type fromType, Type toType, string key)
{
registrator.Register(new DependencyDescriptor(fromType, toType, Lifetime.Transient), key);
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="func"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient<TFrom>(this IRegistrator registrator, Func<IResolver, object> func)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), Lifetime.Transient)
{
ImplementationFactory = func
});
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="func"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient<TFrom>(this IRegistrator registrator, Func<IResolver, object> func, string key)
{
registrator.Register(new DependencyDescriptor(typeof(TFrom), Lifetime.Transient)
{
ImplementationFactory = func
}, key);
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="func"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient(this IRegistrator registrator, Type fromType, Func<IResolver, object> func)
{
registrator.Register(new DependencyDescriptor(fromType, Lifetime.Transient)
{
ImplementationFactory = func
});
return registrator;
}
/// <summary>
/// 注册临时映射
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="func"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator RegisterTransient(this IRegistrator registrator, Type fromType, Func<IResolver, object> func, string key)
{
registrator.Register(new DependencyDescriptor(fromType, Lifetime.Transient)
{
ImplementationFactory = func
}, key);
return registrator;
}
#endregion Transient
#region Unregister
/// <summary>
/// 移除注册信息
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <returns></returns>
public static IRegistrator Unregister(this IRegistrator registrator, Type fromType)
{
registrator.Unregister(new DependencyDescriptor(fromType));
return registrator;
}
/// <summary>
/// 移除注册信息
/// </summary>
/// <param name="registrator"></param>
/// <param name="fromType"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator Unregister(this IRegistrator registrator, Type fromType, string key)
{
registrator.Unregister(new DependencyDescriptor(fromType), key);
return registrator;
}
/// <summary>
/// 移除注册信息
/// </summary>
/// <param name="registrator"></param>
/// <returns></returns>
public static IRegistrator Unregister<TFrom>(this IRegistrator registrator)
{
registrator.Unregister(new DependencyDescriptor(typeof(TFrom)));
return registrator;
}
/// <summary>
/// 移除注册信息
/// </summary>
/// <param name="registrator"></param>
/// <param name="key"></param>
/// <returns></returns>
public static IRegistrator Unregister<TFrom>(this IRegistrator registrator, string key)
{
registrator.Unregister(new DependencyDescriptor(typeof(TFrom)), key);
return registrator;
}
#endregion Unregister
#region Resolve
/// <summary>
/// 创建类型对应的实例
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="resolver"></param>
/// <returns></returns>
public static T Resolve<T>(this IResolver resolver)
{
return (T)resolver.Resolve(typeof(T));
}
/// <summary>
/// 创建类型对应的实例
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="resolver"></param>
/// <param name="key"></param>
/// <returns></returns>
public static T Resolve<T>(this IResolver resolver, string key)
{
return (T)resolver.Resolve(typeof(T), key);
}
/// <summary>
/// 创建<see cref="Lifetime.Transient"/>生命的未注册的根类型实例。一般适用于:目标类型没有注册,但是其成员类型已经注册的情况。
/// </summary>
/// <param name="resolver"></param>
/// <param name="fromType"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static object ResolveWithoutRoot(this IResolver resolver, Type fromType)
{
object[] ops = null;
var ctor = fromType.GetConstructors().FirstOrDefault(x => x.IsDefined(typeof(DependencyInjectAttribute), true));
if (ctor is null)
{
//如果没有被特性标记,那就取构造函数参数最多的作为注入目标
if (fromType.GetConstructors().Length == 0)
{
throw new Exception($"没有找到类型{fromType.FullName}的公共构造函数。");
}
ctor = fromType.GetConstructors().OrderByDescending(x => x.GetParameters().Length).First();
}
DependencyTypeAttribute dependencyTypeAttribute = null;
if (fromType.IsDefined(typeof(DependencyTypeAttribute), true))
{
dependencyTypeAttribute = fromType.GetCustomAttribute<DependencyTypeAttribute>();
}
var parameters = ctor.GetParameters();
var ps = new object[parameters.Length];
if (dependencyTypeAttribute == null || dependencyTypeAttribute.Type.HasFlag(DependencyType.Constructor))
{
for (var i = 0; i < parameters.Length; i++)
{
if (ops != null && ops.Length - 1 >= i)
{
ps[i] = ops[i];
}
else
{
if (parameters[i].ParameterType.IsPrimitive || parameters[i].ParameterType == typeof(string))
{
ps[i] = parameters[i].HasDefaultValue ? parameters[i].DefaultValue : default;
}
else
{
if (parameters[i].IsDefined(typeof(DependencyInjectAttribute), true))
{
var attribute = parameters[i].GetCustomAttribute<DependencyInjectAttribute>();
var type = attribute.Type ?? parameters[i].ParameterType;
ps[i] = resolver.Resolve(type, attribute.Key);
}
else
{
ps[i] = resolver.Resolve(parameters[i].ParameterType);
}
}
}
}
}
if (ps == null || ps.Length == 0)
{
return Activator.CreateInstance(fromType);
}
return Activator.CreateInstance(fromType, ps);
}
/// <summary>
/// 创建<see cref="Lifetime.Transient"/>生命的未注册的根类型实例。一般适用于:目标类型没有注册,但是其成员类型已经注册的情况。
/// </summary>
/// <param name="resolver"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static T ResolveWithoutRoot<T>(this IResolver resolver)
{
return (T)ResolveWithoutRoot(resolver, typeof(T));
}
/// <summary>
/// 尝试创建类型对应的实例如果类型没有注册则会返回null或者默认值类型。
/// </summary>
/// <param name="resolver"></param>
/// <param name="fromType"></param>
/// <returns></returns>
public static object TryResolve(this IResolver resolver, Type fromType)
{
if (resolver.IsRegistered(fromType))
{
return resolver.Resolve(fromType);
}
return default;
}
/// <summary>
/// 尝试创建类型对应的实例如果类型没有注册则会返回null或者默认值类型。
/// </summary>
/// <param name="resolver"></param>
/// <param name="fromType"></param>
/// <param name="key"></param>
/// <returns></returns>
public static object TryResolve(this IResolver resolver, Type fromType, string key)
{
if (resolver.IsRegistered(fromType))
{
return resolver.Resolve(fromType, key);
}
return default;
}
/// <summary>
/// 尝试创建类型对应的实例如果类型没有注册则会返回null或者默认值类型。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="resolver"></param>
/// <returns></returns>
public static T TryResolve<T>(this IResolver resolver)
{
return (T)TryResolve(resolver, typeof(T));
}
/// <summary>
/// 尝试创建类型对应的实例如果类型没有注册则会返回null或者默认值类型。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="resolver"></param>
/// <param name="key"></param>
/// <returns></returns>
public static T TryResolve<T>(this IResolver resolver, string key)
{
return (T)TryResolve(resolver, typeof(T), key);
}
#endregion Resolve
#region IsRegistered
/// <summary>
/// <inheritdoc cref="IRegistered.IsRegistered(Type)"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="registered"></param>
/// <returns></returns>
public static bool IsRegistered<T>(this IRegistered registered)
{
return registered.IsRegistered(typeof(T));
}
/// <summary>
/// <inheritdoc cref="IRegistered.IsRegistered(Type, string)"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="registered"></param>
/// <param name="key"></param>
/// <returns></returns>
public static bool IsRegistered<T>(this IRegistered registered, string key)
{
return registered.IsRegistered(typeof(T), key);
}
#endregion
}
}

Some files were not shown because too many files have changed in this diff Show More