Compare commits
334 Commits
10.11.99.0
...
1.7.2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8ad693f717 | ||
![]() |
f4c2ee7cc4 | ||
![]() |
6043441faa | ||
![]() |
4a065c3710 | ||
![]() |
0ef800bdd7 | ||
![]() |
56eaa1910d | ||
![]() |
201788e286 | ||
![]() |
506e0f144f | ||
![]() |
72f68bfdd9 | ||
![]() |
2f9869b11d | ||
![]() |
8ffcf6498c | ||
![]() |
d224ae1923 | ||
![]() |
fed2063a19 | ||
![]() |
db2810cdd7 | ||
![]() |
4f1a6781ef | ||
![]() |
beffa5d5a4 | ||
![]() |
7a20f1de07 | ||
![]() |
cd25cf726b | ||
![]() |
d6b1bc3842 | ||
![]() |
a4385fb9bb | ||
![]() |
7045f2b8ea | ||
![]() |
07ca1a4de8 | ||
![]() |
24f289e692 | ||
![]() |
01bcdaae2d | ||
![]() |
55890008d1 | ||
![]() |
5ab9b01879 | ||
![]() |
e4abb333b3 | ||
![]() |
09f476c745 | ||
![]() |
8806e68dce | ||
![]() |
2ef1e25cd8 | ||
![]() |
10e7f202aa | ||
![]() |
ccd7000c09 | ||
![]() |
8ee7b798cf | ||
![]() |
7733cf5bf0 | ||
![]() |
a05ce86dd7 | ||
![]() |
91f51c32e8 | ||
![]() |
f910202bba | ||
![]() |
6d77194a8f | ||
![]() |
9deb89c15f | ||
![]() |
4b62a092b4 | ||
![]() |
81c8f626f9 | ||
![]() |
3e846c42fb | ||
![]() |
63ad7fd766 | ||
![]() |
9ff1e9aa34 | ||
![]() |
8d162b6f3d | ||
![]() |
9844d10bef | ||
![]() |
b908fa8489 | ||
![]() |
15a10643a7 | ||
![]() |
299617aca1 | ||
![]() |
45647d697a | ||
![]() |
48f5105d38 | ||
![]() |
fe1c741d68 | ||
![]() |
fa42cc1f00 | ||
![]() |
42cf5e7a81 | ||
![]() |
47905e1aa1 | ||
![]() |
9a8e907df3 | ||
![]() |
106fe85582 | ||
![]() |
4b3571bd57 | ||
![]() |
96b537401a | ||
![]() |
721c9eb057 | ||
![]() |
51701bf6d6 | ||
![]() |
dbde68bd56 | ||
![]() |
ad2c9f585a | ||
![]() |
562093c468 | ||
![]() |
b0295584a3 | ||
![]() |
208c54de98 | ||
![]() |
63e2d941a1 | ||
![]() |
3956838e9c | ||
![]() |
abeee58bb0 | ||
![]() |
d5b1b49722 | ||
![]() |
564ed03ff8 | ||
![]() |
70db4c76b4 | ||
![]() |
d059f7975b | ||
![]() |
4e74e6dc2d | ||
![]() |
b6deb96658 | ||
![]() |
3839e966be | ||
![]() |
3dd035849c | ||
![]() |
3d6532b5d6 | ||
![]() |
bf7c175ee7 | ||
![]() |
f84af35ed6 | ||
![]() |
99063b3eb1 | ||
![]() |
3bec18f28d | ||
![]() |
15de7a7894 | ||
![]() |
e20e04e677 | ||
![]() |
5fc6ae2835 | ||
![]() |
7d281b8c96 | ||
![]() |
4880b801a7 | ||
![]() |
74e354456a | ||
![]() |
af2e03aa36 | ||
![]() |
d8fa660ab6 | ||
![]() |
1a62d48297 | ||
![]() |
7ba01be13d | ||
![]() |
1a83d64db7 | ||
![]() |
5b53014c40 | ||
![]() |
83685340af | ||
![]() |
31e0cc4dec | ||
![]() |
56b87fc1f5 | ||
![]() |
6b956a2dd7 | ||
![]() |
1937623d7d | ||
![]() |
3b60b10945 | ||
![]() |
7173acd350 | ||
![]() |
6310d87338 | ||
![]() |
49a1ed7c18 | ||
![]() |
d426e280d9 | ||
![]() |
6154fb29f1 | ||
![]() |
97d48ef9d6 | ||
![]() |
88992625c4 | ||
![]() |
bc6eb44218 | ||
![]() |
cf9ccd799d | ||
![]() |
ffa0e4e771 | ||
![]() |
60fa9c196c | ||
![]() |
df860d22fb | ||
![]() |
cb46ff326c | ||
![]() |
f277a853ef | ||
![]() |
9ae34f67c3 | ||
![]() |
c9223218cc | ||
![]() |
c0dd645aba | ||
![]() |
2e948eb5b6 | ||
![]() |
c3276889cf | ||
![]() |
a76ca8282d | ||
![]() |
8ce6b8362f | ||
![]() |
842fb12f05 | ||
![]() |
d63e1511af | ||
![]() |
278783b8e0 | ||
![]() |
d24e3c922d | ||
![]() |
1d02cd2283 | ||
![]() |
8edeb82a87 | ||
![]() |
146e9279de | ||
![]() |
47105f50a9 | ||
![]() |
16c9c80f37 | ||
![]() |
8e7e4bc95a | ||
![]() |
0aa3d2f930 | ||
![]() |
ce77755a1e | ||
![]() |
0f31f20c87 | ||
![]() |
ee6da2aaa5 | ||
![]() |
a35f087cd9 | ||
![]() |
6e029b44dd | ||
![]() |
973c0cff34 | ||
![]() |
2027eea6ac | ||
![]() |
2f43692f33 | ||
![]() |
6d24992f88 | ||
![]() |
b4388a58d6 | ||
![]() |
158aa05fac | ||
![]() |
f2731bf55e | ||
![]() |
7304e99fce | ||
![]() |
02700b83eb | ||
![]() |
676b25acf9 | ||
![]() |
556359ea2d | ||
![]() |
b72923e0f5 | ||
![]() |
115ac9f75e | ||
![]() |
32e36f6708 | ||
![]() |
d949b7a4f9 | ||
![]() |
eae1171ff5 | ||
![]() |
76a1b75a51 | ||
![]() |
8882c0daea | ||
![]() |
07ebc16d59 | ||
![]() |
0ceb109964 | ||
![]() |
118b0d0038 | ||
![]() |
5e87067792 | ||
![]() |
c946a252e8 | ||
![]() |
f9ad2ba1dd | ||
![]() |
0d0ecd33bd | ||
![]() |
e4b98fd05b | ||
![]() |
95a5933303 | ||
![]() |
da3b55fa64 | ||
![]() |
fbbabfb90e | ||
![]() |
f13da6830d | ||
![]() |
f560a8e2f8 | ||
![]() |
56f1139c2f | ||
![]() |
773bdfc1e2 | ||
![]() |
f449666628 | ||
![]() |
3f282de0ab | ||
![]() |
440dd8d22f | ||
![]() |
dcff9de2f7 | ||
![]() |
a192866543 | ||
![]() |
10081416de | ||
![]() |
e2bed618f9 | ||
![]() |
03ab1f3823 | ||
![]() |
ac8aeb63d9 | ||
![]() |
2e16d822fa | ||
![]() |
e407d873fa | ||
![]() |
fd712a1dbe | ||
![]() |
e9028b40ce | ||
![]() |
c9da3dee7c | ||
![]() |
c8c224e202 | ||
![]() |
f34559daaf | ||
![]() |
9fefbf4c27 | ||
![]() |
1af9fd73ea | ||
![]() |
75ef394eff | ||
![]() |
ec6cc2c63e | ||
![]() |
06bc2e192b | ||
![]() |
78701ec7c1 | ||
![]() |
c925fab7e4 | ||
![]() |
42fd72c164 | ||
![]() |
7fd160e1a2 | ||
![]() |
97a0d940eb | ||
![]() |
efaa099d81 | ||
![]() |
47864a804b | ||
![]() |
91136c0e43 | ||
![]() |
28c3b1bd61 | ||
![]() |
551352bc40 | ||
![]() |
e73c24c925 | ||
![]() |
7ec4c286cc | ||
![]() |
6705e2ec4b | ||
![]() |
6f0373063b | ||
![]() |
f64eef60b5 | ||
![]() |
89546bf86b | ||
![]() |
793678feca | ||
![]() |
923cc3019a | ||
![]() |
10eb98a5f6 | ||
![]() |
bd9e89d8dd | ||
![]() |
1926b4ce73 | ||
![]() |
4ef3062d74 | ||
![]() |
abb6e0f60f | ||
![]() |
f204d8d84e | ||
![]() |
fa301656f1 | ||
![]() |
7e1221028f | ||
![]() |
41308cb2dd | ||
![]() |
130600521c | ||
![]() |
cd57548a48 | ||
![]() |
efacc99f76 | ||
![]() |
f0d236e172 | ||
![]() |
a8118bd8c6 | ||
![]() |
0e58f2ef53 | ||
![]() |
f4b22b3a0c | ||
![]() |
df5bd281c7 | ||
![]() |
a3f23837ce | ||
![]() |
612d989b97 | ||
![]() |
42c01ee9a2 | ||
![]() |
14074db591 | ||
![]() |
43dfdd7942 | ||
![]() |
f397b97ccf | ||
![]() |
95f8716144 | ||
![]() |
17ba472b2e | ||
![]() |
42d82571ab | ||
![]() |
9119a28141 | ||
![]() |
a32263d838 | ||
![]() |
208ae2bb88 | ||
![]() |
4d85462a85 | ||
![]() |
f601aa9ca0 | ||
![]() |
8aee3ad455 | ||
![]() |
6a2a1e9561 | ||
![]() |
5f8786c9dc | ||
![]() |
73f1d3eead | ||
![]() |
2bf21bb3c3 | ||
![]() |
f80f0dbb11 | ||
![]() |
37518c70c4 | ||
![]() |
e5951b5bef | ||
![]() |
ab320bd90b | ||
![]() |
7bd36b5371 | ||
![]() |
b882b0f2bc | ||
![]() |
38d7ae73cc | ||
![]() |
4527c6ee5d | ||
![]() |
85829e70c1 | ||
![]() |
256c08d82a | ||
![]() |
c2ce03c047 | ||
![]() |
f2af19e198 | ||
![]() |
930b7c092d | ||
![]() |
00757c69c6 | ||
![]() |
55f267d0fc | ||
![]() |
6b96aff6e8 | ||
![]() |
32b773a8fa | ||
![]() |
03089adad6 | ||
![]() |
4a1fe746ab | ||
![]() |
aa52c05d2c | ||
![]() |
26407a43e7 | ||
![]() |
a02934bf19 | ||
![]() |
09c65fba09 | ||
![]() |
4305c727d0 | ||
![]() |
188339897f | ||
![]() |
4ecff9a707 | ||
![]() |
355aed49c6 | ||
![]() |
4717b6b0f0 | ||
![]() |
45ebe9048d | ||
![]() |
b2170c49a3 | ||
![]() |
dc2f4d6115 | ||
![]() |
1eb132440f | ||
![]() |
a464bbc37a | ||
![]() |
ed995697c2 | ||
![]() |
163cd84c7b | ||
![]() |
293d7cc292 | ||
![]() |
5de1b4e74c | ||
![]() |
7b474975da | ||
![]() |
beab51516b | ||
![]() |
fe8685a50c | ||
![]() |
f9af5d0885 | ||
![]() |
e8136a9720 | ||
![]() |
531e5d4556 | ||
![]() |
e66255963a | ||
![]() |
246aac8ee4 | ||
![]() |
23cfeff685 | ||
![]() |
a5e7e0d126 | ||
![]() |
5bebc30ba0 | ||
![]() |
0e7057f5b9 | ||
![]() |
7c6c365ba4 | ||
![]() |
424c9bb0c5 | ||
![]() |
9d0f26594c | ||
![]() |
99c17de079 | ||
![]() |
b1e3dd0af6 | ||
![]() |
261cb89530 | ||
![]() |
ff6773ba37 | ||
![]() |
bdfbbfcbbd | ||
![]() |
0c4cd56758 | ||
![]() |
4a36658321 | ||
![]() |
7aae938685 | ||
![]() |
3723401e7a | ||
![]() |
70631366a9 | ||
![]() |
0e40bbda3e | ||
![]() |
e9aa475398 | ||
![]() |
8d2a811184 | ||
![]() |
dd7f5b6700 | ||
![]() |
a4f6277737 | ||
![]() |
c2bfaacbb7 | ||
![]() |
a17cbfa2d4 | ||
![]() |
fb9a101555 | ||
![]() |
e319cf0200 | ||
![]() |
0a8395ef6a | ||
![]() |
38df5e01be | ||
![]() |
ebd891a868 | ||
![]() |
4ab2395cbe | ||
![]() |
5f1f989fc9 | ||
![]() |
44b709eee3 | ||
![]() |
d0d7726597 | ||
![]() |
054c342aeb | ||
![]() |
c79c33baf7 | ||
![]() |
23b00e35b2 | ||
![]() |
fe51079266 | ||
![]() |
0791b0bbee | ||
![]() |
dbf04c8eeb | ||
![]() |
6204256df8 | ||
![]() |
93cc8c2327 | ||
![]() |
68a2e5bbbc | ||
![]() |
72792153f2 | ||
![]() |
88b6ef1897 |
13
.gitignore
vendored
@@ -362,7 +362,14 @@ MigrationBackup/
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
/src/*Pro*/
|
||||
/src/Plugins/Other
|
||||
/src/ThingsGateway.Web.Server/*.db
|
||||
/src/PluginPro*/
|
||||
/src/*Pro*
|
||||
/src/ThingsGateway.Server/Configuration/GiteeOAuthSettings.json
|
||||
/src/.idea/
|
||||
/src/TestResults*/
|
||||
/src/ThingsGateway.Web.Server/ThingsGateway.db
|
||||
|
||||
/handbook/
|
||||
|
||||
|
||||
/test
|
||||
|
BIN
Image/1.png
Normal file
After Width: | Height: | Size: 135 KiB |
BIN
Image/2.png
Normal file
After Width: | Height: | Size: 125 KiB |
BIN
Image/3.png
Normal file
After Width: | Height: | Size: 217 KiB |
BIN
Image/4.png
Normal file
After Width: | Height: | Size: 119 KiB |
BIN
Image/5.png
Normal file
After Width: | Height: | Size: 189 KiB |
BIN
Image/6.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
Image/7.png
Normal file
After Width: | Height: | Size: 187 KiB |
BIN
Image/8.png
Normal file
After Width: | Height: | Size: 164 KiB |
BIN
Image/9.png
Normal file
After Width: | Height: | Size: 149 KiB |
BIN
Image/gitLogo.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
Image/pay.png
Normal file
After Width: | Height: | Size: 326 KiB |
202
LICENSE
@@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is field.
|
||||
|
||||
4. Cachetribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2023-present Diego
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
201
LICENSE.txt
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
184
README.md
@@ -1,101 +1,131 @@
|
||||
# ThingsGateway
|
||||
|
||||
|
||||
<div align='center'>
|
||||
<img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/gitLogo.png" height=100 />
|
||||
</div>
|
||||
|
||||
## Introduction
|
||||
#### 介绍
|
||||
|
||||
|
||||
A cross-platform, high-performance edge data collection gateway based on net9.
|
||||
|
||||
基于Net6/7+Blazor Server的跨平台边缘采集网关,支持南北端插件式开发,
|
||||
并拥有较完善的北端Rpc权限管理。
|
||||
|
||||
## Documentation
|
||||
[Github地址](https://github.com/kimdiego2098/ThingsGateway)
|
||||
|
||||
|
||||
[Documentation](https://thingsgateway.cn/).
|
||||
|
||||
[NuGet](https://www.nuget.org/packages?q=Tags%3A%22ThingsGateway%22)
|
||||
|
||||
<div >
|
||||
如果对您有帮助,请点击右上角⭐Star关注,感谢支持开源!
|
||||
</div>
|
||||
|
||||
#### 开源说明
|
||||
|
||||
Apache 2.0+[附加协议](https://diego2098.gitee.io/thingsgateway-docs/docs/)
|
||||
|
||||
Apache 2.0 开源协议的核心内容是以保护和尊重原作者的著作权为主要目的。对使用,复制,修改,商用不做过多限制,但必须包含原著的License信息。
|
||||
|
||||
#### 功能亮点
|
||||
|
||||
- Blazor Server架构,开发部署更简单
|
||||
- 采集/上传配置完全支持Excel导入导出
|
||||
- 插件式驱动,方便驱动二次开发
|
||||
- 支持采集通道冗余,上传离线缓存
|
||||
- 时序数据库存储
|
||||
- 实时/历史报警(Sql转储),支持布尔/高低限值
|
||||
|
||||
#### 演示
|
||||
|
||||
http://120.24.62.140:5000/
|
||||
|
||||
默认账户密码:superAdmin 111111
|
||||
|
||||
|
||||
## Demo
|
||||
#### 社区版采集插件
|
||||
> 支持分包解析/订阅
|
||||
- Modbus(Rtu/Tcp/Udp)
|
||||
- OPCDAClient(支持导入节点)
|
||||
- OPCUAClient(支持导入节点,动态类型)
|
||||
- 西门子S7协议
|
||||
|
||||
|
||||
[Demo](https://demo.thingsgateway.cn/)
|
||||
#### 社区版上传插件
|
||||
> 支持Rpc写入
|
||||
- Modbus Server
|
||||
- OPCUA Server (支持历史查询)
|
||||
- Mqtt Server (支持自定义json)
|
||||
- Mqtt Client (支持自定义json)
|
||||
- IotSharp Client (IotSharp网关插件,Rpc待测试)
|
||||
|
||||
|
||||
Account: **SuperAdmin**
|
||||
> 不支持Rpc
|
||||
- RabbitMQ (支持自定义json)
|
||||
- Kafka
|
||||
|
||||
|
||||
Password: **111111**
|
||||
#### nuget
|
||||
|
||||
|
||||
**In the upper-right corner, switch to the IoT Gateway module in the personal popup box**
|
||||
|
||||
## Docker
|
||||
|
||||
```shell
|
||||
|
||||
docker pull registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway
|
||||
|
||||
docker pull registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway_arm64
|
||||
- Modbus库,支持ModbusTcp、ModbusRtu、ModbusRtuOverTcp、ModbusUdp、ModbusServer等
|
||||
``` powershell
|
||||
dotnet add package ThingsGateway.Foundation.Adapter.Modbus
|
||||
```
|
||||
- OPCDA客户端库,支持X64,支持NetCore,支持检测重连
|
||||
``` powershell
|
||||
dotnet add package ThingsGateway.Foundation.Adapter.OPCDA
|
||||
```
|
||||
- OPCUA客户端库
|
||||
``` powershell
|
||||
dotnet add package ThingsGateway.Foundation.Adapter.OPCUA
|
||||
```
|
||||
|
||||
- S7库
|
||||
``` powershell
|
||||
dotnet add package ThingsGateway.Foundation.Adapter.Siemens
|
||||
```
|
||||
|
||||
#### 效果图
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/1.png"/></td>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/2.png"/></td>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/3.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/4.png"/></td>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/5.png"/></td>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/6.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/7.png"/></td>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/8.png"/></td>
|
||||
<td><img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/9.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
### Plugin List
|
||||
#### 文档
|
||||
|
||||
|
||||
使用前请查看Gitee Pages [文档站点](https://diego2098.gitee.io/thingsgateway-docs/)
|
||||
|
||||
#### Data Collection Plugins
|
||||
#### 特别鸣谢
|
||||
- Furion:[https://dotnetchina.gitee.io/furion](https://dotnetchina.gitee.io/furion)
|
||||
- SqlSugar:[https://gitee.com/dotnetchina/SqlSugar](https://gitee.com/dotnetchina/SqlSugar)
|
||||
- Simple.Admin:[https://gitee.com/zxzyjs/SimpleAdmin](https://gitee.com/zxzyjs/SimpleAdmin)
|
||||
- Masa.Blazor:[https://www.masastack.com/blazor](https://www.masastack.com/blazor)
|
||||
- MiniExcel:[https://gitee.com/dotnetchina/MiniExcel](https://gitee.com/dotnetchina/MiniExcel)
|
||||
- TouchSocket:[https://gitee.com/rrqm_home/touchsocket](https://gitee.com/rrqm_home/touchsocket)
|
||||
- IdGenerator:[https://github.com/yitter/idgenerator](https://github.com/yitter/idgenerator)
|
||||
- CodingSeb.ExpressionEvaluator:[https://github.com/codingseb/ExpressionEvaluator](https://github.com/codingseb/ExpressionEvaluator)
|
||||
- Hardware.Info:[https://github.com/Jinjinov/Hardware.Info](https://github.com/Jinjinov/Hardware.Info)
|
||||
- UAParser:[https://github.com/ua-parser/uap-csharp](https://github.com/ua-parser/uap-csharp)
|
||||
- OPCUAWebPlatformUniCT:[https://github.com/OPCUAUniCT/OPCUAWebPlatformUniCT](https://github.com/OPCUAUniCT/OPCUAWebPlatformUniCT)
|
||||
|
||||
#### 补充说明
|
||||
* 使用OPC相关插件时请遵循OPC基金会的授权规则
|
||||
* 使用OPCDA插件时,需安装OPC核心库,[文件地址](https://gitee.com/diego2098/ThingsGateway/attach_files)
|
||||
|
||||
| Plugin Name | Remarks |
|
||||
| ----------- | ------------------------------------------------------------- |
|
||||
| Modbus | Supports Rtu/Tcp message formats, with Serial/Tcp/Udp links |
|
||||
| SiemensS7 | Siemens PLC S7 series |
|
||||
| Dlt6452007 | Supports Serial/Tcp/Udp links |
|
||||
| OpcDaMaster | Compiled for 64-bit |
|
||||
| OpcUaMaster | Supports certificate login, object extension, Json read/write |
|
||||
| Webhook | Webhook |
|
||||
|
||||
|
||||
#### Business Plugins
|
||||
#### 支持作者
|
||||
如果对您有帮助,请点击右上角⭐Star关注,感谢支持开源!
|
||||
|
||||
若希望捐赠项目,请查看以下捐赠码或使用Gitee捐赠功能
|
||||
|
||||
| Plugin Name | Remarks |
|
||||
| ---------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| ModbusSlave | Supports Rtu/Tcp message formats, with Serial/Tcp/Udp links, supports Rpc reverse writing |
|
||||
| OpcUaServer | OpcUa server, supports Rpc reverse writing |
|
||||
| MqttClient | Mqtt client, supports Rpc reverse writing, script-customizable upload content |
|
||||
| MqttServer | Mqtt server, supports WebSocket, supports Rpc reverse writing, script-customizable upload content |
|
||||
| KafkaProducer | Script-customizable upload content |
|
||||
| RabbitMQProducer | Script-customizable upload content |
|
||||
| SqlDB | Relational database storage, supports historical storage and real-time data updates |
|
||||
| SqlHistoryAlarm | Alarm historical data relational database storage |
|
||||
| TDengineDB | Time-series database storage |
|
||||
| QuestDB | Time-series database storage |
|
||||
<img src="https://gitee.com/diego2098/ThingsGateway/raw/master/Image/pay.png" height=180 />
|
||||
|
||||
|
||||
#### 联系作者
|
||||
* QQ群:605534569
|
||||
* 邮箱:2248356998@qq.com
|
||||
|
||||
## License
|
||||
|
||||
|
||||
[License](https://thingsgateway.cn/docs/1)
|
||||
|
||||
|
||||
|
||||
## Sponsorship
|
||||
|
||||
|
||||
[Sponsorship Approach](https://thingsgateway.cn/docs/1000)
|
||||
|
||||
|
||||
## Community
|
||||
|
||||
|
||||
QQ Group: 605534569 [Jump](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=NnBjPO-8kcNFzo_RzSbdICflb97u2O1i&authKey=V1MI3iJtpDMHc08myszP262kDykbx2Yev6ebE4Me0elTe0P0IFAmtU5l7Sy5w0jx&noverify=0&group_code=605534569)
|
||||
|
||||
|
||||
## Pro Plugins
|
||||
|
||||
|
||||
[Plugin List](https://thingsgateway.cn/docs/1001)
|
||||
|
@@ -1,86 +0,0 @@
|
||||
# ThingsGateway
|
||||
|
||||
## 介绍
|
||||
|
||||
基于net9的跨平台高性能边缘采集网关
|
||||
|
||||
## 文档
|
||||
|
||||
[文档](https://thingsgateway.cn/)
|
||||
|
||||
[NuGet](https://www.nuget.org/packages?q=Tags%3A%22ThingsGateway%22)
|
||||
|
||||
|
||||
## 演示
|
||||
|
||||
[ThingsGateway演示地址](https://demo.thingsgateway.cn/)
|
||||
|
||||
账户 : **SuperAdmin**
|
||||
|
||||
密码 : **111111**
|
||||
|
||||
**右上角个人弹出框中,切换到物联网关模块**
|
||||
|
||||
## Docker
|
||||
|
||||
```shell
|
||||
|
||||
docker pull registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway
|
||||
|
||||
docker pull registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway_arm64
|
||||
```
|
||||
|
||||
|
||||
### 插件列表
|
||||
|
||||
#### 采集插件
|
||||
|
||||
|
||||
| 插件名称 | 备注 |
|
||||
| ----------- | ------------------------------------- |
|
||||
| Modbus | Rtu/Tcp报文格式,支持串口/Tcp/Udp链路 |
|
||||
| SiemensS7 | 西门子PLC S7系列 |
|
||||
| Dlt6452007 | 支持串口/Tcp/Udp链路 |
|
||||
| OpcDaMaster | 64位编译 |
|
||||
| OpcUaMaster | 支持证书登录,扩展对象,Json读写 |
|
||||
|
||||
#### 业务插件
|
||||
|
||||
|
||||
| 插件名称 | 备注 |
|
||||
| ---------------- | ---------------------------------------------------------- |
|
||||
| ModbusSlave | Rtu/Tcp报文格式,支持串口/Tcp/Udp链路,支持Rpc反写 |
|
||||
| OpcUaServer | OpcUa服务端,支持Rpc反写 |
|
||||
| MqttClient | Mqtt客户端,支持Rpc反写,脚本自定义上传内容 |
|
||||
| MqttServer | Mqtt服务端,支持WebSocket,支持Rpc反写,脚本自定义上传内容 |
|
||||
| KafkaProducer | 脚本自定义上传内容 |
|
||||
| RabbitMQProducer | 脚本自定义上传内容 |
|
||||
| SqlDB | 关系数据库存储,支持历史存储和实时数据更新 |
|
||||
| SqlHistoryAlarm | 报警历史数据关系数据库存储 |
|
||||
| TDengineDB | 时序数据库存储 |
|
||||
| QuestDB | 时序数据库存储 |
|
||||
| Webhook | Webhook |
|
||||
|
||||
## 协议
|
||||
|
||||
[版权声明](https://thingsgateway.cn/docs/1)
|
||||
|
||||
|
||||
## 赞助
|
||||
|
||||
[赞助途径](https://thingsgateway.cn/docs/1000)
|
||||
|
||||
## 社区
|
||||
|
||||
QQ群:605534569 [跳转](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=NnBjPO-8kcNFzo_RzSbdICflb97u2O1i&authKey=V1MI3iJtpDMHc08myszP262kDykbx2Yev6ebE4Me0elTe0P0IFAmtU5l7Sy5w0jx&noverify=0&group_code=605534569)
|
||||
|
||||
## Pro插件
|
||||
|
||||
[插件列表](https://thingsgateway.cn/docs/1001)
|
||||
|
||||
|
||||
## 特别声明
|
||||
|
||||
ThingsGateway 项目已加入 [dotNET China](https://gitee.com/dotnetchina) 组织。<br/>
|
||||
|
||||

|
@@ -1,133 +0,0 @@
|
||||
root = true
|
||||
|
||||
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
|
||||
###############################
|
||||
# Core EditorConfig Options #
|
||||
###############################
|
||||
|
||||
[*.cs]
|
||||
#### 命名样式 ####
|
||||
|
||||
# 命名规则
|
||||
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
|
||||
|
||||
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
|
||||
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
||||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
||||
|
||||
# 符号规范
|
||||
|
||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.interface.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
|
||||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.types.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||
|
||||
# 命名样式
|
||||
|
||||
dotnet_naming_style.begins_with_i.required_prefix = I
|
||||
dotnet_naming_style.begins_with_i.required_suffix =
|
||||
dotnet_naming_style.begins_with_i.word_separator =
|
||||
dotnet_naming_style.begins_with_i.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.pascal_case.required_prefix =
|
||||
dotnet_naming_style.pascal_case.required_suffix =
|
||||
dotnet_naming_style.pascal_case.word_separator =
|
||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.pascal_case.required_prefix =
|
||||
dotnet_naming_style.pascal_case.required_suffix =
|
||||
dotnet_naming_style.pascal_case.word_separator =
|
||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||
csharp_using_directive_placement = outside_namespace:silent
|
||||
csharp_style_expression_bodied_methods = false:silent
|
||||
csharp_style_expression_bodied_constructors = false:silent
|
||||
csharp_style_expression_bodied_operators = false:silent
|
||||
csharp_style_expression_bodied_properties = true:silent
|
||||
csharp_style_expression_bodied_indexers = true:silent
|
||||
csharp_style_expression_bodied_accessors = true:silent
|
||||
csharp_style_expression_bodied_lambdas = true:silent
|
||||
csharp_style_expression_bodied_local_functions = false:silent
|
||||
csharp_style_conditional_delegate_call = true:suggestion
|
||||
csharp_style_var_for_built_in_types = false:silent
|
||||
csharp_style_var_when_type_is_apparent = false:silent
|
||||
csharp_style_var_elsewhere = false:silent
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
csharp_prefer_braces = true:silent
|
||||
csharp_style_namespace_declarations = block_scoped:silent
|
||||
|
||||
[*.vb]
|
||||
#### 命名样式 ####
|
||||
|
||||
# 命名规则
|
||||
|
||||
dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion
|
||||
dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface
|
||||
dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始
|
||||
|
||||
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion
|
||||
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型
|
||||
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
|
||||
|
||||
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion
|
||||
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员
|
||||
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
|
||||
|
||||
# 符号规范
|
||||
|
||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
|
||||
dotnet_naming_symbols.interface.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum
|
||||
dotnet_naming_symbols.类型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
|
||||
dotnet_naming_symbols.类型.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method
|
||||
dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
|
||||
dotnet_naming_symbols.非字段成员.required_modifiers =
|
||||
|
||||
# 命名样式
|
||||
|
||||
dotnet_naming_style.以_i_开始.required_prefix = I
|
||||
dotnet_naming_style.以_i_开始.required_suffix =
|
||||
dotnet_naming_style.以_i_开始.word_separator =
|
||||
dotnet_naming_style.以_i_开始.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.帕斯卡拼写法.required_prefix =
|
||||
dotnet_naming_style.帕斯卡拼写法.required_suffix =
|
||||
dotnet_naming_style.帕斯卡拼写法.word_separator =
|
||||
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.帕斯卡拼写法.required_prefix =
|
||||
dotnet_naming_style.帕斯卡拼写法.required_suffix =
|
||||
dotnet_naming_style.帕斯卡拼写法.word_separator =
|
||||
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
|
||||
|
||||
file_header_template = ------------------------------------------------------------------------------\n此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充\n此代码版权(除特别声明外的代码)归作者本人Diego所有\n源代码使用协议遵循本仓库的开源协议及附加协议\nGitee源代码仓库:https://gitee.com/diego2098/ThingsGateway\nGithub源代码仓库:https://github.com/kimdiego2098/ThingsGateway\n使用文档:https://thingsgateway.cn/\nQQ群:605534569\n------------------------------------------------------------------------------
|
||||
|
||||
[*.{cs,vb}]
|
||||
end_of_line = crlf
|
||||
dotnet_style_qualification_for_field = false:silent
|
||||
dotnet_style_qualification_for_property = false:silent
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
dotnet_style_qualification_for_event = false:silent
|
||||
|
||||
dotnet_diagnostic.RCS1146.severity = warning
|
||||
dotnet_diagnostic.RCS1059.severity = none
|
||||
dotnet_diagnostic.RCS1138.severity = suggestion
|
||||
|
||||
dotnet_code_quality.CA1822.api_surface = private, internal
|
@@ -1,6 +0,0 @@
|
||||
## Release 1.0
|
||||
|
||||
### New Rules
|
||||
Rule ID | Category | Severity | Notes
|
||||
--------|----------|----------|--------------------
|
||||
TG0001 | Conflict | Error | SetParametersAsyncGenerator
|
@@ -1,32 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
|
||||
<Version>$(SourceGeneratorVersion)</Version>
|
||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
|
||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<!-- 避免 DLL 被打包到 lib/ -->
|
||||
<EnableSourceGenerator>true</EnableSourceGenerator>
|
||||
|
||||
<!-- 可选 -->
|
||||
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(OutputPath)\$(TargetFileName)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" Private="false" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,9 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
@@ -1,440 +0,0 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components;
|
||||
|
||||
[Generator]
|
||||
public sealed partial class SetParametersAsyncGenerator : IIncrementalGenerator
|
||||
{
|
||||
private const string m_DoNotGenerateSetParametersAsyncAttribute = """
|
||||
using System;
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
||||
internal sealed class DoNotGenerateSetParametersAsyncAttribute : Attribute { }
|
||||
}
|
||||
""";
|
||||
|
||||
private const string m_GenerateSetParametersAsyncAttribute = """
|
||||
using System;
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
||||
internal sealed class GenerateSetParametersAsyncAttribute : Attribute
|
||||
{
|
||||
public bool RequireExactMatch { get; set; }
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private const string m_GlobalGenerateSetParametersAsyncAttribute = """
|
||||
using System;
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
|
||||
internal sealed class GlobalGenerateSetParametersAsyncAttribute : Attribute
|
||||
{
|
||||
public bool Enable { get; }
|
||||
public GlobalGenerateSetParametersAsyncAttribute(bool enable = true) { Enable = enable; }
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static readonly DiagnosticDescriptor ParameterNameConflict = new DiagnosticDescriptor(
|
||||
id: "TG0001",
|
||||
title: "Parameter name conflict",
|
||||
messageFormat: "Parameter names are case insensitive. {0} conflicts with {1}.",
|
||||
category: "Conflict",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "Parameter names must be case insensitive to be usable in routes. Rename the parameter to not be in conflict with other parameters.");
|
||||
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
// 注入 attribute 源码
|
||||
context.RegisterPostInitializationOutput(ctx =>
|
||||
{
|
||||
ctx.AddSource("DoNotGenerateSetParametersAsyncAttribute.g.cs", SourceText.From(m_DoNotGenerateSetParametersAsyncAttribute, Encoding.UTF8));
|
||||
ctx.AddSource("GenerateSetParametersAsyncAttribute.g.cs", SourceText.From(m_GenerateSetParametersAsyncAttribute, Encoding.UTF8));
|
||||
ctx.AddSource("GlobalGenerateSetParametersAsyncAttribute.g.cs", SourceText.From(m_GlobalGenerateSetParametersAsyncAttribute, Encoding.UTF8));
|
||||
});
|
||||
|
||||
// 筛选 ClassDeclarationSyntax
|
||||
var classDeclarations = context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
predicate: static (node, _) => node is ClassDeclarationSyntax,
|
||||
transform: static (ctx, _) => (ClassDeclarationSyntax)ctx.Node)
|
||||
.Where(static c => c is not null);
|
||||
|
||||
// 合并 Compilation
|
||||
var compilationProvider = context.CompilationProvider;
|
||||
|
||||
var candidateClasses = classDeclarations.Combine(compilationProvider);
|
||||
|
||||
context.RegisterSourceOutput(candidateClasses, static (spc, tuple) =>
|
||||
{
|
||||
var (classDeclaration, compilation) = tuple;
|
||||
Execute(spc, compilation, classDeclaration);
|
||||
});
|
||||
}
|
||||
|
||||
private static void Execute(SourceProductionContext context, Compilation compilation, ClassDeclarationSyntax classDeclaration)
|
||||
{
|
||||
var model = compilation.GetSemanticModel(classDeclaration.SyntaxTree);
|
||||
var classSymbol = model.GetDeclaredSymbol(classDeclaration);
|
||||
if (classSymbol is null || classSymbol.Name == "_Imports")
|
||||
return;
|
||||
|
||||
var positiveAttr = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.GenerateSetParametersAsyncAttribute");
|
||||
var negativeAttr = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.DoNotGenerateSetParametersAsyncAttribute");
|
||||
|
||||
if (classSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, negativeAttr)))
|
||||
return;
|
||||
|
||||
if (!IsPartial(classSymbol) || !IsComponent(classDeclaration, classSymbol, compilation))
|
||||
return;
|
||||
|
||||
var globalEnable = compilation.Assembly.GetAttributes()
|
||||
.FirstOrDefault(a => a.AttributeClass?.ToDisplayString() == "Microsoft.AspNetCore.Components.GlobalGenerateSetParametersAsyncAttribute")
|
||||
?.ConstructorArguments.FirstOrDefault().Value as bool? ?? false;
|
||||
|
||||
var hasPositive = classSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, positiveAttr));
|
||||
|
||||
if (!globalEnable && !hasPositive)
|
||||
return;
|
||||
|
||||
GenerateSetParametersAsyncMethod(context, classSymbol);
|
||||
}
|
||||
|
||||
private static void GenerateSetParametersAsyncMethod(SourceProductionContext context, INamedTypeSymbol class_symbol)
|
||||
{
|
||||
var force_exact_match = class_symbol.GetAttributes().Any(a => a.NamedArguments.Any(na => na.Key == "RequireExactMatch" && na.Value.Value is bool v && v));
|
||||
var namespaceName = class_symbol.ContainingNamespace.ToDisplayString();
|
||||
var type_kind = class_symbol.TypeKind switch { TypeKind.Class => "class", TypeKind.Interface => "interface", _ => "struct" };
|
||||
var type_parameters = string.Join(", ", class_symbol.TypeArguments.Select(t => t.Name));
|
||||
type_parameters = string.IsNullOrEmpty(type_parameters) ? type_parameters : "<" + type_parameters + ">";
|
||||
context.AddCode(class_symbol.ToDisplayString() + "_override.cs", $@"
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#pragma warning disable CA1849
|
||||
#pragma warning disable CA2007
|
||||
#pragma warning disable CS0162
|
||||
#pragma warning disable CS8632
|
||||
namespace {namespaceName}
|
||||
{{
|
||||
public partial class {class_symbol.Name}{type_parameters}
|
||||
{{
|
||||
private bool _initialized;
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
public override Task SetParametersAsync(ParameterView parameters)
|
||||
{{
|
||||
Dictionary<string,object?> parameterValues = new();
|
||||
foreach (var parameter in parameters)
|
||||
{{
|
||||
if(BlazorImplementation__WriteSingleParameter(parameter.Name, parameter.Value)==false)
|
||||
{{
|
||||
// 如果没有处理参数,则添加到参数列表中
|
||||
parameterValues.Add(parameter.Name, parameter.Value);
|
||||
}}
|
||||
}}
|
||||
|
||||
if(parameterValues.Count > 0)
|
||||
{{
|
||||
parameters.SetParameterProperties(this);
|
||||
}}
|
||||
if (!_initialized)
|
||||
{{
|
||||
_initialized = true;
|
||||
|
||||
return RunInitAndSetParametersAsync();
|
||||
}}
|
||||
else
|
||||
{{
|
||||
return CallOnParametersSetAsync();
|
||||
}}
|
||||
}}
|
||||
|
||||
// We do not want the debugger to consider NavigationExceptions caught by this method as user-unhandled.
|
||||
#if NET9_0_OR_GREATER
|
||||
[System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
|
||||
#endif
|
||||
private async Task RunInitAndSetParametersAsync()
|
||||
{{
|
||||
Task task;
|
||||
|
||||
try
|
||||
{{
|
||||
OnInitialized();
|
||||
task = OnInitializedAsync();
|
||||
}}
|
||||
catch (Exception ex) when (ex is not NavigationException)
|
||||
{{
|
||||
throw;
|
||||
}}
|
||||
|
||||
if (task.Status != TaskStatus.RanToCompletion && task.Status != TaskStatus.Canceled)
|
||||
{{
|
||||
// Call state has changed here so that we render after the sync part of OnInitAsync has run
|
||||
// and wait for it to finish before we continue. If no async work has been done yet, we want
|
||||
// to defer calling StateHasChanged up until the first bit of async code happens or until
|
||||
// the end. Additionally, we want to avoid calling StateHasChanged if no
|
||||
// async work is to be performed.
|
||||
StateHasChanged();
|
||||
|
||||
try
|
||||
{{
|
||||
await task;
|
||||
}}
|
||||
catch // avoiding exception filters for AOT runtime support
|
||||
{{
|
||||
// Ignore exceptions from task cancellations.
|
||||
// Awaiting a canceled task may produce either an OperationCanceledException (if produced as a consequence of
|
||||
// CancellationToken.ThrowIfCancellationRequested()) or a TaskCanceledException (produced as a consequence of awaiting Task.FromCanceled).
|
||||
// It's much easier to check the state of the Task (i.e. Task.IsCanceled) rather than catch two distinct exceptions.
|
||||
if (!task.IsCanceled)
|
||||
{{
|
||||
throw;
|
||||
}}
|
||||
}}
|
||||
|
||||
// Don't call StateHasChanged here. CallOnParametersSetAsync should handle that for us.
|
||||
}}
|
||||
|
||||
await CallOnParametersSetAsync();
|
||||
}}
|
||||
|
||||
// We do not want the debugger to consider NavigationExceptions caught by this method as user-unhandled.
|
||||
#if NET9_0_OR_GREATER
|
||||
[System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
|
||||
#endif
|
||||
private Task CallOnParametersSetAsync()
|
||||
{{
|
||||
Task task;
|
||||
|
||||
try
|
||||
{{
|
||||
OnParametersSet();
|
||||
task = OnParametersSetAsync();
|
||||
}}
|
||||
catch (Exception ex) when (ex is not NavigationException)
|
||||
{{
|
||||
#if NET9_0_OR_GREATER
|
||||
System.Diagnostics.Debugger.BreakForUserUnhandledException(ex);
|
||||
#endif
|
||||
throw;
|
||||
}}
|
||||
|
||||
// If no async work is to be performed, i.e. the task has already ran to completion
|
||||
// or was canceled by the time we got to inspect it, avoid going async and re-invoking
|
||||
// StateHasChanged at the culmination of the async work.
|
||||
var shouldAwaitTask = task.Status != TaskStatus.RanToCompletion &&
|
||||
task.Status != TaskStatus.Canceled;
|
||||
|
||||
// We always call StateHasChanged here as we want to trigger a rerender after OnParametersSet and
|
||||
// the synchronous part of OnParametersSetAsync has run.
|
||||
StateHasChanged();
|
||||
|
||||
return shouldAwaitTask ?
|
||||
CallStateHasChangedOnAsyncCompletion(task) :
|
||||
Task.CompletedTask;
|
||||
}}
|
||||
|
||||
// We do not want the debugger to stop more than once per user-unhandled exception.
|
||||
#if NET9_0_OR_GREATER
|
||||
[System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
|
||||
#endif
|
||||
private async Task CallStateHasChangedOnAsyncCompletion(Task task)
|
||||
{{
|
||||
try
|
||||
{{
|
||||
await task;
|
||||
}}
|
||||
catch // avoiding exception filters for AOT runtime support
|
||||
{{
|
||||
// Ignore exceptions from task cancellations, but don't bother issuing a state change.
|
||||
if (task.IsCanceled)
|
||||
{{
|
||||
return;
|
||||
}}
|
||||
|
||||
throw;
|
||||
}}
|
||||
|
||||
StateHasChanged();
|
||||
}}
|
||||
|
||||
}}
|
||||
}}
|
||||
#pragma warning restore CS8632
|
||||
#pragma warning restore CS0162
|
||||
#pragma warning restore CA2007
|
||||
#pragma warning restore CA1849
|
||||
");
|
||||
var bases = class_symbol.GetTypeHierarchy().Where(t => !SymbolEqualityComparer.Default.Equals(t, class_symbol));
|
||||
var members = class_symbol.GetMembers() // members of the type itself
|
||||
.Concat(bases.SelectMany(t => t.GetMembers().Where(m => m.DeclaredAccessibility != Accessibility.Private))) // plus accessible members of any base
|
||||
.Distinct(SymbolEqualityComparer.Default);
|
||||
var property_symbols = members.OfType<IPropertySymbol>();
|
||||
var writable_property_symbols = property_symbols.Where(ps =>
|
||||
!ps.IsReadOnly || ps.GetAttributes().Any(a =>
|
||||
a.AttributeClass?.Name is "CascadingParameter" or "CascadingParameterAttribute")
|
||||
);
|
||||
|
||||
var parameter_symbols = writable_property_symbols
|
||||
.Where(ps => ps.GetAttributes().Any(a => false
|
||||
|| a.AttributeClass.Name == "Parameter"
|
||||
|| a.AttributeClass.Name == "ParameterAttribute"
|
||||
|| a.AttributeClass.Name == "CascadingParameter"
|
||||
|| a.AttributeClass.Name == "CascadingParameterAttribute"
|
||||
|
||||
));
|
||||
var name_conflicts = parameter_symbols.GroupBy(ps => ps.Name.ToLowerInvariant()).Where(g => g.Count() > 1);
|
||||
foreach (var conflict in name_conflicts)
|
||||
{
|
||||
var key = conflict.Key;
|
||||
var conflicting_parameters = conflict.ToList();
|
||||
foreach (var parameter in conflicting_parameters)
|
||||
{
|
||||
var this_name = parameter.Name;
|
||||
var conflicting_name = conflicting_parameters.Select(p => p.Name).FirstOrDefault(n => n != this_name);
|
||||
foreach (var location in parameter.Locations)
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(ParameterNameConflict, location, this_name, conflicting_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
var all = parameter_symbols.ToList();
|
||||
var catch_all_parameter = parameter_symbols.FirstOrDefault(p =>
|
||||
{
|
||||
var parameter_attr = p.GetAttributes().FirstOrDefault(a => a.AttributeClass!.Name.StartsWith("Parameter"));
|
||||
return parameter_attr?.NamedArguments.Any(n => n.Key == "CaptureUnmatchedValues" && n.Value.Value is bool v && v) == true;
|
||||
});
|
||||
var lower_case_match_cases = parameter_symbols.Except(new[] { catch_all_parameter }).Select(p => $"case \"{p.Name.ToLowerInvariant()}\": this.{p.Name} = ({p.Type.ToDisplayString()}) value; break;");
|
||||
var lower_case_match_default = catch_all_parameter == null ? @"default: {return false;}" : $@"
|
||||
default:
|
||||
{{
|
||||
this.{catch_all_parameter.Name} ??= new System.Collections.Generic.Dictionary<string, object>();
|
||||
var writable_dict = this.{catch_all_parameter.Name};
|
||||
if (!writable_dict.TryAdd(name, value))
|
||||
{{
|
||||
writable_dict[name] = value;
|
||||
}}
|
||||
break;
|
||||
}}";
|
||||
|
||||
var exact_match_cases = parameter_symbols.Except(new[] { catch_all_parameter }).Select(p => $"case \"{p!.Name}\": this.{p.Name} = ({p.Type.ToDisplayString()}) value; break;");
|
||||
string exact_match_default;
|
||||
if (force_exact_match)
|
||||
{
|
||||
if (catch_all_parameter == null) // exact matches are forced, and we do not have a catch-all parameter, therefore we need to throw on unmatched parameter
|
||||
{
|
||||
exact_match_default = @"default: { return false;";
|
||||
}
|
||||
else // exact matches are forced, and we DO have a catch-all parameter, therefore we simply add that unmatched parameter to the dictionary
|
||||
{
|
||||
exact_match_default = $@"
|
||||
default:
|
||||
{{
|
||||
this.{catch_all_parameter.Name} ??= new System.Collections.Generic.Dictionary<string, object>();
|
||||
var writable_dict = this.{catch_all_parameter.Name};
|
||||
if (!writable_dict.TryAdd(name, value))
|
||||
{{
|
||||
writable_dict[name] = value;
|
||||
}}
|
||||
break;
|
||||
}}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// exact matches are not forced, so if there is no exact match, we fall back to compare it in lower case
|
||||
exact_match_default = $@"
|
||||
default:
|
||||
{{
|
||||
switch (name.ToLowerInvariant())
|
||||
{{
|
||||
{string.Join("\n", lower_case_match_cases)}
|
||||
{lower_case_match_default}
|
||||
}}
|
||||
break;
|
||||
}}
|
||||
";
|
||||
}
|
||||
context.AddCode(class_symbol.ToDisplayString() + "_implementation.cs", $@"
|
||||
using System;
|
||||
|
||||
#pragma warning disable CS0162
|
||||
#pragma warning disable CS0618
|
||||
#pragma warning disable CS8632
|
||||
namespace {namespaceName}
|
||||
{{
|
||||
public partial class {class_symbol.Name}{type_parameters}
|
||||
{{
|
||||
|
||||
private bool BlazorImplementation__WriteSingleParameter(string name, object value)
|
||||
{{
|
||||
if(name != ""Body"")
|
||||
{{
|
||||
|
||||
switch (name)
|
||||
{{
|
||||
{string.Join("\n", exact_match_cases)}
|
||||
{exact_match_default}
|
||||
}}
|
||||
return true;
|
||||
}}
|
||||
return false;
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
#pragma warning restore CS8632
|
||||
#pragma warning restore CS0618
|
||||
#pragma warning restore CS0162");
|
||||
}
|
||||
|
||||
private static bool IsPartial(INamedTypeSymbol symbol)
|
||||
{
|
||||
return symbol.DeclaringSyntaxReferences
|
||||
.Select(r => r.GetSyntax())
|
||||
.OfType<ClassDeclarationSyntax>()
|
||||
.Any(c => c.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword)));
|
||||
}
|
||||
|
||||
private static bool IsComponent(ClassDeclarationSyntax classDeclaration, INamedTypeSymbol symbol, Compilation compilation)
|
||||
{
|
||||
if (HasUserDefinedSetParametersAsync(symbol))
|
||||
return false;
|
||||
|
||||
if (classDeclaration.SyntaxTree.FilePath.EndsWith(".razor") || classDeclaration.SyntaxTree.FilePath.EndsWith(".razor.cs"))
|
||||
return true;
|
||||
|
||||
var iComponent = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.IComponent");
|
||||
var componentBase = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.ComponentBase");
|
||||
|
||||
if (iComponent == null || componentBase == null)
|
||||
return false;
|
||||
|
||||
return symbol.AllInterfaces.Contains(iComponent) || SymbolEqualityComparer.Default.Equals(symbol.BaseType, componentBase);
|
||||
}
|
||||
|
||||
private static bool HasUserDefinedSetParametersAsync(INamedTypeSymbol classSymbol)
|
||||
{
|
||||
return classSymbol
|
||||
.GetMembers("SetParametersAsync")
|
||||
.OfType<IMethodSymbol>()
|
||||
.Any(m =>
|
||||
m.Parameters.Length == 1 &&
|
||||
m.Parameters[0].Type.ToDisplayString() == "Microsoft.AspNetCore.Components.ParameterView" &&
|
||||
m.DeclaredAccessibility == Accessibility.Public &&
|
||||
!m.IsStatic);
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
internal static class SourceGeneratorContextExtension
|
||||
{
|
||||
public static void AddCode(this SourceProductionContext context, string hint_name, string code)
|
||||
{
|
||||
context.AddSource(hint_name.Replace("<", "_").Replace(">", "_"), SourceText.From(code, Encoding.UTF8));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components
|
||||
{
|
||||
public static class TypeSymbolExtension
|
||||
{
|
||||
public static IEnumerable<INamedTypeSymbol> GetTypeHierarchy(this INamedTypeSymbol symbol)
|
||||
{
|
||||
yield return symbol;
|
||||
if (symbol.BaseType != null)
|
||||
{
|
||||
foreach (var type in GetTypeHierarchy(symbol.BaseType))
|
||||
{
|
||||
yield return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve
|
||||
|
||||
foreach($analyzersPath in $analyzersPaths)
|
||||
{
|
||||
# Install the language agnostic analyzers.
|
||||
if (Test-Path $analyzersPath)
|
||||
{
|
||||
foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll)
|
||||
{
|
||||
if($project.Object.AnalyzerReferences)
|
||||
{
|
||||
$project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# $project.Type gives the language name like (C# or VB.NET)
|
||||
$languageFolder = ""
|
||||
if($project.Type -eq "C#")
|
||||
{
|
||||
$languageFolder = "cs"
|
||||
}
|
||||
if($project.Type -eq "VB.NET")
|
||||
{
|
||||
$languageFolder = "vb"
|
||||
}
|
||||
if($languageFolder -eq "")
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
foreach($analyzersPath in $analyzersPaths)
|
||||
{
|
||||
# Install language specific analyzers.
|
||||
$languageAnalyzersPath = join-path $analyzersPath $languageFolder
|
||||
if (Test-Path $languageAnalyzersPath)
|
||||
{
|
||||
foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll)
|
||||
{
|
||||
if($project.Object.AnalyzerReferences)
|
||||
{
|
||||
$project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve
|
||||
|
||||
foreach($analyzersPath in $analyzersPaths)
|
||||
{
|
||||
# Uninstall the language agnostic analyzers.
|
||||
if (Test-Path $analyzersPath)
|
||||
{
|
||||
foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll)
|
||||
{
|
||||
if($project.Object.AnalyzerReferences)
|
||||
{
|
||||
$project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# $project.Type gives the language name like (C# or VB.NET)
|
||||
$languageFolder = ""
|
||||
if($project.Type -eq "C#")
|
||||
{
|
||||
$languageFolder = "cs"
|
||||
}
|
||||
if($project.Type -eq "VB.NET")
|
||||
{
|
||||
$languageFolder = "vb"
|
||||
}
|
||||
if($languageFolder -eq "")
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
foreach($analyzersPath in $analyzersPaths)
|
||||
{
|
||||
# Uninstall language specific analyzers.
|
||||
$languageAnalyzersPath = join-path $analyzersPath $languageFolder
|
||||
if (Test-Path $languageAnalyzersPath)
|
||||
{
|
||||
foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll)
|
||||
{
|
||||
if($project.Object.AnalyzerReferences)
|
||||
{
|
||||
try
|
||||
{
|
||||
$project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
|
||||
<div align="center"><h1 align="center">ThingsBlazor</h1></div>
|
||||
<div align="center"><h3 align="center">权限管理框架</h3></div>
|
||||
|
||||
|
||||
### 🎁 框架介绍
|
||||
一个通用的AspNetCore小型权限框架,BlazorServer实现RBAC权限管理,在线会话管理。
|
||||
|
||||
|
||||
### 📙 衍生作品
|
||||
- 👉[ThingsGateway](https://gitee.com/diego2098/ThingsGateway)
|
||||
跨平台边缘采集网关
|
||||
|
||||
### 💐 特别鸣谢/源码参考(引用)
|
||||
- 👉[Simple.Admin](https://gitee.com/zxzyjs/SimpleAdmin)
|
||||
- 👉[Furion](https://gitee.com/dotnetchina/Furion)
|
||||
- 👉[Bootstrap Blazor](https://www.blazor.zone/)
|
||||
|
||||
### 🍎 联系作者
|
||||
* QQ群:605534569
|
||||
* 邮箱:2248356998@qq.com
|
@@ -1,21 +0,0 @@
|
||||
|
||||
<div align="center"><h1 align="center">ThingsBlazor</a></h1></div>
|
||||
<div align="center"><h3 align="center">权限管理框架</h3></div>
|
||||
|
||||
|
||||
### 🎁 框架介绍
|
||||
一个通用的AspNetCore小型权限框架,BlazorServer实现RBAC权限管理,在线会话管理。
|
||||
|
||||
|
||||
### 📙 衍生作品
|
||||
- 👉[ThingsGateway](https://gitee.com/diego2098/ThingsGateway)
|
||||
跨平台边缘采集网关
|
||||
|
||||
### 💐 特别鸣谢/源码参考(引用)
|
||||
- 👉[Simple.Admin](https://gitee.com/zxzyjs/SimpleAdmin)
|
||||
- 👉[Furion](https://gitee.com/dotnetchina/Furion)
|
||||
- 👉[Bootstrap Blazor](https://www.blazor.zone/)
|
||||
|
||||
### 🍎 联系作者
|
||||
* QQ群:605534569
|
||||
* 邮箱:2248356998@qq.com
|
@@ -1,169 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using Rougamo;
|
||||
using Rougamo.Context;
|
||||
using Rougamo.Metadatas;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.Extension;
|
||||
using ThingsGateway.FriendlyException;
|
||||
using ThingsGateway.NewLife.Json.Extension;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Aop拦截器
|
||||
/// </summary>
|
||||
[Pointcut(AccessFlags.Public | AccessFlags.Method)]
|
||||
[Advice(Feature.OnException | Feature.OnSuccess)]
|
||||
public sealed class OperDescAttribute : MoAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志消息队列(线程安全)
|
||||
/// </summary>
|
||||
private static readonly ConcurrentQueue<SysOperateLog> _logMessageQueue = new();
|
||||
private static readonly IAppService AppService;
|
||||
|
||||
static OperDescAttribute()
|
||||
{
|
||||
AppService = App.RootServices.GetService<IAppService>();
|
||||
// 创建长时间运行的后台任务,并将日志消息队列中数据写入存储中
|
||||
Task.Factory.StartNew(ProcessQueueAsync, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
public OperDescAttribute(string description, bool isRecordPar = true, object localizerType = null)
|
||||
{
|
||||
Description = description;
|
||||
IsRecordPar = isRecordPar;
|
||||
LocalizerType = (Type)localizerType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 说明,需配置本地化json文件
|
||||
/// </summary>
|
||||
public string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否记录进出参数
|
||||
/// </summary>
|
||||
public bool IsRecordPar { get; }
|
||||
|
||||
public Type? LocalizerType { get; }
|
||||
|
||||
public override void OnException(MethodContext context)
|
||||
{
|
||||
if (App.HttpContext?.Request.Path.StartsWithSegments("/_blazor") == true)
|
||||
{
|
||||
//插入异常日志
|
||||
SysOperateLog log = GetOperLog(LocalizerType, context);
|
||||
|
||||
log.Category = LogCateGoryEnum.Exception;//操作类型为异常
|
||||
log.ExeStatus = false;//操作状态为失败
|
||||
if (context.Exception is AppFriendlyException exception)
|
||||
log.ExeMessage = exception?.Message;
|
||||
else
|
||||
log.ExeMessage = context.Exception?.ToString();
|
||||
|
||||
OperDescAttribute.WriteToQueue(log);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSuccess(MethodContext context)
|
||||
{
|
||||
if (App.HttpContext?.Request.Path.StartsWithSegments("/_blazor") == true)
|
||||
{
|
||||
//插入操作日志
|
||||
SysOperateLog log = GetOperLog(LocalizerType, context);
|
||||
OperDescAttribute.WriteToQueue(log);
|
||||
}
|
||||
}
|
||||
private static SqlSugarClient _db = DbContext.GetDB<SysOperateLog>();
|
||||
/// <summary>
|
||||
/// 将日志消息写入数据库中
|
||||
/// </summary>
|
||||
private static async Task ProcessQueueAsync()
|
||||
{
|
||||
var appLifetime = App.RootServices!.GetService<IHostApplicationLifetime>()!;
|
||||
while (!appLifetime.ApplicationStopping.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _logMessageQueue.ToListWithDequeue(); // 从日志队列中获取数据
|
||||
if (data.Count > 0)
|
||||
{
|
||||
await _db.InsertableWithAttr(data).ExecuteCommandAsync(appLifetime.ApplicationStopping).ConfigureAwait(false);//入库
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NewLife.Log.XTrace.WriteException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Task.Delay(3000, appLifetime.ApplicationStopping).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SysOperateLog GetOperLog(Type? localizerType, MethodContext context)
|
||||
{
|
||||
var methodBase = context.Method;
|
||||
var userAgent = AppService.UserAgent;
|
||||
string? paramJson = null;
|
||||
if (IsRecordPar)
|
||||
{
|
||||
var args = context.Arguments;
|
||||
var parametersInfo = methodBase.GetParameters();
|
||||
var parametersDict = new Dictionary<string, object>();
|
||||
|
||||
for (int i = 0; i < parametersInfo.Length; i++)
|
||||
{
|
||||
parametersDict[parametersInfo[i].Name!] = args[i];
|
||||
}
|
||||
paramJson = parametersDict.ToSystemTextJsonString();
|
||||
}
|
||||
var result = context.ReturnValue;
|
||||
var resultJson = IsRecordPar ? result?.ToSystemTextJsonString() : null;
|
||||
//操作日志表实体
|
||||
var log = new SysOperateLog
|
||||
{
|
||||
Name = (localizerType == null ? App.CreateLocalizerByType(typeof(OperDescAttribute)) : App.CreateLocalizerByType(localizerType))![Description],
|
||||
Category = LogCateGoryEnum.Operate,
|
||||
ExeStatus = true,
|
||||
OpIp = AppService?.RemoteIpAddress ?? string.Empty,
|
||||
OpBrowser = userAgent?.Browser,
|
||||
OpOs = userAgent?.Platform,
|
||||
OpTime = DateTime.Now,
|
||||
OpAccount = UserManager.UserAccount,
|
||||
ReqUrl = null,
|
||||
ReqMethod = "browser",
|
||||
ResultJson = resultJson,
|
||||
ClassName = methodBase.ReflectedType!.Name,
|
||||
MethodName = methodBase.Name,
|
||||
ParamJson = paramJson,
|
||||
VerificatId = UserManager.VerificatId,
|
||||
};
|
||||
return log;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将日志消息写入队列中等待后台任务出队写入数据库
|
||||
/// </summary>
|
||||
/// <param name="logMsg">结构化日志消息</param>
|
||||
private static void WriteToQueue(SysOperateLog logMsg)
|
||||
{
|
||||
_logMessageQueue.Enqueue(logMsg);
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 需要角色授权权限
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||
public sealed class RolePermissionAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略角色授权权限
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class IgnoreRolePermissionAttribute : Attribute
|
||||
{
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class LoginLogAttribute : Attribute
|
||||
{
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class LogoutLogAttribute : Attribute
|
||||
{
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 管理员才能访问
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public sealed class SuperAdminAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略超级管理员才能访问特性
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class IgnoreSuperAdminAttribute : Attribute
|
||||
{
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class CacheConst
|
||||
{
|
||||
/// <summary>
|
||||
/// Token表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_HardwareInfo = $"{CacheConst.Cache_Prefix_Admin}Cache_HardwareInfo:";
|
||||
|
||||
public const string Cache_Prefix_Admin = "ThingsGatewayAdmin:";
|
||||
|
||||
/// <summary>
|
||||
/// 系统字典表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysDict = $"{CacheConst.Cache_Prefix_Admin}SysDict:";
|
||||
|
||||
/// <summary>
|
||||
/// 关系表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysRelation = $"{CacheConst.Cache_Prefix_Admin}SysRelation:";
|
||||
|
||||
/// <summary>
|
||||
/// 资源表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysResource = $"{CacheConst.Cache_Prefix_Admin}SysResource:List";
|
||||
|
||||
/// <summary>
|
||||
/// 角色表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysRole = $"{CacheConst.Cache_Prefix_Admin}SysRole:List";
|
||||
|
||||
/// <summary>
|
||||
/// 用户表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysUser = $"{CacheConst.Cache_Prefix_Admin}SysUser:Hash";
|
||||
|
||||
/// <summary>
|
||||
/// 用户账号关系缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysUserAccount = $"{CacheConst.Cache_Prefix_Admin}SysUserAccount:Hash";
|
||||
|
||||
/// <summary>
|
||||
/// 职位表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysPosition = $"{CacheConst.Cache_Prefix_Admin}SysPosition:";
|
||||
|
||||
/// <summary>
|
||||
/// 机构表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysOrg = $"{CacheConst.Cache_Prefix_Admin}SysOrg:List";
|
||||
|
||||
/// <summary>
|
||||
/// 公司表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysTenant = $"{CacheConst.Cache_Prefix_Admin}Tenant:";
|
||||
/// <summary>
|
||||
/// 公司表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_SysOrgTenant = $"{CacheConst.Cache_Prefix_Admin}OrgTenant:Hash";
|
||||
|
||||
/// <summary>
|
||||
/// Token表缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_Token = $"{CacheConst.Cache_Prefix_Admin}Token:Hash";
|
||||
|
||||
#region 登录错误次数
|
||||
|
||||
/// <summary>
|
||||
/// 登录错误次数缓存Key
|
||||
/// </summary>
|
||||
public const string Cache_LoginErrorCount = $"{CacheConst.Cache_Prefix_Admin}LoginErrorCount:";
|
||||
|
||||
#endregion 登录错误次数
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 通讯器常量
|
||||
/// </summary>
|
||||
public static class HubConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统HubUrl
|
||||
/// </summary>
|
||||
public const string SysHubUrl = "/hubs/thingsgateway";
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 资源表常量
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class ResourceConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统内置编码
|
||||
/// </summary>
|
||||
public const string System = "System";
|
||||
|
||||
/// <summary>
|
||||
/// 系统管理内置ID 1
|
||||
/// </summary>
|
||||
public const long SystemId = 2;
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 角色常量
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class RoleConst
|
||||
{
|
||||
/// <summary>
|
||||
/// api角色
|
||||
/// </summary>
|
||||
public const string ApiRole = "ApiRole";
|
||||
|
||||
/// <summary>
|
||||
/// 业务管理员
|
||||
/// </summary>
|
||||
public const string BizAdmin = "BizAdmin";
|
||||
|
||||
/// <summary>
|
||||
/// 超级管理员
|
||||
/// </summary>
|
||||
public const string SuperAdmin = "SuperAdmin";
|
||||
|
||||
/// <summary>
|
||||
/// 超级管理员Id
|
||||
/// </summary>
|
||||
public const long SuperAdminId = 212725263002001;
|
||||
/// <summary>
|
||||
/// 默认租户Id
|
||||
/// </summary>
|
||||
public const long DefaultTenantId = 252885263003720;
|
||||
/// <summary>
|
||||
/// 默认岗位Id
|
||||
/// </summary>
|
||||
public const long DefaultPositionId = 212725263003001;
|
||||
/// <summary>
|
||||
/// 超级管理员Id
|
||||
/// </summary>
|
||||
public const long SuperAdminRoleId = 212725263001001;
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// SqlSugar系统常量
|
||||
/// </summary>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class SqlSugarConst
|
||||
{
|
||||
/// <summary>
|
||||
/// DB_Admin
|
||||
/// </summary>
|
||||
public const string DB_Admin = "DB_Admin";
|
||||
|
||||
/// <summary>
|
||||
/// DB_Custom
|
||||
/// </summary>
|
||||
public const string DB_Custom = "DB_Custom";
|
||||
|
||||
/// <summary>
|
||||
/// DB_HardwareInfo
|
||||
/// </summary>
|
||||
public const string DB_HardwareInfo = "DB_HardwareInfo";
|
||||
|
||||
/// <summary>
|
||||
/// DB_Log
|
||||
/// </summary>
|
||||
public const string DB_Log = "DB_Log";
|
||||
|
||||
/// <summary>
|
||||
/// DB_TokenCache
|
||||
/// </summary>
|
||||
public const string DB_TokenCache = "DB_TokenCache";
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[ApiDescriptionSettings(false)]
|
||||
[Route("api/auth")]
|
||||
[RequestAudit]
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
private readonly IAuthService _authService;
|
||||
|
||||
public AuthController(IAuthService authService)
|
||||
{
|
||||
_authService = authService;
|
||||
}
|
||||
|
||||
[HttpPost("login")]
|
||||
[AllowAnonymous]
|
||||
[LoginLog]
|
||||
public Task<LoginOutput> LoginAsync([FromBody] LoginInput input)
|
||||
{
|
||||
return _authService.LoginAsync(input);
|
||||
}
|
||||
|
||||
[HttpGet("oauth-login")]
|
||||
[AllowAnonymous]
|
||||
[SuppressRequestAudit]
|
||||
public IActionResult OAuthLogin(string scheme = "Gitee", string returnUrl = "/")
|
||||
{
|
||||
var props = new AuthenticationProperties
|
||||
{
|
||||
RedirectUri = returnUrl
|
||||
};
|
||||
return Challenge(props, scheme);
|
||||
}
|
||||
|
||||
[HttpPost("logout")]
|
||||
[Authorize]
|
||||
[IgnoreRolePermission]
|
||||
[LogoutLog]
|
||||
public Task LogoutAsync()
|
||||
{
|
||||
return _authService.LoginOutAsync();
|
||||
}
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 文化 Controller
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(false)]
|
||||
[Route("[controller]/[action]")]
|
||||
public class CultureController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// 重置文化方法
|
||||
/// </summary>
|
||||
/// <param name="redirectUri"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult ResetCulture(string redirectUri)
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete(CookieRequestCultureProvider.DefaultCookieName);
|
||||
|
||||
return LocalRedirect(redirectUri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置文化方法
|
||||
/// </summary>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="redirectUri"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult SetCulture(string culture, string redirectUri)
|
||||
{
|
||||
if (string.IsNullOrEmpty(culture))
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete(CookieRequestCultureProvider.DefaultCookieName);
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpContext.Response.Cookies.Append(
|
||||
CookieRequestCultureProvider.DefaultCookieName,
|
||||
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture, culture)), new CookieOptions()
|
||||
{
|
||||
Expires = DateTimeOffset.Now.AddYears(1)
|
||||
});
|
||||
|
||||
//更改全局文化,采集后台也会变化
|
||||
//var cultureInfo = new CultureInfo(culture);
|
||||
//CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
|
||||
//CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
|
||||
|
||||
//CultureInfo.CurrentCulture = cultureInfo;
|
||||
//CultureInfo.CurrentUICulture = cultureInfo;
|
||||
}
|
||||
|
||||
return LocalRedirect(redirectUri);
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 文件下载
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(false)]
|
||||
[Route("api/file")]
|
||||
public class FileController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 下载wwwroot文件夹下的文件
|
||||
/// </summary>
|
||||
/// <param name="fileName">相对路径</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("download")]
|
||||
public IActionResult Download(string fileName)
|
||||
{
|
||||
// Validate the fileName to prevent path injection
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return BadRequest("Invalid file name.");
|
||||
}
|
||||
|
||||
var root = Directory.GetCurrentDirectory();
|
||||
var wwwroot = Path.Combine(root, "wwwroot");
|
||||
var filePath = Path.Combine(wwwroot, fileName);
|
||||
#pragma warning disable CA3003
|
||||
if ((!(fileName.StartsWith(@"../Logs") || fileName.StartsWith(@"..\Logs")) && filePath.Contains("..")) || !System.IO.File.Exists(filePath))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
#pragma warning restore CA3003
|
||||
|
||||
var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
|
||||
Response.Headers.Append("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
|
||||
return File(fileStream, "application/octet-stream", (Path.GetFileName(filePath).Replace('/', '_')));
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings("ThingsGateway.OpenApi", Order = 200)]
|
||||
[Description("登录")]
|
||||
[Route("openapi/auth")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
[RequestAudit]
|
||||
[ApiController]
|
||||
public class OpenApiController : ControllerBase
|
||||
{
|
||||
private readonly IAuthService _authService;
|
||||
|
||||
public OpenApiController(IAuthService authService)
|
||||
{
|
||||
_authService = authService;
|
||||
}
|
||||
|
||||
[HttpPost("login")]
|
||||
[DisplayName("登录")]
|
||||
[AllowAnonymous]
|
||||
public async Task<OpenApiLoginOutput> LoginAsync([FromBody] OpenApiLoginInput input)
|
||||
{
|
||||
var output = await _authService.LoginAsync(input.AdaptLoginInput(), false).ConfigureAwait(false);
|
||||
|
||||
var openApiLoginOutput = output.AdaptOpenApiLoginOutput();
|
||||
|
||||
return openApiLoginOutput;
|
||||
}
|
||||
|
||||
[HttpPost("logout")]
|
||||
[Authorize]
|
||||
[DisplayName("登出")]
|
||||
[IgnoreRolePermission]
|
||||
public Task LogoutAsync()
|
||||
{
|
||||
return _authService.LoginOutAsync();
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[SugarTable("sys_dict", TableDescription = "字典表")]
|
||||
[Tenant(SqlSugarConst.DB_Admin)]
|
||||
public class SysDict : BaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "类型")]
|
||||
[AutoGenerateColumn(Ignore = true, Filterable = true, Sortable = true)]
|
||||
public virtual DictTypeEnum DictType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "分类", Length = 200)]
|
||||
[Required]
|
||||
[AutoGenerateColumn(Searchable = true, Filterable = true, Sortable = true)]
|
||||
public string Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "名称", Length = 200)]
|
||||
[Required]
|
||||
[AutoGenerateColumn(Searchable = true, Filterable = true, Sortable = true)]
|
||||
public virtual string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "代码", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
[Required]
|
||||
[AutoGenerateColumn(Searchable = true, Filterable = true, Sortable = true)]
|
||||
public virtual string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "描述", Length = 200, IsNullable = true)]
|
||||
public string Remark { get; set; }
|
||||
}
|
@@ -1,132 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 操作日志表
|
||||
///</summary>
|
||||
[SugarTable("sys_operatelog", TableDescription = "操作日志表")]
|
||||
[Tenant(SqlSugarConst.DB_Log)]
|
||||
public class SysOperateLog
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "日志分类")]
|
||||
[AutoGenerateColumn(Order = 1, Filterable = true, Sortable = true)]
|
||||
public LogCateGoryEnum Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日志名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "日志名称", Length = 200)]
|
||||
[AutoGenerateColumn(Order = 2, Filterable = true, Sortable = true)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "类名称", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
|
||||
public string ClassName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 方法名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "方法名称", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
|
||||
public string MethodName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求参数
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "请求参数", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
|
||||
[AutoGenerateColumn(ShowTips = true, Filterable = true, Sortable = true)]
|
||||
public string? ParamJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求方式
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "请求方式", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
|
||||
public string? ReqMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "请求地址", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
|
||||
public string? ReqUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回结果
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "返回结果", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
|
||||
[AutoGenerateColumn(ShowTips = true, Filterable = true, Sortable = true)]
|
||||
public string? ResultJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 具体消息
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "具体消息", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
|
||||
[AutoGenerateColumn(ShowTips = true, Filterable = true, Sortable = true)]
|
||||
public string? ExeMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行状态
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "执行状态")]
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true)]
|
||||
public bool ExeStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作账号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "操作账号", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true)]
|
||||
public string? OpAccount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作浏览器
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "操作浏览器", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
|
||||
public string OpBrowser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作ip
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "操作ip", Length = 200)]
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true)]
|
||||
public string? OpIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作系统
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "操作系统", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
|
||||
public string OpOs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "操作时间")]
|
||||
[AutoGenerateColumn(Visible = true, DefaultSort = true, Sortable = true, DefaultSortOrder = SortOrder.Desc)]
|
||||
public DateTime OpTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证Id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "验证Id")]
|
||||
[IgnoreExcel]
|
||||
[AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
|
||||
public long VerificatId { get; set; }
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 组织表
|
||||
///</summary>
|
||||
[SugarTable("sys_org", TableDescription = "组织表")]
|
||||
[Tenant(SqlSugarConst.DB_Admin)]
|
||||
public class SysOrg : BaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 父id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ParentId", ColumnDescription = "父id")]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public long ParentId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "ParentIdList", ColumnDescription = "父id列表", IsNullable = true, IsJson = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public List<long> ParentIdList { get; set; } = new List<long>();
|
||||
|
||||
/// <summary>
|
||||
/// 主管ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DirectorId", ColumnDescription = "主管ID", IsNullable = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public long? DirectorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Name", ColumnDescription = "名称", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Names", ColumnDescription = "全称", Length = 500)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public string Names { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Code", ColumnDescription = "编码", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Category", ColumnDescription = "分类")]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public OrgEnum Category { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "Status", ColumnDescription = "启用")]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public bool Status { get; set; } = true;
|
||||
|
||||
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 职位表
|
||||
///</summary>
|
||||
[SugarTable("sys_position", TableDescription = "职位表")]
|
||||
[Tenant(SqlSugarConst.DB_Admin)]
|
||||
public class SysPosition : BaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 组织id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "OrgId", ColumnDescription = "组织id")]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
[MinValue(1)]
|
||||
public virtual long OrgId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Name", ColumnDescription = "名称", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
[Required]
|
||||
public virtual string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Code", ColumnDescription = "编码", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public string Code { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "Status", ColumnDescription = "启用")]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public bool Status { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Category", ColumnDescription = "分类")]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual PositionCategoryEnum Category { get; set; }
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 系统关系表
|
||||
///</summary>
|
||||
[SugarTable("sys_relation", TableDescription = "系统关系表")]
|
||||
[Tenant(SqlSugarConst.DB_Admin)]
|
||||
public class SysRelation : PrimaryKeyEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "分类")]
|
||||
public RelationCategoryEnum Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对象ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "对象ID")]
|
||||
public long ObjectId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "目标ID", IsNullable = true)]
|
||||
public string? TargetId { get; set; }
|
||||
}
|
@@ -1,97 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 系统资源表
|
||||
///</summary>
|
||||
[SugarTable("sys_resource", TableDescription = "系统资源表")]
|
||||
[Tenant(SqlSugarConst.DB_Admin)]
|
||||
public class SysResource : BaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 父id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "父id")]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public virtual long ParentId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 模块
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "模块")]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public virtual long Module { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "标题", Length = 200)]
|
||||
[Required]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true, Searchable = true)]
|
||||
public virtual string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图标
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "图标", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = false, Filterable = false)]
|
||||
public virtual string? Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "编码", Length = 200)]
|
||||
[Required]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public virtual string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "分类")]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public ResourceCategoryEnum Category { get; set; } = ResourceCategoryEnum.Menu;
|
||||
|
||||
/// <summary>
|
||||
/// 目标类型
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "目标类型", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual TargetEnum? Target { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单匹配类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "菜单匹配类型", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual NavLinkMatch? NavLinkMatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路径
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "路径", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true, Searchable = true)]
|
||||
public virtual string Href { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子节点
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public List<SysResource>? Children { get; set; }
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 系统角色表
|
||||
///</summary>
|
||||
[SugarTable("sys_role", TableDescription = "系统角色表")]
|
||||
[Tenant(SqlSugarConst.DB_Admin)]
|
||||
public class SysRole : BaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "名称", Length = 200)]
|
||||
[Required]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "编码", Length = 200)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "分类", IsNullable = false)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual RoleCategoryEnum Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组织id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "OrgId", ColumnDescription = "组织id", IsNullable = false)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public long OrgId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认数据范围
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DefaultDataScope", ColumnDescription = "默认数据范围", IsJson = true, ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = false)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public virtual DefaultDataScope DefaultDataScope { get; set; } = new();
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null || !(obj is SysRole))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Id == ((SysRole)obj).Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 默认数据范围
|
||||
/// </summary>
|
||||
public class DefaultDataScope
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据范围
|
||||
/// </summary>
|
||||
public DataScopeEnum ScopeCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义机构范围列表
|
||||
/// </summary>
|
||||
public List<long> ScopeDefineOrgIdList { get; set; } = new List<long>();
|
||||
}
|
@@ -1,247 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Riok.Mapperly.Abstractions;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 系统用户表
|
||||
///</summary>
|
||||
[SugarTable("sys_user", TableDescription = "系统用户表")]
|
||||
[Tenant(SqlSugarConst.DB_Admin)]
|
||||
public class SysUser : BaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 头像
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "头像", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = false, Filterable = false)]
|
||||
[MapperIgnore]
|
||||
public virtual string? Avatar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "账号", Length = 200)]
|
||||
[Required]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual string Account { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "密码", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "状态")]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public bool Status { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 手机
|
||||
/// 这里使用了SM4自动加密解密
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "手机", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public string? Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "邮箱", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public string? Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上次登录ip
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "上次登录ip", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public string? LastLoginIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上次登录设备
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "上次登录设备", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public string? LastLoginDevice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上次登录时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "上次登录时间", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public DateTime? LastLoginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上次登录地点
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "上次登录地点", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public string LastLoginAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最新登录ip
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "最新登录ip", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public string? LatestLoginIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最新登录时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "最新登录时间", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public DateTime? LatestLoginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最新登录设备
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "最新登录设备", IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public string? LatestLoginDevice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最新登录地点
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "最新登录地点", Length = 200, IsNullable = true)]
|
||||
[AutoGenerateColumn(Visible = false, Sortable = true, Filterable = true, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
|
||||
public string LatestLoginAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 机构id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "OrgId", ColumnDescription = "机构id", IsNullable = false)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public virtual long OrgId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 职位id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "PositionId", ColumnDescription = "职位id", IsNullable = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
[Required]
|
||||
[NotNull]
|
||||
public virtual long? PositionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主管id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DirectorId", ColumnDescription = "主管id", IsNullable = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public long? DirectorId { get; set; }
|
||||
|
||||
#region other
|
||||
/// <summary>
|
||||
/// 机构信息
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public string OrgName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 机构信息全称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string OrgNames { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 职位信息
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string PositionName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组织和机构ID列表,组织ID从上到下最后是职位
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true, IsJson = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public List<long>? OrgAndPosIdList { get; set; } = new List<long>();
|
||||
|
||||
/// <summary>
|
||||
/// 主管信息
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public UserSelectorOutput? DirectorInfo { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region other
|
||||
|
||||
/// <summary>
|
||||
/// 按钮码集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public Dictionary<string, List<string>>? ButtonCodeList { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 权限码集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public HashSet<string>? PermissionCodeList { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 角色ID集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public HashSet<long>? RoleIdList { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 机构及以下机构ID集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public HashSet<long>? ScopeOrgChildList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模块集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public List<SysResource>? ModuleList { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public long? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全局用戶
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public bool IsGlobal { get; set; }
|
||||
|
||||
#endregion other
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据范围类
|
||||
/// </summary>
|
||||
public class DataScope
|
||||
{
|
||||
/// <summary>
|
||||
/// API接口
|
||||
/// </summary>
|
||||
public string ApiUrl { get; set; }
|
||||
}
|
@@ -1,84 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.Common.List;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 会话信息
|
||||
/// </summary>
|
||||
[SugarTable("verificatinfo", TableDescription = "验证缓存表")]
|
||||
[Tenant(SqlSugarConst.DB_TokenCache)]
|
||||
public class VerificatInfo : PrimaryIdEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户端ID列表
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
[SugarColumn(ColumnDescription = "客户端ID列表", IsNullable = true, IsJson = true)]
|
||||
public ConcurrentList<string> ClientIds { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 验证Id
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证Id
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true)]
|
||||
[SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true)]
|
||||
[IgnoreExcel]
|
||||
[System.ComponentModel.DataAnnotations.Key]
|
||||
public override long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录IP
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true, Width = 200)]
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string LoginIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录时间
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true, Width = 200)]
|
||||
public DateTime LoginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 在线状态
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true, Width = 120)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public bool Online => ClientIds.Count > 0;
|
||||
|
||||
/// <summary>
|
||||
/// 过期时间
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true)]
|
||||
public int Expire { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 超时时间
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true)]
|
||||
public DateTime VerificatTimeout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录设备
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Filterable = true, Sortable = true, Width = 100)]
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string Device { get; set; }
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum DataScopeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 仅自己
|
||||
/// </summary>
|
||||
SCOPE_SELF,
|
||||
|
||||
/// <summary>
|
||||
/// 所有
|
||||
/// </summary>
|
||||
SCOPE_ALL,
|
||||
|
||||
/// <summary>
|
||||
/// 仅所属组织
|
||||
/// </summary>
|
||||
SCOPE_ORG,
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织及以下
|
||||
/// </summary>
|
||||
SCOPE_ORG_CHILD,
|
||||
|
||||
/// <summary>
|
||||
/// 自定义
|
||||
/// </summary>
|
||||
SCOPE_ORG_DEFINE,
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 字典表类型
|
||||
/// </summary>
|
||||
public enum DictTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统使用
|
||||
/// </summary>
|
||||
System,
|
||||
|
||||
/// <summary>
|
||||
/// 用户自定义
|
||||
/// </summary>
|
||||
Define,
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum LogCateGoryEnum
|
||||
{
|
||||
Login,
|
||||
Logout,
|
||||
Operate,
|
||||
Exception
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum OrgEnum
|
||||
{
|
||||
DEPT,
|
||||
COMPANY,
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum PositionCategoryEnum
|
||||
{
|
||||
HIGH,
|
||||
MIDDLE,
|
||||
LOW,
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum RelationCategoryEnum
|
||||
{
|
||||
UserHasRole,
|
||||
UserHasResource,
|
||||
UserHasPermission,
|
||||
UserHasOpenApiPermission,
|
||||
UserHasModule,
|
||||
UserWorkbenchData,
|
||||
RoleHasResource,
|
||||
RoleHasPermission,
|
||||
RoleHasOpenApiPermission,
|
||||
RoleHasModule,
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum ResourceCategoryEnum
|
||||
{
|
||||
Module,
|
||||
Menu,
|
||||
Button,
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum RoleCategoryEnum
|
||||
{
|
||||
Global = 0,
|
||||
Org = 2,
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public enum TargetEnum
|
||||
{
|
||||
_self,
|
||||
_blank,
|
||||
_parent,
|
||||
_top
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Builder;
|
||||
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class ApplicationBuilderExtensions
|
||||
{
|
||||
public static IApplicationBuilder UseBootstrapBlazor(this IApplicationBuilder builder)
|
||||
{
|
||||
// 获得客户端 IP 地址
|
||||
builder.UseWhen(context => context.Request.Path.StartsWithSegments("/ip.axd"), app => app.Run(async context =>
|
||||
{
|
||||
var ip = "";
|
||||
var headers = context.Request.Headers;
|
||||
if (headers.TryGetValue("X-Forwarded-For", out var value))
|
||||
{
|
||||
var ips = new List<string>();
|
||||
foreach (var xf in value)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(xf))
|
||||
{
|
||||
ips.Add(xf);
|
||||
}
|
||||
}
|
||||
ip = string.Join(";", ips);
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = context.Connection.RemoteIpAddress.ToIPv4String();
|
||||
}
|
||||
|
||||
context.Response.Headers.TryAdd("Content-Type", new Microsoft.Extensions.Primitives.StringValues("application/json; charset=utf-8"));
|
||||
await context.Response.WriteAsync(JsonSerializer.Serialize(new { Id = context.TraceIdentifier, Ip = ip })).ConfigureAwait(false);
|
||||
}));
|
||||
return builder;
|
||||
}
|
||||
public static string ToIPv4String(this IPAddress? address)
|
||||
{
|
||||
var ipv4Address = (address ?? IPAddress.IPv6Loopback).ToString();
|
||||
return ipv4Address.StartsWith("::ffff:") ? (address ?? IPAddress.IPv6Loopback).MapToIPv4().ToString() : ipv4Address;
|
||||
}
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class CacheExtensions
|
||||
{
|
||||
private static int? _age;
|
||||
|
||||
private static List<string>? _files;
|
||||
|
||||
public static void ProcessCache(this StaticFileResponseContext context, IConfiguration configuration)
|
||||
{
|
||||
if (context.CanCache(configuration, out var age))
|
||||
{
|
||||
context.Context.Response.Headers[HeaderNames.CacheControl] = $"public, max-age={age}";
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CanCache(this StaticFileResponseContext context, IConfiguration configuration, out int age)
|
||||
{
|
||||
var ret = false;
|
||||
age = 0;
|
||||
|
||||
var files = configuration.GetFiles();
|
||||
if (files.Any(i => context.CanCache(i)))
|
||||
{
|
||||
ret = true;
|
||||
age = configuration.GetAge();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static bool CanCache(this StaticFileResponseContext context, string file)
|
||||
{
|
||||
var ext = Path.GetExtension(context.File.PhysicalPath) ?? "";
|
||||
bool ret = file.Equals(ext, StringComparison.OrdinalIgnoreCase);
|
||||
if (ret && ext.Equals(".js", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// process javascript file
|
||||
ret = false;
|
||||
if (context.Context.Request.QueryString.HasValue)
|
||||
{
|
||||
var paras = QueryHelpers.ParseQuery(context.Context.Request.QueryString.Value);
|
||||
ret = paras.ContainsKey("v");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static int GetAge(this IConfiguration configuration)
|
||||
{
|
||||
_age ??= GetAge();
|
||||
return _age.Value;
|
||||
|
||||
int GetAge()
|
||||
{
|
||||
var cacheSection = configuration.GetSection("Cache-Control");
|
||||
return cacheSection.GetValue<int>("Max-Age", 1000 * 60 * 10);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> GetFiles(this IConfiguration configuration)
|
||||
{
|
||||
_files ??= GetFiles();
|
||||
return _files;
|
||||
|
||||
List<string> GetFiles()
|
||||
{
|
||||
var cacheSection = configuration.GetSection("Cache-Control");
|
||||
return cacheSection.GetSection("Files").Get<List<string>>() ?? new();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.Extension;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
|
||||
public static class SchemeHelper
|
||||
{
|
||||
public static string GetOrCreate()
|
||||
{
|
||||
var path = "Keys/SchemeKey.txt";
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var data = File.ReadAllText(path);
|
||||
return data;
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = DateTime.UtcNow.ToDefaultDateTimeFormat();
|
||||
Directory.CreateDirectory("Keys");
|
||||
File.WriteAllText(path, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Logging;
|
||||
|
||||
public class RequestAudit
|
||||
{
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
|
||||
using ThingsGateway.DependencyInjection;
|
||||
|
||||
namespace System;
|
||||
|
||||
[SuppressSniffer, AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class RequestAuditAttribute : Attribute
|
||||
{
|
||||
}
|
@@ -1,99 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class RequestAuditData
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public string CateGory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户端信息
|
||||
/// </summary>
|
||||
public UserAgent Client { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求方法:POST/GET
|
||||
/// </summary>
|
||||
public string Method { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作名称
|
||||
/// </summary>
|
||||
public string Operation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 方法名称
|
||||
/// </summary>
|
||||
public string ActionName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 认证信息
|
||||
/// </summary>
|
||||
public List<AuthorizationClaims> AuthorizationClaims { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 控制器名
|
||||
/// </summary>
|
||||
public string ControllerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 异常信息
|
||||
/// </summary>
|
||||
public LogException Exception { get; set; }
|
||||
|
||||
public long TimeOperationElapsedMilliseconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务端
|
||||
/// </summary>
|
||||
public string LocalIPv4 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日志时间
|
||||
/// </summary>
|
||||
public DateTimeOffset LogDateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数列表
|
||||
/// </summary>
|
||||
public List<Parameters> Parameters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户端IPV4地址
|
||||
/// </summary>
|
||||
public string RemoteIPv4 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
/// </summary>
|
||||
public string RequestUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回信息
|
||||
/// </summary>
|
||||
public object ReturnInformation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证错误信息
|
||||
/// </summary>
|
||||
public Validation Validation { get; set; }
|
||||
public MethodInfo MethodInfo { get; set; }
|
||||
}
|
@@ -1,287 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Logging;
|
||||
|
||||
using ThingsGateway.FriendlyException;
|
||||
using ThingsGateway.Logging;
|
||||
using ThingsGateway.NewLife.Json.Extension;
|
||||
using ThingsGateway.UnifyResult;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class RequestAuditFilter : IAsyncActionFilter, IOrderedFilter
|
||||
{
|
||||
private const int FilterOrder = -3000;
|
||||
public int Order => FilterOrder;
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var timeOperation = Stopwatch.StartNew();
|
||||
var resultContext = await next().ConfigureAwait(false);
|
||||
// 计算接口执行时间
|
||||
timeOperation.Stop();
|
||||
|
||||
var controllerActionDescriptor = (context.ActionDescriptor as ControllerActionDescriptor);
|
||||
// 获取动作方法描述器
|
||||
var actionMethod = controllerActionDescriptor?.MethodInfo;
|
||||
|
||||
// 处理 Blazor Server
|
||||
if (actionMethod == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 排除 WebSocket 请求处理
|
||||
if (context.HttpContext.IsWebSocketRequest())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果贴了 [SuppressMonitor] 特性则跳过
|
||||
if (actionMethod.IsDefined(typeof(SuppressRequestAuditAttribute), true)
|
||||
|| actionMethod.DeclaringType.IsDefined(typeof(SuppressRequestAuditAttribute), true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 只有方法贴有特性才进行审计
|
||||
if (
|
||||
!actionMethod.DeclaringType.IsDefined(typeof(RequestAuditAttribute), true)
|
||||
&&
|
||||
!actionMethod.IsDefined(typeof(RequestAuditAttribute), true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var logData = new RequestAuditData();
|
||||
|
||||
logData.TimeOperationElapsedMilliseconds = timeOperation.ElapsedMilliseconds;
|
||||
|
||||
var resultHttpContext = (resultContext as Microsoft.AspNetCore.Mvc.Filters.FilterContext).HttpContext;
|
||||
|
||||
// 获取 HttpContext 和 HttpRequest 对象
|
||||
var httpContext = context.HttpContext;
|
||||
var httpRequest = httpContext.Request;
|
||||
|
||||
// 获取客户端 Ipv4 地址
|
||||
var remoteIPv4 = httpContext.GetRemoteIpAddressToIPv4();
|
||||
logData.RemoteIPv4 = remoteIPv4;
|
||||
var requestUrl = Uri.UnescapeDataString(httpRequest.GetRequestUrlAddress());
|
||||
logData.RequestUrl = requestUrl;
|
||||
|
||||
object returnValue = null;
|
||||
Type finalReturnType;
|
||||
var result = resultContext.Result as IActionResult;
|
||||
// 解析返回值
|
||||
if (UnifyContext.CheckVaildResult(result, out var data))
|
||||
{
|
||||
returnValue = data;
|
||||
finalReturnType = data?.GetType();
|
||||
}
|
||||
// 处理文件类型
|
||||
else if (result is FileResult fresult)
|
||||
{
|
||||
returnValue = new
|
||||
{
|
||||
FileName = fresult.FileDownloadName,
|
||||
fresult.ContentType,
|
||||
Length = fresult is FileContentResult cresult ? (object)cresult.FileContents.Length : null
|
||||
};
|
||||
finalReturnType = fresult?.GetType();
|
||||
}
|
||||
else finalReturnType = result?.GetType();
|
||||
|
||||
logData.ReturnInformation = returnValue;
|
||||
|
||||
//获取客户端信息
|
||||
var client = App.GetService<IAppService>().UserAgent;
|
||||
//操作名称默认是控制器名加方法名,自定义操作名称要在action上加Description特性
|
||||
var option = $"{controllerActionDescriptor.ControllerName}/{controllerActionDescriptor.ActionName}";
|
||||
|
||||
var desc = App.CreateLocalizerByType(controllerActionDescriptor.ControllerTypeInfo.AsType())[actionMethod.Name];
|
||||
//获取特性
|
||||
|
||||
logData.CateGory = desc.Value;//传操作名称
|
||||
logData.Operation = desc.Value;//传操作名称
|
||||
logData.Client = client;
|
||||
logData.Path = httpContext.Request.Path.Value;//请求地址
|
||||
logData.Method = httpContext.Request.Method;//请求方法
|
||||
logData.MethodInfo = actionMethod;//请求方法
|
||||
|
||||
logData.ControllerName = controllerActionDescriptor.ControllerName;
|
||||
logData.ActionName = controllerActionDescriptor.ActionName;
|
||||
|
||||
logData.AuthorizationClaims = new();
|
||||
// 获取授权用户
|
||||
var user = httpContext.User;
|
||||
foreach (var claim in user.Claims)
|
||||
{
|
||||
logData.AuthorizationClaims.Add(new AuthorizationClaims
|
||||
{
|
||||
Type = claim.Type,
|
||||
Value = claim.Value,
|
||||
});
|
||||
}
|
||||
|
||||
logData.LocalIPv4 = httpContext.GetLocalIpAddressToIPv4();
|
||||
logData.LogDateTime = DateTimeOffset.Now;
|
||||
var parameterValues = context.ActionArguments;
|
||||
|
||||
logData.Parameters = new();
|
||||
var parameters = actionMethod.GetParameters();
|
||||
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
// 判断是否禁用记录特定参数
|
||||
if (parameter.IsDefined(typeof(SuppressRequestAuditAttribute), false)) continue;
|
||||
|
||||
// 排除标记 [FromServices] 的解析
|
||||
if (parameter.IsDefined(typeof(FromServicesAttribute), false)) continue;
|
||||
|
||||
var name = parameter.Name;
|
||||
var parameterType = parameter.ParameterType;
|
||||
|
||||
_ = parameterValues.TryGetValue(name, out var value);
|
||||
|
||||
var par = new Parameters()
|
||||
{
|
||||
Name = name,
|
||||
};
|
||||
logData.Parameters.Add(par);
|
||||
|
||||
object rawValue = default;
|
||||
|
||||
// 文件类型参数
|
||||
if (value is IFormFile || value is List<IFormFile>)
|
||||
{
|
||||
// 单文件
|
||||
if (value is IFormFile formFile)
|
||||
{
|
||||
var fileSize = Math.Round(formFile.Length / 1024D);
|
||||
rawValue = new
|
||||
{
|
||||
name = formFile.Name,
|
||||
fileName = formFile.FileName,
|
||||
length = formFile.Length,
|
||||
contentType = formFile.ContentType
|
||||
};
|
||||
}
|
||||
// 多文件
|
||||
else if (value is List<IFormFile> formFiles)
|
||||
{
|
||||
var rawValues1 = new List<object>();
|
||||
for (var i = 0; i < formFiles.Count; i++)
|
||||
{
|
||||
var file = formFiles[i];
|
||||
var size = Math.Round(file.Length / 1024D);
|
||||
var rawValue1 = new
|
||||
{
|
||||
name = file.Name,
|
||||
fileName = file.FileName,
|
||||
length = file.Length,
|
||||
contentType = file.ContentType
|
||||
};
|
||||
rawValues1.Add(rawValue1);
|
||||
}
|
||||
rawValue = rawValues1;
|
||||
}
|
||||
}
|
||||
// 处理 byte[] 参数类型
|
||||
else if (value is byte[] byteArray)
|
||||
{
|
||||
rawValue = new
|
||||
{
|
||||
length = byteArray.Length,
|
||||
};
|
||||
}
|
||||
// 处理基元类型,字符串类型和空值
|
||||
else if (parameterType.IsPrimitive || value is string || value == null)
|
||||
{
|
||||
rawValue = value;
|
||||
}
|
||||
// 其他类型统一进行序列化
|
||||
else
|
||||
{
|
||||
rawValue = value;
|
||||
}
|
||||
|
||||
par.Value = rawValue;
|
||||
}
|
||||
|
||||
// 获取异常对象情况
|
||||
Exception exception = resultContext.Exception;
|
||||
if (exception is AppFriendlyException friendlyException)
|
||||
{
|
||||
logData.Validation = new();
|
||||
logData.Validation.Message = friendlyException.Message;
|
||||
}
|
||||
else if (exception != null)
|
||||
{
|
||||
logData.Exception = new();
|
||||
logData.Exception.Message = exception.Message;
|
||||
logData.Exception.StackTrace = exception.StackTrace;
|
||||
logData.Exception.Type = HandleGenericType(exception.GetType());
|
||||
}
|
||||
|
||||
// 创建日志记录器
|
||||
var logger = httpContext.RequestServices.GetRequiredService<ILogger<RequestAudit>>();
|
||||
|
||||
var logContext = new LogContext();
|
||||
|
||||
logContext.Set(nameof(RequestAuditData), logData);
|
||||
|
||||
// 设置日志上下文
|
||||
using var scope = logger.ScopeContext(logContext);
|
||||
|
||||
if (exception == null)
|
||||
{
|
||||
logger.Log(LogLevel.Information, $"{logData.Method}:{logData.Path}-{logData.Operation}");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Warning, $"{logData.Method}:{logData.Path}-{logData.Operation}{Environment.NewLine}{logData.Exception?.ToSystemTextJsonString()}{Environment.NewLine}{logData.Validation?.ToSystemTextJsonString()}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理泛型类型转字符串打印问题
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private static string HandleGenericType(Type type)
|
||||
{
|
||||
if (type == null) return string.Empty;
|
||||
|
||||
var typeName = type.FullName ?? (!string.IsNullOrEmpty(type.Namespace) ? type.Namespace + "." : string.Empty) + type.Name;
|
||||
|
||||
// 处理泛型类型问题
|
||||
if (type.IsConstructedGenericType)
|
||||
{
|
||||
var prefix = type.GetGenericArguments()
|
||||
.Select(genericArg => HandleGenericType(genericArg))
|
||||
.Aggregate((previous, current) => previous + ", " + current);
|
||||
|
||||
typeName = typeName.Split('`').First() + "<" + prefix + ">";
|
||||
}
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
|
||||
using ThingsGateway.DependencyInjection;
|
||||
|
||||
namespace System;
|
||||
|
||||
[SuppressSniffer, AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class SuppressRequestAuditAttribute : Attribute
|
||||
{
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<Rougamo />
|
||||
</Weavers>
|
@@ -1,22 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
global using BootstrapBlazor.Components;
|
||||
|
||||
global using Microsoft.Extensions.Localization;
|
||||
global using Microsoft.Extensions.Options;
|
||||
|
||||
global using System.Diagnostics.CodeAnalysis;
|
||||
global using System.Globalization;
|
||||
|
||||
global using ThingsGateway.Common;
|
||||
global using ThingsGateway.DB;
|
||||
global using ThingsGateway.NewLife.Extension;
|
||||
global using ThingsGateway.SqlSugar;
|
@@ -1,58 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.NewLife;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class HardwareInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前磁盘信息
|
||||
/// </summary>
|
||||
public DriveInfo DriveInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 硬件信息获取
|
||||
/// </summary>
|
||||
public MachineInfo? MachineInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主机环境
|
||||
/// </summary>
|
||||
public string Environment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// NET框架
|
||||
/// </summary>
|
||||
public string FrameworkDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统架构
|
||||
/// </summary>
|
||||
public string OsArchitecture { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 唯一编码
|
||||
/// </summary>
|
||||
public string UUID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程占用内存
|
||||
/// </summary>
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
public int WorkingSet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public string UpdateTime { get; set; }
|
||||
}
|
@@ -1,156 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using ThingsGateway.Extension;
|
||||
using ThingsGateway.NewLife;
|
||||
using ThingsGateway.NewLife.Caching;
|
||||
using ThingsGateway.NewLife.Threading;
|
||||
using ThingsGateway.Schedule;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 获取硬件信息作业任务
|
||||
/// </summary>
|
||||
[JobDetail("hardware_log", Description = "获取硬件信息", GroupName = "Hardware", Concurrent = false)]
|
||||
[PeriodSeconds(30, TriggerId = "trigger_hardware", Description = "获取硬件信息", RunOnStart = true)]
|
||||
public class HardwareJob : IJob, IHardwareJob
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStringLocalizer _localizer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public HardwareJob(ILogger<HardwareJob> logger, IStringLocalizer<HardwareJob> localizer, IOptions<HardwareInfoOptions> options)
|
||||
{
|
||||
_logger = logger;
|
||||
_localizer = localizer;
|
||||
HardwareInfoOptions = options.Value;
|
||||
}
|
||||
#region 属性
|
||||
|
||||
/// <summary>
|
||||
/// 运行信息获取
|
||||
/// </summary>
|
||||
public HardwareInfo HardwareInfo { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public HardwareInfoOptions HardwareInfoOptions { get; private set; }
|
||||
|
||||
#endregion 属性
|
||||
|
||||
private ICache MemoryCache => App.CacheService;
|
||||
private const string CacheKey = $"{CacheConst.Cache_HardwareInfo}HistoryHardwareInfo";
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<HistoryHardwareInfo>> GetHistoryHardwareInfos()
|
||||
{
|
||||
var historyHardwareInfos = MemoryCache.Get<List<HistoryHardwareInfo>>(CacheKey);
|
||||
if (historyHardwareInfos == null)
|
||||
{
|
||||
using var db = DbContext.GetDB<HistoryHardwareInfo>();
|
||||
historyHardwareInfos = await db.Queryable<HistoryHardwareInfo>().Where(a => a.Date > DateTime.Now.AddDays(-3)).Take(1000).ToListAsync().ConfigureAwait(false);
|
||||
|
||||
MemoryCache.Set(CacheKey, historyHardwareInfos);
|
||||
}
|
||||
return historyHardwareInfos;
|
||||
}
|
||||
|
||||
private bool error = false;
|
||||
private DateTime hisInsertTime = default;
|
||||
private SqlSugarClient _db = DbContext.GetDB<HistoryHardwareInfo>();
|
||||
|
||||
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
|
||||
{
|
||||
if (HardwareInfoOptions.Enable)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HardwareInfo.MachineInfo == null)
|
||||
{
|
||||
HardwareInfo.MachineInfo = MachineInfo.GetCurrent();
|
||||
|
||||
string currentPath = Directory.GetCurrentDirectory();
|
||||
DriveInfo drive = new(Path.GetPathRoot(currentPath));
|
||||
|
||||
HardwareInfoOptions.DaysAgo = Math.Min(Math.Max(HardwareInfoOptions.DaysAgo, 1), 7);
|
||||
if (HardwareInfoOptions.HistoryInterval < 60000) HardwareInfoOptions.HistoryInterval = 60000;
|
||||
HardwareInfo.DriveInfo = drive;
|
||||
HardwareInfo.OsArchitecture = Environment.OSVersion.Platform.ToString() + " " + RuntimeInformation.OSArchitecture.ToString(); // 系统架构
|
||||
HardwareInfo.FrameworkDescription = RuntimeInformation.FrameworkDescription; // NET框架
|
||||
HardwareInfo.Environment = App.HostEnvironment.IsDevelopment() ? "Development" : "Production";
|
||||
HardwareInfo.UUID = HardwareInfo.MachineInfo.UUID;
|
||||
|
||||
HardwareInfo.UpdateTime = TimerX.Now.ToDefaultDateTimeFormat();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
HardwareInfo.MachineInfo.Refresh();
|
||||
HardwareInfo.UpdateTime = TimerX.Now.ToDefaultDateTimeFormat();
|
||||
HardwareInfo.WorkingSet = (Environment.WorkingSet / 1024.0 / 1024.0).ToInt();
|
||||
error = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!error)
|
||||
_logger.LogWarning(ex, "Get Hardwareinfo Fail");
|
||||
error = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (HardwareInfoOptions.Enable)
|
||||
{
|
||||
if (DateTime.Now > hisInsertTime.Add(TimeSpan.FromMilliseconds(HardwareInfoOptions.HistoryInterval)))
|
||||
{
|
||||
hisInsertTime = DateTime.Now;
|
||||
{
|
||||
var his = new HistoryHardwareInfo()
|
||||
{
|
||||
Date = TimerX.Now,
|
||||
DriveUsage = (100 - (HardwareInfo.DriveInfo.TotalFreeSpace * 100.00 / HardwareInfo.DriveInfo.TotalSize)).ToInt(),
|
||||
Battery = (HardwareInfo.MachineInfo.Battery * 100).ToInt(),
|
||||
MemoryUsage = (HardwareInfo.WorkingSet),
|
||||
CpuUsage = (HardwareInfo.MachineInfo.CpuRate * 100).ToInt(),
|
||||
Temperature = (HardwareInfo.MachineInfo.Temperature).ToInt(),
|
||||
};
|
||||
await _db.InsertableT(his).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false);
|
||||
MemoryCache.Remove(CacheKey);
|
||||
}
|
||||
var sevenDaysAgo = TimerX.Now.AddDays(-HardwareInfoOptions.DaysAgo);
|
||||
//删除特定信息
|
||||
var result = await _db.Deleteable<HistoryHardwareInfo>(a => a.Date <= sevenDaysAgo).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false);
|
||||
if (result > 0)
|
||||
{
|
||||
MemoryCache.Remove(CacheKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
error = false;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!error)
|
||||
_logger.LogWarning(ex, "Get Hardwareinfo Fail");
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[SugarTable("his_hardwareinfo", TableDescription = "硬件信息历史表")]
|
||||
[Tenant(SqlSugarConst.DB_HardwareInfo)]
|
||||
public class HistoryHardwareInfo
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[SugarColumn(ColumnDescription = "磁盘使用率")]
|
||||
public int DriveUsage { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[SugarColumn(ColumnDescription = "内存")]
|
||||
public int MemoryUsage { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[SugarColumn(ColumnDescription = "CPU使用率")]
|
||||
public int CpuUsage { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[SugarColumn(ColumnDescription = "温度")]
|
||||
public int Temperature { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[SugarColumn(ColumnDescription = "电池")]
|
||||
public int Battery { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[SugarColumn(ColumnDescription = "时间")]
|
||||
public DateTime Date { get; set; }
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public interface IHardwareJob
|
||||
{
|
||||
HardwareInfo HardwareInfo { get; }
|
||||
HardwareInfoOptions HardwareInfoOptions { get; }
|
||||
Task<List<HistoryHardwareInfo>> GetHistoryHardwareInfos();
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.Schedule;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 作业持久化(数据库)
|
||||
/// </summary>
|
||||
public class JobPersistence : IJobPersistence
|
||||
{
|
||||
/// <summary>
|
||||
/// 作业调度服务启动时
|
||||
/// </summary>
|
||||
/// <param name="stoppingToken"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotSupportedException"></exception>
|
||||
public async Task<IEnumerable<SchedulerBuilder>> PreloadAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await Task.CompletedTask.ConfigureAwait(false);
|
||||
// 获取所有定义的作业
|
||||
var allJobs = App.EffectiveTypes.ScanToBuilders().ToList();
|
||||
return allJobs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 作业计划初始化通知
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <param name="stoppingToken"></param>
|
||||
/// <returns></returns>
|
||||
public Task<SchedulerBuilder> OnLoadingAsync(SchedulerBuilder builder, CancellationToken stoppingToken)
|
||||
{
|
||||
return Task.FromResult(builder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 作业计划Scheduler的JobDetail变化时
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task OnChangedAsync(PersistenceContext context)
|
||||
{
|
||||
await Task.CompletedTask.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 作业计划Scheduler的触发器Trigger变化时
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task OnTriggerChangedAsync(PersistenceTriggerContext context)
|
||||
{
|
||||
await Task.CompletedTask.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 作业触发器运行记录
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task OnExecutionRecordAsync(PersistenceExecutionRecordContext context)
|
||||
{
|
||||
await Task.CompletedTask.ConfigureAwait(false);
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.Schedule;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 清理日志作业任务
|
||||
/// </summary>
|
||||
[JobDetail("job_log", Description = "清理操作日志", GroupName = "Log", Concurrent = false)]
|
||||
[Daily(TriggerId = "trigger_log", Description = "清理操作日志", RunOnStart = true)]
|
||||
public class LogJob : IJob
|
||||
{
|
||||
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
|
||||
{
|
||||
var daysAgo = App.GetOptions<AdminLogOptions>()?.OperateLogDaysAgo ?? 7;
|
||||
await LogJob.DeleteSysOperateLog(daysAgo, stoppingToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static async Task DeleteSysOperateLog(int daysAgo, CancellationToken stoppingToken)
|
||||
{
|
||||
using var db = DbContext.GetDB<SysOperateLog>();
|
||||
var time = DateTime.Now.AddDays(-daysAgo);
|
||||
await db.DeleteableWithAttr<SysOperateLog>().Where(u => u.OpTime < time).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false); // 删除操作日志
|
||||
}
|
||||
}
|
@@ -1,393 +0,0 @@
|
||||
{
|
||||
"ThingsGateway.Admin.Application.AppConfig": {
|
||||
"LoginPolicy": "LoginPolicy",
|
||||
"PagePolicy": "PagePolicy",
|
||||
"PasswordPolicy": "PasswordPolicy",
|
||||
"WebsitePolicy": "WebsitePolicy"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.AuthController": {
|
||||
"AuthController": "Login API",
|
||||
"LoginAsync": "Login",
|
||||
"LogoutAsync": "Logout"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.AuthService": {
|
||||
"AuthErrorMax": "Account password error, will be locked for {1} minutes after exceeding {0} times, error count {2}",
|
||||
"MustDesc": "Password needs to be encrypted with DESC before passing",
|
||||
"OrgDisable": "The affiliated company/department has been deactivated, please contact the administrator",
|
||||
"PasswordError": "Too many password errors, please try again in {0} minutes",
|
||||
"SingleLoginWarn": "Your account is logged in elsewhere",
|
||||
"TenantNull": "The tenant does not exist",
|
||||
"UserDisable": "Account {0} has been disabled",
|
||||
"UserNoModule": "This account has not been assigned a module. Please contact the administrator",
|
||||
"UserNull": "User {0} does not exist"
|
||||
},
|
||||
|
||||
"ThingsGateway.Admin.Application.BlazorAuthenticationHandler": {
|
||||
"UserExpire": "User expired, please login again"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.DataScopeEnum": {
|
||||
"SCOPE_ALL": "All",
|
||||
"SCOPE_ORG": "OnlyOrg",
|
||||
"SCOPE_ORG_CHILD": "OrgChild",
|
||||
"SCOPE_ORG_DEFINE": "Define",
|
||||
"SCOPE_SELF": "Self"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.DefaultDataScope": {
|
||||
"ScopeCategory": "DataScope",
|
||||
"ScopeDefineOrgIdList": "DefineOrgList"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.DictTypeEnum": {
|
||||
"Define": "Business",
|
||||
"System": "System"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.FileService": {
|
||||
"FileLengthError": "File size cannot exceed {0} M",
|
||||
"FileNullError": "File cannot be empty",
|
||||
"FileTypeError": "Not supported format {0}"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.HardwareInfo": {
|
||||
"Environment": "HostEnvironment",
|
||||
"FrameworkDescription": ".NETFramework",
|
||||
"OsArchitecture": "System Architecture",
|
||||
"UpdateTime": "UpdateTime",
|
||||
"UUID": "UUID"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.HardwareJob": {
|
||||
"GetHardwareInfoFail": "Get Hardwareinfo Fail"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.HistoryHardwareInfo": {
|
||||
"Battery": "Battery",
|
||||
"CpuUsage": "CPU Usage",
|
||||
"DriveUsage": "Disk Usage",
|
||||
"MemoryUsage": "Memory",
|
||||
"Temperature": "Temperature"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LogCateGoryEnum": {
|
||||
"Exception": "Exception",
|
||||
"Login": "Login",
|
||||
"Logout": "Logout",
|
||||
"Operate": "Operation"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LogEnum": {
|
||||
"FAIL": "Fail",
|
||||
"SUCCESS": "Success"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LoginInput": {
|
||||
"Account": "Account",
|
||||
"Account.Required": "{0} is required",
|
||||
"Password": "Password",
|
||||
"Password.Required": "{0} is required"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LoginPolicy": {
|
||||
"ErrorCount": "Login error count lock threshold",
|
||||
"ErrorCount.MinValue": "{0} value is too small",
|
||||
"ErrorLockTime": "Login error lock duration (min)",
|
||||
"ErrorLockTime.MinValue": "{0} value is too small",
|
||||
"ErrorResetTime": "Login error count expiration duration (min)",
|
||||
"ErrorResetTime.MinValue": "{0} value is too small",
|
||||
"SingleOpen": "Single user login switch",
|
||||
"VerificatExpireTime": "Login expiration time (min)",
|
||||
"VerificatExpireTime.MinValue": "{0} value is too small"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LogoutInput": {
|
||||
"VerificatId.Required": "{0} is required"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OpenApiAuthController": {
|
||||
"LoginAsync": "Login",
|
||||
"LogoutAsync": "Logout",
|
||||
"OpenApiAuthController": "Login API"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OperateLogPageInput": {
|
||||
"Account": "Account",
|
||||
"Category": "Category",
|
||||
"SearchDate": "SearchDate"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OperDescAttribute": {
|
||||
"ChangeParentResource": "ChangeParentResource",
|
||||
"CopyOrg": "Copy Organization",
|
||||
"CopyResource": "CopyResource",
|
||||
"DeleteDict": "Delete dictionary",
|
||||
"DeleteOperLog": "Delete operation log",
|
||||
"DeleteOrg": "Delete Organization",
|
||||
"DeletePosition": "Delete Position",
|
||||
"DeleteResource": "Delete resource",
|
||||
"DeleteRole": "Delete role",
|
||||
"DeleteuSER": "Delete user",
|
||||
"EditLoginPolicy": "Modify login policy",
|
||||
"EditPagePolicy": "Modify page policy",
|
||||
"EditPasswordPolicy": "Modify password policy",
|
||||
"EditWebsitePolicy": "Modify website settings",
|
||||
"ExitSession": "Force session off",
|
||||
"ExitVerificat": "Force token off",
|
||||
"ExportOperLog": "Export operation log",
|
||||
"GrantApi": "GrantApi",
|
||||
"GrantResource": "GrantResource",
|
||||
"GrantRole": "GrantRole",
|
||||
"GrantUser": "GrantUser",
|
||||
"NoPermission": "No Permission",
|
||||
"ResetPassword": "Reset pw",
|
||||
"RoleGrantApiPermission": "Role grant OpenApi",
|
||||
"RoleGrantResource": "Role grant resource",
|
||||
"RoleGrantUser": "Role grant user",
|
||||
"SaveDict": "Modify dictionary",
|
||||
"SaveOrg": "Save Organization",
|
||||
"SavePosition": "Save Position",
|
||||
"SaveResource": "Modify resource",
|
||||
"SaveRole": "Modify role",
|
||||
"SaveUser": "Modify user",
|
||||
"UpdatePassword": "Update personal password",
|
||||
"UpdateUserInfo": "Update personal information",
|
||||
"UserGrantApiPermission": "User grant OpenApi",
|
||||
"UserGrantResource": "User grant resource",
|
||||
"UserGrantRole": "User grant role",
|
||||
"WorkbenchInfo": "Update personal workbench"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OrgEnum": {
|
||||
"COMPANY": "Company",
|
||||
"DEPT": "Dept"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.PagePolicy": {
|
||||
"Razor": "Default homepage",
|
||||
"Shortcuts": "Default shortcuts"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.PasswordPolicy": {
|
||||
"DefaultPassword": "Default user password",
|
||||
"DefaultPassword.Required": "{0} is required",
|
||||
"PasswordContainChar": "Contain special characters",
|
||||
"PasswordContainLower": "Contain lowercase letters",
|
||||
"PasswordContainNum": "Contain numbers",
|
||||
"PasswordContainUpper": "Contain uppercase letters",
|
||||
"PasswordMinLen": "Minimum password length",
|
||||
"PasswordMinLen.MinValue": "{0} value is too small"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.PositionCategoryEnum": {
|
||||
"HIGH": "High",
|
||||
"LOW": "Low",
|
||||
"MIDDLE": "Middle"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.ResourceCategoryEnum": {
|
||||
"Button": "Button",
|
||||
"Menu": "Menu",
|
||||
"Module": "Module"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.ResourceTableSearchModel": {
|
||||
"Href": "Path",
|
||||
"Module": "Module",
|
||||
"Title": "Title"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.RoleCategoryEnum": {
|
||||
"Global": "Global",
|
||||
"Org": "Org"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SessionOutput": {
|
||||
"Account": "Account",
|
||||
"LatestLoginIp": "Latest login IP",
|
||||
"LatestLoginTime": "Latest login time",
|
||||
"Online": "Online status",
|
||||
"VerificatCount": "Token count"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysDict": {
|
||||
"Category": "Category",
|
||||
"Category.Required": "{0} is required",
|
||||
"Code": "Code",
|
||||
"Code.Required": "{0} is required",
|
||||
"DemoCanotUpdateWebsitePolicy": "DEMO environment does not allow modifying website settings",
|
||||
"DictDup": "Duplicate configuration exists, category {0}, name {1}",
|
||||
"Name": "Name",
|
||||
"Name.Required": "{0} is required",
|
||||
"Remark": "Remark"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysOperateLog": {
|
||||
"Category": "Category",
|
||||
"ClassName": "ClassName",
|
||||
"ExeMessage": "ExeMessage",
|
||||
"ExeStatus": "ExeStatus",
|
||||
"MethodName": "MethodName",
|
||||
"Name": "Name",
|
||||
"OpAccount": "OpAccount",
|
||||
"OpBrowser": "OpBrowser",
|
||||
"OpIp": "OpIp",
|
||||
"OpOs": "OpOs",
|
||||
"OpTime": "OpTime",
|
||||
"ParamJson": "ParamJson",
|
||||
"ReqMethod": "RequestMethod",
|
||||
"ReqUrl": "RequestUrl",
|
||||
"ResultJson": "ResultJson",
|
||||
"VerificatId": "VerificatId"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysOrg": {
|
||||
"CanotContainsSelf": "Cannot contain itself",
|
||||
"Category": "Category",
|
||||
"Category.Required": "{0} is a required field",
|
||||
"Code": "Code",
|
||||
"Code.Required": "{0} is a required field",
|
||||
"CodeDup": "Duplicate code {0} exists",
|
||||
"DeletePositionFirst": "Please remove the positions under the organization first",
|
||||
"DeleteRoleFirst": "Please remove the roles under the organization first",
|
||||
"DeleteUserFirst": "Please remove the users under the organization first",
|
||||
"DirectorId": "Director",
|
||||
"Dup": "Duplicate organization exists with Category {0} and Name {1}",
|
||||
"Name": "Name",
|
||||
"Name.Required": "{0} is a required field",
|
||||
"NameDup": "Duplicate name {0} exists",
|
||||
"Names": "Names",
|
||||
"ParentChoiceSelf": "Parent cannot be itself",
|
||||
"ParentId": "ParentOrg",
|
||||
"ParentNull": "Parent does not exist {0}",
|
||||
"Remark": "Remarks",
|
||||
"RootOrg": "Unable to create top-level organization",
|
||||
"Status": "Status",
|
||||
"TargetNameDup": "Target node has duplicate name {0}"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysOrgCopyInput": {
|
||||
"ContainsChild": "ContainsChild",
|
||||
"ContainsPosition": "ContainsPosition",
|
||||
"TargetId": "Target"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysPosition": {
|
||||
"CanotContainsSelf": "Cannot contain itself",
|
||||
"Category": "Category",
|
||||
"Category.Required": "{0} is a required field",
|
||||
"Code": "Code",
|
||||
"Code.Required": "{0} is a required field",
|
||||
"CodeDup": "Duplicate code {0} exists",
|
||||
"DeleteUserFirst": "Please remove the users under the position first",
|
||||
"Dup": "Duplicate position exists with Category {0} and Name {1}",
|
||||
"Name": "Name",
|
||||
"Name.Required": "{0} is a required field",
|
||||
"NameDup": "Duplicate name {0} exists",
|
||||
"OrgId": "Organization",
|
||||
"OrgId.MinValue": "{0} is a required field",
|
||||
"ParentChoiceSelf": "Parent cannot be itself",
|
||||
"ParentNull": "Parent does not exist {0}",
|
||||
"Remark": "Remarks",
|
||||
"Status": "Status",
|
||||
"TargetNameDup": "Target node has duplicate name {0}"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysResource": {
|
||||
"CanotDeleteSystemResource": "Cannot delete system resource {0}",
|
||||
"Category": "Category",
|
||||
"Code": "Code",
|
||||
"Href": "Path",
|
||||
"Href.Required": "{0} is required",
|
||||
"Icon": "Icon",
|
||||
"Module": "Module",
|
||||
"ModuleIdDiff": "Module is inconsistent with parent menu",
|
||||
"NavLinkMatch": "NavLinkMatch",
|
||||
"NotFoundResource": "System exception, menu not found",
|
||||
"ParentId": "Parent",
|
||||
"ResourceDup": "Duplicate name {0} exists",
|
||||
"ResourceMenuHrefNotNull": "Menu href cannot null",
|
||||
"ResourceParentChoiceSelf": "Parent cannot choose itself",
|
||||
"ResourceParentNull": "Parent does not exist {0}",
|
||||
"Target": "Target",
|
||||
"Title": "Title",
|
||||
"Title.Required": "{0} is required"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysRole": {
|
||||
"CannotRoleScopeAll": "Organization role cannot select global data scope",
|
||||
"CanotDeleteAdmin": "Cannot delete built-in super admin role",
|
||||
"CanotEditAdmin": "Cannot edit super admin role",
|
||||
"CanotGrantAdmin": "Cannot assign admins roles",
|
||||
"Category": "Category",
|
||||
"Code": "Code",
|
||||
"CodeDup": "Duplicate code exists: {0}",
|
||||
"Global": "Global",
|
||||
"Name": "Name",
|
||||
"Name.Required": "{0} is required",
|
||||
"NameDup": "Duplicate role name {0}",
|
||||
"OrgId": "Org",
|
||||
"OrgNotNull": "Organization cannot be null",
|
||||
"SameOrgNameDup": "Duplicate role name exists: {0}",
|
||||
"Status": "Status"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysUser": {
|
||||
"Account": "Account",
|
||||
"Account.Required": "Account.Required",
|
||||
"AccountDup": "Duplicate account {0} exists",
|
||||
"Avatar": "Avatar",
|
||||
"CanotDeleteAdminUser": "Cannot delete built-in super admin user",
|
||||
"CanotDeleteSelf": "Cannot delete yourself",
|
||||
"CanotEditAdminUser": "Cannot edit super admin user",
|
||||
"CanotGrantAdmin": "Cannot assign admins roles",
|
||||
"CheckSelf": "Prohibit {0} yourself",
|
||||
"ConfirmPasswordDiff": "Passwords entered twice are inconsistent",
|
||||
"DemoCanotUpdatePassword": "DEMO environment does not allow password modification",
|
||||
"DirectorId": "Director",
|
||||
"DirectorSelf": "Cannot set oneself as the supervisor",
|
||||
"Disable": "Disable",
|
||||
"Email": "Email",
|
||||
"EmailDup": "Duplicate email {0} exists",
|
||||
"EmailError": "Email format error {0}",
|
||||
"Enable": "Enable",
|
||||
"ExitVerificat": "You have been forcibly logged out",
|
||||
"GrantRole": "GrantRole",
|
||||
"LastLoginAddress": "LastLoginAddress",
|
||||
"LastLoginDevice": "LastLoginDevice",
|
||||
"LastLoginIp": "LastLoginIp",
|
||||
"LastLoginTime": "LastLoginTime",
|
||||
"LatestLoginAddress": "LatestLoginAddress",
|
||||
"LatestLoginDevice": "LatestLoginDevice",
|
||||
"LatestLoginIp": "LatestLoginIp",
|
||||
"LatestLoginTime": "LatestLoginTime",
|
||||
"NoOrg": "The organization does not exist",
|
||||
"OldPasswordError": "Incorrect old password",
|
||||
"OrgId": "Org",
|
||||
"OrgNames": "OrgNames",
|
||||
"Password": "Password",
|
||||
"PasswordEdited": "Password changed, logged out",
|
||||
"PasswordLengthLess": "Password length cannot be less than {0}",
|
||||
"PasswordMustLow": "Password must contain lowercase letters",
|
||||
"PasswordMustNum": "Password must contain numbers",
|
||||
"PasswordMustSpecial": "Password must contain special characters",
|
||||
"PasswordMustUpp": "Password must contain uppercase letters",
|
||||
"Phone": "Phone",
|
||||
"PhoneError": "Phone number format error {0}",
|
||||
"PositionId": "Position",
|
||||
"PositionName": "PositionName",
|
||||
"Status": "Status"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.TargetEnum": {
|
||||
"_blank": "New window",
|
||||
"_parent": "Parent window",
|
||||
"_self": "Current window",
|
||||
"_top": "Top window"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.TestController": {
|
||||
"Test": "Test",
|
||||
"TestController": "Test API"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.UnifyResultProvider": {
|
||||
"NoPermission": "Access denied, no permission",
|
||||
"TokenOver": "Login has expired, please login again"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.UpdatePasswordInput": {
|
||||
"ConfirmPassword": "Confirm password",
|
||||
"ConfirmPassword.Required": "{0} is required",
|
||||
"NewPassword": "New password",
|
||||
"NewPassword.Required": "{0} is required",
|
||||
"Password": "Password",
|
||||
"Password.Required": "{0} is required"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.UserSelectorOutput": {
|
||||
"Account": "Account",
|
||||
"OrgId": "Org"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.VerificatInfo": {
|
||||
"Device": "Device",
|
||||
"Expire": "Expire(min)",
|
||||
"LoginIp": "LoginIp",
|
||||
"LoginTime": "LoginTime",
|
||||
"Online": "Online",
|
||||
"VerificatTimeout": "VerificatTimeout"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.WebsitePolicy": {
|
||||
"CloseTip": "CloseTip",
|
||||
"CloseTip.Required": "{0} is required",
|
||||
"WebStatus": "WebStatus"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.WorkbenchInfo": {
|
||||
"Razor": "Homepage",
|
||||
"Shortcuts": "Shortcuts"
|
||||
}
|
||||
}
|
@@ -1,393 +0,0 @@
|
||||
{
|
||||
"ThingsGateway.Admin.Application.AppConfig": {
|
||||
"LoginPolicy": "登录策略",
|
||||
"PagePolicy": "页面设置",
|
||||
"PasswordPolicy": "密码策略",
|
||||
"WebsitePolicy": "网站设置"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.AuthController": {
|
||||
"AuthController": "登录API",
|
||||
"LoginAsync": "登录",
|
||||
"LogoutAsync": "注销"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.AuthService": {
|
||||
"AuthErrorMax": "账号密码错误,超过 {0} 次后将锁定 {1} 分钟,错误次数 {2} ",
|
||||
"MustDesc": "密码需要DESC加密后传入",
|
||||
"OrgDisable": "所属公司/部门已停用,请联系管理员",
|
||||
"PasswordError": "密码错误次数过多,请 {0} 分钟后再试",
|
||||
"SingleLoginWarn": "您的账号已在别处登录",
|
||||
"TenantNull": "租户不存在",
|
||||
"UserDisable": "账号 {0} 已停用",
|
||||
"UserNoModule": "该账号未分配模块,请联系管理员",
|
||||
"UserNull": "用户 {0} 不存在"
|
||||
},
|
||||
|
||||
"ThingsGateway.Admin.Application.BlazorAuthenticationHandler": {
|
||||
"UserExpire": "用户登录已过期,请重新登录"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.DataScopeEnum": {
|
||||
"SCOPE_ALL": "全部",
|
||||
"SCOPE_ORG": "仅所属组织",
|
||||
"SCOPE_ORG_CHILD": "所属组织及以下",
|
||||
"SCOPE_ORG_DEFINE": "自定义",
|
||||
"SCOPE_SELF": "仅自己"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.DefaultDataScope": {
|
||||
"ScopeCategory": "数据范围",
|
||||
"ScopeDefineOrgIdList": "自定义列表"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.DictTypeEnum": {
|
||||
"Define": "业务配置",
|
||||
"System": "系统配置"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.FileService": {
|
||||
"FileLengthError": "文件大小不允许超过 {0} M",
|
||||
"FileNullError": "文件不能为空",
|
||||
"FileTypeError": "不支持 {0} 格式"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.HardwareInfo": {
|
||||
"Environment": "主机环境",
|
||||
"FrameworkDescription": "NET框架",
|
||||
"OsArchitecture": "系统架构",
|
||||
"UpdateTime": "更新时间",
|
||||
"UUID": "唯一编码"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.HardwareJob": {
|
||||
"GetHardwareInfoFail": "获取硬件信息出错"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.HistoryHardwareInfo": {
|
||||
"Battery": "电池",
|
||||
"CpuUsage": "CPU使用率",
|
||||
"DriveUsage": "磁盘使用率",
|
||||
"MemoryUsage": "内存",
|
||||
"Temperature": "温度"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LogCateGoryEnum": {
|
||||
"Exception": "异常",
|
||||
"Login": "登录",
|
||||
"Logout": "注销",
|
||||
"Operate": "操作"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LogEnum": {
|
||||
"FAIL": "失败",
|
||||
"SUCCESS": "成功"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LoginInput": {
|
||||
"Account": "登录账号",
|
||||
"Account.Required": "{0} 是必填项",
|
||||
"Password": "登录密码",
|
||||
"Password.Required": "{0} 是必填项"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LoginPolicy": {
|
||||
"ErrorCount": "登录错误次数锁定阈值",
|
||||
"ErrorCount.MinValue": " {0} 值太小",
|
||||
"ErrorLockTime": "登录错误锁定时长(分)",
|
||||
"ErrorLockTime.MinValue": " {0} 值太小",
|
||||
"ErrorResetTime": "登录错误次数过期时长(分)",
|
||||
"ErrorResetTime.MinValue": " {0} 值太小",
|
||||
"SingleOpen": "单用户登录开关",
|
||||
"VerificatExpireTime": "登录过期时间(分)",
|
||||
"VerificatExpireTime.MinValue": " {0} 值太小"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.LogoutInput": {
|
||||
"VerificatId.Required": "{0} 是必填项"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OpenApiAuthController": {
|
||||
"LoginAsync": "登录",
|
||||
"LogoutAsync": "注销",
|
||||
"OpenApiAuthController": "登录API"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OperateLogPageInput": {
|
||||
"Account": "操作账号",
|
||||
"Category": "分类",
|
||||
"SearchDate": "时间范围"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OperDescAttribute": {
|
||||
"ChangeParentResource": "更改父节点",
|
||||
"CopyOrg": "复制机构",
|
||||
"CopyResource": "复制资源",
|
||||
"DeleteDict": "删除字典",
|
||||
"DeleteOperLog": "删除操作日志",
|
||||
"DeleteOrg": "删除机构",
|
||||
"DeletePosition": "删除岗位",
|
||||
"DeleteResource": "删除资源",
|
||||
"DeleteRole": "删除角色",
|
||||
"DeleteuSER": "删除用户",
|
||||
"EditLoginPolicy": "修改登录策略",
|
||||
"EditPagePolicy": "修改页面策略",
|
||||
"EditPasswordPolicy": "修改密码策略",
|
||||
"EditWebsitePolicy": "修改网站设置",
|
||||
"ExitSession": "强退会话",
|
||||
"ExitVerificat": "强退令牌",
|
||||
"ExportOperLog": "导出操作日志",
|
||||
"GrantApi": "API",
|
||||
"GrantResource": "资源",
|
||||
"GrantRole": "角色",
|
||||
"GrantUser": "用户",
|
||||
"NoPermission": "无权限操作",
|
||||
"ResetPassword": "重置密码",
|
||||
"RoleGrantApiPermission": "角色授权OpenApi",
|
||||
"RoleGrantResource": "角色授权资源",
|
||||
"RoleGrantUser": "角色授权用户",
|
||||
"SaveDict": "修改字典",
|
||||
"SaveOrg": "保存机构",
|
||||
"SavePosition": "保存岗位",
|
||||
"SaveResource": "修改资源",
|
||||
"SaveRole": "修改角色",
|
||||
"SaveUser": "修改用户",
|
||||
"UpdatePassword": "更新个人密码",
|
||||
"UpdateUserInfo": "更新个人信息",
|
||||
"UserGrantApiPermission": "用户授权OpenApi",
|
||||
"UserGrantResource": "用户授权资源",
|
||||
"UserGrantRole": "用户授权角色",
|
||||
"WorkbenchInfo": "更新个人工作台"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.OrgEnum": {
|
||||
"COMPANY": "公司",
|
||||
"DEPT": "部门"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.PagePolicy": {
|
||||
"Razor": "默认主页",
|
||||
"Shortcuts": "默认快捷方式"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.PasswordPolicy": {
|
||||
"DefaultPassword": "默认用户密码",
|
||||
"DefaultPassword.Required": " {0} 是必填项",
|
||||
"PasswordContainChar": "包含特殊字符",
|
||||
"PasswordContainLower": "包含小写字母",
|
||||
"PasswordContainNum": "包含数字",
|
||||
"PasswordContainUpper": "包含大写字母",
|
||||
"PasswordMinLen": "密码最小长度",
|
||||
"PasswordMinLen.MinValue": " {0} 值太小"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.PositionCategoryEnum": {
|
||||
"HIGH": "高层",
|
||||
"LOW": "低层",
|
||||
"MIDDLE": "中层"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.ResourceCategoryEnum": {
|
||||
"Button": "按钮",
|
||||
"Menu": "菜单",
|
||||
"Module": "模块"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.ResourceTableSearchModel": {
|
||||
"Href": "路径",
|
||||
"Module": "模块",
|
||||
"Title": "标题"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.RoleCategoryEnum": {
|
||||
"Global": "全局",
|
||||
"Org": "机构"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SessionOutput": {
|
||||
"Account": "账号",
|
||||
"LatestLoginIp": "最新登录ip",
|
||||
"LatestLoginTime": "最新登录时间",
|
||||
"Online": "在线状态",
|
||||
"VerificatCount": "令牌数量"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysDict": {
|
||||
"Category": "分类",
|
||||
"Category.Required": "{0} 是必填项",
|
||||
"Code": "代码",
|
||||
"Code.Required": "{0} 是必填项",
|
||||
"DemoCanotUpdateWebsitePolicy": "DEMO环境不允许修改网站设置",
|
||||
"DictDup": "存在重复的配置 分类 {0} 名称 {1}",
|
||||
"Name": "名称",
|
||||
"Name.Required": "{0} 是必填项",
|
||||
"Remark": "备注"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysOperateLog": {
|
||||
"Category": "日志分类",
|
||||
"ClassName": "类名",
|
||||
"ExeMessage": "具体消息",
|
||||
"ExeStatus": "执行状态",
|
||||
"MethodName": "方法名称",
|
||||
"Name": "日志名称",
|
||||
"OpAccount": "账号",
|
||||
"OpBrowser": "浏览器",
|
||||
"OpIp": "ip",
|
||||
"OpOs": "系统",
|
||||
"OpTime": "操作时间",
|
||||
"ParamJson": "请求参数",
|
||||
"ReqMethod": "请求方式",
|
||||
"ReqUrl": "请求地址",
|
||||
"ResultJson": "返回结果",
|
||||
"VerificatId": "验证Id"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysOrg": {
|
||||
"CanotContainsSelf": "不可包含自己",
|
||||
"Category": "分类",
|
||||
"Category.Required": "{0} 是必填项",
|
||||
"Code": "代码",
|
||||
"Code.Required": "{0} 是必填项",
|
||||
"CodeDup": "存在重复的编码 {0}",
|
||||
"DeletePositionFirst": "请先删除机构下的职位",
|
||||
"DeleteRoleFirst": "请先删除机构下的角色",
|
||||
"DeleteUserFirst": "请先删除机构下的用户",
|
||||
"DirectorId": "主管",
|
||||
"Dup": "存在重复的机构 分类 {0} 名称 {1}",
|
||||
"Name": "名称",
|
||||
"Name.Required": "{0} 是必填项",
|
||||
"NameDup": "存在重复的名称 {0}",
|
||||
"Names": "机构全称",
|
||||
"ParentChoiceSelf": "父级不能选择自己",
|
||||
"ParentId": "上级机构",
|
||||
"ParentNull": "父级不存在 {0}",
|
||||
"Remark": "备注",
|
||||
"RootOrg": "无法创建顶层机构",
|
||||
"Status": "状态",
|
||||
"TargetNameDup": "目标节点存在重复的名称 {0}"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysOrgCopyInput": {
|
||||
"ContainsChild": "包含下级",
|
||||
"ContainsPosition": "包含职位",
|
||||
"TargetId": "目标机构"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysPosition": {
|
||||
"CanotContainsSelf": "不可包含自己",
|
||||
"Category": "分类",
|
||||
"Category.Required": "{0} 是必填项",
|
||||
"Code": "代码",
|
||||
"Code.Required": "{0} 是必填项",
|
||||
"CodeDup": "存在重复的编码 {0}",
|
||||
"DeleteUserFirst": "请先删除职位下的用户",
|
||||
"Dup": "存在重复的岗位 分类 {0} 名称 {1}",
|
||||
"Name": "名称",
|
||||
"Name.Required": "{0} 是必填项",
|
||||
"NameDup": "存在重复的名称 {0}",
|
||||
"OrgId": "机构",
|
||||
"OrgId.MinValue": "{0} 是必填项",
|
||||
"ParentChoiceSelf": "父级不能选择自己",
|
||||
"ParentNull": "父级不存在 {0}",
|
||||
"Remark": "备注",
|
||||
"Status": "状态",
|
||||
"TargetNameDup": "目标节点存在重复的名称 {0}"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysResource": {
|
||||
"CanotDeleteSystemResource": "不可删除系统资源 {0}",
|
||||
"Category": "分类",
|
||||
"Code": "编码",
|
||||
"Href": "路径",
|
||||
"Href.Required": "{0} 是必填项",
|
||||
"Icon": "图标",
|
||||
"Module": "模块",
|
||||
"ModuleIdDiff": "模块与上级菜单不一致",
|
||||
"NavLinkMatch": "匹配类型",
|
||||
"NotFoundResource": "系统异常,没找到该菜单",
|
||||
"ParentId": "上级菜单",
|
||||
"ResourceDup": "存在重复的名称 {0}",
|
||||
"ResourceMenuHrefNotNull": "菜单的路径不能为空",
|
||||
"ResourceParentChoiceSelf": "父级不能选择自己",
|
||||
"ResourceParentNull": "父级不存在 {0}",
|
||||
"Target": "跳转类型",
|
||||
"Title": "标题",
|
||||
"Title.Required": "{0} 是必填项"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysRole": {
|
||||
"CannotRoleScopeAll": "机构角色不能选择全局数据范围",
|
||||
"CanotDeleteAdmin": "不可删除系统内置超管角色",
|
||||
"CanotEditAdmin": "不可编辑超管角色",
|
||||
"CanotGrantAdmin": "不能分配超管角色",
|
||||
"Category": "分类",
|
||||
"Code": "编码",
|
||||
"CodeDup": "存在重复的编码 {0}",
|
||||
"Global": "全局",
|
||||
"Name": "名称",
|
||||
"Name.Required": " {0} 是必填项",
|
||||
"NameDup": "存在重复的角色名称 {0}",
|
||||
"OrgId": "机构",
|
||||
"OrgNotNull": "机构不能为空",
|
||||
"SameOrgNameDup": "存在重复的角色名称 {0}",
|
||||
"Status": "状态"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.SysUser": {
|
||||
"Account": "账号",
|
||||
"Account.Required": " {0} 是必填项",
|
||||
"AccountDup": "存在重复的账号 {0}",
|
||||
"Avatar": "头像",
|
||||
"CanotDeleteAdminUser": "不可删除系统内置超管用户",
|
||||
"CanotDeleteSelf": "不可删除自己",
|
||||
"CanotEditAdminUser": "不可编辑超管用户",
|
||||
"CanotGrantAdmin": "不能分配超管角色",
|
||||
"CheckSelf": "禁止 {0} 自己",
|
||||
"ConfirmPasswordDiff": "两次输入的密码不一致",
|
||||
"DemoCanotUpdatePassword": "DEMO环境不允许修改密码",
|
||||
"DirectorId": "主管",
|
||||
"DirectorSelf": "不能设置自己为主管",
|
||||
"Disable": "禁用",
|
||||
"Email": "邮箱",
|
||||
"EmailDup": "存在重复的邮箱 {0}",
|
||||
"EmailError": "邮箱 {0} 格式错误",
|
||||
"Enable": "启用",
|
||||
"ExitVerificat": "您已被强制下线",
|
||||
"GrantRole": "分配角色",
|
||||
"LastLoginAddress": "上次登录地点",
|
||||
"LastLoginDevice": "上次登录设备",
|
||||
"LastLoginIp": "上次登录ip",
|
||||
"LastLoginTime": "上次登录时间",
|
||||
"LatestLoginAddress": "最新登录地点",
|
||||
"LatestLoginDevice": "最新登录设备",
|
||||
"LatestLoginIp": "最新登录ip",
|
||||
"LatestLoginTime": "最新登录时间",
|
||||
"NoOrg": "组织机构不存在",
|
||||
"OldPasswordError": "原密码错误",
|
||||
"OrgId": "机构",
|
||||
"OrgNames": "机构名称",
|
||||
"Password": "密码",
|
||||
"PasswordEdited": "密码被修改,已退出登录",
|
||||
"PasswordLengthLess": "密码长度不能小于 {0} ",
|
||||
"PasswordMustLow": "密码必须包含小写字母",
|
||||
"PasswordMustNum": "密码必须包含数字",
|
||||
"PasswordMustSpecial": "密码必须包含特殊字符",
|
||||
"PasswordMustUpp": "密码必须包含大写字母",
|
||||
"Phone": "手机",
|
||||
"PhoneError": "手机号码 {0} 格式错误",
|
||||
"PositionId": "职位",
|
||||
"PositionName": "职位名称",
|
||||
"Status": "状态"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.TargetEnum": {
|
||||
"_blank": "新窗口",
|
||||
"_parent": "父级窗口",
|
||||
"_self": "本窗口",
|
||||
"_top": "顶级窗口"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.TestController": {
|
||||
"Test": "测试",
|
||||
"TestController": "测试API"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.UnifyResultProvider": {
|
||||
"NoPermission": "禁止访问,没有权限",
|
||||
"TokenOver": "登录已过期,请重新登录"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.UpdatePasswordInput": {
|
||||
"ConfirmPassword": "确认密码",
|
||||
"ConfirmPassword.Required": " {0} 是必填项",
|
||||
"NewPassword": "新密码",
|
||||
"NewPassword.Required": " {0} 是必填项",
|
||||
"Password": "密码",
|
||||
"Password.Required": " {0} 是必填项"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.UserSelectorOutput": {
|
||||
"Account": "账号",
|
||||
"OrgId": "机构"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.VerificatInfo": {
|
||||
"Device": "登录设备",
|
||||
"Expire": "过期时间(分)",
|
||||
"LoginIp": "登录IP",
|
||||
"LoginTime": "登录时间",
|
||||
"Online": "在线状态",
|
||||
"VerificatTimeout": "超时时间"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.WebsitePolicy": {
|
||||
"CloseTip": "关闭提示",
|
||||
"CloseTip.Required": " {0} 是必填项",
|
||||
"WebStatus": "是否开放"
|
||||
},
|
||||
"ThingsGateway.Admin.Application.WorkbenchInfo": {
|
||||
"Razor": "主页",
|
||||
"Shortcuts": "快捷方式"
|
||||
}
|
||||
}
|
@@ -1,208 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Reflection;
|
||||
|
||||
using ThingsGateway.Extension;
|
||||
using ThingsGateway.FriendlyException;
|
||||
using ThingsGateway.Logging;
|
||||
using ThingsGateway.NewLife.Json.Extension;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 数据库写入器
|
||||
/// </summary>
|
||||
public class DatabaseLoggingWriter : IDatabaseLoggingWriter
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志消息队列(线程安全)
|
||||
/// </summary>
|
||||
private readonly ConcurrentQueue<SysOperateLog> _operateLogMessageQueue = new();
|
||||
|
||||
private SqlSugarClient SqlSugarClient;
|
||||
|
||||
/// <summary>
|
||||
/// 此方法只会写入经由MVCFilter捕捉的方法日志,对于BlazorServer的内部操作,由<see cref="OperDescAttribute"/>执行
|
||||
/// </summary>
|
||||
/// <param name="logMsg"></param>
|
||||
/// <param name="flush"></param>
|
||||
public async Task WriteAsync(LogMessage logMsg, bool flush)
|
||||
{
|
||||
//转成实体
|
||||
var requestAuditData = logMsg.Context.Get(nameof(RequestAuditData)) as RequestAuditData;
|
||||
//日志时间赋值
|
||||
requestAuditData.LogDateTime = logMsg.LogDateTime;
|
||||
// requestAuditData.ReturnInformation.Value
|
||||
//验证失败不记录日志
|
||||
bool save = false;
|
||||
if (requestAuditData.Validation == null)
|
||||
{
|
||||
var operation = requestAuditData.Operation;//获取操作名称
|
||||
var client = requestAuditData.Client;//获取客户端信息
|
||||
var path = requestAuditData.Path;//获取操作名称
|
||||
var method = requestAuditData.Method;//获取方法
|
||||
var methodInfo = requestAuditData.MethodInfo;
|
||||
var login = methodInfo.GetCustomAttribute(typeof(LoginLogAttribute));
|
||||
var logout = methodInfo.GetCustomAttribute(typeof(LogoutLogAttribute));
|
||||
|
||||
//表示访问日志
|
||||
if (login != null || logout != null)
|
||||
{
|
||||
//如果没有异常信息
|
||||
if (requestAuditData.Exception == null)
|
||||
{
|
||||
LogCateGoryEnum logCateGoryEnum = login != null ? LogCateGoryEnum.Login : LogCateGoryEnum.Logout;
|
||||
save = await CreateVisitLog(operation, path, requestAuditData, client, logCateGoryEnum, flush).ConfigureAwait(false);//添加到访问日志
|
||||
}
|
||||
else
|
||||
{
|
||||
//添加到异常日志
|
||||
save = await CreateOperationLog(operation, path, requestAuditData, client, flush).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//只有定义了Title的POST方法才记录日志
|
||||
if (!operation.IsNullOrWhiteSpace() && method == "POST")
|
||||
{
|
||||
//添加到操作日志
|
||||
save = await CreateOperationLog(operation, path, requestAuditData, client, flush).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (save)
|
||||
{
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建操作日志
|
||||
/// </summary>
|
||||
/// <param name="operation">操作名称</param>
|
||||
/// <param name="path">请求地址</param>
|
||||
/// <param name="requestAuditData">requestAuditData</param>
|
||||
/// <param name="userAgent">客户端信息</param>
|
||||
/// <param name="flush"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> CreateOperationLog(string operation, string path, RequestAuditData requestAuditData, UserAgent userAgent, bool flush)
|
||||
{
|
||||
//账号
|
||||
var opAccount = requestAuditData.AuthorizationClaims?.Where(it => it.Type == ClaimConst.Account).Select(it => it.Value).FirstOrDefault();
|
||||
|
||||
//获取参数json字符串,
|
||||
var paramJson = requestAuditData.Parameters == null || requestAuditData.Parameters.Count == 0 ? null : requestAuditData.Parameters.ToSystemTextJsonString();
|
||||
|
||||
//获取结果json字符串
|
||||
var resultJson = requestAuditData.ReturnInformation?.ToSystemTextJsonString();
|
||||
|
||||
//操作日志表实体
|
||||
var sysLogOperate = new SysOperateLog
|
||||
{
|
||||
Name = operation,
|
||||
Category = LogCateGoryEnum.Operate,
|
||||
ExeStatus = true,
|
||||
OpIp = requestAuditData.RemoteIPv4,
|
||||
OpBrowser = userAgent?.Browser,
|
||||
OpOs = userAgent?.Platform,
|
||||
OpTime = requestAuditData.LogDateTime.LocalDateTime,
|
||||
OpAccount = opAccount,
|
||||
ReqMethod = requestAuditData.Method,
|
||||
ReqUrl = path,
|
||||
ResultJson = resultJson,
|
||||
ClassName = requestAuditData.ControllerName,
|
||||
MethodName = requestAuditData.ActionName,
|
||||
ParamJson = paramJson,
|
||||
VerificatId = UserManager.VerificatId,
|
||||
};
|
||||
//如果异常不为空
|
||||
if (requestAuditData.Exception != null)
|
||||
{
|
||||
sysLogOperate.Category = LogCateGoryEnum.Exception;//操作类型为异常
|
||||
sysLogOperate.ExeStatus = false;//操作状态为失败
|
||||
|
||||
if (requestAuditData.Exception.Type == typeof(AppFriendlyException).ToString())
|
||||
sysLogOperate.ExeMessage = requestAuditData?.Exception.Message;
|
||||
else
|
||||
sysLogOperate.ExeMessage = $"{requestAuditData.Exception.Type}:{requestAuditData.Exception.Message}{Environment.NewLine}{requestAuditData.Exception.StackTrace}";
|
||||
}
|
||||
|
||||
_operateLogMessageQueue.Enqueue(sysLogOperate);
|
||||
|
||||
if (flush)
|
||||
{
|
||||
SqlSugarClient ??= DbContext.GetDB<SysOperateLog>();
|
||||
await SqlSugarClient.InsertableWithAttr(_operateLogMessageQueue.ToListWithDequeue()).ExecuteCommandAsync().ConfigureAwait(false);//入库
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建访问日志
|
||||
/// </summary>
|
||||
/// <param name="operation">访问类型</param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestAuditData">requestAuditData</param>
|
||||
/// <param name="userAgent">客户端信息</param>
|
||||
/// <param name="logCateGoryEnum">logCateGory</param>
|
||||
/// <param name="flush"></param>
|
||||
private async Task<bool> CreateVisitLog(string operation, string path, RequestAuditData requestAuditData, UserAgent userAgent, LogCateGoryEnum logCateGoryEnum, bool flush)
|
||||
{
|
||||
long verificatId = 0;//验证Id
|
||||
var opAccount = "";//用户账号
|
||||
if (logCateGoryEnum == LogCateGoryEnum.Login)
|
||||
{
|
||||
//如果是登录,用户信息就从返回值里拿
|
||||
if (requestAuditData.ReturnInformation is UnifyResult<LoginOutput> userInfo)
|
||||
{
|
||||
opAccount = userInfo.Data.Account;//赋值账号
|
||||
verificatId = userInfo.Data.VerificatId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果是登录出,用户信息就从AuthorizationClaims里拿
|
||||
opAccount = requestAuditData.AuthorizationClaims.Where(it => it.Type == ClaimConst.Account).Select(it => it.Value).FirstOrDefault();
|
||||
verificatId = requestAuditData.AuthorizationClaims.Where(it => it.Type == ClaimConst.VerificatId).Select(it => it.Value).FirstOrDefault().ToLong();
|
||||
}
|
||||
//日志表实体
|
||||
var sysLogVisit = new SysOperateLog
|
||||
{
|
||||
Name = operation,
|
||||
Category = logCateGoryEnum,
|
||||
ExeStatus = true,
|
||||
OpIp = requestAuditData.RemoteIPv4,
|
||||
OpBrowser = userAgent?.Browser,
|
||||
OpOs = userAgent?.Platform,
|
||||
OpTime = requestAuditData.LogDateTime.LocalDateTime,
|
||||
VerificatId = verificatId,
|
||||
OpAccount = opAccount,
|
||||
|
||||
ReqMethod = requestAuditData.Method,
|
||||
ReqUrl = path,
|
||||
ResultJson = requestAuditData.ReturnInformation?.ToSystemTextJsonString(),
|
||||
ClassName = requestAuditData.ControllerName,
|
||||
MethodName = requestAuditData.ActionName,
|
||||
ParamJson = requestAuditData.Parameters?.ToSystemTextJsonString(),
|
||||
};
|
||||
_operateLogMessageQueue.Enqueue(sysLogVisit);
|
||||
|
||||
if (flush)
|
||||
{
|
||||
SqlSugarClient ??= DbContext.GetDB<SysOperateLog>();
|
||||
await SqlSugarClient.InsertableWithAttr(_operateLogMessageQueue.ToListWithDequeue()).ExecuteCommandAsync().ConfigureAwait(false);//入库
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 日志常量
|
||||
/// </summary>
|
||||
public static class LoggingConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public const string CateGory = "CateGory";
|
||||
|
||||
/// <summary>
|
||||
/// 客户端信息
|
||||
/// </summary>
|
||||
public const string Client = "Client";
|
||||
|
||||
/// <summary>
|
||||
/// 请求方法:POST/GET
|
||||
/// </summary>
|
||||
public const string Method = "Method";
|
||||
|
||||
/// <summary>
|
||||
/// 操作名称
|
||||
/// </summary>
|
||||
public const string Operation = "Operation";
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
/// </summary>
|
||||
public const string Path = "Path";
|
||||
}
|
@@ -1,187 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 认证信息
|
||||
/// </summary>
|
||||
public class AuthorizationClaims
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异常信息
|
||||
/// </summary>
|
||||
public class LogException
|
||||
{
|
||||
/// <summary>
|
||||
/// 异常内容
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 堆栈信息
|
||||
/// </summary>
|
||||
public string StackTrace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 异常类型
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求信息格式化
|
||||
/// </summary>
|
||||
public class LoggingMonitorJson
|
||||
{
|
||||
/// <summary>
|
||||
/// 方法名称
|
||||
/// </summary>
|
||||
public string ActionName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 认证信息
|
||||
/// </summary>
|
||||
public List<AuthorizationClaims> AuthorizationClaims { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 控制器名
|
||||
/// </summary>
|
||||
public string ControllerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类名称
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 环境
|
||||
/// </summary>
|
||||
public string Environment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 异常信息
|
||||
/// </summary>
|
||||
public LogException Exception { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求方法
|
||||
/// </summary>
|
||||
public string HttpMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务端
|
||||
/// </summary>
|
||||
public string LocalIPv4 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日志时间
|
||||
/// </summary>
|
||||
public DateTimeOffset LogDateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统架构
|
||||
/// </summary>
|
||||
public string OsArchitecture { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统名称
|
||||
/// </summary>
|
||||
public string OsDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数列表
|
||||
/// </summary>
|
||||
public List<Parameters> Parameters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户端IPV4地址
|
||||
/// </summary>
|
||||
public string RemoteIPv4 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 认证信息
|
||||
/// </summary>
|
||||
public string RequestHeaderAuthorization { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 认证信息
|
||||
/// </summary>
|
||||
public string RequestHeaderCookies { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
/// </summary>
|
||||
public string RequestUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回信息
|
||||
/// </summary>
|
||||
public ReturnInformation ReturnInformation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 浏览器标识
|
||||
/// </summary>
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证错误信息
|
||||
/// </summary>
|
||||
public Validation Validation { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求参数
|
||||
/// </summary>
|
||||
public class Parameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数名
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回信息
|
||||
/// </summary>
|
||||
public class ReturnInformation
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回值
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证失败信息
|
||||
/// </summary>
|
||||
public class Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误详情
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Riok.Mapperly.Abstractions;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
[Mapper(UseDeepCloning = true, EnumMappingStrategy = EnumMappingStrategy.ByName, RequiredMappingStrategy = RequiredMappingStrategy.None)]
|
||||
public static partial class AdminMapper
|
||||
{
|
||||
public static partial LoginInput AdaptLoginInput(this OpenApiLoginInput src);
|
||||
public static partial OpenApiLoginOutput AdaptOpenApiLoginOutput(this LoginOutput src);
|
||||
public static partial SessionOutput AdaptSessionOutput(this SysUser src);
|
||||
public static partial SysUser AdaptSysUser(this SysUser src);
|
||||
public static partial UserSelectorOutput AdaptUserSelectorOutput(this SysUser src);
|
||||
public static partial List<SysResource> AdaptListSysResource(this IEnumerable<SysResource> src);
|
||||
public static partial AppConfig AdaptAppConfig(this AppConfig src);
|
||||
public static partial WorkbenchInfo AdaptWorkbenchInfo(this WorkbenchInfo src);
|
||||
public static partial QueryData<UserSelectorOutput> AdaptQueryDataUserSelectorOutput(this QueryData<SysUser> src);
|
||||
public static partial LoginInput AdaptLoginInput(this LoginInput src);
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class USheetDatas
|
||||
{
|
||||
public string locale { get; set; } = System.Globalization.CultureInfo.CurrentUICulture.Name;
|
||||
public Dictionary<string, USheetData> sheets { get; set; } = new();
|
||||
}
|
||||
|
||||
public class USheetData
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public int rowCount { get; set; }
|
||||
public int columnCount { get; set; }
|
||||
|
||||
public Dictionary<int, Dictionary<int, USheetCelldata>> cellData { get; set; } = new();
|
||||
}
|
||||
|
||||
public class USheetCelldata
|
||||
{
|
||||
public object v { get; set; }
|
||||
}
|
@@ -1,228 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
|
||||
using ThingsGateway.Extension;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 只适合 Demo 登录,会直接授权超管的权限
|
||||
/// </summary>
|
||||
public class AdminOAuthHandler<TOptions>(
|
||||
IVerificatInfoService verificatInfoService,
|
||||
IAppService appService,
|
||||
ISysUserService sysUserService,
|
||||
ISysDictService configService,
|
||||
IOptionsMonitor<TOptions> options,
|
||||
ILoggerFactory logger,
|
||||
IUserAgentService userAgentService,
|
||||
UrlEncoder encoder
|
||||
) : OAuthHandler<TOptions>(options, logger, encoder)
|
||||
where TOptions : AdminOAuthOptions, new()
|
||||
{
|
||||
static AdminOAuthHandler()
|
||||
{
|
||||
Task.Factory.StartNew(InsertableAsync, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志消息队列(线程安全)
|
||||
/// </summary>
|
||||
protected static readonly ConcurrentQueue<SysOperateLog> _operateLogMessageQueue = new();
|
||||
|
||||
/// <summary>
|
||||
/// 创建访问日志
|
||||
/// </summary>
|
||||
private static async Task InsertableAsync()
|
||||
{
|
||||
var db = DbContext.GetDB<SysOperateLog>();
|
||||
var appLifetime = App.RootServices!.GetService<IHostApplicationLifetime>()!;
|
||||
while (!appLifetime.ApplicationStopping.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _operateLogMessageQueue.ToListWithDequeue(); // 从日志队列中获取数据
|
||||
if (data.Count > 0)
|
||||
{
|
||||
await db.InsertableWithAttr(data).ExecuteCommandAsync(appLifetime.ApplicationStopping).ConfigureAwait(false);//入库
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NewLife.Log.XTrace.WriteException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Task.Delay(3000, appLifetime.ApplicationStopping).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task<AuthenticationTicket> CreateTicketAsync(
|
||||
ClaimsIdentity identity,
|
||||
AuthenticationProperties properties,
|
||||
OAuthTokenResponse tokens)
|
||||
{
|
||||
Backchannel.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokens.AccessToken);
|
||||
properties.RedirectUri = Options.HomePath;
|
||||
properties.IsPersistent = true;
|
||||
var appConfig = await configService.GetAppConfigAsync().ConfigureAwait(false);
|
||||
|
||||
int expire = appConfig.LoginPolicy.VerificatExpireTime;
|
||||
if (!string.IsNullOrEmpty(tokens.ExpiresIn) && int.TryParse(tokens.ExpiresIn, out var result))
|
||||
{
|
||||
properties.ExpiresUtc = TimeProvider.System.GetUtcNow().AddSeconds(result);
|
||||
expire = (int)(result / 60.0);
|
||||
}
|
||||
var user = await Options.HandleUserInfoAsync(Context, tokens).ConfigureAwait(false);
|
||||
|
||||
var loginEvent = await GetLogin(expire).ConfigureAwait(false);
|
||||
await UpdateUser(loginEvent).ConfigureAwait(false);
|
||||
identity.AddClaim(new Claim(ClaimConst.VerificatId, loginEvent.VerificatId.ToString()));
|
||||
identity.AddClaim(new Claim(ClaimConst.UserId, RoleConst.SuperAdminId.ToString()));
|
||||
|
||||
identity.AddClaim(new Claim(ClaimConst.SuperAdmin, "true"));
|
||||
identity.AddClaim(new Claim(ClaimConst.OrgId, RoleConst.DefaultTenantId.ToString()));
|
||||
identity.AddClaim(new Claim(ClaimConst.TenantId, RoleConst.DefaultTenantId.ToString()));
|
||||
|
||||
var context = new OAuthCreatingTicketContext(
|
||||
new ClaimsPrincipal(identity),
|
||||
properties,
|
||||
Context,
|
||||
Scheme,
|
||||
Options,
|
||||
Backchannel,
|
||||
tokens,
|
||||
user
|
||||
);
|
||||
|
||||
context.RunClaimActions();
|
||||
await Events.CreatingTicket(context).ConfigureAwait(false);
|
||||
|
||||
var httpContext = context.HttpContext;
|
||||
UserAgent? userAgent = null;
|
||||
var str = httpContext?.Request?.Headers?.UserAgent;
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
userAgent = userAgentService.Parse(str);
|
||||
}
|
||||
|
||||
var sysOperateLog = new SysOperateLog()
|
||||
{
|
||||
Name = this.Scheme.Name,
|
||||
Category = LogCateGoryEnum.Login,
|
||||
ExeStatus = true,
|
||||
OpIp = httpContext.GetRemoteIpAddressToIPv4(),
|
||||
OpBrowser = userAgent?.Browser,
|
||||
OpOs = userAgent?.Platform,
|
||||
OpTime = DateTime.Now,
|
||||
VerificatId = loginEvent.VerificatId,
|
||||
OpAccount = Options.GetName(user),
|
||||
|
||||
ReqMethod = "OAuth",
|
||||
ReqUrl = string.Empty,
|
||||
ResultJson = string.Empty,
|
||||
ClassName = nameof(AdminOAuthHandler<TOptions>),
|
||||
MethodName = string.Empty,
|
||||
ParamJson = string.Empty,
|
||||
};
|
||||
_operateLogMessageQueue.Enqueue(sysOperateLog);
|
||||
return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name);
|
||||
}
|
||||
|
||||
private async Task<LoginEvent> GetLogin(int expire)
|
||||
{
|
||||
var sysUser = await sysUserService.GetUserByIdAsync(RoleConst.SuperAdminId).ConfigureAwait(false);//获取用户信息
|
||||
|
||||
var loginEvent = new LoginEvent
|
||||
{
|
||||
Ip = appService.RemoteIpAddress,
|
||||
Device = appService.UserAgent?.Platform ?? "Unknown",
|
||||
Expire = expire,
|
||||
SysUser = sysUser,
|
||||
VerificatId = CommonUtils.GetSingleId()
|
||||
};
|
||||
|
||||
//获取verificat列表
|
||||
var tokenTimeout = loginEvent.DateTime.AddMinutes(loginEvent.Expire);
|
||||
//生成verificat信息
|
||||
var verificatInfo = new VerificatInfo
|
||||
{
|
||||
Device = loginEvent.Device ?? "Unknown",
|
||||
Expire = loginEvent.Expire,
|
||||
VerificatTimeout = tokenTimeout,
|
||||
Id = loginEvent.VerificatId,
|
||||
UserId = loginEvent.SysUser.Id,
|
||||
LoginIp = loginEvent.Ip,
|
||||
LoginTime = loginEvent.DateTime
|
||||
};
|
||||
|
||||
//添加到verificat列表
|
||||
verificatInfoService.Add(verificatInfo);
|
||||
return loginEvent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录事件
|
||||
/// </summary>
|
||||
/// <param name="loginEvent"></param>
|
||||
/// <returns></returns>
|
||||
private async Task UpdateUser(LoginEvent loginEvent)
|
||||
{
|
||||
var sysUser = loginEvent.SysUser;
|
||||
|
||||
#region 登录/密码策略
|
||||
|
||||
var key = CacheConst.Cache_LoginErrorCount + sysUser.Account;//获取登录错误次数Key值
|
||||
App.CacheService.Remove(key);//移除登录错误次数
|
||||
|
||||
//获取用户verificat列表
|
||||
var userToken = verificatInfoService.GetOne(loginEvent.VerificatId);
|
||||
|
||||
#endregion 登录/密码策略
|
||||
|
||||
#region 重新赋值属性,设置本次登录信息为最新的信息
|
||||
|
||||
sysUser.LastLoginIp = sysUser.LatestLoginIp;
|
||||
sysUser.LastLoginTime = sysUser.LatestLoginTime;
|
||||
sysUser.LatestLoginIp = loginEvent.Ip;
|
||||
sysUser.LatestLoginTime = loginEvent.DateTime;
|
||||
|
||||
#endregion 重新赋值属性,设置本次登录信息为最新的信息
|
||||
|
||||
using var db = DbContext.GetDB<SysUser>();
|
||||
//更新用户登录信息
|
||||
if (await db.UpdateableT(sysUser).UpdateColumns(it => new
|
||||
{
|
||||
it.LastLoginIp,
|
||||
it.LastLoginTime,
|
||||
it.LatestLoginIp,
|
||||
it.LatestLoginTime,
|
||||
}).ExecuteCommandAsync().ConfigureAwait(false) > 0)
|
||||
App.CacheService.HashAdd(CacheConst.Cache_SysUser, sysUser.Id.ToString(), sysUser);//更新Cache信息
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>自定义 Token 异常</summary>
|
||||
public class OAuthTokenException : Exception
|
||||
{
|
||||
public OAuthTokenException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public OAuthTokenException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public OAuthTokenException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,84 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>OAuthOptions 配置类</summary>
|
||||
public abstract class AdminOAuthOptions : OAuthOptions
|
||||
{
|
||||
/// <summary>默认构造函数</summary>
|
||||
protected AdminOAuthOptions()
|
||||
{
|
||||
ConfigureClaims();
|
||||
this.Events.OnRemoteFailure = context =>
|
||||
{
|
||||
var redirectUri = string.IsNullOrEmpty(HomePath) ? "/" : HomePath;
|
||||
context.Response.Redirect(redirectUri);
|
||||
context.HandleResponse();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
Backchannel = new HttpClient(new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
||||
});
|
||||
Backchannel.DefaultRequestHeaders.UserAgent.Add(
|
||||
new ProductInfoHeaderValue("ThingsGateway", "1.0"));
|
||||
}
|
||||
|
||||
/// <summary>配置 Claims 映射</summary>
|
||||
protected virtual void ConfigureClaims()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual string GetName(JsonElement element)
|
||||
{
|
||||
JsonElement.ObjectEnumerator target = element.EnumerateObject();
|
||||
return target.TryGetValue("name");
|
||||
}
|
||||
|
||||
/// <summary>获得/设置 登陆后首页</summary>
|
||||
public string HomePath { get; set; } = "/";
|
||||
|
||||
/// <summary>处理用户信息方法</summary>
|
||||
public virtual async Task<JsonElement> HandleUserInfoAsync(HttpContext context, OAuthTokenResponse tokens)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, BuildUserInfoUrl(tokens));
|
||||
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
var response = await Backchannel.SendAsync(request, context.RequestAborted).ConfigureAwait(false);
|
||||
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonDocument.Parse(content).RootElement;
|
||||
}
|
||||
|
||||
throw new OAuthTokenException($"OAuth user info endpoint failure: {await Display(response).ConfigureAwait(false)}");
|
||||
}
|
||||
|
||||
/// <summary>生成用户信息请求地址方法</summary>
|
||||
protected virtual string BuildUserInfoUrl(OAuthTokenResponse tokens)
|
||||
{
|
||||
return QueryHelpers.AddQueryString(UserInformationEndpoint, new Dictionary<string, string>
|
||||
{
|
||||
{ "access_token", tokens.AccessToken }
|
||||
});
|
||||
}
|
||||
/// <summary>生成错误信息方法</summary>
|
||||
protected async Task<string> Display(HttpResponseMessage response)
|
||||
{
|
||||
var output = new StringBuilder();
|
||||
output.Append($"Status: {response.StatusCode}; ");
|
||||
output.Append($"Headers: {response.Headers}; ");
|
||||
output.Append($"Body: {await response.Content.ReadAsStringAsync().ConfigureAwait(false)};");
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
}
|
@@ -1,115 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
|
||||
using ThingsGateway.NewLife.Log;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class GiteeOAuthOptions : AdminOAuthOptions
|
||||
{
|
||||
INoticeService _noticeService;
|
||||
IVerificatInfoService _verificatInfoService;
|
||||
public GiteeOAuthOptions() : base()
|
||||
{
|
||||
_noticeService = App.GetService<INoticeService>();
|
||||
_verificatInfoService = App.GetService<IVerificatInfoService>();
|
||||
this.SignInScheme = ClaimConst.Scheme;
|
||||
this.AuthorizationEndpoint = "https://gitee.com/oauth/authorize";
|
||||
this.TokenEndpoint = "https://gitee.com/oauth/token";
|
||||
this.UserInformationEndpoint = "https://gitee.com/api/v5/user";
|
||||
this.HomePath = "/";
|
||||
this.CallbackPath = "/signin-gitee";
|
||||
Scope.Add("user_info");
|
||||
Scope.Add("projects");
|
||||
|
||||
Events.OnCreatingTicket = async context => await HandlerGiteeStarredUrl(context).ConfigureAwait(false);
|
||||
|
||||
Events.OnRedirectToAuthorizationEndpoint = context =>
|
||||
{
|
||||
context.Response.Redirect(context.RedirectUri);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
Events.OnRemoteFailure = context =>
|
||||
{
|
||||
XTrace.WriteException(context.Failure);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>刷新 Token 方法</summary>
|
||||
protected virtual async Task<OAuthTokenResponse> RefreshTokenAsync(TicketReceivedContext ticketReceivedContext, string refreshToken)
|
||||
{
|
||||
var query = new Dictionary<string, string>
|
||||
{
|
||||
{ "refresh_token", refreshToken },
|
||||
{ "grant_type", "refresh_token" }
|
||||
};
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, QueryHelpers.AddQueryString(TokenEndpoint, query));
|
||||
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
var response = await Backchannel.SendAsync(request, ticketReceivedContext.HttpContext.RequestAborted).ConfigureAwait(false);
|
||||
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return OAuthTokenResponse.Success(JsonDocument.Parse(content));
|
||||
}
|
||||
|
||||
return OAuthTokenResponse.Failed(new OAuthTokenException($"OAuth token endpoint failure: {await Display(response).ConfigureAwait(false)}"));
|
||||
}
|
||||
|
||||
public override string GetName(JsonElement element)
|
||||
{
|
||||
JsonElement.ObjectEnumerator target = element.EnumerateObject();
|
||||
return target.TryGetValue("name");
|
||||
}
|
||||
|
||||
private async Task HandlerGiteeStarredUrl(OAuthCreatingTicketContext context, string repoFullName = "ThingsGateway/ThingsGateway")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(context.AccessToken))
|
||||
throw new InvalidOperationException("Access token is missing.");
|
||||
|
||||
var uri = $"https://gitee.com/api/v5/user/starred/{repoFullName}";
|
||||
|
||||
var queryString = new Dictionary<string, string>
|
||||
{
|
||||
{ "access_token", context.AccessToken }
|
||||
};
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, QueryHelpers.AddQueryString(uri, queryString))
|
||||
{
|
||||
Headers = { Accept = { new MediaTypeWithQualityHeaderValue("application/json") } }
|
||||
};
|
||||
|
||||
var response = await context.Backchannel.SendAsync(request, context.HttpContext.RequestAborted).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
var id = context.Identity.Claims.FirstOrDefault(a => a.Type == ClaimConst.VerificatId).Value;
|
||||
|
||||
var verificatInfoIds = _verificatInfoService.GetOne(id.ToLong());
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(5000).ConfigureAwait(false);
|
||||
await _noticeService.NavigationMesage(verificatInfoIds.ClientIds, "https://gitee.com/ThingsGateway/ThingsGateway", "创作不易,如有帮助请star仓库").ConfigureAwait(false);
|
||||
});
|
||||
//throw new Exception($"Failed to star repository: {response.StatusCode}, {content}");
|
||||
}
|
||||
}
|
||||
protected override void ConfigureClaims()
|
||||
{
|
||||
ClaimActions.MapJsonKey(ClaimConst.AvatarUrl, "avatar_url");
|
||||
ClaimActions.MapJsonKey(ClaimConst.Account, "name");
|
||||
|
||||
base.ConfigureClaims();
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class GiteeOAuthSettings
|
||||
{
|
||||
public string ClientId { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
|
||||
using ThingsGateway.NewLife.Log;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class GitHubOAuthOptions : AdminOAuthOptions
|
||||
{
|
||||
INoticeService _noticeService;
|
||||
IVerificatInfoService _verificatInfoService;
|
||||
public GitHubOAuthOptions() : base()
|
||||
{
|
||||
_noticeService = App.GetService<INoticeService>();
|
||||
_verificatInfoService = App.GetService<IVerificatInfoService>();
|
||||
SignInScheme = ClaimConst.Scheme;
|
||||
AuthorizationEndpoint = "https://github.com/login/oauth/authorize";
|
||||
TokenEndpoint = "https://github.com/login/oauth/access_token";
|
||||
UserInformationEndpoint = "https://api.github.com/user";
|
||||
HomePath = "/";
|
||||
CallbackPath = "/signin-github";
|
||||
|
||||
Scope.Add("read:user");
|
||||
Scope.Add("public_repo"); // 需要用于 Star 仓库
|
||||
|
||||
Events.OnCreatingTicket = async context => await HandleGitHubStarAsync(context).ConfigureAwait(false);
|
||||
|
||||
Events.OnRedirectToAuthorizationEndpoint = context =>
|
||||
{
|
||||
context.Response.Redirect(context.RedirectUri);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
Events.OnRemoteFailure = context =>
|
||||
{
|
||||
XTrace.WriteException(context.Failure);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
}
|
||||
|
||||
protected override void ConfigureClaims()
|
||||
{
|
||||
ClaimActions.MapJsonKey(ClaimConst.AvatarUrl, "avatar_url");
|
||||
ClaimActions.MapJsonKey(ClaimConst.Account, "login");
|
||||
|
||||
base.ConfigureClaims();
|
||||
}
|
||||
|
||||
public override string GetName(JsonElement element)
|
||||
{
|
||||
if (element.TryGetProperty("login", out var loginProp))
|
||||
{
|
||||
return loginProp.GetString() ?? string.Empty;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private async Task HandleGitHubStarAsync(OAuthCreatingTicketContext context, string repoFullName = "ThingsGateway/ThingsGateway")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(context.AccessToken))
|
||||
throw new InvalidOperationException("Access token is missing.");
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Put, $"https://api.github.com/user/starred/{repoFullName}")
|
||||
{
|
||||
Headers =
|
||||
{
|
||||
Accept = { new MediaTypeWithQualityHeaderValue("application/vnd.github+json") },
|
||||
Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken),
|
||||
},
|
||||
Content = new StringContent(string.Empty) // GitHub Star 接口需要空内容
|
||||
};
|
||||
request.Headers.UserAgent.Add(new ProductInfoHeaderValue("ThingsGateway", "1.0")); // GitHub API 要求 User-Agent
|
||||
|
||||
var response = await context.Backchannel.SendAsync(request, context.HttpContext.RequestAborted).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
var id = context.Identity.Claims.FirstOrDefault(a => a.Type == ClaimConst.VerificatId).Value;
|
||||
|
||||
var verificatInfoIds = _verificatInfoService.GetOne(id.ToLong());
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(5000).ConfigureAwait(false);
|
||||
await _noticeService.NavigationMesage(verificatInfoIds.ClientIds, "https://github.com/ThingsGateway/ThingsGateway", "创作不易,如有帮助请star仓库").ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>处理用户信息方法</summary>
|
||||
public override async Task<JsonElement> HandleUserInfoAsync(HttpContext context, OAuthTokenResponse tokens)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, UserInformationEndpoint);
|
||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
|
||||
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github+json"));
|
||||
request.Headers.UserAgent.Add(new ProductInfoHeaderValue("ThingsGateway", "1.0")); // GitHub API 要求 User-Agent
|
||||
var response = await Backchannel.SendAsync(request, context.RequestAborted).ConfigureAwait(false);
|
||||
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonDocument.Parse(content).RootElement;
|
||||
}
|
||||
|
||||
throw new OAuthTokenException($"OAuth user info endpoint failure: {await Display(response).ConfigureAwait(false)}");
|
||||
}
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public class GithubOAuthSettings : GiteeOAuthSettings
|
||||
{
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public static class OAuthUserExtensions
|
||||
{
|
||||
public static string TryGetValue(this JsonElement.ObjectEnumerator target, string propertyName)
|
||||
{
|
||||
return target.FirstOrDefault<JsonProperty>((Func<JsonProperty, bool>)(t => t.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase))).Value.ToString() ?? string.Empty;
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.ConfigurableOptions;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public sealed class AdminLogOptions : IConfigurableOptions
|
||||
{
|
||||
public int OperateLogDaysAgo { get; set; }
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.ConfigurableOptions;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 邮件配置选项
|
||||
/// </summary>
|
||||
public sealed class EmailOptions : IConfigurableOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 主机
|
||||
/// </summary>
|
||||
public string Host { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认发件者邮箱
|
||||
/// </summary>
|
||||
public string DefaultFromEmail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认接收人邮箱
|
||||
/// </summary>
|
||||
public string DefaultToEmail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用SSL
|
||||
/// </summary>
|
||||
public bool EnableSsl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱账号
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱密码
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认邮件标题
|
||||
/// </summary>
|
||||
public string DefaultFromName { get; set; }
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.ConfigurableOptions;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 历史硬件信息
|
||||
/// </summary>
|
||||
public class HardwareInfoOptions : IConfigurableOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 历史保存间隔
|
||||
/// </summary>
|
||||
public int HistoryInterval { get; set; } = 60000;
|
||||
|
||||
/// <summary>
|
||||
/// 历史保留天数
|
||||
/// </summary>
|
||||
public int DaysAgo { get; set; } = 7;
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using ThingsGateway.ConfigurableOptions;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
public sealed class TenantOptions : IConfigurableOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
@@ -1,278 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
using System.Security.Claims;
|
||||
|
||||
using ThingsGateway.Authorization;
|
||||
using ThingsGateway.DataEncryption;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class BlazorAuthenticationHandler : AppAuthorizeHandler
|
||||
{
|
||||
private readonly ISysDictService _sysDictService;
|
||||
private readonly ISysRoleService _sysRoleService;
|
||||
private readonly ISysUserService _sysUserService;
|
||||
|
||||
public BlazorAuthenticationHandler(ISysUserService sysUserService, ISysRoleService sysRoleService, ISysDictService sysDictService)
|
||||
{
|
||||
_sysUserService = sysUserService;
|
||||
_sysRoleService = sysRoleService;
|
||||
_sysDictService = sysDictService;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task HandleAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)
|
||||
{
|
||||
var isAuthenticated = context.User.Identity?.IsAuthenticated;
|
||||
if (isAuthenticated == true)
|
||||
{
|
||||
if (await CheckVerificatFromCacheAsync(context).ConfigureAwait(false))
|
||||
{
|
||||
await AuthorizeHandleAsync(context).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Fail(context).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await Fail(context).ConfigureAwait(false);// 授权失败
|
||||
}
|
||||
}
|
||||
static async Task Fail(AuthorizationHandlerContext context)
|
||||
{
|
||||
var verificatId = UserManager.VerificatId;
|
||||
var verificatInfo = App.GetService<IVerificatInfoService>().GetOne(verificatId, false);
|
||||
if (App.HttpContext != null)
|
||||
{
|
||||
var identity = new ClaimsIdentity();
|
||||
App.HttpContext.User = new ClaimsPrincipal(identity);
|
||||
}
|
||||
context.Fail(); // 授权失败
|
||||
|
||||
if (verificatInfo != null)
|
||||
await App.GetService<INoticeService>().UserLoginOut(verificatInfo.ClientIds, App.CreateLocalizerByType(typeof(BlazorAuthenticationHandler))["UserExpire"]).ConfigureAwait(false);
|
||||
|
||||
DefaultHttpContext currentHttpContext = context.GetCurrentHttpContext();
|
||||
if (currentHttpContext == null)
|
||||
return;
|
||||
currentHttpContext.Response.StatusCode = 401; //返回401给授权筛选器用
|
||||
currentHttpContext.SignoutToSwagger();
|
||||
await currentHttpContext.SignOutAsync().ConfigureAwait(false);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public override async Task<bool> PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)
|
||||
{
|
||||
var userId = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.UserId)?.Value?.ToLong(0) ?? 0;
|
||||
|
||||
var user = await _sysUserService.GetUserByIdAsync(userId).ConfigureAwait(false);
|
||||
if (context.Resource is Microsoft.AspNetCore.Components.RouteData routeData)
|
||||
{
|
||||
var roles = await _sysRoleService.GetRoleListByUserIdAsync(userId).ConfigureAwait(false);
|
||||
|
||||
//这里鉴别用户使能状态
|
||||
if (user?.Status != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//超级管理员都能访问
|
||||
var isSuperAdmin = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.SuperAdmin)?.Value.ToBoolean();
|
||||
if (isSuperAdmin == true) return true;
|
||||
|
||||
// 获取超级管理员特性
|
||||
var superAdminAttr = routeData.PageType.CustomAttributes.FirstOrDefault(x =>
|
||||
x.AttributeType == typeof(SuperAdminAttribute));
|
||||
|
||||
if (superAdminAttr != null) //如果是超级管理员才能访问的接口
|
||||
{
|
||||
return false; //直接没权限
|
||||
}
|
||||
//获取角色授权特性
|
||||
var isRolePermission = routeData.PageType.CustomAttributes.FirstOrDefault(x =>
|
||||
x.AttributeType == typeof(RolePermissionAttribute));
|
||||
if (isRolePermission != null)
|
||||
{
|
||||
//获取忽略角色授权特性
|
||||
var isIgnoreRolePermission = routeData.PageType.CustomAttributes.FirstOrDefault(x =>
|
||||
x.AttributeType == typeof(IgnoreRolePermissionAttribute));
|
||||
if (isIgnoreRolePermission == null)
|
||||
{
|
||||
// 路由名称
|
||||
var routeName = routeData.PageType.CustomAttributes.FirstOrDefault(x =>
|
||||
x.AttributeType == typeof(Microsoft.AspNetCore.Components.RouteAttribute))?.ConstructorArguments?[0].Value as string;
|
||||
if (routeName == null) return true;
|
||||
|
||||
if ((!user.PermissionCodeList.Contains(routeName.CutStart("/")) && !user.PermissionCodeList.Contains(routeName))) //如果当前路由信息不包含在角色授权路由列表中则认证失败
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//这里鉴别用户使能状态
|
||||
if (user?.Status != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//超级管理员都能访问
|
||||
var isSuperAdmin = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.SuperAdmin)?.Value?.ToBoolean();
|
||||
if (isSuperAdmin == true) return true;
|
||||
|
||||
if (httpContext == null)
|
||||
{
|
||||
//非API请求
|
||||
return true;
|
||||
}
|
||||
|
||||
var superAdminAttr = httpContext.GetMetadata<SuperAdminAttribute>();
|
||||
|
||||
if (superAdminAttr != null) //如果是超级管理员才能访问的接口
|
||||
{
|
||||
//获取忽略超级管理员特性
|
||||
var ignoreSpuerAdmin = httpContext.GetMetadata<IgnoreSuperAdminAttribute>();
|
||||
if (ignoreSpuerAdmin == null && isSuperAdmin != true) //如果只能超级管理员访问并且用户不是超级管理员
|
||||
return false; //直接没权限
|
||||
}
|
||||
|
||||
//获取角色授权特性
|
||||
var isRolePermission = httpContext.GetMetadata<RolePermissionAttribute>();
|
||||
if (isRolePermission != null)
|
||||
{
|
||||
//获取忽略角色授权特性
|
||||
var ignoreRolePermission = httpContext.GetMetadata<IgnoreRolePermissionAttribute>();
|
||||
if (ignoreRolePermission == null)
|
||||
{
|
||||
// 路由名称
|
||||
var routeName = httpContext.Request.Path.Value;
|
||||
if (routeName == null) return true;
|
||||
if ((!user.PermissionCodeList.Contains(routeName.CutStart("/")) && !user.PermissionCodeList.Contains(routeName))) //如果当前路由信息不包含在角色授权路由列表中则认证失败
|
||||
return false;
|
||||
else
|
||||
{
|
||||
return true; //没有用户信息则返回认证失败
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查 BearerToken/Cookie 有效性
|
||||
/// </summary>
|
||||
/// <param name="context">DefaultHttpContext</param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> CheckVerificatFromCacheAsync(AuthorizationHandlerContext context)
|
||||
{
|
||||
DefaultHttpContext currentHttpContext = context.GetCurrentHttpContext();
|
||||
var userId = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.UserId)?.Value?.ToLong();
|
||||
var verificatId = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.VerificatId)?.Value?.ToLong();
|
||||
var expire = (await _sysDictService.GetAppConfigAsync().ConfigureAwait(false)).LoginPolicy.VerificatExpireTime;
|
||||
if (currentHttpContext == null)
|
||||
{
|
||||
return CheckVerificat(userId, verificatId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (await JWTEncryption.AutoRefreshToken(context, currentHttpContext, expire, expire * 2).ConfigureAwait(false))
|
||||
{
|
||||
//var token = JWTEncryption.GetJwtBearerToken(currentHttpContext); //获取当前token
|
||||
|
||||
var verificatInfo = userId != null ? VerificatInfoService.GetOne(verificatId ?? 0, false) : null;//获取token信息
|
||||
if (verificatInfo != null)
|
||||
{
|
||||
if (verificatInfo.VerificatTimeout < DateTime.Now.AddMinutes(1))
|
||||
{
|
||||
verificatInfo.VerificatTimeout = verificatInfo.VerificatTimeout.AddMinutes(verificatInfo.Expire); //新的过期时间
|
||||
VerificatInfoService.Update(verificatInfo); //更新tokne信息到cache
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//失败
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static IVerificatInfoService _verificatInfoService;
|
||||
private static IVerificatInfoService VerificatInfoService
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_verificatInfoService == null)
|
||||
_verificatInfoService = App.GetService<IVerificatInfoService>();
|
||||
|
||||
return _verificatInfoService;
|
||||
}
|
||||
}
|
||||
public static bool CheckVerificat(long? userId, long? verificatId, bool autoUpdate = true)
|
||||
{
|
||||
var verificatInfo = userId != null ? VerificatInfoService.GetOne(verificatId ?? 0, false) : null;//获取token信息
|
||||
|
||||
if (verificatInfo != null)
|
||||
{
|
||||
if (verificatInfo.VerificatTimeout < DateTime.Now.AddMinutes(1))
|
||||
{
|
||||
if (!autoUpdate && verificatInfo.VerificatTimeout < DateTime.Now)
|
||||
return false;
|
||||
|
||||
if (verificatInfo.VerificatTimeout.AddMinutes(verificatInfo.Expire) < DateTime.Now)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (autoUpdate)
|
||||
{
|
||||
verificatInfo.VerificatTimeout = verificatInfo.VerificatTimeout.AddMinutes(verificatInfo.Expire); //新的过期时间
|
||||
VerificatInfoService.Update(verificatInfo); //更新tokne信息到cache
|
||||
}
|
||||
|
||||
//无法在server中刷新cookies,单页面应用会一直保持登录状态,所以这里不需要刷新cookies,但是F5刷新后会重新登录
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class BlazorHybridAuthenticationStateProvider : AuthenticationStateProvider
|
||||
{
|
||||
private readonly IAppService _appService;
|
||||
private CancellationTokenSource _loopCancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
public BlazorHybridAuthenticationStateProvider(IAppService appService)
|
||||
{
|
||||
_appService = appService;
|
||||
}
|
||||
|
||||
private AuthenticationState AuthenticationState = new AuthenticationState(new ClaimsPrincipal());
|
||||
public void UserChanged(ClaimsPrincipal user)
|
||||
{
|
||||
AuthenticationState = new AuthenticationState(user);
|
||||
NotifyAuthenticationStateChanged(GetAuthenticationStateAsync());
|
||||
var oldCancellationTokenSource = _loopCancellationTokenSource;
|
||||
if (oldCancellationTokenSource is not null)
|
||||
{
|
||||
oldCancellationTokenSource.Cancel();
|
||||
oldCancellationTokenSource.Dispose();
|
||||
}
|
||||
|
||||
_loopCancellationTokenSource = new CancellationTokenSource();
|
||||
if (AuthenticationState.User?.Identity?.IsAuthenticated == true)
|
||||
_ = RevalidationLoop(_loopCancellationTokenSource.Token);
|
||||
}
|
||||
private async Task RevalidationLoop(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (AuthenticationState.User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
bool isValid = false;
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Delay(30000, cancellationToken).ConfigureAwait(false);
|
||||
isValid = await ValidateAuthenticationStateAsync(AuthenticationState, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
ForceSignOut();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
ForceSignOut();
|
||||
}
|
||||
}
|
||||
protected virtual async Task<bool> ValidateAuthenticationStateAsync(AuthenticationState authenticationState, CancellationToken cancellationToken)
|
||||
{
|
||||
var userId = authenticationState.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.UserId)?.Value?.ToLong();
|
||||
var verificatId = authenticationState.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.VerificatId)?.Value?.ToLong();
|
||||
var result = BlazorAuthenticationHandler.CheckVerificat(userId, verificatId, false);
|
||||
if (!result)
|
||||
{
|
||||
var verificatInfo = App.GetService<IVerificatInfoService>().GetOne(verificatId ?? 0, false);
|
||||
if (App.HttpContext != null)
|
||||
{
|
||||
var identity = new ClaimsIdentity();
|
||||
App.HttpContext.User = new ClaimsPrincipal(identity);
|
||||
}
|
||||
|
||||
if (verificatInfo != null)
|
||||
await App.GetService<INoticeService>().UserLoginOut(verificatInfo.ClientIds, App.CreateLocalizerByType(typeof(BlazorAuthenticationHandler))["UserExpire"]).ConfigureAwait(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private void ForceSignOut()
|
||||
{
|
||||
var anonymousUser = new ClaimsPrincipal(new ClaimsIdentity());
|
||||
UserChanged(anonymousUser);
|
||||
}
|
||||
public override Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||
{
|
||||
return Task.FromResult(AuthenticationState);
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class BlazorHybridAuthorizationHandler : BlazorAuthenticationHandler
|
||||
{
|
||||
public BlazorHybridAuthorizationHandler(ISysUserService sysUserService, ISysRoleService sysRoleService, ISysDictService sysDictService) : base(sysUserService, sysRoleService, sysDictService)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class BlazorServerAuthenticationHandler : BlazorAuthenticationHandler
|
||||
{
|
||||
public BlazorServerAuthenticationHandler(ISysUserService sysUserService, ISysRoleService sysRoleService, ISysDictService sysDictService) : base(sysUserService, sysRoleService, sysDictService)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Server;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public class BlazorServerAuthenticationStateProvider : RevalidatingServerAuthenticationStateProvider
|
||||
{
|
||||
private readonly IAppService _appService;
|
||||
|
||||
public BlazorServerAuthenticationStateProvider(ILoggerFactory loggerFactory, IAppService appService) : base(loggerFactory)
|
||||
{
|
||||
_appService = appService;
|
||||
}
|
||||
|
||||
protected override TimeSpan RevalidationInterval => TimeSpan.FromSeconds(30);
|
||||
|
||||
protected override async Task<bool> ValidateAuthenticationStateAsync(AuthenticationState authenticationState, CancellationToken cancellationToken)
|
||||
{
|
||||
var userId = authenticationState.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.UserId)?.Value?.ToLong();
|
||||
var verificatId = authenticationState.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.VerificatId)?.Value?.ToLong();
|
||||
var result = BlazorAuthenticationHandler.CheckVerificat(userId, verificatId, false);
|
||||
if (!result)
|
||||
{
|
||||
var verificatInfo = App.GetService<IVerificatInfoService>().GetOne(verificatId ?? 0, false);
|
||||
if (App.HttpContext != null)
|
||||
{
|
||||
var identity = new ClaimsIdentity();
|
||||
App.HttpContext.User = new ClaimsPrincipal(identity);
|
||||
}
|
||||
|
||||
if (verificatInfo != null)
|
||||
await App.GetService<INoticeService>().UserLoginOut(verificatInfo.ClientIds, App.CreateLocalizerByType(typeof(BlazorAuthenticationHandler))["UserExpire"]).ConfigureAwait(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://thingsgateway.cn/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
using ThingsGateway.DataValidation;
|
||||
using ThingsGateway.FriendlyException;
|
||||
using ThingsGateway.UnifyResult;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 规范化RESTful风格返回值
|
||||
/// </summary>
|
||||
[UnifyModel(typeof(UnifyResult<>))]
|
||||
public class UnifyResultProvider : IUnifyResultProvider
|
||||
{
|
||||
private static IStringLocalizer Localizer = App.CreateLocalizerByType(typeof(UnifyResultProvider))!;
|
||||
|
||||
/// <summary>
|
||||
/// 状态码响应拦截
|
||||
/// </summary>
|
||||
public async Task OnResponseStatusCodes(HttpContext context, int statusCode, UnifyResultSettingsOptions unifyResultSettings = null)
|
||||
{
|
||||
switch (statusCode)
|
||||
{
|
||||
// 处理 401 状态码
|
||||
case StatusCodes.Status401Unauthorized:
|
||||
await context.Response.WriteAsJsonAsync(RESTfulResult(statusCode, false, Localizer["TokenOver"].Value)).ConfigureAwait(false);
|
||||
break;
|
||||
// 处理 403 状态码
|
||||
case StatusCodes.Status403Forbidden:
|
||||
await context.Response.WriteAsJsonAsync(RESTfulResult(statusCode, false, default, Localizer["NoPermission"].Value)).ConfigureAwait(false);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成功返回
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public IActionResult OnSucceeded(ActionExecutedContext context, object? data)
|
||||
{
|
||||
return new JsonResult(RESTfulResult(StatusCodes.Status200OK, true, data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回 RESTful 风格结果集
|
||||
/// </summary>
|
||||
/// <param name="statusCode">状态码</param>
|
||||
/// <param name="succeeded">是否成功</param>
|
||||
/// <param name="data">数据</param>
|
||||
/// <param name="errors">错误信息</param>
|
||||
/// <returns></returns>
|
||||
private static UnifyResult<object> RESTfulResult(int statusCode, bool succeeded = default, object? data = default, object? errors = default)
|
||||
{
|
||||
return new UnifyResult<object>
|
||||
{
|
||||
Code = statusCode,
|
||||
Msg = statusCode == StatusCodes.Status200OK ? "Success" : errors,
|
||||
Data = data,
|
||||
Time = DateTime.Now,
|
||||
};
|
||||
}
|
||||
|
||||
public IActionResult OnAuthorizeException(DefaultHttpContext context, ExceptionMetadata metadata)
|
||||
{
|
||||
return new JsonResult(RESTfulResult(metadata.StatusCode, data: metadata.Data, errors: metadata.Errors ?? metadata.Exception?.Message)
|
||||
, UnifyContext.GetSerializerSettings(context));
|
||||
}
|
||||
|
||||
public IActionResult OnException(ExceptionContext context, ExceptionMetadata metadata)
|
||||
{
|
||||
return new JsonResult(RESTfulResult(metadata.StatusCode, data: metadata.Data, errors: metadata.Errors ?? metadata.Exception?.Message)
|
||||
, UnifyContext.GetSerializerSettings(context));
|
||||
}
|
||||
|
||||
public IActionResult OnValidateFailed(ActionExecutingContext context, ValidationMetadata metadata)
|
||||
{
|
||||
return new JsonResult(RESTfulResult(metadata.StatusCode ?? StatusCodes.Status400BadRequest, data: metadata.Data, errors: metadata.ValidationResult) // 如果需要只显示第一条错误,修改为:errors: metadata.FirstErrorMessage
|
||||
, UnifyContext.GetSerializerSettings(context));
|
||||
}
|
||||
}
|