Compare commits
611 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bbcab237d4 | |||
| 010367d018 | |||
| ea43698ee9 | |||
| 7155f6c985 | |||
| 3bdba35501 | |||
| ebcf3c95e2 | |||
| 75c3c9ee06 | |||
| 048193e4f3 | |||
| 7879504b71 | |||
| 93558164de | |||
| 83d123a31e | |||
| 733de4c942 | |||
| 0e7bd5f5dd | |||
| 0ef7ef675c | |||
| ee76366a1c | |||
| 369a0803f9 | |||
| 1f7b96d9f0 | |||
| 72ff2bbf15 | |||
| 0862182f8e | |||
| 746a8de799 | |||
| 37e8545eba | |||
| 570318cf3b | |||
| 7e13edc440 | |||
| 5579181f54 | |||
| 39b840f8fc | |||
| 02fb4c9753 | |||
| cf15883d52 | |||
| 84380a0d21 | |||
| 76993b4c8b | |||
| 0a4f00e63d | |||
| 9a52e30172 | |||
| 120d583a5a | |||
| dd8e244e64 | |||
| 5d7a083f4a | |||
| b7f22245e1 | |||
| 876deb102c | |||
| 49741e5c44 | |||
| 29ee2ba800 | |||
| 65e2bee680 | |||
| d45871a0db | |||
| ab3b9bddc8 | |||
| 7a5ad83cbb | |||
| 2d2e0f6f2f | |||
| 3b5a735abf | |||
| e00f8b3549 | |||
| dee8c90319 | |||
| 47fd242200 | |||
| 1181540302 | |||
| e6b3c662e2 | |||
| 3a06ecd66d | |||
| 7121799900 | |||
| c814736427 | |||
| 4ac9e83903 | |||
| 782270d462 | |||
| ad77b66bdd | |||
| 77538ab7c2 | |||
| 2e1e042658 | |||
| 6736fa96fd | |||
| a965ab9336 | |||
| 2ce112720a | |||
| f8b7e7d764 | |||
| 1aa1189ae8 | |||
| 9b90ded79f | |||
| 61ab33b3f3 | |||
| e6458e66df | |||
| 0ef7fd85d4 | |||
| 2bf47515e7 | |||
| 296ecfa9d2 | |||
| 473d10533a | |||
| 59ba1a6193 | |||
| cf2b3f5954 | |||
| 7fed9cdceb | |||
| 0585966215 | |||
| 7f9d6afc62 | |||
| 6dce301ff7 | |||
| 7a2d95a77c | |||
| 74a8ac7575 | |||
| e9c6d123d3 | |||
| 310c4a0f70 | |||
| 571f81f271 | |||
| c3a9ca3ca2 | |||
| 6874459046 | |||
| f4af6d3218 | |||
| ec87ed1caf | |||
| 0bb5d09a23 | |||
| f43ac9e649 | |||
| 9e3180b326 | |||
| 1011e704b9 | |||
| 0afcaa7d70 | |||
| 5fb889bac9 | |||
| febf8868f9 | |||
| 665d9a27fb | |||
| ccf16423d2 | |||
| a5155457b1 | |||
| e358601232 | |||
| 1514694e37 | |||
| fbd128138d | |||
| eca7871684 | |||
| 8eb31d0c81 | |||
| 051094a742 | |||
| 9012b9c35c | |||
| c49cd2e75e | |||
| f8b36df86d | |||
| 8e5b7fb57c | |||
| b5a76804ad | |||
| d4e79e0905 | |||
| 11e4c39dba | |||
| 02dd26188d | |||
| 4f439c6ee7 | |||
| bb36240c3c | |||
| e17b26b41d | |||
| 3fce7b772e | |||
| 8ca740bae3 | |||
| ead07cb1ca | |||
| 951081edb7 | |||
| 7ceca5d802 | |||
| 86a3f1d2a5 | |||
| b0a349b5ff | |||
| 7523f646fe | |||
| fcd0dd9b08 | |||
| 208cb40525 | |||
| aa2861c399 | |||
| 4ee064dd14 | |||
| 8803a5f5b2 | |||
| 834f6be548 | |||
| df8292b2a5 | |||
| 312c96ef8f | |||
| de29bd7d15 | |||
| 3a2c78fe37 | |||
| 4465e19987 | |||
| afe84fdb5b | |||
| 728727af54 | |||
| 987667f59f | |||
| af1ca2ffc1 | |||
| e71682f8fa | |||
| 339414694d | |||
| 3ad6fad018 | |||
| adf82e862d | |||
| c9e4f63e03 | |||
| ade2ffd9c0 | |||
| 3919d6a8a3 | |||
| 0fab295995 | |||
| aa7eac50a5 | |||
| 23e0fae6ac | |||
| 27233c1e01 | |||
| c16905101f | |||
| 6ef9708bb7 | |||
| cd9769b39c | |||
| 109bdd263e | |||
| c8e5a5173c | |||
| e94e875a8a | |||
| 9d7bd3c35b | |||
| 5725e684c0 | |||
| 7927ad4161 | |||
| e070a78872 | |||
| 1a6ec6b315 | |||
| 64ea537dae | |||
| 990cf0ec41 | |||
| 9cdd70f491 | |||
| a8623ade44 | |||
| c0e19eaab4 | |||
| 43241709af | |||
| 292263a60c | |||
| 760f75061e | |||
| e11ca4a244 | |||
| 0266072c6a | |||
| 99b76704d3 | |||
| b39edee3eb | |||
| 9e426308d0 | |||
| 416d76e03a | |||
| ae867ae230 | |||
| e83dc93dca | |||
| da220a3f5a | |||
| 8141c64f87 | |||
| 5aaedffe20 | |||
| 9ec53e39ec | |||
| c93807d67f | |||
| 6430f11188 | |||
| bc4c523d88 | |||
| b7aaeee13e | |||
| 504304c341 | |||
| 941bddb771 | |||
| 1990cebd58 | |||
| 041d6724e2 | |||
| 0086ed4723 | |||
| b83dd29b20 | |||
| aa01c68887 | |||
| 00f5fa993a | |||
| 6b98e23e50 | |||
| 3810b33c9e | |||
| e58b0e5315 | |||
| a2548c4f95 | |||
| 0151305ca3 | |||
| fbdac497fa | |||
| 052ac1ff8d | |||
| e113bc9fe1 | |||
| 03b7f00bcd | |||
| 3bedea2aba | |||
| 90a7e20be4 | |||
| 4a02ae2e98 | |||
| 9852cacb01 | |||
| eda79fd455 | |||
| 45af1d7ba6 | |||
| 7a4520086f | |||
| a252142cef | |||
| 12a0f7ad82 | |||
| 3ef3586bf7 | |||
| 4aecfb3bed | |||
| 9a31e04fad | |||
| af333e72f5 | |||
| 26f1a2b8ee | |||
| 497d91f4a4 | |||
| bd2d698d9f | |||
| b4c884a367 | |||
| 337dec37b8 | |||
| c12ecfdcf0 | |||
| 919e2bcdd7 | |||
| 943dbb28a6 | |||
| 0926da24f7 | |||
| 6ad80f540d | |||
| 77b9b14cb6 | |||
| b9c55871b8 | |||
| 848581452a | |||
| 2e53cdf29b | |||
| d9bc12c8d4 | |||
| 234f8b074b | |||
| 079c11a7e3 | |||
| 9d9d65e381 | |||
| 2517c57778 | |||
| 5d15ae6fe3 | |||
| f9fbb59c53 | |||
| c55f7a427c | |||
| 70b8c23e41 | |||
| 2591a794bf | |||
| 1c4be1012a | |||
| 030eeb663b | |||
| 4b3180bdfe | |||
| 28b7cdb187 | |||
| f57f6bb389 | |||
| 673abdfec2 | |||
| 1d4d068e08 | |||
| 72d83e9cfd | |||
| 883783250f | |||
| cc1ae55480 | |||
| 1bc3e77c1a | |||
| e24d865ce3 | |||
| 2762c83d84 | |||
| c58ad6142f | |||
| c45f5ca083 | |||
| fc5c792328 | |||
| 1b00209c55 | |||
| f199d18c4b | |||
| 3f1d07727b | |||
| 64d70269f9 | |||
| f0a71f8e70 | |||
| 8901479dd5 | |||
| 389456c46b | |||
| 40483dd4ee | |||
| fe1d7724bc | |||
| 9204183add | |||
| db9895077c | |||
| 36c086136f | |||
| f3c78c1892 | |||
| 6d538bf250 | |||
| 7a84eebf98 | |||
| 064101b155 | |||
| 91e7d04e4d | |||
| 711fa5a2b8 | |||
| 9f7bc4be75 | |||
| df7022b2e3 | |||
| 6ee51a7f43 | |||
| aed8a77e13 | |||
| bcfa22a818 | |||
| 0840d57689 | |||
| deb7e77263 | |||
| aba477a49c | |||
| a9e5a7754e | |||
| a2d4d100d3 | |||
| 7f4f5e9d08 | |||
| 55a2301bb5 | |||
| 14ac852eee | |||
| d2e53c7b8c | |||
| 4a335d2a28 | |||
| 999fde1f5c | |||
| 024e62103a | |||
| 73889c51ae | |||
| 7a0b29bda6 | |||
| a592a39fae | |||
| aa96ef66c6 | |||
| 2b24ce723e | |||
| 867ee32f91 | |||
| 662001accd | |||
| 334b2fe440 | |||
| 2f728629f3 | |||
| eb8628da5b | |||
| 1427940224 | |||
| 06f10e38f5 | |||
| 5092f5204f | |||
| 13f4420e42 | |||
| e0e6e60ae0 | |||
| 9cac49d539 | |||
| 97d9aefbeb | |||
| 340119f697 | |||
| a075eb34cd | |||
| 53913d3777 | |||
| c1d79a7e9f | |||
| 3ee6f0ceaa | |||
| 1821d82ded | |||
| 476ca95aa3 | |||
| d8b799f057 | |||
| 4c4807c22e | |||
| 8a9afc2d9a | |||
| 6fcb670a89 | |||
| d224b519f7 | |||
| b382595767 | |||
| 64ff6f73d4 | |||
| e1632b58ac | |||
| 7e39692cc4 | |||
| 8de44fb7b3 | |||
| 647aee010a | |||
| 296459d38a | |||
| 7941328a29 | |||
| 38d9a21a5d | |||
| 7d88f49e68 | |||
| 3c46215a3c | |||
| 137ed07b2b | |||
| 6f05850fbc | |||
| 80447f5c7a | |||
| 971d94495a | |||
| 77790a1cb2 | |||
| ecfadcb5a3 | |||
| d9e3b642a5 | |||
| e56e269f2e | |||
| 98f7ab8c02 | |||
| 5d33bd03a7 | |||
| 55882aa0ba | |||
| 43d1a94f22 | |||
| 53b2b9156f | |||
| fafc075735 | |||
| 09ee238e50 | |||
| 7be3813527 | |||
| e6491a6203 | |||
| 4955a24d6f | |||
| 425f53b74c | |||
| 2ed9595186 | |||
| 4d1e3beda6 | |||
| 8b0e1b8988 | |||
| c77682a9ad | |||
| 8e0ff1f2b2 | |||
| b5e027a553 | |||
| ef712949ad | |||
| b429b2cf8c | |||
| 9fb95c3030 | |||
| 6883d47508 | |||
| dae44745ca | |||
| 24b7d2e1b9 | |||
| 21ac6850d2 | |||
| 8b69a07b93 | |||
| f92bf347e3 | |||
| 78669051de | |||
| ea90b2b38b | |||
| bd61a0f2e9 | |||
| 888ad8897e | |||
| eb18021988 | |||
| 7b243a9615 | |||
| 5716c4169a | |||
| abb9f47646 | |||
| 9a5221ef7d | |||
| d9eaa06de3 | |||
| 4f91874b82 | |||
| 139438133d | |||
| 6705cf0fc0 | |||
| 00255e902c | |||
| 71e867156f | |||
| 658f437f73 | |||
| 95bf613263 | |||
| 03d61347ca | |||
| 050a0875fe | |||
| d9c46acb03 | |||
| f19fc0e92f | |||
| 3bc4b86749 | |||
| 43455da7bc | |||
| 0030eac22e | |||
| 671c071a45 | |||
| 3419015542 | |||
| 3eea6cf8b7 | |||
| 2c407c6e4e | |||
| ab90591e7c | |||
| 33a2b7f373 | |||
| 9158f28998 | |||
| 680a6cb437 | |||
| 21c19f4b6d | |||
| 8c03167f7e | |||
| b629b2eec4 | |||
| 01af8f72d3 | |||
| 4d10db054c | |||
| a019a542b0 | |||
| b42325337e | |||
| a3152bb6e1 | |||
| 4ec0441d28 | |||
| 9adc8a93b1 | |||
| 3f3d1a562b | |||
| 1b6ba91240 | |||
| c406976a6d | |||
| d213fa7a99 | |||
| 60707150a6 | |||
| 008906d245 | |||
| 762b8b7425 | |||
| 24228428fa | |||
| 9148651556 | |||
| 1c9c3eb893 | |||
| 17e0517e5b | |||
| 7662880352 | |||
| c3c433244e | |||
| df65d592ad | |||
| 7873523c1b | |||
| 8b5800b32e | |||
| 2e46791466 | |||
| fc0ef2e89f | |||
| 1de687cbf3 | |||
| 3a017dbfa3 | |||
| 1f828b403b | |||
| f75fafaa42 | |||
| 7c561a4656 | |||
| 033b849bdc | |||
| 8ae0b0d621 | |||
| b6bad061b7 | |||
| 1dd8515ac2 | |||
| 9f3bb29004 | |||
| 52dd676cf9 | |||
| 342b567e2c | |||
| 35ee76be0b | |||
| b4d40a4770 | |||
| 84bfcb4d3e | |||
| f030ed9b66 | |||
| c6920a1995 | |||
| 2d681ce6bc | |||
| 3981f2cd50 | |||
| 2b961c7985 | |||
| fb2fdd2c27 | |||
| f6bcefd1e8 | |||
| 1d7b28e7f9 | |||
| 3ea2bdfc92 | |||
| 4aa0161c41 | |||
| ff4ab39025 | |||
| bb35ae1b9a | |||
| 0e0ce59d74 | |||
| 82d3157e2a | |||
| 12cb53b167 | |||
| 5fc53a1999 | |||
| b712abd1d5 | |||
| a1c13b5850 | |||
| a0fe7be308 | |||
| bbfa966b57 | |||
| 6d11fc68b4 | |||
| eef764dd90 | |||
| 8423b00bec | |||
| dbaac006c7 | |||
| 510c73dd24 | |||
| 41486798d2 | |||
| f40faa5519 | |||
| eecfe6dcae | |||
| 8a004ef35f | |||
| 369805e6c6 | |||
| 93b93f6a3a | |||
| 9fbee7e0c9 | |||
| 46704d5299 | |||
| 4225014cdd | |||
| ae36d4680a | |||
| d48f736392 | |||
| b0d8a49929 | |||
| e45791c676 | |||
| ca425c602b | |||
| 44e7ffaeeb | |||
| cf42b2e57f | |||
| 840de08e69 | |||
| 929903aa1b | |||
| 5eafcc9c8c | |||
| a1657f5827 | |||
| dff2e712ad | |||
| a5f3430965 | |||
| 5059d66aa1 | |||
| 668af5ee0b | |||
| a70caefe01 | |||
| 64bd6a5604 | |||
| b68deafa82 | |||
| d29c150081 | |||
| 4d3ecd05dc | |||
| 143d7f0c4b | |||
| 4d2f04b30e | |||
| 955ca4a1a6 | |||
| 6e92895043 | |||
| 6102309828 | |||
| 8f34644d45 | |||
| f347b34f59 | |||
| dc7e71dc74 | |||
| 749bf95761 | |||
| a67472c9b4 | |||
| 32c8d70179 | |||
| 510dfcac30 | |||
| 9b59a55423 | |||
| 0bd269f93e | |||
| e55a13cfb1 | |||
| 1617de2fc1 | |||
| 40c3ea65ff | |||
| 541e000183 | |||
| 0e93894ed8 | |||
| 7f1621915f | |||
| 70e4829f32 | |||
| c77b3d74c8 | |||
| 1f4ea09bc6 | |||
| c45020f24f | |||
| ca679057c4 | |||
| 456793293b | |||
| 75d3908911 | |||
| a7fbd00530 | |||
| 785d5ec869 | |||
| c5feb98ed8 | |||
| 121b1d4eb4 | |||
| 8e2b99333c | |||
| 5bd055c77d | |||
| 5ea9d63cb9 | |||
| 0134d6c723 | |||
| a9c80a670b | |||
| 998b92aa79 | |||
| 60ce8c45b2 | |||
| a66d25f564 | |||
| 91b66660a6 | |||
| 1031222e47 | |||
| 2005eacaa9 | |||
| b581afebe6 | |||
| 1532ac4a7e | |||
| 231b3f71c5 | |||
| 308f5140a1 | |||
| ef673fc44b | |||
| f347b0cace | |||
| 102cf5f6dc | |||
| d9ca71009f | |||
| 114ee50273 | |||
| 54bb66f738 | |||
| 19f52bc133 | |||
| 2439dec9fb | |||
| fb0fd7d91f | |||
| 3765b390a6 | |||
| f6be3186e7 | |||
| 7399568e36 | |||
| 37d798627a | |||
| fe2a375b4e | |||
| 70443b7b8d | |||
| 7a37c01b7f | |||
| 7215c75f5a | |||
| a34c47dc3c | |||
| 6fdad9a482 | |||
| 08e62e4500 | |||
| 3cfb4556f3 | |||
| b8e3e83b80 | |||
| 7e9bf65f9f | |||
| 5197e49c1f | |||
| 7880836f39 | |||
| 487eb9dca8 | |||
| 473cee0e30 | |||
| 817cdcc8f7 | |||
| bf03430958 | |||
| 58321c4c82 | |||
| 8cabc8c96a | |||
| 7f050a1dd6 | |||
| e5e2a0394b | |||
| a56ab0680b | |||
| ee13d0ae2e | |||
| ee2c66c8fb | |||
| f1fb2068de | |||
| 95e0239e42 | |||
| 0b28ef5461 | |||
| 68fe2b75dc | |||
| ecfeee1693 | |||
| 9cda4360ca | |||
| 18b9c08101 | |||
| d4e89aec20 | |||
| 01a3a9057b | |||
| 2107a42e37 | |||
| d96e746db7 | |||
| be034d4d8b | |||
| ca44b4786a | |||
| 74056167d6 | |||
| e6aec6b559 | |||
| 9a488610da | |||
| f82420b7ef | |||
| fbeaec2820 | |||
| b4907bfe9b | |||
| 6e75e45942 | |||
| 3292b9f978 | |||
| 1959045ab2 | |||
| 6a99e3104a | |||
| ab91d360b1 | |||
| 50a4a82819 | |||
| 498c02431b | |||
| fd54d64ae3 | |||
| ac80e3a455 | |||
| c6a55949b3 | |||
| 18547cdec1 | |||
| d29707c8ee | |||
| c7e29116dd | |||
| a85cc1236c | |||
| 7b4c603fa6 | |||
| 67c93e654e | |||
| 9b0c874314 | |||
| d172e48c79 | |||
| 2a2419af90 | |||
| 7e39094b13 | |||
| 8936e9db99 | |||
| bd92d48232 |
@@ -14,9 +14,9 @@
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.401.81" />
|
||||
<PackageReference Include="DistributedLock.Core" Version="1.0.8" />
|
||||
<PackageReference Include="DistributedLock.SqlServer" Version="1.0.6" />
|
||||
<PackageReference Include="fo-dicom" Version="5.2.1" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.16.1" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.2.1" />
|
||||
<PackageReference Include="fo-dicom" Version="5.2.4" />
|
||||
<PackageReference Include="fo-dicom.Codecs" Version="5.16.4" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.2.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.10" />
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Minio" Version="6.0.3" />
|
||||
|
||||
@@ -113,6 +113,9 @@ builder.Services.AddAutoMapper(automapper =>
|
||||
//EF ORM QueryWithNoLock
|
||||
builder.Services.AddEFSetup(_configuration);
|
||||
|
||||
// FusionCache
|
||||
builder.Services.AddFusionCache();
|
||||
|
||||
builder.Services.AddMediator(cfg =>
|
||||
{
|
||||
|
||||
@@ -191,6 +194,7 @@ app.MapControllers();
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
//.MinimumLevel.Information()
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
|
||||
.MinimumLevel.Override("ZiggyCreatures.Caching.Fusion", LogEventLevel.Warning)
|
||||
.WriteTo.Console()
|
||||
.WriteTo.File($"{AppContext.BaseDirectory}Serilogs/.log", rollingInterval: RollingInterval.Day)
|
||||
.CreateLogger();
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
using FellowOakDicom.Network;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom.Imaging;
|
||||
using FellowOakDicom.IO.Buffer;
|
||||
using FellowOakDicom.Network;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using IRaCIS.Core.SCP.Service;
|
||||
using Medallion.Threading;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Serilog;
|
||||
using SharpCompress.Common;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using IRaCIS.Core.SCP.Service;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using Medallion.Threading;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using Serilog;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Data;
|
||||
using FellowOakDicom.Imaging;
|
||||
using SharpCompress.Common;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using FellowOakDicom.IO.Buffer;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
|
||||
namespace IRaCIS.Core.SCP.Service
|
||||
{
|
||||
@@ -51,6 +52,8 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
private Guid _trialSiteId { get; set; }
|
||||
|
||||
private bool _releasedNormally = false;
|
||||
|
||||
|
||||
|
||||
private static readonly DicomTransferSyntax[] _acceptedTransferSyntaxes = new DicomTransferSyntax[]
|
||||
@@ -118,7 +121,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
var _trialSiteDicomAERepository = _serviceProvider.GetService<IRepository<TrialSiteDicomAE>>();
|
||||
|
||||
|
||||
var findTrialSiteAE = _trialSiteDicomAERepository.Where(t => t.CallingAE == association.CallingAE && t.TrialId==_trialId).FirstOrDefault();
|
||||
var findTrialSiteAE = _trialSiteDicomAERepository.Where(t => t.CallingAE == association.CallingAE && t.TrialId == _trialId).FirstOrDefault();
|
||||
|
||||
if (findTrialSiteAE != null)
|
||||
{
|
||||
@@ -127,7 +130,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
isCanReceiveIamge = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (association.CallingAE == "test-callingAE")
|
||||
@@ -180,12 +183,15 @@ namespace IRaCIS.Core.SCP.Service
|
||||
await AddUploadLogAsync();
|
||||
|
||||
|
||||
_releasedNormally = true;
|
||||
|
||||
var _studyRepository = _serviceProvider.GetService<IRepository<SCPStudy>>();
|
||||
//将检查设置为传输结束
|
||||
await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true });
|
||||
Log.Logger.Information($"进入释放连接请求 {_releasedNormally}");
|
||||
|
||||
await _studyRepository.SaveChangesAndClearAllTrackingAsync();
|
||||
//var _studyRepository = _serviceProvider.GetService<IRepository<SCPStudy>>();
|
||||
////将检查设置为传输结束
|
||||
//await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true });
|
||||
|
||||
//await _studyRepository.SaveChangesAndClearAllTrackingAsync();
|
||||
|
||||
}
|
||||
|
||||
@@ -199,15 +205,25 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
var _SCPImageUploadRepository = _serviceProvider.GetService<IRepository<SCPImageUpload>>();
|
||||
|
||||
_upload.EndTime = DateTime.Now;
|
||||
_upload.StudyCount = _ImageUploadList.Count;
|
||||
_upload.TrialId = _trialId;
|
||||
_upload.TrialSiteId = _trialSiteId;
|
||||
//有时候没有建立连接会走关闭通过日志发现
|
||||
if (_upload != null)
|
||||
{
|
||||
_upload.EndTime = DateTime.Now;
|
||||
_upload.StudyCount = _ImageUploadList.Count;
|
||||
_upload.TrialId = _trialId;
|
||||
_upload.TrialSiteId = _trialSiteId;
|
||||
|
||||
_upload.UploadJsonStr = (new SCPImageLog() { UploadList = _ImageUploadList }).ToJsonStr();
|
||||
|
||||
//可能是测试echo 导致记录了
|
||||
if (_upload.FileCount > 0)
|
||||
{
|
||||
//可能是测试echo 导致记录了
|
||||
await _SCPImageUploadRepository.AddAsync(_upload, true);
|
||||
}
|
||||
}
|
||||
|
||||
_upload.UploadJsonStr = (new SCPImageLog() { UploadList = _ImageUploadList }).ToJsonStr();
|
||||
|
||||
//可能是测试echo 导致记录了
|
||||
await _SCPImageUploadRepository.AddAsync(_upload, _upload.FileCount > 0 ? true : false);
|
||||
}
|
||||
|
||||
|
||||
@@ -262,22 +278,25 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
public async void OnConnectionClosed(Exception exception)
|
||||
{
|
||||
/* nothing to do here */
|
||||
var _studyRepository = _serviceProvider.GetService<IRepository<SCPStudy>>();
|
||||
|
||||
//奇怪的bug 上传的时候,用王捷修改的影像,会关闭,重新连接,导致检查id 丢失,然后状态不一致
|
||||
if (exception == null)
|
||||
{
|
||||
//var _studyRepository = _serviceProvider.GetService<IRepository<SCPStudy>>();
|
||||
////将检查设置为传输结束
|
||||
//await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true });
|
||||
|
||||
//await _studyRepository.SaveChangesAndClearAllTrackingAsync();
|
||||
}
|
||||
else
|
||||
if (exception != null || _releasedNormally == false)
|
||||
{
|
||||
//客户端断网,恢复后,也是没有异常的,估计是超时走了关闭
|
||||
|
||||
await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true, IsUploadFaild = true });
|
||||
//记录日志
|
||||
await AddUploadLogAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
//将检查设置为传输结束
|
||||
await _studyRepository.BatchUpdateNoTrackingAsync(t => _SCPStudyIdList.Contains(t.Id), u => new SCPStudy() { IsUploadFinished = true, IsUploadFaild = false });
|
||||
}
|
||||
|
||||
|
||||
await _studyRepository.SaveChangesAndClearAllTrackingAsync();
|
||||
|
||||
Log.Logger.Warning($"连接关闭 {exception?.Message} {exception?.InnerException?.Message}");
|
||||
}
|
||||
@@ -316,6 +335,11 @@ namespace IRaCIS.Core.SCP.Service
|
||||
var _seriesRepository = _serviceProvider.GetService<IRepository<SCPSeries>>();
|
||||
|
||||
var _distributedLockProvider = _serviceProvider.GetService<IDistributedLockProvider>();
|
||||
var _fusionCache = _serviceProvider.GetService<IFusionCache>();
|
||||
var _trialSiteRepository = _serviceProvider.GetService<IRepository<TrialSite>>();
|
||||
var _systemAnonymizationRepository = _serviceProvider.GetService<IRepository<SystemAnonymization>>();
|
||||
|
||||
|
||||
|
||||
var storeRelativePath = string.Empty;
|
||||
var ossFolderPath = $"{_trialId}/Image/PACS/{_trialSiteId}/{studyInstanceUid}";
|
||||
@@ -324,74 +348,383 @@ namespace IRaCIS.Core.SCP.Service
|
||||
long fileSize = 0;
|
||||
try
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
// 直接拿 Dataset(已经完整)
|
||||
var dataset = request.Dataset;
|
||||
|
||||
#region 匿名化
|
||||
|
||||
|
||||
var anonymizeList = await _fusionCache.GetOrSetAsync(CacheKeys.SystemAnonymization, _ => CacheHelper.GetSystemAnonymizationListAsync(_systemAnonymizationRepository), TimeSpan.FromDays(7));
|
||||
|
||||
var trialSiteInfo = await _fusionCache.GetOrSetAsync(CacheKeys.TrialSiteInfo(_trialSiteId), _ => CacheHelper.GetTrialSiteInfo(_trialSiteId, _trialSiteRepository), TimeSpan.FromMinutes(2));
|
||||
|
||||
var fixedFiledList = anonymizeList.Where(t => t.IsFixed).ToList();
|
||||
|
||||
var ircFiledList = anonymizeList.Where(t => t.IsFixed == false).ToList();
|
||||
|
||||
foreach (var item in fixedFiledList)
|
||||
{
|
||||
await request.File.SaveAsync(ms);
|
||||
|
||||
#region 1帧拆成多个固定大小的,方便移动端浏览
|
||||
var dicomTag = new DicomTag(Convert.ToUInt16(item.Group, 16), Convert.ToUInt16(item.Element, 16));
|
||||
|
||||
// 回到开头,读取 dicom
|
||||
ms.Position = 0;
|
||||
var dicomFile = DicomFile.Open(ms);
|
||||
dataset.AddOrUpdate(dicomTag, item.ReplaceValue);
|
||||
}
|
||||
|
||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||
var syntax = pixelData.Syntax;
|
||||
foreach (var item in ircFiledList)
|
||||
{
|
||||
|
||||
// 每个 fragment 固定大小 (64KB 示例,可以自己调整)
|
||||
int fragmentSize = 20 * 1024;
|
||||
var dicomTag = new DicomTag(Convert.ToUInt16(item.Group, 16), Convert.ToUInt16(item.Element, 16));
|
||||
|
||||
if (syntax.IsEncapsulated)
|
||||
if (dicomTag == DicomTag.ClinicalTrialProtocolID)
|
||||
{
|
||||
var newFragments = new DicomOtherByteFragment(DicomTag.PixelData);
|
||||
dataset.AddOrUpdate(DicomTag.ClinicalTrialProtocolID, trialSiteInfo.TrialCode);
|
||||
|
||||
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||
}
|
||||
if (dicomTag == DicomTag.ClinicalTrialSiteID)
|
||||
{
|
||||
dataset.AddOrUpdate(DicomTag.ClinicalTrialSiteID, trialSiteInfo.TrialSiteCode);
|
||||
|
||||
}
|
||||
|
||||
if (dicomTag == DicomTag.ClinicalTrialSubjectID)
|
||||
{
|
||||
dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "");
|
||||
|
||||
}
|
||||
if (dicomTag == DicomTag.ClinicalTrialTimePointID)
|
||||
{
|
||||
dataset.AddOrUpdate(DicomTag.ClinicalTrialTimePointID, "");
|
||||
}
|
||||
|
||||
if (dicomTag == DicomTag.PatientID)
|
||||
{
|
||||
var pid = dataset.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty);
|
||||
|
||||
dataset.AddOrUpdate(DicomTag.PatientID, trialSiteInfo.TrialCode + "-" + pid);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
// 构造 DicomFile(不用 Open)
|
||||
var dicomFile = new DicomFile(dataset);
|
||||
|
||||
|
||||
|
||||
#region 1帧拆成多个固定大小的,方便移动端浏览
|
||||
|
||||
|
||||
|
||||
var numberOfFrames = dicomFile.Dataset.GetSingleValueOrDefault(DicomTag.NumberOfFrames, 1);
|
||||
|
||||
//多帧处理逻辑
|
||||
if (numberOfFrames > 1)
|
||||
{
|
||||
//一定要有像素数据才处理
|
||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||
|
||||
if (pixelData != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var frameData = pixelData.GetFrame(n); // 获取完整一帧
|
||||
var data = frameData.Data;
|
||||
int offset = 0;
|
||||
|
||||
while (offset < data.Length)
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 开始处理多帧instanceId:{instanceId}");
|
||||
|
||||
var syntax = pixelData.Syntax;
|
||||
|
||||
// 每个 fragment 固定大小 (64KB 示例,可以自己调整)
|
||||
int fragmentSize = 20 * 1024;
|
||||
|
||||
|
||||
|
||||
var frag = dicomFile.Dataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData);
|
||||
|
||||
int fragmentCount = frag?.Fragments?.Count() ?? 0;
|
||||
|
||||
var originOffsetTable = frag?.OffsetTable; //有可能没有表,需要自己重建
|
||||
|
||||
var bot = new List<uint>();
|
||||
|
||||
uint botOffset = 0;
|
||||
|
||||
//需要拆成固定片段的
|
||||
if (syntax.IsEncapsulated && fragmentCount == pixelData.NumberOfFrames && numberOfFrames > 1)
|
||||
{
|
||||
int size = Math.Min(fragmentSize, data.Length - offset);
|
||||
var buffer = new byte[size];
|
||||
Buffer.BlockCopy(data, offset, buffer, 0, size);
|
||||
|
||||
newFragments.Fragments.Add(new MemoryByteBuffer(buffer));
|
||||
offset += size;
|
||||
|
||||
|
||||
var newFragments = new DicomOtherByteFragment(DicomTag.PixelData);
|
||||
|
||||
#region test
|
||||
//var newDicomFile = dicomFile.Clone();
|
||||
|
||||
//var newDataset = newDicomFile.Dataset;
|
||||
|
||||
//var dstPd = DicomPixelData.Create(newDataset, true);
|
||||
|
||||
//for (int i = 0; i < pixelData.NumberOfFrames; i++)
|
||||
//{
|
||||
// var frame = pixelData.GetFrame(i);
|
||||
|
||||
// dstPd.AddFrame(frame);
|
||||
|
||||
// var data = frame.Data;
|
||||
// int offset = 0;
|
||||
|
||||
// while (offset < data.Length)
|
||||
// {
|
||||
// int size = Math.Min(fragmentSize, data.Length - offset);
|
||||
// var buffer = new byte[size];
|
||||
// Buffer.BlockCopy(data, offset, buffer, 0, size);
|
||||
|
||||
// newFragments.Fragments.Add(new MemoryByteBuffer(buffer));
|
||||
|
||||
// offset += size;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
//var newOffsetTable = newDataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData).OffsetTable;
|
||||
|
||||
//newFragments.OffsetTable.AddRange(newOffsetTable.ToArray());
|
||||
#endregion
|
||||
|
||||
#region test fo-dicom auto bot
|
||||
//var newDicomFile = dicomFile.Clone();
|
||||
|
||||
//var newDataset = newDicomFile.Dataset;
|
||||
|
||||
//var dstPd = DicomPixelData.Create(newDataset, true);
|
||||
|
||||
//for (int i = 0; i < pixelData.NumberOfFrames; i++)
|
||||
//{
|
||||
// var frame = pixelData.GetFrame(i);
|
||||
|
||||
// dstPd.AddFrame(frame);
|
||||
//}
|
||||
//var newOffsetTable = newDataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData).OffsetTable;
|
||||
|
||||
//Console.WriteLine(newOffsetTable.ToJsonStr());
|
||||
#endregion
|
||||
|
||||
#region 最终使用
|
||||
|
||||
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||
{
|
||||
var frameData = pixelData.GetFrame(n); // 获取完整一帧
|
||||
var data = frameData.Data;
|
||||
int offset = 0;
|
||||
|
||||
bot.Add(botOffset);
|
||||
|
||||
botOffset += (uint)data.Length;
|
||||
|
||||
|
||||
while (offset < data.Length)
|
||||
{
|
||||
botOffset += 8;
|
||||
|
||||
|
||||
int size = Math.Min(fragmentSize, data.Length - offset);
|
||||
var buffer = new byte[size];
|
||||
Buffer.BlockCopy(data, offset, buffer, 0, size);
|
||||
|
||||
newFragments.Fragments.Add(new MemoryByteBuffer(buffer));
|
||||
|
||||
offset += size;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//保留原始偏移表
|
||||
|
||||
if (originOffsetTable.Count == pixelData.NumberOfFrames)
|
||||
{
|
||||
newFragments.OffsetTable.AddRange(originOffsetTable.ToArray());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
newFragments.OffsetTable.AddRange(bot.ToArray());
|
||||
|
||||
//Console.WriteLine(bot.ToJsonStr());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
dicomFile.Dataset.AddOrUpdate(newFragments);
|
||||
|
||||
|
||||
}
|
||||
//传递过来的就是拆分的,但是是没有偏移表的,我需要自己创建偏移表,不然生成缩略图失败
|
||||
else if (syntax.IsEncapsulated && fragmentCount > pixelData.NumberOfFrames && originOffsetTable.Count == 0)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint offset = 0;
|
||||
|
||||
bot.Add(offset);
|
||||
|
||||
var fistSize = frag.Fragments.FirstOrDefault()?.Size ?? 0;
|
||||
|
||||
//和上一个大小不一样
|
||||
var isDiffrentBefore = false;
|
||||
|
||||
uint count = 0;
|
||||
|
||||
// 假设你知道每帧对应的 fragment 数量
|
||||
foreach (var frameFragments in frag.Fragments)
|
||||
{
|
||||
count++;
|
||||
|
||||
if (frameFragments.Size == fistSize)
|
||||
{
|
||||
isDiffrentBefore = false;
|
||||
// 累加这一帧所有 fragment 的大小
|
||||
offset += (uint)frameFragments.Size;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset += (uint)frameFragments.Size;
|
||||
isDiffrentBefore = true;
|
||||
|
||||
}
|
||||
|
||||
if (isDiffrentBefore)
|
||||
{
|
||||
//每个Fragment 也占用字节
|
||||
offset += 8 * count;
|
||||
bot.Add(offset);
|
||||
count = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bot.RemoveAt(bot.Count - 1);
|
||||
// 设置到新的 PixelData
|
||||
frag.OffsetTable.AddRange(bot.ToArray());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception mutiEx)
|
||||
{
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 处理多帧失败,上传原始文件:{mutiEx.ToString()}");
|
||||
}
|
||||
|
||||
// 替换原 PixelData
|
||||
dicomFile.Dataset.AddOrUpdate(newFragments);
|
||||
|
||||
|
||||
// 重新保存 dicom 到流
|
||||
ms.SetLength(0);
|
||||
dicomFile.Save(ms);
|
||||
}
|
||||
|
||||
|
||||
ms.Position = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 本地测试
|
||||
//// --- 保存到本地文件测试 ---
|
||||
//var localPath = @"D:\TestDicom.dcm";
|
||||
//using (var fs = new FileStream(localPath, FileMode.Create, FileAccess.Write))
|
||||
//{
|
||||
// ms.CopyTo(fs);
|
||||
//}
|
||||
//return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
|
||||
#endregion
|
||||
|
||||
// 直接写入内存
|
||||
await using var ms = new MemoryStream();
|
||||
await dicomFile.SaveAsync(ms);
|
||||
ms.Position = 0;
|
||||
|
||||
//irc 从路径最后一截取Guid
|
||||
storeRelativePath = await ossService.UploadToOSSAsync(ms, ossFolderPath, instanceId.ToString(), false);
|
||||
|
||||
fileSize = ms.Length;
|
||||
|
||||
|
||||
#region 本地测试
|
||||
//// --- 保存到本地文件测试 ---
|
||||
//var localPath = @"D:\TestDicom.dcm";
|
||||
//using (var fs = new FileStream(localPath, FileMode.Create, FileAccess.Write))
|
||||
//{
|
||||
// ms.CopyTo(fs);
|
||||
//}
|
||||
//return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
var @lock = _distributedLockProvider.CreateLock($"{studyInstanceUid}");
|
||||
|
||||
#endregion
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
try
|
||||
{
|
||||
var scpStudyId = await dicomArchiveService.ArchiveDicomFileAsync(dicomFile, _trialId, _trialSiteId, storeRelativePath, Association.CallingAE, Association.CalledAE, fileSize);
|
||||
|
||||
|
||||
//irc 从路径最后一截取Guid
|
||||
storeRelativePath = await ossService.UploadToOSSAsync(ms, ossFolderPath, instanceId.ToString(), false);
|
||||
var series = await _seriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId);
|
||||
|
||||
//没有缩略图
|
||||
if (series != null && string.IsNullOrEmpty(series.ImageResizePath))
|
||||
{
|
||||
|
||||
// 生成缩略图
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
DicomImage image = new DicomImage(dicomFile.Dataset);
|
||||
|
||||
var sharpimage = image.RenderImage().AsSharpImage();
|
||||
sharpimage.Save(memoryStream, new JpegEncoder());
|
||||
|
||||
// 上传缩略图到 OSS
|
||||
|
||||
var seriesPath = await ossService.UploadToOSSAsync(memoryStream, ossFolderPath, $"{seriesId.ToString()}_{instanceId.ToString()}.preview.jpg", false);
|
||||
|
||||
|
||||
series.ImageResizePath = seriesPath;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await _seriesRepository.SaveChangesAsync();
|
||||
|
||||
if (_ImageUploadList.Any(t => t.StudyInstanceUid == studyInstanceUid))
|
||||
{
|
||||
var find = _ImageUploadList.FirstOrDefault(t => t.StudyInstanceUid.Equals(studyInstanceUid));
|
||||
|
||||
|
||||
find.SuccessImageCount++;
|
||||
|
||||
if (!find.PatientNameList.Any(t => t == patientIdStr) && patientIdStr.IsNotNullOrEmpty())
|
||||
{
|
||||
find.PatientNameList.Add(patientIdStr);
|
||||
}
|
||||
|
||||
//首次 (默认是Guid 空,数据库归档出了Id)
|
||||
if (find.SCPStudyId != scpStudyId)
|
||||
{
|
||||
find.SCPStudyId = scpStudyId;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//监控信息设置
|
||||
_upload.FileCount++;
|
||||
_upload.FileSize = _upload.FileSize + fileSize;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 传输处理异常:{ex.ToString()}");
|
||||
|
||||
if (_ImageUploadList.Any(t => t.StudyInstanceUid == studyInstanceUid))
|
||||
{
|
||||
var find = _ImageUploadList.FirstOrDefault(t => t.StudyInstanceUid.Equals(studyInstanceUid));
|
||||
|
||||
find.FailedImageCount++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileSize = ms.Length;
|
||||
}
|
||||
|
||||
Log.Logger.Information($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} {request.SOPInstanceUID} 上传完成 ");
|
||||
@@ -402,87 +735,6 @@ namespace IRaCIS.Core.SCP.Service
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 上传异常 {ec.Message}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
var @lock = _distributedLockProvider.CreateLock($"{studyInstanceUid}");
|
||||
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
try
|
||||
{
|
||||
var scpStudyId = await dicomArchiveService.ArchiveDicomFileAsync(request.File, _trialId, _trialSiteId, storeRelativePath, Association.CallingAE, Association.CalledAE,fileSize);
|
||||
|
||||
|
||||
var series = await _seriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId);
|
||||
|
||||
//没有缩略图
|
||||
if (series != null && string.IsNullOrEmpty(series.ImageResizePath))
|
||||
{
|
||||
|
||||
// 生成缩略图
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
DicomImage image = new DicomImage(request.Dataset);
|
||||
|
||||
var sharpimage = image.RenderImage().AsSharpImage();
|
||||
sharpimage.Save(memoryStream, new JpegEncoder());
|
||||
|
||||
// 上传缩略图到 OSS
|
||||
|
||||
var seriesPath = await ossService.UploadToOSSAsync(memoryStream, ossFolderPath, seriesId.ToString() + ".preview.jpg", false);
|
||||
|
||||
Console.WriteLine(seriesPath + " Id: " + seriesId);
|
||||
|
||||
series.ImageResizePath = seriesPath;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await _seriesRepository.SaveChangesAsync();
|
||||
|
||||
if (_ImageUploadList.Any(t => t.StudyInstanceUid == studyInstanceUid))
|
||||
{
|
||||
var find = _ImageUploadList.FirstOrDefault(t => t.StudyInstanceUid.Equals(studyInstanceUid));
|
||||
|
||||
|
||||
find.SuccessImageCount++;
|
||||
|
||||
if (!find.PatientNameList.Any(t => t == patientIdStr) && patientIdStr.IsNotNullOrEmpty())
|
||||
{
|
||||
find.PatientNameList.Add(patientIdStr);
|
||||
}
|
||||
|
||||
//首次 (默认是Guid 空,数据库归档出了Id)
|
||||
if (find.SCPStudyId != scpStudyId)
|
||||
{
|
||||
find.SCPStudyId = scpStudyId;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 传输处理异常:{ex.ToString()}");
|
||||
|
||||
if (_ImageUploadList.Any(t => t.StudyInstanceUid == studyInstanceUid))
|
||||
{
|
||||
var find = _ImageUploadList.FirstOrDefault(t => t.StudyInstanceUid.Equals(studyInstanceUid));
|
||||
|
||||
find.FailedImageCount++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//监控信息设置
|
||||
_upload.FileCount++;
|
||||
_upload.FileSize = _upload.FileSize + fileSize;
|
||||
return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace IRaCIS.Core.SCP.Service;
|
||||
|
||||
|
||||
public static class CacheKeys
|
||||
{
|
||||
//项目缓存
|
||||
public static string Trial(string trialIdStr) => $"TrialId:{trialIdStr}";
|
||||
|
||||
//检查编号递增锁
|
||||
public static string TrialStudyMaxCode(Guid trialId) => $"TrialStudyMaxCode:{trialId}";
|
||||
|
||||
public static string TrialStudyUidUploading(Guid trialId, string studyUid) => $"TrialStudyUid:{trialId}_{studyUid}";
|
||||
//CRC上传影像提交锁key
|
||||
public static string TrialStudyUidDBLock(Guid trialId, string studyUid) => $"TrialStudyUidDBLock:{trialId}_{studyUid}";
|
||||
|
||||
public static string TrialTaskStudyUidUploading(Guid trialId, Guid visiTaskId, string studyUid) => $"TrialStudyUid:{trialId}_{visiTaskId}_{studyUid}";
|
||||
//影像后处理上传提交锁key
|
||||
public static string TrialTaskStudyUidDBLock(Guid trialId, Guid visiTaskId, string studyUid) => $"TrialTaskStudyUidDBLock:{trialId}_{visiTaskId}_{studyUid}";
|
||||
//系统匿名化
|
||||
public static string SystemAnonymization => $"SystemAnonymization";
|
||||
//前端国际化
|
||||
public static string FrontInternational => $"FrontInternationalList";
|
||||
|
||||
//登录挤账号
|
||||
public static string UserToken(Guid userId) => $"UserToken:{userId}";
|
||||
|
||||
//超时没请求接口自动退出
|
||||
public static string UserAutoLoginOut(Guid userId) => $"UserAutoLoginOut:{userId}";
|
||||
|
||||
|
||||
public static string UserDisable(Guid userId) => $"UserDisable:{userId}";
|
||||
|
||||
public static string UserRoleDisable(Guid userRoleId) => $"UserRoleDisable:{userRoleId}";
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录错误 限制登录
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static string UserLoginError(string userName) => $"login-failures:{userName}";
|
||||
|
||||
/// <summary>
|
||||
/// 跳过阅片
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public static string SkipReadingCacheKey(Guid userId) => $"{userId}SkipReadingCache";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 开始阅片时间
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public static string StartReadingTimeKey(Guid userId) => $"{userId}StartReadingTime";
|
||||
|
||||
/// <summary>
|
||||
/// 开始休息时间
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public static string StartRestTime(Guid userId) => $"{userId}StartRestTime";
|
||||
|
||||
//每个用户 每个浏览器独立时间
|
||||
public static string UserMFAVerifyPass(Guid userId, string browserFingerprint) => $"UserMFAVerifyPass:{userId}:{browserFingerprint}";
|
||||
|
||||
public static string TrialSiteInfo(Guid trialSiteId) => $"{trialSiteId}TrialSiteInfo";
|
||||
}
|
||||
|
||||
public static class CacheHelper
|
||||
{
|
||||
public static async Task<string?> GetTrialStatusAsync(Guid trialId, IRepository<Trial> _trialRepository)
|
||||
{
|
||||
var statusStr = await _trialRepository.Where(t => t.Id == trialId, ignoreQueryFilters: true).Select(t => t.TrialStatusStr).FirstOrDefaultAsync();
|
||||
|
||||
return statusStr;
|
||||
}
|
||||
|
||||
public class TrialSiteInfoDTO
|
||||
{
|
||||
public string TrialSiteCode { get; set; }
|
||||
public string TrialCode { get; set; }
|
||||
}
|
||||
public static async Task<TrialSiteInfoDTO> GetTrialSiteInfo(Guid trialSiteId, IRepository<TrialSite> _trialSiteRepository)
|
||||
{
|
||||
var obj = await _trialSiteRepository.Where(t => t.Id == trialSiteId, ignoreQueryFilters: true).Select(t => new TrialSiteInfoDTO { TrialCode= t.Trial.TrialCode, TrialSiteCode= t.TrialSiteCode }).FirstOrDefaultAsync();
|
||||
|
||||
return obj??new TrialSiteInfoDTO();
|
||||
}
|
||||
|
||||
public static async Task<List<SystemAnonymization>> GetSystemAnonymizationListAsync(IRepository<SystemAnonymization> _systemAnonymizationRepository)
|
||||
{
|
||||
var list = await _systemAnonymizationRepository.Where(t => t.IsEnable).ToListAsync();
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,32 @@
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Medallion.Threading;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom.Imaging.Codec;
|
||||
using System.Data;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using FellowOakDicom.Network;
|
||||
using IRaCIS.Core.SCP.Service;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using MassTransit;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using Serilog.Sinks.File;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using IRaCIS.Core.SCP.Service;
|
||||
using MassTransit;
|
||||
using Medallion.Threading;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Serilog.Sinks.File;
|
||||
using System.Data;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Text;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
using static IRaCIS.Core.SCP.Service.CacheHelper;
|
||||
|
||||
namespace IRaCIS.Core.SCP.Service
|
||||
{
|
||||
public class DicomArchiveService : BaseService, IDicomArchiveService
|
||||
public class DicomArchiveService(IRepository<SCPPatient> _patientRepository,
|
||||
IRepository<SCPStudy> _studyRepository,
|
||||
IRepository<SCPSeries> _seriesRepository,
|
||||
IRepository<SCPInstance> _instanceRepository
|
||||
) : BaseService, IDicomArchiveService
|
||||
{
|
||||
private readonly IRepository<SCPPatient> _patientRepository;
|
||||
private readonly IRepository<SCPStudy> _studyRepository;
|
||||
private readonly IRepository<SCPSeries> _seriesRepository;
|
||||
private readonly IRepository<SCPInstance> _instanceRepository;
|
||||
private readonly IRepository<Dictionary> _dictionaryRepository;
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
|
||||
|
||||
private List<Guid> _instanceIdList = new List<Guid>();
|
||||
|
||||
public DicomArchiveService(IRepository<SCPPatient> patientRepository, IRepository<SCPStudy> studyRepository,
|
||||
IRepository<SCPSeries> seriesRepository,
|
||||
IRepository<SCPInstance> instanceRepository,
|
||||
IRepository<Dictionary> dictionaryRepository,
|
||||
IDistributedLockProvider distributedLockProvider)
|
||||
{
|
||||
_distributedLockProvider = distributedLockProvider;
|
||||
_studyRepository = studyRepository;
|
||||
_patientRepository = patientRepository;
|
||||
_seriesRepository = seriesRepository;
|
||||
_instanceRepository = instanceRepository;
|
||||
_dictionaryRepository = dictionaryRepository;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -53,18 +36,19 @@ namespace IRaCIS.Core.SCP.Service
|
||||
/// <param name="dataset"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Guid> ArchiveDicomFileAsync(DicomFile dicomFile, Guid trialId, Guid trialSiteId, string fileRelativePath, string callingAE, string calledAE,long fileSize)
|
||||
public async Task<Guid> ArchiveDicomFileAsync(DicomFile dicomFile, Guid trialId, Guid trialSiteId, string fileRelativePath, string callingAE, string calledAE, long fileSize)
|
||||
{
|
||||
|
||||
var dataset = dicomFile.Dataset;
|
||||
|
||||
string studyInstanceUid = dataset.GetString(DicomTag.StudyInstanceUID);
|
||||
string seriesInstanceUid = dataset.GetString(DicomTag.SeriesInstanceUID);
|
||||
string sopInstanceUid = dataset.GetString(DicomTag.SOPInstanceUID);
|
||||
|
||||
string patientIdStr = dataset.GetSingleValueOrDefault(DicomTag.PatientID,string.Empty);
|
||||
string patientIdStr = dataset.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty);
|
||||
|
||||
//Guid patientId= IdentifierHelper.CreateGuid(patientIdStr);
|
||||
Guid studyId = IdentifierHelper.CreateGuid(studyInstanceUid,trialId.ToString());
|
||||
Guid studyId = IdentifierHelper.CreateGuid(studyInstanceUid, trialId.ToString());
|
||||
Guid seriesId = IdentifierHelper.CreateGuid(studyInstanceUid, seriesInstanceUid, trialId.ToString());
|
||||
Guid instanceId = IdentifierHelper.CreateGuid(studyInstanceUid, seriesInstanceUid, sopInstanceUid, trialId.ToString());
|
||||
|
||||
@@ -77,9 +61,9 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
//using (@lock.Acquire())
|
||||
{
|
||||
var findPatient = await _patientRepository.FirstOrDefaultAsync(t => t.PatientIdStr == patientIdStr && t.TrialSiteId==trialSiteId );
|
||||
var findStudy = await _studyRepository.FirstOrDefaultAsync(t=>t.Id== studyId);
|
||||
var findSerice = await _seriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId);
|
||||
var findPatient = await _patientRepository.FirstOrDefaultAsync(t => t.PatientIdStr == patientIdStr && t.TrialSiteId == trialSiteId);
|
||||
var findStudy = await _studyRepository.FirstOrDefaultAsync(t => t.Id == studyId);
|
||||
var findSerice = await _seriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId);
|
||||
var findInstance = await _instanceRepository.FirstOrDefaultAsync(t => t.Id == instanceId);
|
||||
|
||||
DateTime? studyTime = dataset.GetSingleValueOrDefault(DicomTag.StudyDate, string.Empty) == string.Empty ? null : dataset.GetSingleValue<DateTime>(DicomTag.StudyDate).Add(dataset.GetSingleValueOrDefault(DicomTag.StudyTime, string.Empty) == string.Empty ? TimeSpan.Zero : dataset.GetSingleValue<DateTime>(DicomTag.StudyTime).TimeOfDay);
|
||||
@@ -93,8 +77,8 @@ namespace IRaCIS.Core.SCP.Service
|
||||
findPatient = new SCPPatient()
|
||||
{
|
||||
Id = NewId.NextSequentialGuid(),
|
||||
TrialId=trialId,
|
||||
TrialSiteId=trialSiteId,
|
||||
TrialId = trialId,
|
||||
TrialSiteId = trialSiteId,
|
||||
PatientIdStr = dataset.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty),
|
||||
PatientName = dataset.GetSingleValueOrDefault(DicomTag.PatientName, string.Empty),
|
||||
PatientAge = dataset.GetSingleValueOrDefault(DicomTag.PatientAge, string.Empty),
|
||||
@@ -122,7 +106,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
DateTime birthDate;
|
||||
|
||||
if (findPatient.PatientAge == string.Empty && studyTime.HasValue && DateTime.TryParse(findPatient.PatientBirthDate,out birthDate))
|
||||
if (findPatient.PatientAge == string.Empty && studyTime.HasValue && DateTime.TryParse(findPatient.PatientBirthDate, out birthDate))
|
||||
{
|
||||
var patientAge = studyTime.Value.Year - birthDate.Year;
|
||||
// 如果生日还未到,年龄减去一岁
|
||||
@@ -220,6 +204,12 @@ namespace IRaCIS.Core.SCP.Service
|
||||
AcquisitionNumber = dataset.GetSingleValueOrDefault(DicomTag.AcquisitionNumber, string.Empty),
|
||||
TriggerTime = dataset.GetSingleValueOrDefault(DicomTag.TriggerTime, string.Empty),
|
||||
|
||||
Manufacturer = dataset.GetSingleValueOrDefault(DicomTag.Manufacturer, string.Empty),
|
||||
ManufacturerModelName = dataset.GetSingleValueOrDefault(DicomTag.ManufacturerModelName, string.Empty),
|
||||
DeviceSerialNumber = dataset.GetSingleValueOrDefault(DicomTag.DeviceSerialNumber, string.Empty),
|
||||
DeviceUID = dataset.GetSingleValueOrDefault(DicomTag.DeviceUID, string.Empty),
|
||||
SoftwareVersions = dataset.GetSingleValueOrDefault(DicomTag.SoftwareVersions, string.Empty),
|
||||
PatientWeight = dataset.GetSingleValueOrDefault(DicomTag.PatientWeight, string.Empty),
|
||||
|
||||
|
||||
//IsDoubleReview = addtionalInfo.IsDoubleReview,
|
||||
@@ -239,6 +229,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
findStudy.DicomStudyTime = dataset.GetSingleValueOrDefault(DicomTag.StudyTime, string.Empty);
|
||||
findStudy.CalledAE = calledAE;
|
||||
findStudy.CallingAE = callingAE;
|
||||
findStudy.PatientIdStr = patientIdStr;
|
||||
findStudy.PatientName = dataset.GetSingleValueOrDefault(DicomTag.PatientName, string.Empty);
|
||||
findStudy.PatientSex = dataset.GetSingleValueOrDefault(DicomTag.PatientSex, string.Empty);
|
||||
findStudy.PatientAge = dataset.GetSingleValueOrDefault(DicomTag.PatientAge, string.Empty);
|
||||
@@ -281,6 +272,9 @@ namespace IRaCIS.Core.SCP.Service
|
||||
AcquisitionNumber = dataset.GetSingleValueOrDefault(DicomTag.AcquisitionNumber, string.Empty),
|
||||
TriggerTime = dataset.GetSingleValueOrDefault(DicomTag.TriggerTime, string.Empty),
|
||||
|
||||
RadiopharmaceuticalInformationSequence = dataset.GetSingleValueOrDefault(DicomTag.RadiopharmaceuticalInformationSequence, string.Empty),
|
||||
AcquisitionDate = dataset.GetSingleValueOrDefault(DicomTag.AcquisitionDate, string.Empty),
|
||||
|
||||
|
||||
InstanceCount = 0
|
||||
};
|
||||
@@ -325,16 +319,31 @@ namespace IRaCIS.Core.SCP.Service
|
||||
SliceLocation = dataset.GetSingleValueOrDefault(DicomTag.SliceLocation, 0),
|
||||
|
||||
SliceThickness = dataset.GetSingleValueOrDefault(DicomTag.SliceThickness, string.Empty),
|
||||
NumberOfFrames = dataset.GetSingleValueOrDefault(DicomTag.NumberOfFrames, 0),
|
||||
NumberOfFrames = dataset.GetSingleValueOrDefault(DicomTag.NumberOfFrames, 1),
|
||||
PixelSpacing = dataset.GetSingleValueOrDefault(DicomTag.PixelSpacing, string.Empty),
|
||||
ImagerPixelSpacing = dataset.GetSingleValueOrDefault(DicomTag.ImagerPixelSpacing, string.Empty),
|
||||
FrameOfReferenceUID = dataset.GetSingleValueOrDefault(DicomTag.FrameOfReferenceUID, string.Empty),
|
||||
WindowCenter = dataset.GetSingleValueOrDefault(DicomTag.WindowCenter, string.Empty),
|
||||
WindowWidth = dataset.GetSingleValueOrDefault(DicomTag.WindowWidth, string.Empty),
|
||||
|
||||
PhotometricInterpretation = dataset.GetSingleValueOrDefault(DicomTag.PhotometricInterpretation, string.Empty),
|
||||
BitsAllocated = dataset.GetSingleValueOrDefault(DicomTag.BitsAllocated, 0),
|
||||
PixelRepresentation = dataset.GetSingleValueOrDefault(DicomTag.PixelRepresentation, string.Empty),
|
||||
RescaleIntercept = dataset.GetSingleValueOrDefault(DicomTag.RescaleIntercept, string.Empty),
|
||||
RescaleSlope = dataset.GetSingleValueOrDefault(DicomTag.RescaleSlope, string.Empty),
|
||||
ImagePositionPatient = dataset.GetSingleValueOrDefault(DicomTag.ImagePositionPatient, string.Empty),
|
||||
ImageOrientationPatient = dataset.GetSingleValueOrDefault(DicomTag.ImageOrientationPatient, string.Empty),
|
||||
SequenceOfUltrasoundRegions = dataset.GetSingleValueOrDefault(DicomTag.SequenceOfUltrasoundRegions, string.Empty),
|
||||
FrameTime = dataset.GetSingleValueOrDefault(DicomTag.FrameTime, string.Empty),
|
||||
CorrectedImage = dataset.GetSingleValueOrDefault(DicomTag.CorrectedImage, string.Empty),
|
||||
Units = dataset.GetSingleValueOrDefault(DicomTag.Units, string.Empty),
|
||||
DecayCorrection = dataset.GetSingleValueOrDefault(DicomTag.DecayCorrection, string.Empty),
|
||||
EncapsulatedDocument = dataset.GetSingleValueOrDefault(DicomTag.EncapsulatedDocument, string.Empty),
|
||||
|
||||
|
||||
Path = fileRelativePath,
|
||||
|
||||
FileSize= fileSize,
|
||||
FileSize = fileSize,
|
||||
|
||||
};
|
||||
|
||||
@@ -374,7 +383,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
}
|
||||
else
|
||||
{
|
||||
await _instanceRepository.BatchUpdateNoTrackingAsync(t => t.Id == instanceId, u => new SCPInstance() { Path = fileRelativePath,FileSize=fileSize });
|
||||
await _instanceRepository.BatchUpdateNoTrackingAsync(t => t.Id == instanceId, u => new SCPInstance() { Path = fileRelativePath, FileSize = fileSize });
|
||||
}
|
||||
|
||||
await _studyRepository.SaveChangesAsync();
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace IRaCIS.Api.Controllers
|
||||
var token = _tokenService.GetToken(new UserTokenInfo()
|
||||
{
|
||||
IdentityUserId = Guid.NewGuid(),
|
||||
UserName = "Share001",
|
||||
UserName = "ImageShare",
|
||||
UserTypeEnum = UserTypeEnum.ShareImage,
|
||||
|
||||
});
|
||||
@@ -279,7 +279,7 @@ namespace IRaCIS.Api.Controllers
|
||||
|
||||
var isExpire = _tokenService.IsTokenExpired(token);
|
||||
|
||||
if (!await _useRepository.AnyAsync(t => t.Id == Guid.Parse(userId) && t.EmailToken == token && t.IsFirstAdd) || isExpire)
|
||||
if ( Guid.TryParse(userId,out _) == false || isExpire || !await _useRepository.AnyAsync(t => t.Id == Guid.Parse(userId) && t.EmailToken == token && t.IsFirstAdd) )
|
||||
{
|
||||
decodeUrl = errorUrl + $"?lang={lang}&ErrorMessage={System.Web.HttpUtility.UrlEncode(I18n.T("UserRedirect_InitializationLinkExpire"))} ";
|
||||
}
|
||||
|
||||
@@ -568,6 +568,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
/// 一致性核查 excel上传 支持三种格式
|
||||
/// </summary>
|
||||
/// <param name="trialId"></param>
|
||||
/// <param name="isFullCheck"></param>
|
||||
/// <param name="oSSService"></param>
|
||||
/// <param name="_inspectionFileRepository"></param>
|
||||
/// <returns></returns>
|
||||
@@ -575,12 +576,14 @@ namespace IRaCIS.Core.API.Controllers
|
||||
[HttpPost("QCOperation/UploadVisitCheckExcel/{trialId:guid}")]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
|
||||
public async Task<IResponseOutput> UploadVisitCheckExcel(Guid trialId, [FromServices] IOSSService oSSService, [FromServices] IRepository<InspectionFile> _inspectionFileRepository)
|
||||
public async Task<IResponseOutput> UploadVisitCheckExcel(Guid trialId, bool isFullCheck, [FromServices] IOSSService oSSService, [FromServices] IRepository<InspectionFile> _inspectionFileRepository)
|
||||
{
|
||||
|
||||
var fileName = string.Empty;
|
||||
var templateFileStream = new MemoryStream();
|
||||
|
||||
var inspectionFileId = Guid.Empty;
|
||||
|
||||
await FileUploadToOSSAsync(async (realFileName, fileStream) =>
|
||||
{
|
||||
fileName = realFileName;
|
||||
@@ -597,7 +600,9 @@ namespace IRaCIS.Core.API.Controllers
|
||||
|
||||
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, $"{trialId.ToString()}/InspectionUpload/DataReconciliation", realFileName);
|
||||
|
||||
await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = realFileName, RelativePath = ossRelativePath, TrialId = trialId }, true);
|
||||
var addEntity = await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = realFileName, RelativePath = ossRelativePath, TrialId = trialId }, true);
|
||||
|
||||
inspectionFileId = addEntity.Id;
|
||||
|
||||
return ossRelativePath;
|
||||
|
||||
@@ -743,8 +748,11 @@ namespace IRaCIS.Core.API.Controllers
|
||||
|
||||
if (etcCheckList == null || etcCheckList.Count == 0)
|
||||
{
|
||||
await _inspectionFileRepository.BatchUpdateNoTrackingAsync(t => t.Id == inspectionFileId, u => new InspectionFile() { CheckState = EDCCheckState.Failed });
|
||||
|
||||
//---请保证上传数据符合模板文件中的样式,且存在有效数据。
|
||||
return ResponseOutput.NotOk(_localizer["UploadDownLoad_InvalidData"]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -764,6 +772,8 @@ namespace IRaCIS.Core.API.Controllers
|
||||
|
||||
if (etcCheckList.Count == 0)
|
||||
{
|
||||
await _inspectionFileRepository.BatchUpdateNoTrackingAsync(t => t.Id == inspectionFileId, u => new InspectionFile() { CheckState = EDCCheckState.Failed });
|
||||
|
||||
//---请保证上传数据符合模板文件中的样式,且存在有效数据。
|
||||
return ResponseOutput.NotOk(_localizer["UploadDownLoad_InvalidData"]);
|
||||
}
|
||||
@@ -775,8 +785,19 @@ namespace IRaCIS.Core.API.Controllers
|
||||
//var client = _mediator.CreateRequestClient<ConsistenCheckCommand>();
|
||||
//await client.GetResponse<ConsistenCheckResult>(new ConsistenCheckCommand() { ETCList = etcCheckList, TrialId = trialId });
|
||||
|
||||
//不获取结果,不用定义返回类型
|
||||
await _mediator.Send(new ConsistenCheckCommand() { ETCList = etcCheckList, TrialId = trialId });
|
||||
if (isFullCheck)
|
||||
{
|
||||
await _mediator.Send(new ConsistenFullCheckCommand() { ETCList = etcCheckList, TrialId = trialId, InspectionFileId = inspectionFileId });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//不获取结果,不用定义返回类型
|
||||
await _mediator.Send(new ConsistenCheckCommand() { ETCList = etcCheckList, TrialId = trialId });
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
@@ -983,7 +1004,11 @@ namespace IRaCIS.Core.API.Controllers
|
||||
|
||||
EmailBodyHtml = 4,
|
||||
|
||||
Other = 5
|
||||
ReadKeyFile = 5,
|
||||
|
||||
Other = 6,
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1015,6 +1040,9 @@ namespace IRaCIS.Core.API.Controllers
|
||||
case UploadFileType.EmailBodyHtml:
|
||||
result = await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.EmailTemplate, fileName));
|
||||
break;
|
||||
case UploadFileType.ReadKeyFile:
|
||||
result = await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.ReadKetFile, fileName));
|
||||
break;
|
||||
|
||||
default:
|
||||
result = await SingleFileUploadAsync((fileName) => FileStoreHelper.GetOtherFileUploadPath(_hostEnvironment, StaticData.Folder.TempFile, fileName));
|
||||
|
||||
@@ -15,12 +15,13 @@ using Hangfire.Storage;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MassTransit.Mediator;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace IRaCIS.Core.API.HostService;
|
||||
|
||||
public class HangfireHostService(IRecurringMessageScheduler _recurringMessageScheduler,
|
||||
IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigRepository,
|
||||
|
||||
IConfiguration _config,
|
||||
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
||||
IMediator _mediator,
|
||||
ILogger<HangfireHostService> _logger) : IHostedService
|
||||
@@ -56,7 +57,9 @@ public class HangfireHostService(IRecurringMessageScheduler _recurringMessageSch
|
||||
}
|
||||
}
|
||||
|
||||
string defaultCulture = _config.GetValue<string>("SystemEmailSendConfig:CronEmailDefaultCulture");
|
||||
|
||||
// 项目手动选择,周期性邮件
|
||||
var taskInfoList = await _trialEmailNoticeConfigRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing && t.EmailCron != string.Empty && t.IsAutoSend)
|
||||
.Select(t => new { t.Id, t.Code, TrialCode = t.Trial.TrialCode, t.EmailCron, t.BusinessScenarioEnum, t.TrialId })
|
||||
.ToListAsync();
|
||||
@@ -68,11 +71,11 @@ public class HangfireHostService(IRecurringMessageScheduler _recurringMessageSch
|
||||
|
||||
var trialId = task.TrialId;
|
||||
|
||||
HangfireJobHelper.AddOrUpdateTrialCronJob(jobId, trialId, task.BusinessScenarioEnum, task.EmailCron);
|
||||
HangfireJobHelper.AddOrUpdateTrialCronJob(jobId, trialId, task.BusinessScenarioEnum, task.EmailCron, defaultCulture);
|
||||
}
|
||||
|
||||
|
||||
// 系统邮件定时任务
|
||||
// 系统邮件定时任务 要设置默认语言
|
||||
var systemTaskInfoList = await _emailNoticeConfigrepository.Where(t => t.EmailCron != string.Empty && t.IsAutoSend)
|
||||
.Select(t => new { t.Id, t.Code, t.EmailCron, t.BusinessScenarioEnum, })
|
||||
.ToListAsync();
|
||||
@@ -82,7 +85,7 @@ public class HangfireHostService(IRecurringMessageScheduler _recurringMessageSch
|
||||
//利用主键作为任务Id
|
||||
var jobId = $"{task.Id}_({task.BusinessScenarioEnum})";
|
||||
|
||||
HangfireJobHelper.AddOrUpdateTimingCronJob(jobId, task.BusinessScenarioEnum, task.EmailCron);
|
||||
HangfireJobHelper.AddOrUpdateTimingCronJob(jobId, task.BusinessScenarioEnum, task.EmailCron, defaultCulture);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -318,11 +318,12 @@
|
||||
<param name="_noneDicomStudyFileRepository"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.API.Controllers.StudyController.UploadVisitCheckExcel(System.Guid,IRaCIS.Core.Application.Helper.IOSSService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.InspectionFile})">
|
||||
<member name="M:IRaCIS.Core.API.Controllers.StudyController.UploadVisitCheckExcel(System.Guid,System.Boolean,IRaCIS.Core.Application.Helper.IOSSService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.InspectionFile})">
|
||||
<summary>
|
||||
一致性核查 excel上传 支持三种格式
|
||||
</summary>
|
||||
<param name="trialId"></param>
|
||||
<param name="isFullCheck"></param>
|
||||
<param name="oSSService"></param>
|
||||
<param name="_inspectionFileRepository"></param>
|
||||
<returns></returns>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using IRaCIS.Core.API;
|
||||
using IRaCIS.Core.API.HostService;
|
||||
using IRaCIS.Core.Application.BusinessFilter;
|
||||
using IRaCIS.Core.Application.BusinessFilter.LegacyController.Database.Api;
|
||||
using IRaCIS.Core.Application.Filter;
|
||||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
@@ -21,6 +22,7 @@ using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -28,6 +30,10 @@ using System.Runtime.InteropServices;
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
|
||||
|
||||
Console.WriteLine("Startup Culture: " + CultureInfo.CurrentCulture.Name);
|
||||
Console.WriteLine("Startup UI Culture: " + CultureInfo.CurrentUICulture.Name);
|
||||
|
||||
#region 获取环境变量
|
||||
//以配置文件为准,否则 从url中取环境值(服务以命令行传递参数启动,配置文件配置了就不需要传递环境参数)
|
||||
var config = new ConfigurationBuilder()
|
||||
@@ -95,11 +101,18 @@ builder.Services.AddJsonLocalization(options => options.ResourcesPath = "Resourc
|
||||
// 异常、参数统一验证过滤器、Json序列化配置、字符串参数绑型统一Trim()
|
||||
builder.Services.AddControllers(options =>
|
||||
{
|
||||
// 关键配置:禁用不可空引用类型的自动 Required 验证
|
||||
options.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes = true;
|
||||
|
||||
// 插到最前,抢在默认绑定器之前
|
||||
//options.ModelBinderProviders.Insert(0, new SpecificNullableBinderProvider());
|
||||
|
||||
options.Filters.Add<ModelActionFilter>();
|
||||
options.Filters.Add<ProjectExceptionFilter>();
|
||||
options.Filters.Add<UnitOfWorkFilter>();
|
||||
options.Filters.Add<LimitUserRequestAuthorization>();
|
||||
options.Filters.Add<TrialGlobalLimitActionFilter>();
|
||||
options.Filters.Add<RequestDuplicationFilter>();
|
||||
|
||||
})
|
||||
.AddNewtonsoftJsonSetup(builder.Services); // NewtonsoftJson 序列化 处理
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:3305",
|
||||
"applicationUrl": "http://0.0.0.0:3305",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
@@ -23,7 +23,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Test_IRC",
|
||||
"ASPNETCORE_OpenSwagger": "true"
|
||||
},
|
||||
"applicationUrl": "http://localhost:6100"
|
||||
"applicationUrl": "http://0.0.0.0:6100"
|
||||
},
|
||||
"IRaCIS.Test_IRC_PGSQL": {
|
||||
"commandName": "Project",
|
||||
@@ -31,7 +31,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Test_IRC_PGSQL"
|
||||
},
|
||||
"applicationUrl": "http://localhost:6100"
|
||||
"applicationUrl": "http://0.0.0.0:6100"
|
||||
},
|
||||
"IRaCIS.Event_IRC": {
|
||||
"commandName": "Project",
|
||||
@@ -39,7 +39,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Event_IRC"
|
||||
},
|
||||
"applicationUrl": "http://localhost:6100"
|
||||
"applicationUrl": "http://0.0.0.0:6100"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
@@ -53,7 +53,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Uat_IRC"
|
||||
},
|
||||
"applicationUrl": "http://localhost:6100"
|
||||
"applicationUrl": "http://0.0.0.0:6100"
|
||||
},
|
||||
"IRaCIS.Prod_IRC": {
|
||||
"commandName": "Project",
|
||||
@@ -61,7 +61,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Prod_IRC"
|
||||
},
|
||||
"applicationUrl": "http://localhost:6100"
|
||||
"applicationUrl": "http://0.0.0.0:6100"
|
||||
},
|
||||
"IRaCIS.US_Uat_IRC": {
|
||||
"commandName": "Project",
|
||||
@@ -69,7 +69,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "US_Uat_IRC"
|
||||
},
|
||||
"applicationUrl": "http://localhost:6100"
|
||||
"applicationUrl": "http://0.0.0.0:6100"
|
||||
},
|
||||
"IRaCIS.US_Prod_IRC": {
|
||||
"commandName": "Project",
|
||||
@@ -77,7 +77,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "US_Prod_IRC"
|
||||
},
|
||||
"applicationUrl": "http://localhost:6100"
|
||||
"applicationUrl": "http://0.0.0.0:6100"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace IRaCIS.Core.API._PipelineExtensions.Serilog
|
||||
|
||||
var requestBodyPayload = await ReadRequestBody(context.Request);
|
||||
|
||||
context.Items["RequestBody"] = requestBodyPayload;
|
||||
|
||||
using (LogContext.PushProperty("RequestBody", requestBodyPayload))
|
||||
{
|
||||
//await _next.Invoke()
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace IRaCIS.Core.API
|
||||
}
|
||||
else
|
||||
{
|
||||
options.UseSqlServer(configuration.GetSection("ConnectionStrings:RemoteNew").Value, contextOptionsBuilder => contextOptionsBuilder.EnableRetryOnFailure());
|
||||
options.UseSqlServer(configuration.GetSection("ConnectionStrings:RemoteNew").Value, contextOptionsBuilder => contextOptionsBuilder.EnableRetryOnFailure()/*.CommandTimeout(60)*/);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -71,29 +71,27 @@ namespace IRaCIS.Core.API
|
||||
|
||||
DateTime dateTime;
|
||||
|
||||
if (reader.ValueType == typeof(DateTime) || reader.ValueType == typeof(DateTime?))
|
||||
// 2. 检查目标类型是否可空
|
||||
bool isNullable = objectType == typeof(DateTime?);
|
||||
|
||||
var canConvert = DateTime.TryParse(reader.Value?.ToString(), out dateTime);
|
||||
|
||||
|
||||
if (isNullable == false && canConvert == false)
|
||||
{
|
||||
DateTime? nullableDateTime = reader.Value as DateTime?;
|
||||
|
||||
|
||||
if (nullableDateTime != null && nullableDateTime.HasValue)
|
||||
{
|
||||
dateTime = nullableDateTime.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
throw new JsonSerializationException($"Could not convert string to DateTime: {reader.Value} Path {reader.Path}");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DateTime.TryParse((string)reader.Value, out dateTime) == false)
|
||||
if (canConvert == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////如果前端传递带时区的,那么转换会报错,需要DateTimeKind.Unspecified
|
||||
//dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
|
||||
|
||||
// 将客户端时间转换为服务器时区的时间
|
||||
var serverZoneTime = TimeZoneInfo.ConvertTime(dateTime, _clientTimeZone, TimeZoneInfo.Local);
|
||||
@@ -113,7 +111,10 @@ namespace IRaCIS.Core.API
|
||||
//第一个参数默认使用系统本地时区 也就是应用服务器的时区
|
||||
DateTime clientZoneTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, _clientTimeZone);
|
||||
|
||||
//writer.WriteValue(clientZoneTime);
|
||||
|
||||
//// 最简单的方式:创建 DateTimeOffset
|
||||
//DateTimeOffset dateTimeOffset = new DateTimeOffset(clientZoneTime, _clientTimeZone.GetUtcOffset(clientZoneTime));
|
||||
//writer.WriteValue(dateTimeOffset.ToString("yyyy-MM-dd HH:mm:sszzz"));
|
||||
|
||||
writer.WriteValue(clientZoneTime.ToString(_dateFormat));
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
@@ -51,34 +53,90 @@ namespace IRaCIS.Core.API
|
||||
}
|
||||
public class NullToEmptyStringValueProvider : IValueProvider
|
||||
{
|
||||
PropertyInfo _MemberInfo;
|
||||
PropertyInfo _memberInfo;
|
||||
private readonly bool _isNullable;
|
||||
public NullToEmptyStringValueProvider(PropertyInfo memberInfo)
|
||||
{
|
||||
_MemberInfo = memberInfo;
|
||||
_memberInfo = memberInfo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// DTO → JSON 返回前端的时候 处理null 变为"" 方便前端判断
|
||||
public object GetValue(object target)
|
||||
{
|
||||
object result = _MemberInfo.GetValue(target);
|
||||
if (_MemberInfo.PropertyType == typeof(string) && result == null) result = "";
|
||||
else if (_MemberInfo.PropertyType == typeof(String[]) && result == null) result = new string[] { };
|
||||
//else if (_MemberInfo.PropertyType == typeof(Nullable<Int32>) && result == null) result = 0;
|
||||
//else if (_MemberInfo.PropertyType == typeof(Nullable<Decimal>) && result == null) result = 0.00M;
|
||||
var result = _memberInfo.GetValue(target);
|
||||
// 检查类型是否为string或string?
|
||||
if (_memberInfo.PropertyType == typeof(string) && result == null)
|
||||
{
|
||||
|
||||
#region 返回的时候处理 string string? null 为"" 不区分处理
|
||||
|
||||
|
||||
//// 如果是string?类型,返回null 可以做到,但是得反射,因为 string string? 是编译层区分的
|
||||
|
||||
//var isNullable1 = _memberInfo.CustomAttributes
|
||||
// .Any(a => a.AttributeType.Name == "NullableAttribute");
|
||||
|
||||
////var isNullable2 = _memberInfo.CustomAttributes
|
||||
//// .Any(a => a.AttributeType.FullName == "System.Runtime.CompilerServices.NullableAttribute");
|
||||
|
||||
//if (isNullable1)
|
||||
//{
|
||||
// return result;
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
// 如果是string类型,返回空字符串
|
||||
return string.Empty;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//影响 模型绑定时接收前端的值,同时影响 正常 JSON 序列化
|
||||
public void SetValue(object target, object value)
|
||||
{
|
||||
|
||||
if (_MemberInfo.PropertyType == typeof(string))
|
||||
{
|
||||
//去掉前后空格
|
||||
_MemberInfo.SetValue(target, value == null ? string.Empty : value.ToString() == string.Empty ? value : value/*.ToString().Trim()*/);
|
||||
_memberInfo.SetValue(target, value);
|
||||
|
||||
#region 前端针对 string 类型的变量,如果传递null 会报错必传
|
||||
|
||||
//if (_memberInfo.PropertyType == typeof(string))
|
||||
//{
|
||||
// _memberInfo.SetValue(target, value == null ? string.Empty : value);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// _memberInfo.SetValue(target, value);
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 处理模型验证区分 string string?
|
||||
|
||||
//////接收模型的时候 定义的明明是string 但是上面也有该属性,判断不准的 比如阅片跟踪列表查询
|
||||
//var isNullable1 = _memberInfo.CustomAttributes.Any(a => a.AttributeType.Name == "NullableAttribute");
|
||||
|
||||
////不影响 string? 传递null 变为""
|
||||
//if (_memberInfo.PropertyType == typeof(string) && isNullable1 == false)
|
||||
//{
|
||||
// //如果不处理 前段传递null string不会接收,说前段没传递会验证报错
|
||||
// _memberInfo.SetValue(target, value == null ? string.Empty : value);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
||||
// _memberInfo.SetValue(target, value);
|
||||
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_MemberInfo.SetValue(target, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace IRaCIS.Core.API
|
||||
.Enrich.FromLogContext()
|
||||
.Filter.ByExcluding(logEvent => logEvent.Properties.ContainsKey("RequestPath") && logEvent.Properties["RequestPath"].ToString().Contains("/health"))
|
||||
.WriteTo.Console()
|
||||
.WriteTo.File($"{AppContext.BaseDirectory}Serilogs/.log", rollingInterval: RollingInterval.Day,retainedFileCountLimit:60);
|
||||
.WriteTo.File($"{AppContext.BaseDirectory}Serilogs/.log", rollingInterval: RollingInterval.Day,retainedFileCountLimit:365);
|
||||
|
||||
#region 根据环境配置是否打开错误发送邮件通知
|
||||
|
||||
|
||||
@@ -28,12 +28,13 @@ public static class ServiceCollectionSetup
|
||||
services.AddOptions().Configure<AliyunOSSOptions>(_configuration.GetSection("AliyunOSS"));
|
||||
services.AddOptions().Configure<ObjectStoreServiceOptions>(_configuration.GetSection("ObjectStoreService"));
|
||||
services.AddOptions().Configure<IRCEncreptOption>(_configuration.GetSection("EncrypteResponseConfig"));
|
||||
services.AddOptions().Configure<RequestDuplicationOptions>(_configuration.GetSection("RequestDuplicationOptions"));
|
||||
services.AddOptions().Configure<SystemPacsConfig>(_configuration.GetSection("SystemPacsConfig"));
|
||||
services.Configure<IRaCISBasicConfigOption>(_configuration.GetSection("IRaCISBasicConfig"));
|
||||
|
||||
services.Configure<ServiceVerifyConfigOption>(_configuration.GetSection("BasicSystemConfig"));
|
||||
|
||||
//转发头设置 获取真实IP
|
||||
//ת��ͷ���� ��ȡ��ʵIP
|
||||
services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders =
|
||||
@@ -51,7 +52,7 @@ public static class ServiceCollectionSetup
|
||||
|
||||
services.AddScoped<IObtainTaskAutoCancelJob, ObtainTaskAutoCancelJob>();
|
||||
|
||||
// 注册以Service 结尾的服务
|
||||
// ע����Service ��β�ķ���
|
||||
services.Scan(scan => scan
|
||||
.FromAssemblies(typeof(BaseService).Assembly)
|
||||
.AddClasses(classes => classes.Where(t => t.Name.Contains("Service")))
|
||||
@@ -70,23 +71,23 @@ public static class ServiceCollectionSetup
|
||||
#endregion
|
||||
|
||||
|
||||
// MediatR 进程内消息 事件解耦 从程序集中 注册命令和handler对应关系
|
||||
// MediatR ��������Ϣ �¼����� �ӳ����� ע�������handler��Ӧ��ϵ
|
||||
//builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<ConsistencyVerificationHandler>());
|
||||
|
||||
|
||||
|
||||
#region 历史废弃配置
|
||||
#region ��ʷ��������
|
||||
//builder.Services.AddMemoryCache();
|
||||
////上传限制 配置
|
||||
////�ϴ����� ����
|
||||
//builder.Services.Configure<FormOptions>(options =>
|
||||
//{
|
||||
// options.MultipartBodyLengthLimit = int.MaxValue;
|
||||
// options.ValueCountLimit = int.MaxValue;
|
||||
// options.ValueLengthLimit = int.MaxValue;
|
||||
//});
|
||||
//IP 限流 可设置白名单 或者黑名单
|
||||
//IP ���� �����ð����� ���ߺ�����
|
||||
//services.AddIpPolicyRateLimitSetup(_configuration);
|
||||
// 用户类型 策略授权
|
||||
// �û����� ������Ȩ
|
||||
//services.AddAuthorizationPolicySetup(_configuration);
|
||||
#endregion
|
||||
}
|
||||
@@ -94,25 +95,25 @@ public static class ServiceCollectionSetup
|
||||
|
||||
}
|
||||
|
||||
#region Autofac 废弃
|
||||
#region Autofac ����
|
||||
//public class AutofacModuleSetup : Autofac.Module
|
||||
//{
|
||||
// protected override void Load(ContainerBuilder containerBuilder)
|
||||
// {
|
||||
|
||||
// #region byzhouhang 20210917 此处注册泛型仓储 可以减少Domain层 和Infra.EFcore 两层 空的仓储接口定义和 仓储文件定义
|
||||
// #region byzhouhang 20210917 �˴�ע�᷺�Ͳִ� ���Լ���Domain�� ��Infra.EFcore ���� �յIJִ��ӿڶ���� �ִ��ļ�����
|
||||
|
||||
// containerBuilder.RegisterGeneric(typeof(Repository<>))
|
||||
// .As(typeof(IRepository<>)).InstancePerLifetimeScope();//注册泛型仓储
|
||||
// .As(typeof(IRepository<>)).InstancePerLifetimeScope();//ע�᷺�Ͳִ�
|
||||
|
||||
// containerBuilder.RegisterType<Repository>().As<IRepository>().InstancePerLifetimeScope();
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 指定控制器也由autofac 来进行实例获取 https://www.cnblogs.com/xwhqwer/p/15320838.html
|
||||
// #region ָ��������Ҳ��autofac ������ʵ����ȡ https://www.cnblogs.com/xwhqwer/p/15320838.html
|
||||
|
||||
// //获取所有控制器类型并使用属性注入
|
||||
// //��ȡ���п��������Ͳ�ʹ������ע��
|
||||
// containerBuilder.RegisterAssemblyTypes(typeof(BaseService).Assembly)
|
||||
// .Where(type => typeof(IDynamicWebApi).IsAssignableFrom(type))
|
||||
// .PropertiesAutowired();
|
||||
@@ -128,7 +129,7 @@ public static class ServiceCollectionSetup
|
||||
// //containerBuilder.RegisterType<UserInfo>().As<IUserInfo>().InstancePerLifetimeScope();
|
||||
|
||||
|
||||
// //注册hangfire任务 依赖注入
|
||||
// //ע��hangfire���� ����ע��
|
||||
// containerBuilder.RegisterType<ObtainTaskAutoCancelJob>().As<IObtainTaskAutoCancelJob>().InstancePerDependency();
|
||||
|
||||
// }
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
},
|
||||
|
||||
"BasicSystemConfig": {
|
||||
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": true,
|
||||
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
@@ -55,11 +56,15 @@
|
||||
"ChangePassWordDays": 90,
|
||||
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
"TemplateType": 2
|
||||
"TemplateType": 2,
|
||||
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
},
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 465,
|
||||
"Host": "smtp.qiye.aliyun.com",
|
||||
"Imap": "imap.qiye.aliyun.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "uat@extimaging.com",
|
||||
"FromName": "UAT_IRC",
|
||||
"AuthorizationCode": "SHzyyl2021",
|
||||
@@ -69,7 +74,13 @@
|
||||
"CompanyShortName": "Extensive Imaging",
|
||||
"CompanyShortNameCN": "展影医疗",
|
||||
"IsEnv_US": false
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
//"RemoteNew": "Server=prod_mssql_standard,1433;Database=Prod_IRC;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true",
|
||||
//"Hangfire": "Server=prod_mssql_standard,1433;Database=Prod_IRC_Hangfire;User ID=sa;Password=zhanying@2021;TrustServerCertificate=true"
|
||||
},
|
||||
"WeComNoticeConfig": {
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
"ObjectStoreUse": "AliyunOSS",
|
||||
"AliyunOSS": {
|
||||
@@ -36,7 +42,8 @@
|
||||
}
|
||||
},
|
||||
"BasicSystemConfig": {
|
||||
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": true,
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
|
||||
@@ -53,19 +60,26 @@
|
||||
"IsNeedChangePassWord": true,
|
||||
"ChangePassWordDays": 90,
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
"TemplateType": 2
|
||||
"TemplateType": 2,
|
||||
//MFA免验证发送天数
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
},
|
||||
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 465,
|
||||
"Host": "smtp.qiye.aliyun.com",
|
||||
"Imap": "imap.qiye.aliyun.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "irc@extimaging.com",
|
||||
"FromName": "IRC Imaging System",
|
||||
"AuthorizationCode": "ExtImg@2022",
|
||||
"SiteUrl": "http://irc.extimaging.com/login",
|
||||
|
||||
"PlatformName": "EICS",
|
||||
"PlatformNameCN": "展影云平台",
|
||||
"SystemShortName": "IRC",
|
||||
"OrganizationName": "Extlmaging",
|
||||
"OrganizationNameCN": "Extlmaging",
|
||||
"OrganizationName": "ExtImaging",
|
||||
"OrganizationNameCN": "ExtImaging",
|
||||
"CompanyName": "Extensive Imaging",
|
||||
"CompanyNameCN": "上海展影医疗科技有限公司",
|
||||
"CompanyShortName": "Extensive Imaging",
|
||||
@@ -73,11 +87,18 @@
|
||||
"IsEnv_US": false,
|
||||
"IsOpenErrorNoticeEmail": false,
|
||||
"EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
||||
"CronEmailDefaultCulture": "zh-CN",
|
||||
"ErrorNoticeEmailList": [ "872297557@qq.com" ]
|
||||
},
|
||||
"SystemPacsConfig": {
|
||||
"Port": "11113",
|
||||
"IP": "101.132.193.237"
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
// Hangfire 定时任务数据库链接字符串
|
||||
"Hangfire": "Server=106.14.89.110,1435;Database=Test_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
|
||||
},
|
||||
"WeComNoticeConfig": {
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
},
|
||||
// 对象存储服务配置
|
||||
"ObjectStoreService": {
|
||||
// 使用的对象存储服务类型
|
||||
@@ -88,6 +94,8 @@
|
||||
},
|
||||
// 系统配置
|
||||
"BasicSystemConfig": {
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
// 打开用户复杂密码
|
||||
"OpenUserComplexPassword": false,
|
||||
// 是否在开始工作前强制签署电子知情同意书
|
||||
@@ -110,12 +118,14 @@
|
||||
"IsNeedChangePassWord": true,
|
||||
// 密码有效期(天),到期后必须修改
|
||||
"ChangePassWordDays": 90,
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
// 模板类型 1 Elevate(LiLi) 2 Extensive(展影)
|
||||
"TemplateType": 2,
|
||||
// 是否打开项目关联删除
|
||||
"OpenTrialRelationDelete": true,
|
||||
// 转换PDF服务配置
|
||||
"ThirdPdfUrl": "http://106.14.89.110:30088/api/v1/convert/file/pdf"
|
||||
"ThirdPdfUrl": "http://106.14.89.110:30088/api/v1/convert/file/pdf",
|
||||
//MFA免验证发送天数
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
},
|
||||
// 邮件服务配置(用于系统通知、找回密码、错误报警等)
|
||||
"SystemEmailSendConfig": {
|
||||
@@ -123,6 +133,10 @@
|
||||
"Port": 465,
|
||||
// 企业邮箱SMTP服务器地址
|
||||
"Host": "smtp.qiye.aliyun.com",
|
||||
|
||||
"Imap": "imap.qiye.aliyun.com",
|
||||
|
||||
"ImapPort": 993,
|
||||
// 发件人邮箱地址
|
||||
"FromEmail": "test@extimaging.com",
|
||||
// 发件人显示名称
|
||||
@@ -131,12 +145,15 @@
|
||||
"AuthorizationCode": "SHzyyl2021",
|
||||
// 系统对外访问地址
|
||||
"SiteUrl": "http://irc.test.extimaging.com/login",
|
||||
// 系统简称
|
||||
|
||||
"PlatformName": "EICS",
|
||||
"PlatformNameCN": "展影云平台",
|
||||
// 系统简称一致性核查使用
|
||||
"SystemShortName": "IRC",
|
||||
// 组织英文名称
|
||||
"OrganizationName": "Extlmaging",
|
||||
"OrganizationName": "ExtImaging",
|
||||
// 组织中文名称
|
||||
"OrganizationNameCN": "Extlmaging",
|
||||
"OrganizationNameCN": "ExtImaging",
|
||||
// 公司英文全称
|
||||
"CompanyName": "Extensive Imaging",
|
||||
// 公司中文全称
|
||||
@@ -151,6 +168,7 @@
|
||||
"IsOpenErrorNoticeEmail": false,
|
||||
// 邮箱格式校验正则表达式
|
||||
"EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
||||
"CronEmailDefaultCulture": "zh-CN",
|
||||
// 接收系统异常报警的邮箱列表
|
||||
"ErrorNoticeEmailList": [ "872297557@qq.com" ]
|
||||
},
|
||||
@@ -160,5 +178,16 @@
|
||||
"Port": "11113",
|
||||
// PACS服务器IP地址
|
||||
"IP": "106.14.89.110"
|
||||
},
|
||||
// 重复请求配置
|
||||
"RequestDuplicationOptions": {
|
||||
// 是否启用重复请求检测
|
||||
"IsEnabled": true,
|
||||
// 重复请求时间窗口(毫秒)
|
||||
"DuplicationWindowMs": 200,
|
||||
// 缓存请求时间(秒)
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
},
|
||||
|
||||
"BasicSystemConfig": {
|
||||
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": false,
|
||||
|
||||
"OpenSignDocumentBeforeWork": false,
|
||||
@@ -75,13 +76,15 @@
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 465,
|
||||
"Host": "smtp.qiye.aliyun.com",
|
||||
"Imap": "imap.qiye.aliyun.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "test@extimaging.com",
|
||||
"FromName": "Test_IRC",
|
||||
"AuthorizationCode": "SHzyyl2021",
|
||||
"SiteUrl": "http://irc.test.extimaging.com/login",
|
||||
|
||||
"OrganizationName": "Extlmaging",
|
||||
"OrganizationNameCN": "Extlmaging",
|
||||
"OrganizationName": "ExtImaging",
|
||||
"OrganizationNameCN": "ExtImaging",
|
||||
"CompanyName": "Extensive Imaging",
|
||||
"CompanyNameCN": "上海展影医疗科技有限公司",
|
||||
"CompanyShortName": "Extensive Imaging",
|
||||
@@ -91,5 +94,12 @@
|
||||
"SystemPacsConfig": {
|
||||
"Port": "11113",
|
||||
"IP": "106.14.89.110"
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,12 @@
|
||||
//"RemoteNew": "Server=44.210.231.169,1435;Database=US_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
|
||||
//"Hangfire": "Server=44.210.231.169,1435;Database=US_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
|
||||
},
|
||||
|
||||
"WeComNoticeConfig": {
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
"ObjectStoreUse": "AWS",
|
||||
"MinIO": {
|
||||
@@ -38,7 +43,8 @@
|
||||
}
|
||||
},
|
||||
"BasicSystemConfig": {
|
||||
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": true,
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
|
||||
@@ -57,17 +63,24 @@
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
"TemplateType": 1,
|
||||
|
||||
"OpenTrialRelationDelete": false
|
||||
"OpenTrialRelationDelete": false,
|
||||
//MFA免验证
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
|
||||
},
|
||||
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 587,
|
||||
"Host": "smtp-mail.outlook.com",
|
||||
"Imap": "imap-mail.outlook.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "donotreply@elevateimaging.ai",
|
||||
"FromName": "LiLi System",
|
||||
"AuthorizationCode": "Q#669869497420ul",
|
||||
|
||||
|
||||
"PlatformName": "LiLi",
|
||||
"PlatformNameCN": "LiLi",
|
||||
"SystemShortName": "LiLi",
|
||||
"OrganizationName": "Elevate Imaging",
|
||||
"OrganizationNameCN": "Elevate Imaging",
|
||||
@@ -79,12 +92,20 @@
|
||||
"IsEnv_US": true,
|
||||
"IsOpenErrorNoticeEmail": false,
|
||||
"EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
||||
"CronEmailDefaultCulture": "en-US",
|
||||
"ErrorNoticeEmailList": [ "872297557@qq.com" ]
|
||||
},
|
||||
|
||||
"SystemPacsConfig": {
|
||||
"Port": "104",
|
||||
"IP": "44.210.231.169"
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
}
|
||||
},
|
||||
"BasicSystemConfig": {
|
||||
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": true,
|
||||
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
@@ -66,16 +67,24 @@
|
||||
"ChangePassWordDays": 90,
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
"TemplateType": 1,
|
||||
"OpenLoginMFA": true
|
||||
"OpenLoginMFA": true,
|
||||
//MFA免验证发送天数
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
|
||||
},
|
||||
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 587,
|
||||
"Host": "smtp-mail.outlook.com",
|
||||
"Imap": "imap-mail.outlook.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "donotreply@elevateimaging.ai",
|
||||
"FromName": "LiLi System",
|
||||
"AuthorizationCode": "Q#669869497420ul",
|
||||
|
||||
|
||||
"PlatformName": "LiLi",
|
||||
"PlatformNameCN": "LiLi",
|
||||
"SystemShortName": "LiLi",
|
||||
"OrganizationName": "Elevate Imaging",
|
||||
"OrganizationNameCN": "Elevate Imaging",
|
||||
@@ -92,6 +101,13 @@
|
||||
"SystemPacsConfig": {
|
||||
"Port": "104",
|
||||
"IP": "3.226.182.187"
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
"RemoteNew": "Server=3.226.182.187,1435;Database=US_Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
|
||||
"Hangfire": "Server=3.226.182.187,1435;Database=US_Uat_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
|
||||
},
|
||||
"WeComNoticeConfig": {
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
},
|
||||
|
||||
"ObjectStoreService": {
|
||||
|
||||
@@ -48,7 +54,8 @@
|
||||
}
|
||||
},
|
||||
"BasicSystemConfig": {
|
||||
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": true,
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
|
||||
@@ -65,16 +72,22 @@
|
||||
"IsNeedChangePassWord": true,
|
||||
"ChangePassWordDays": 90,
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
"TemplateType": 1
|
||||
"TemplateType": 1,
|
||||
//MFA免验证发送天数
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
},
|
||||
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 587,
|
||||
"Host": "smtp-mail.outlook.com",
|
||||
"Imap": "imap-mail.outlook.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "donotreply@elevateimaging.ai",
|
||||
"FromName": "LiLi System",
|
||||
"AuthorizationCode": "Q#669869497420ul",
|
||||
|
||||
"PlatformName": "LiLi",
|
||||
"PlatformNameCN": "LiLi",
|
||||
"SystemShortName": "LiLi",
|
||||
"OrganizationName": "Elevate Imaging",
|
||||
"OrganizationNameCN": "Elevate Imaging",
|
||||
@@ -86,12 +99,19 @@
|
||||
"IsEnv_US": true,
|
||||
"IsOpenErrorNoticeEmail": false,
|
||||
"EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
||||
"CronEmailDefaultCulture": "en-US",
|
||||
"ErrorNoticeEmailList": [ "872297557@qq.com" ]
|
||||
},
|
||||
|
||||
"SystemPacsConfig": {
|
||||
"Port": "104",
|
||||
"IP": "3.226.182.187"
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
"RemoteNew": "Server=101.132.253.119,1435;Database=Uat_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true",
|
||||
"Hangfire": "Server=101.132.253.119,1435;Database=Uat_IRC_Hangfire;User ID=sa;Password=xc@123456;TrustServerCertificate=true"
|
||||
},
|
||||
"WeComNoticeConfig": {
|
||||
"IsOpenWeComNotice": true,
|
||||
"WebhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4355b98e-1e72-4678-8dfb-2fc6ad0bf449", //4355b98e-1e72-4678-8dfb-2fc6ad0bf449 //cdd97aab-d256-4f07-9145-a0a2b1555322
|
||||
"APINoticeUserList": [ "u", "wait..." ],
|
||||
"VueNoticeUserList": [ "wangxiaoshuang", "6b7717a31647293621697b96f74e6f3d" ]
|
||||
},
|
||||
"ObjectStoreService": {
|
||||
|
||||
"ObjectStoreUse": "AliyunOSS",
|
||||
@@ -54,7 +60,8 @@
|
||||
},
|
||||
|
||||
"BasicSystemConfig": {
|
||||
|
||||
// 启用质控风险控制功能
|
||||
"QCRiskControl": true,
|
||||
"OpenUserComplexPassword": true,
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
|
||||
@@ -72,20 +79,26 @@
|
||||
"IsNeedChangePassWord": true,
|
||||
"ChangePassWordDays": 90,
|
||||
// 模板类型 1 Elevate 2 Extensive
|
||||
"TemplateType": 2
|
||||
"TemplateType": 2,
|
||||
//MFA免验证发送天数
|
||||
"UserMFAVerifyMinutes": 1440
|
||||
|
||||
},
|
||||
"SystemEmailSendConfig": {
|
||||
"Port": 465,
|
||||
"Host": "smtp.qiye.aliyun.com",
|
||||
"Imap": "imap.qiye.aliyun.com",
|
||||
"ImapPort": 993,
|
||||
"FromEmail": "uat@extimaging.com",
|
||||
"FromName": "Uat IRC Imaging System",
|
||||
"AuthorizationCode": "SHzyyl2021",
|
||||
"SiteUrl": "http://irc.uat.extimaging.com/login",
|
||||
|
||||
"PlatformName": "EICS",
|
||||
"PlatformNameCN": "展影云平台",
|
||||
"SystemShortName": "IRC",
|
||||
"OrganizationName": "Extlmaging",
|
||||
"OrganizationNameCN": "Extlmaging",
|
||||
"OrganizationName": "ExtImaging",
|
||||
"OrganizationNameCN": "ExtImaging",
|
||||
"CompanyName": "Extensive Imaging",
|
||||
"CompanyNameCN": "上海展影医疗科技有限公司",
|
||||
"CompanyShortName": "Extensive Imaging",
|
||||
@@ -93,12 +106,20 @@
|
||||
"IsEnv_US": false,
|
||||
"IsOpenErrorNoticeEmail": false,
|
||||
"EmailRegexStr": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
||||
"CronEmailDefaultCulture": "zh-CN",
|
||||
"ErrorNoticeEmailList": [ "872297557@qq.com" ]
|
||||
},
|
||||
|
||||
"SystemPacsConfig": {
|
||||
"Port": "11113",
|
||||
"IP": "101.132.253.119"
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"SecurityKey": "ShangHaiZhanYing_SecurityKey_SHzyyl@2021",
|
||||
"Issuer": "Extimaging",
|
||||
"Audience": "EICS",
|
||||
"TokenExpireMinute": "10080"//7天
|
||||
"TokenExpireMinute": "10080" //7天
|
||||
},
|
||||
"IpRateLimiting": {
|
||||
"EnableEndpointRateLimiting": true,
|
||||
@@ -74,5 +74,12 @@
|
||||
"redirect_uri": "https://oauthlogin.net/oauth/githubcallback",
|
||||
"scope": "repo"
|
||||
}
|
||||
},
|
||||
"RequestDuplicationOptions": {
|
||||
"IsEnabled": true,
|
||||
"DuplicationWindowMs": 200,
|
||||
"CacheTimeSeconds": 5,
|
||||
"ExcludedPaths": [
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>%(DocumentTitle)</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
|
||||
@@ -505,8 +505,8 @@ var abp = abp || {};
|
||||
|
||||
//Inputs
|
||||
createInput(modalUxContent, 'tenancyName', 'Tenancy Name (Leave empty for Host)');
|
||||
createInput(modalUxContent, 'userName', 'Username or email address', 'text', 'cyldev');
|
||||
createInput(modalUxContent, 'password', 'Password', 'password', '123456');
|
||||
createInput(modalUxContent, 'userName', 'Username or email address', 'text', 'user1wj');
|
||||
createInput(modalUxContent, 'password', 'Password', 'password', '1');
|
||||
createInput(modalUxContent, 'pwdMd5', 'PwdMd5', 'text', '');
|
||||
createSelect(modalUxContent, 'roleSelect', 'role', [])
|
||||
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Helper.OtherTool;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Application.Filter;
|
||||
|
||||
|
||||
|
||||
public class ModelActionFilter(IStringLocalizer _localizer) : ActionFilterAttribute, IActionFilter
|
||||
public class ModelActionFilter(IStringLocalizer _localizer, IConfiguration _config, IUserInfo _userInfo) : ActionFilterAttribute, IActionFilter
|
||||
{
|
||||
|
||||
|
||||
@@ -23,8 +31,55 @@ public class ModelActionFilter(IStringLocalizer _localizer) : ActionFilterAttrib
|
||||
.Select(e => e.ErrorMessage)
|
||||
.ToArray();
|
||||
|
||||
var request = context.HttpContext.Request;
|
||||
|
||||
try
|
||||
{
|
||||
bool isOpenWeComNotice = _config.GetValue<bool>("WeComNoticeConfig:IsOpenWeComNotice");
|
||||
|
||||
if (isOpenWeComNotice)
|
||||
{
|
||||
string webhook = _config["WeComNoticeConfig:WebhookUrl"] ?? string.Empty;
|
||||
|
||||
var uri = new Uri(_config["SystemEmailSendConfig:SiteUrl"]);
|
||||
var baseUrl = uri.GetLeftPart(UriPartial.Authority);
|
||||
|
||||
var userList = _config.GetSection("WeComNoticeConfig:VueNoticeUserList").Get<string[]>();
|
||||
|
||||
var requestBody = context.HttpContext.Items["RequestBody"] as string;
|
||||
|
||||
|
||||
// 🔔 异步告警(不要阻塞请求)
|
||||
_ = WeComNotifier.SendAlertAsync(
|
||||
webhook: webhook,
|
||||
alert: new WeComAlert
|
||||
{
|
||||
Env = baseUrl,
|
||||
UserName = _userInfo.UserName.IsNotNullOrEmpty()? $"{_userInfo.UserName}({_userInfo.UserTypeShortName})": "匿名",
|
||||
Api = $"{request.Method} {request.Path}",
|
||||
Message = $"前端传递参数,后端模型验证失败\n 具体信息:{JsonConvert.SerializeObject(validationErrors)}",
|
||||
JsonData = requestBody,
|
||||
AtUsers = userList ?? []
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error($"模型验证过滤器里发送企业微信出现错误:{ex.Message}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---提供给接口的参数无效。
|
||||
context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["ModelAction_InvalidAPIParameter"] + JsonConvert.SerializeObject(validationErrors)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Application.Helper.OtherTool;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace IRaCIS.Core.Application.Filter;
|
||||
|
||||
public class ProjectExceptionFilter(ILogger<ProjectExceptionFilter> _logger, IStringLocalizer _localizer) : Attribute, IExceptionFilter
|
||||
public class ProjectExceptionFilter(ILogger<ProjectExceptionFilter> _logger, IStringLocalizer _localizer, IConfiguration _config, IUserInfo _userInfo) : Attribute, IExceptionFilter
|
||||
{
|
||||
|
||||
public void OnException(ExceptionContext context)
|
||||
@@ -46,7 +49,44 @@ public class ProjectExceptionFilter(ILogger<ProjectExceptionFilter> _logger, ISt
|
||||
else
|
||||
{
|
||||
context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["Project_ExceptionContactDeveloper"] + (exception.InnerException is null ? (exception.Message)
|
||||
: (exception.InnerException?.Message )), ApiResponseCodeEnum.ProgramException));
|
||||
: (exception.Message + "Inner ExceptionMsg:" + exception.InnerException?.Message)), ApiResponseCodeEnum.ProgramException));
|
||||
|
||||
try
|
||||
{
|
||||
bool isOpenWeComNotice = _config.GetValue<bool>("WeComNoticeConfig:IsOpenWeComNotice");
|
||||
|
||||
if (isOpenWeComNotice)
|
||||
{
|
||||
string webhook = _config["WeComNoticeConfig:WebhookUrl"] ?? string.Empty;
|
||||
|
||||
var uri = new Uri(_config["SystemEmailSendConfig:SiteUrl"]);
|
||||
var baseUrl = uri.GetLeftPart(UriPartial.Authority);
|
||||
|
||||
var userList = _config.GetSection("WeComNoticeConfig:APINoticeUserList").Get<string[]>();
|
||||
|
||||
var requestBody = context.HttpContext.Items["RequestBody"] as string;
|
||||
|
||||
var alert = new WeComAlert
|
||||
{
|
||||
Env = baseUrl,
|
||||
UserName = $"{_userInfo.UserName}({_userInfo.UserTypeShortName})",
|
||||
Api = context.HttpContext.Request.Path,
|
||||
Message = exception.Message,
|
||||
JsonData = requestBody,
|
||||
Stack = exception.StackTrace,
|
||||
AtUsers = userList ?? []
|
||||
};
|
||||
|
||||
_ = WeComNotifier.SendAlertAsync(webhook, alert);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
_logger.LogError($"异常过滤器里发送企业微信出现错误:{ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +98,7 @@ public class ProjectExceptionFilter(ILogger<ProjectExceptionFilter> _logger, ISt
|
||||
|
||||
_logger.LogError(errorInfo);
|
||||
|
||||
|
||||
//_logger.LogError(exception, exception.Message);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.BusinessFilter.LegacyController
|
||||
{
|
||||
using Database.Api;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using IRaCIS.Core.Application.Service.Common;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.AspNetCore.Components.Endpoints;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Minio.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Database.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求拦截 请求前后的操作
|
||||
/// </summary>
|
||||
/// <param name="logger">logger</param>
|
||||
/// <param name="accessor">loggerHelper</param>
|
||||
public class RequestDuplicationFilter(ILogger<RequestDuplicationFilter> logger, IHttpContextAccessor accessor, IUserInfo _userInfo, IStringLocalizer _localizer, IOptionsMonitor<RequestDuplicationOptions> RequestDuplicationOptionsMonitor) : ExceptionFilterAttribute, IAsyncActionFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// 传入的参数
|
||||
/// </summary>
|
||||
public string Intoparam { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 这个是正常记录(请求刚进入的时候)
|
||||
/// </summary>
|
||||
/// <param name="context">context</param>
|
||||
/// <param name="next">next</param>
|
||||
/// <returns>返回的对象</returns>
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
if (RequestDuplicationOptionsMonitor.CurrentValue.IsEnabled)
|
||||
{
|
||||
Dictionary<string, object?> dic = new Dictionary<string, object?>();
|
||||
var desc = context.ActionDescriptor as ControllerActionDescriptor;
|
||||
foreach (var p in desc.Parameters)
|
||||
{
|
||||
// 关键判断:绑定源是否是 Services
|
||||
if (p.BindingInfo?.BindingSource == BindingSource.Services) continue;
|
||||
// 普通参数,取值
|
||||
if (context.ActionArguments.TryGetValue(p.Name, out var value) && value != null)
|
||||
{
|
||||
dic.Add(p.Name, value);
|
||||
}
|
||||
}
|
||||
|
||||
this.Intoparam = JsonConvert.SerializeObject(dic);
|
||||
try
|
||||
{
|
||||
this.RequestDuplication();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var resultContext = await next();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void RequestDuplication()
|
||||
{
|
||||
var requestPath = accessor?.HttpContext?.Request?.Path.ToString() ?? string.Empty;
|
||||
|
||||
// 验证请求频繁情况
|
||||
if (
|
||||
!requestPath
|
||||
.Split("/", StringSplitOptions.RemoveEmptyEntries)
|
||||
.Any(segment => segment.StartsWith("get", StringComparison.OrdinalIgnoreCase)) &&
|
||||
_userInfo.UserRoleId != default(Guid)&&
|
||||
RequestDuplicationOptionsMonitor.CurrentValue.IsEnabled &&
|
||||
!RequestDuplicationOptionsMonitor.CurrentValue.ExcludePaths.Contains(requestPath))
|
||||
{
|
||||
RequestInfo requestInfo = new RequestInfo
|
||||
{
|
||||
UserRoleId = _userInfo.UserRoleId,
|
||||
RequestPath = requestPath,
|
||||
ParameterHash = GenerateParameterHash(this.Intoparam),
|
||||
RequestTime = DateTime.Now
|
||||
};
|
||||
|
||||
IRCSystemInfo.RequestRecordList= IRCSystemInfo.RequestRecordList.Where(x => x.RequestTime >= DateTime.Now.AddSeconds(-RequestDuplicationOptionsMonitor.CurrentValue.CacheTimeSeconds)).ToList();
|
||||
|
||||
|
||||
var requestsTimes = IRCSystemInfo.RequestRecordList.Any(x=>
|
||||
x.RequestTime>= requestInfo.RequestTime.AddMilliseconds(-RequestDuplicationOptionsMonitor.CurrentValue.DuplicationWindowMs)&&
|
||||
x.RequestKey== requestInfo.RequestKey);
|
||||
if (requestsTimes)
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["RequestDuplicationFilter_RequestDuplication"], ApiResponseCodeEnum.BusinessValidationFailed);
|
||||
}
|
||||
IRCSystemInfo.RequestRecordList.Add(requestInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public string GenerateParameterHash(string parameters)
|
||||
{
|
||||
if (string.IsNullOrEmpty(parameters))
|
||||
return string.Empty;
|
||||
|
||||
using var sha256 = SHA256.Create();
|
||||
var hashBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(parameters));
|
||||
return Convert.ToBase64String(hashBytes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace IRaCIS.Core.Domain.Share;
|
||||
[Description("多环境 配置环境实体")]
|
||||
public class ServiceVerifyConfigOption
|
||||
{
|
||||
public bool QCRiskControl { get; set; }
|
||||
public bool OpenUserComplexPassword { get; set; }
|
||||
|
||||
public bool OpenSignDocumentBeforeWork { get; set; }
|
||||
@@ -38,6 +39,8 @@ public class ServiceVerifyConfigOption
|
||||
|
||||
public string ThirdPdfUrl { get; set; }
|
||||
|
||||
public int UserMFAVerifyMinutes { get; set; } = 1440;
|
||||
|
||||
}
|
||||
|
||||
public class SystemEmailSendConfig
|
||||
@@ -45,6 +48,10 @@ public class SystemEmailSendConfig
|
||||
public int Port { get; set; }
|
||||
|
||||
public string Host { get; set; } = string.Empty;
|
||||
|
||||
public string Imap { get; set; } = string.Empty;
|
||||
|
||||
public int ImapPort { get; set; }
|
||||
public string FromEmail { get; set; } = string.Empty;
|
||||
|
||||
public string FromName { get; set; } = string.Empty;
|
||||
@@ -53,7 +60,11 @@ public class SystemEmailSendConfig
|
||||
|
||||
public string SiteUrl { get; set; } = string.Empty;
|
||||
|
||||
public string SystemShortName { get; set; } = string.Empty;
|
||||
|
||||
public string PlatformName { get; set; } = string.Empty;
|
||||
public string PlatformNameCN { get; set; } = string.Empty;
|
||||
|
||||
public string SystemShortName { get; set; } = string.Empty;
|
||||
|
||||
public string OrganizationName { get; set; } = string.Empty;
|
||||
public string OrganizationNameCN { get; set; } = string.Empty;
|
||||
@@ -72,12 +83,12 @@ public class SystemEmailSendConfig
|
||||
|
||||
public string EmailRegexStr { get; set; }
|
||||
|
||||
public List<string> ErrorNoticeEmailList { get; set; } =new List<string>();
|
||||
public List<string> ErrorNoticeEmailList { get; set; } = new List<string>();
|
||||
}
|
||||
|
||||
public class SystemEmailSendConfigView
|
||||
{
|
||||
public string SystemShortName { get; set; } = string.Empty;
|
||||
public string SystemShortName { get; set; } = string.Empty;
|
||||
public string CompanyName { get; set; } = string.Empty;
|
||||
|
||||
public string CompanyNameCN { get; set; } = string.Empty;
|
||||
@@ -105,6 +116,54 @@ public class IRCEncreptOption
|
||||
public List<string> ApiPathList { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求缓存配置
|
||||
/// </summary>
|
||||
public class RequestDuplicationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存时间(秒),默认5秒
|
||||
/// </summary>
|
||||
public int CacheTimeSeconds { get; set; } = 5;
|
||||
|
||||
/// <summary>
|
||||
/// 重复请求检测时间窗口(毫秒),默认500毫秒
|
||||
/// </summary>
|
||||
public int DuplicationWindowMs { get; set; } = 500;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用防重复请求
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 需要排除的路径(不进行重复检测)
|
||||
/// </summary>
|
||||
public List<string> ExcludePaths { get; set; } = new List<string>();
|
||||
}
|
||||
|
||||
public static class IRCSystemInfo
|
||||
{
|
||||
public static List<RequestInfo> RequestRecordList { get; set; } = new List<RequestInfo>();
|
||||
}
|
||||
|
||||
public class RequestInfo
|
||||
{
|
||||
public Guid UserRoleId { get; set; }
|
||||
|
||||
public string RequestPath { get; set; } = string.Empty;
|
||||
|
||||
public string ParameterHash { get; set; } = string.Empty;
|
||||
|
||||
public DateTime RequestTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 请求的唯一标识
|
||||
/// </summary>
|
||||
public string RequestKey => $"{UserRoleId}_{RequestPath}_{ParameterHash}";
|
||||
}
|
||||
|
||||
public class IRaCISBasicConfigOption
|
||||
{
|
||||
public string DoctorCodePrefix { get; set; }
|
||||
|
||||
@@ -61,6 +61,11 @@ public static class CacheKeys
|
||||
/// <returns></returns>
|
||||
public static string StartRestTime(Guid userId) => $"{userId}StartRestTime";
|
||||
|
||||
//每个用户 每个浏览器独立时间
|
||||
public static string UserMFAVerifyPass(Guid userId,string browserFingerprint) => $"UserMFAVerifyPass:{userId}:{browserFingerprint}";
|
||||
|
||||
public static string UserMFATag(Guid userId) => $"UserMFAVerifyPass:{userId}";
|
||||
|
||||
}
|
||||
|
||||
public static class CacheHelper
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using FellowOakDicom;
|
||||
using DocumentFormat.OpenXml.Office.CustomUI;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom.Media;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -57,6 +58,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||
var mappings = new List<string>();
|
||||
int index = 1;
|
||||
|
||||
var studyUid=list.FirstOrDefault()?.StudyInstanceUid;
|
||||
|
||||
var dicomDir = new DicomDirectory();
|
||||
|
||||
@@ -100,11 +102,11 @@ namespace IRaCIS.Core.Application.Helper
|
||||
var dicomFile = new DicomFile(dataset);
|
||||
|
||||
// 文件名递增格式:IM_00001, IM_00002, ...
|
||||
string filename = $@"IMAGE/IM_{index:D5}"; // :D5 表示补足5位
|
||||
string filename = $@"IMAGE\IM_{index:D5}"; // :D5 表示补足5位
|
||||
|
||||
mappings.Add($"{filename} => {item.InstanceId}");
|
||||
|
||||
dic.Add(item.InstanceId.ToString(), Path.GetFileName(filename));
|
||||
dic.Add(item.InstanceId.ToString(), filename.TrimEnd('/', '\\').Split('/', '\\').Last());
|
||||
|
||||
dicomDir.AddFile(dicomFile, filename);
|
||||
|
||||
@@ -128,7 +130,9 @@ namespace IRaCIS.Core.Application.Helper
|
||||
// 重置流位置
|
||||
memoryStream.Position = 0;
|
||||
|
||||
await _oSSService.UploadToOSSAsync(memoryStream, ossFolder, "DICOMDIR", false);
|
||||
var relativePath= await _oSSService.UploadToOSSAsync(memoryStream, ossFolder, "DICOMDIR", true);
|
||||
|
||||
dic.Add($"{studyUid}_DICOMDIR" , relativePath.Split('/').Last());
|
||||
}
|
||||
|
||||
//清理临时文件
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MailKit;
|
||||
using MailKit.Security;
|
||||
using MimeKit;
|
||||
using Org.BouncyCastle.Tls;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper;
|
||||
@@ -9,12 +10,15 @@ namespace IRaCIS.Core.Application.Helper;
|
||||
public static class SendEmailHelper
|
||||
{
|
||||
|
||||
public static async Task SendEmailAsync(MimeMessage messageToSend, SystemEmailSendConfig _systemEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||
public static async Task<string> SendEmailAsync(MimeMessage messageToSend, SystemEmailSendConfig _systemEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||
{
|
||||
string result = string.Empty;
|
||||
result = messageToSend.MessageId;
|
||||
|
||||
//没有收件人 那么不发送
|
||||
if (messageToSend.To.Count == 0)
|
||||
{
|
||||
return;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
try
|
||||
@@ -42,6 +46,7 @@ public static class SendEmailHelper
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -51,7 +56,76 @@ public static class SendEmailHelper
|
||||
throw new Exception(I18n.T("SendEmail_SendFail"), new Exception(ex.Message));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static async Task<string> SendEmailAsync(MimeMessage messageToSend, Trial trial, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||
{
|
||||
|
||||
// 项目的需要重设 发件地址与邮件地址
|
||||
var fromAddress = messageToSend.From.Mailboxes.FirstOrDefault();
|
||||
if (fromAddress != null)
|
||||
{
|
||||
messageToSend.From.Clear();
|
||||
messageToSend.From.Add(new MailboxAddress(trial.EmailFromName, trial.EmailFromEmail));
|
||||
}
|
||||
|
||||
|
||||
string result = string.Empty;
|
||||
result = messageToSend.MessageId;
|
||||
|
||||
//没有收件人 那么不发送
|
||||
if (messageToSend.To.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
if (messageSentSuccess != null)
|
||||
{
|
||||
smtp.MessageSent += messageSentSuccess;
|
||||
}
|
||||
|
||||
|
||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
|
||||
//await smtp.ConnectAsync("smtp.qq.com", 465, SecureSocketOptions.SslOnConnect);
|
||||
|
||||
//await smtp.AuthenticateAsync("zhou941003@qq.com", "sqfhlpfdvnexbcab");
|
||||
|
||||
|
||||
//await smtp.ConnectAsync(_systemEmailConfig.Host, _systemEmailConfig.Port, SecureSocketOptions.Auto);
|
||||
|
||||
//await smtp.AuthenticateAsync(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode);
|
||||
|
||||
|
||||
await smtp.ConnectAsync(trial.EmailSMTPServerAddress, trial.EmailSMTPServerPort, SecureSocketOptions.Auto);
|
||||
|
||||
await smtp.AuthenticateAsync(trial.EmailFromEmail, trial.EmailAuthorizationCode);
|
||||
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
//---邮件发送失败,您进行的操作未能成功,请检查邮箱或联系维护人员
|
||||
throw new Exception(I18n.T("SendEmail_SendFail"), new Exception(ex.Message));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<bool> TestEmailConfigAsync(SystemEmailSendConfig _systemEmailConfig)
|
||||
@@ -73,7 +147,7 @@ public static class SendEmailHelper
|
||||
return true;
|
||||
}
|
||||
|
||||
public static async Task SendEmailAsync(SMTPEmailConfig sMTPEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||
public static async Task SendEmailAsync(SMTPEmailConfig sMTPEmailConfig,Trial? trial, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||
{
|
||||
var messageToSend = new MimeMessage();
|
||||
|
||||
@@ -143,7 +217,7 @@ public static class SendEmailHelper
|
||||
|
||||
await smtp.ConnectAsync(sMTPEmailConfig.Host, sMTPEmailConfig.Port, SecureSocketOptions.Auto);
|
||||
|
||||
await smtp.AuthenticateAsync(sMTPEmailConfig.UserName, sMTPEmailConfig.AuthorizationCode);
|
||||
await smtp.AuthenticateAsync(trial.EmailFromEmail, trial.EmailAuthorizationCode);
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using SharpCompress.Common;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using Xceed.Document.NET;
|
||||
@@ -699,7 +700,7 @@ public static class ExcelExportHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
enumValues = JsonConvert.DeserializeObject<int[]>(itemValue)?? new int[0];
|
||||
enumValues = JsonConvert.DeserializeObject<int[]>(itemValue) ?? new int[0];
|
||||
|
||||
}
|
||||
|
||||
@@ -709,7 +710,7 @@ public static class ExcelExportHelper
|
||||
enumValues.Select(code =>
|
||||
dynamicTranslateDataList[itemDicName]
|
||||
.FirstOrDefault(t =>
|
||||
string.Equals(code.ToString(),t.Code, StringComparison.OrdinalIgnoreCase)
|
||||
string.Equals(code.ToString(), t.Code, StringComparison.OrdinalIgnoreCase)
|
||||
) is var r && r != null
|
||||
? (isEn_US ? r.Value : r.ValueCN)
|
||||
: string.Empty
|
||||
@@ -718,7 +719,7 @@ public static class ExcelExportHelper
|
||||
else
|
||||
{
|
||||
|
||||
translatedItemData = dynamicTranslateDataList[itemDicName].Where(t => t.Code.ToLower() == itemValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||
translatedItemData = dynamicTranslateDataList[itemDicName].Where(t => t.Code.ToLower() == itemValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||
|
||||
}
|
||||
|
||||
@@ -727,7 +728,19 @@ public static class ExcelExportHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
row.GetCell(writeIndex).SetCellValue(itemValue);
|
||||
var unit = iteObjDic.ContainsKey("Unit") ? iteObjDic["Unit"]?.ToString() : null;
|
||||
|
||||
if (unit.IsNotNullOrEmpty() && unit == "9")
|
||||
{
|
||||
row.GetCell(writeIndex).SetCellValue(itemValue + "%");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
row.GetCell(writeIndex).SetCellValue(itemValue);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -858,17 +871,16 @@ public static class ExcelExportHelper
|
||||
//模板路径
|
||||
var tplPath = physicalPath;
|
||||
|
||||
#region 根据中英文 删除模板sheet
|
||||
|
||||
// 打开模板文件
|
||||
var templateFile = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
||||
|
||||
// 获取文件流
|
||||
var templateStream = new MemoryStream();
|
||||
templateFile.CopyTo(templateStream);
|
||||
templateStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
var workbook = new XSSFWorkbook(templateStream);
|
||||
#region 根据中英文 删除模板sheet
|
||||
|
||||
// 打开模板文件
|
||||
var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
||||
|
||||
var workbook = new XSSFWorkbook(templateFileStream);
|
||||
|
||||
int sheetCount = workbook.NumberOfSheets;
|
||||
|
||||
@@ -973,14 +985,8 @@ public static class ExcelExportHelper
|
||||
}
|
||||
}
|
||||
|
||||
using (var memoryStream2 = new MemoryStream())
|
||||
{
|
||||
workbook.Write(memoryStream2, true);
|
||||
|
||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
templateStream = memoryStream2;
|
||||
}
|
||||
workbook.Write(templateStream, leaveOpen: true);
|
||||
templateStream.Position = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -1078,6 +1084,91 @@ public static class ExcelExportHelper
|
||||
|
||||
|
||||
|
||||
public static async Task<IActionResult> MutiSheetDataExportAsync(string code, object data, string exportFileNamePrefix, IRepository<CommonDocument> _commonDocumentRepository, IWebHostEnvironment _hostEnvironment)
|
||||
{
|
||||
|
||||
var (physicalPath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code);
|
||||
|
||||
|
||||
//模板路径
|
||||
var tplPath = physicalPath;
|
||||
|
||||
var templateStream = new MemoryStream();
|
||||
|
||||
|
||||
#region npoi 移除某一行
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
|
||||
if (isEn_US)
|
||||
{
|
||||
// 打开模板文件
|
||||
using var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
||||
|
||||
using var workbook = new XSSFWorkbook(templateFileStream);
|
||||
|
||||
int sheetCount = workbook.NumberOfSheets;
|
||||
|
||||
int removeRowIndex = 1; // 要删除的行(0-based)
|
||||
|
||||
for (int i = 0; i < sheetCount; i++)
|
||||
{
|
||||
var sheet = workbook.GetSheetAt(i);
|
||||
|
||||
// 2️ 删除行
|
||||
var row = sheet.GetRow(removeRowIndex);
|
||||
if (row != null)
|
||||
{
|
||||
sheet.RemoveRow(row);
|
||||
}
|
||||
|
||||
// 3️ 上移后续行
|
||||
if (removeRowIndex < sheet.LastRowNum)
|
||||
{
|
||||
sheet.ShiftRows(
|
||||
removeRowIndex + 1,
|
||||
sheet.LastRowNum,
|
||||
-1,
|
||||
true, // copyRowHeight
|
||||
false // resetOriginalRowHeight
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
workbook.Write(templateStream, leaveOpen: true);
|
||||
templateStream.Position = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var fs = new FileStream(tplPath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
fs.CopyTo(templateStream);
|
||||
}
|
||||
|
||||
templateStream.Position = 0;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
|
||||
var config = new OpenXmlConfiguration()
|
||||
{
|
||||
IgnoreTemplateParameterMissing = true,
|
||||
};
|
||||
|
||||
await MiniExcel.SaveAsByTemplateAsync(memoryStream, templateStream.ToArray(), data, config);
|
||||
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
|
||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
FileDownloadName = $"{(string.IsNullOrEmpty(exportFileNamePrefix) ? "" : exportFileNamePrefix + "_")}{Path.GetFileNameWithoutExtension(fileName)}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出文件模板
|
||||
/// </summary>
|
||||
@@ -1159,4 +1250,7 @@ public static class ExcelExportHelper
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MassTransit.Mediator;
|
||||
using System.Globalization;
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper
|
||||
{
|
||||
@@ -57,25 +58,29 @@ namespace IRaCIS.Core.Application.Helper
|
||||
}
|
||||
|
||||
|
||||
public static void AddOrUpdateTrialCronJob(string jobId, Guid trialId, EmailBusinessScenario businessScenario, string emailCron)
|
||||
public static void AddOrUpdateTrialCronJob(string jobId, Guid trialId, EmailBusinessScenario businessScenario, string emailCron,string defaultCulture="")
|
||||
{
|
||||
if (defaultCulture == "")
|
||||
{
|
||||
defaultCulture = CultureInfo.CurrentCulture.Name;
|
||||
}
|
||||
|
||||
switch (businessScenario)
|
||||
{
|
||||
|
||||
case EmailBusinessScenario.QCTask:
|
||||
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new ImageQCRecurringEvent() { TrialId = trialId }, default), emailCron);
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new ImageQCRecurringEvent() { TrialId = trialId,CultureInfoName= defaultCulture }, default), emailCron);
|
||||
break;
|
||||
case EmailBusinessScenario.CRCToQCQuestion:
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new CRCImageQuestionRecurringEvent() { TrialId = trialId }, default), emailCron);
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new CRCImageQuestionRecurringEvent() { TrialId = trialId, CultureInfoName = defaultCulture }, default), emailCron);
|
||||
break;
|
||||
case EmailBusinessScenario.QCToCRCImageQuestion:
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new QCImageQuestionRecurringEvent() { TrialId = trialId }, default), emailCron);
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new QCImageQuestionRecurringEvent() { TrialId = trialId, CultureInfoName = defaultCulture }, default), emailCron);
|
||||
break;
|
||||
//加急阅片 10分钟
|
||||
case EmailBusinessScenario.ExpeditedReading:
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new UrgentIRUnReadTaskRecurringEvent() { TrialId = trialId }, default), emailCron);
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new UrgentIRUnReadTaskRecurringEvent() { TrialId = trialId, CultureInfoName = defaultCulture }, default), emailCron);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -83,20 +88,25 @@ namespace IRaCIS.Core.Application.Helper
|
||||
|
||||
}
|
||||
|
||||
public static void AddOrUpdateTimingCronJob(string jobId, EmailBusinessScenario businessScenario, string emailCron)
|
||||
public static void AddOrUpdateTimingCronJob(string jobId, EmailBusinessScenario businessScenario, string emailCron, string defaultCulture="")
|
||||
{
|
||||
if (defaultCulture == "")
|
||||
{
|
||||
defaultCulture = CultureInfo.CurrentCulture.Name;
|
||||
}
|
||||
|
||||
switch (businessScenario)
|
||||
{
|
||||
|
||||
case EmailBusinessScenario.GeneralTraining_ExpirationNotification:
|
||||
|
||||
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new SystemDocumentErverDayEvent() { }, default), emailCron);
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new SystemDocumentErverDayEvent() { CultureInfoName = defaultCulture }, default), emailCron);
|
||||
break;
|
||||
case EmailBusinessScenario.TrialTraining_ExpirationNotification:
|
||||
|
||||
Console.WriteLine("更新项目到期job");
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new TrialDocumentErverDayEvent() { }, default), emailCron);
|
||||
HangfireJobHelper.AddOrUpdateCronJob<IMediator>(jobId, t => t.Send(new TrialDocumentErverDayEvent() { CultureInfoName = defaultCulture }, default), emailCron);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -16,6 +16,7 @@ using Minio;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.Exceptions;
|
||||
using System.IO;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Web;
|
||||
@@ -142,8 +143,12 @@ public enum ObjectStoreUse
|
||||
|
||||
public interface IOSSService
|
||||
{
|
||||
public Task SetImmediateArchiveRule(string prefix, string ruleId = "immediate-archive", bool isDelete = false);
|
||||
public Task RestoreFilesByPrefixAsync(string prefix, int restoreDays = 3, int batchSize = 100);
|
||||
|
||||
|
||||
public Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true);
|
||||
public Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true);
|
||||
public Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false);
|
||||
|
||||
public Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath);
|
||||
|
||||
@@ -155,7 +160,7 @@ public interface IOSSService
|
||||
|
||||
public Task DeleteFromPrefix(string prefix, bool isCache = false);
|
||||
|
||||
public Task DeleteObjects(List<string> objectKeys);
|
||||
public Task DeleteObjects(List<string> objectKeys, bool isCache = false);
|
||||
|
||||
List<string> GetRootFolderNames();
|
||||
|
||||
@@ -182,7 +187,518 @@ public class OSSService : IOSSService
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将指定前缀下的所有现有文件立即转为目标存储类型
|
||||
/// </summary>
|
||||
/// <param name="prefix">要转换的文件前缀,如 "project-a/logs/"</param>
|
||||
/// <param name="ruleId">规则ID,默认为"immediate-archive"</param>
|
||||
/// <param name="isDelete">默认是添加/更新 </param>
|
||||
public async Task SetImmediateArchiveRule(string prefix, string ruleId = "immediate-archive", bool isDelete = false)
|
||||
{
|
||||
|
||||
BackBatchGetToken();
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
{
|
||||
|
||||
|
||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||
|
||||
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
|
||||
|
||||
try
|
||||
{
|
||||
// 1. 先获取现有的所有生命周期规则(避免覆盖)
|
||||
var existingRules = new List<Aliyun.OSS.LifecycleRule>();
|
||||
try
|
||||
{
|
||||
var existingRuleList = _ossClient.GetBucketLifecycle(aliConfig.BucketName);
|
||||
if (existingRuleList != null)
|
||||
{
|
||||
existingRules.AddRange(existingRuleList);
|
||||
Console.WriteLine($"找到 {existingRules.Count} 条现有规则");
|
||||
}
|
||||
}
|
||||
catch (OssException ex) when (ex.ErrorCode == "NoSuchLifecycle")
|
||||
{
|
||||
// 如果没有生命周期规则,继续创建新规则
|
||||
Console.WriteLine("当前Bucket无生命周期规则,将创建新规则");
|
||||
}
|
||||
|
||||
// 2. 创建立即生效的转换规则
|
||||
|
||||
ruleId = $"{ruleId}_{prefix}";
|
||||
var immediateRule = new Aliyun.OSS.LifecycleRule
|
||||
{
|
||||
ID = ruleId,
|
||||
Prefix = prefix,
|
||||
Status = RuleStatus.Enabled,
|
||||
Transitions = new Aliyun.OSS.LifecycleRule.LifeCycleTransition[]
|
||||
{
|
||||
new Aliyun.OSS.LifecycleRule.LifeCycleTransition
|
||||
{
|
||||
|
||||
LifeCycleExpiration =
|
||||
{
|
||||
Days = 1
|
||||
},
|
||||
StorageClass = StorageClass.IA
|
||||
},
|
||||
new Aliyun.OSS.LifecycleRule.LifeCycleTransition
|
||||
{
|
||||
|
||||
LifeCycleExpiration =
|
||||
{
|
||||
Days = 30 //最后一次修改时间
|
||||
},
|
||||
StorageClass = StorageClass.Archive
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// 3. 移除同名的旧规则(如果存在)
|
||||
existingRules.RemoveAll(r => r.ID == ruleId);
|
||||
|
||||
// 4. 添加新规则到规则列表
|
||||
if (isDelete == false)
|
||||
{
|
||||
existingRules.Add(immediateRule);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var request = new SetBucketLifecycleRequest(aliConfig.BucketName)
|
||||
{
|
||||
LifecycleRules = existingRules
|
||||
};
|
||||
|
||||
|
||||
_ossClient.SetBucketLifecycle(request);
|
||||
|
||||
|
||||
}
|
||||
catch (OssException ex)
|
||||
{
|
||||
Log.Logger.Error($"❌ 设置失败 [错误码: {ex.ErrorCode}] 详细: {ex.Message}");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error($"❌ 发生未知错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||
|
||||
var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
|
||||
|
||||
|
||||
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
|
||||
// 1. 获取现有的生命周期配置(避免覆盖)
|
||||
LifecycleConfiguration existingConfig = null;
|
||||
|
||||
var getRequest = new GetLifecycleConfigurationRequest { BucketName = awsConfig.BucketName };
|
||||
var response = await amazonS3Client.GetLifecycleConfigurationAsync(getRequest);
|
||||
existingConfig = response.Configuration;
|
||||
Console.WriteLine($"找到 {existingConfig?.Rules?.Count ?? 0} 条现有规则");
|
||||
|
||||
// 2. 生成唯一的规则ID
|
||||
ruleId = $"{ruleId}_{prefix.Replace('/', '_').Trim('_')}";
|
||||
|
||||
// 3. 创建新的生命周期规则
|
||||
var immediateRule = new Amazon.S3.Model.LifecycleRule
|
||||
{
|
||||
Id = ruleId,
|
||||
Filter = new LifecycleFilter
|
||||
{
|
||||
// 使用前缀筛选对象
|
||||
LifecycleFilterPredicate = new LifecyclePrefixPredicate { Prefix = prefix }
|
||||
},
|
||||
Status = LifecycleRuleStatus.Enabled,
|
||||
// 定义多个转换阶段
|
||||
Transitions = new List<LifecycleTransition>
|
||||
{
|
||||
// 1天后转为低频访问 (Standard-IA)
|
||||
//new LifecycleTransition
|
||||
//{
|
||||
// Days = 1, //Days' in Transition action must be greater than or equal to 30 for storageClass 'STANDARD_IA'"
|
||||
// StorageClass = S3StorageClass.StandardInfrequentAccess // 对应S3 Standard-IA
|
||||
//},
|
||||
// 30天后转为归档 (Glacier Instant Retrieval)
|
||||
new LifecycleTransition
|
||||
{
|
||||
Days = 30, //创建时间
|
||||
StorageClass = S3StorageClass.GlacierInstantRetrieval // 对应归档(即时检索)
|
||||
}
|
||||
// 如果需要更深的归档,可以继续添加:
|
||||
// new LifecycleTransition { Days = 90, StorageClass = S3StorageClass.GlacierFlexibleRetrieval },
|
||||
// new LifecycleTransition { Days = 180, StorageClass = S3StorageClass.DeepArchive }
|
||||
}
|
||||
// 注意:S3的生命周期规则不支持设置“立即生效(Days=0)”。
|
||||
// 如果要对存量文件立即生效,需要配合其他方法(如批量修改存储类型)。
|
||||
};
|
||||
|
||||
// 4. 更新规则列表(移除同名旧规则,添加新规则)
|
||||
var existingRules = existingConfig.Rules ?? new List<Amazon.S3.Model.LifecycleRule>();
|
||||
existingRules.RemoveAll(r => r.Id == ruleId);
|
||||
|
||||
if (isDelete == false)
|
||||
{
|
||||
existingRules.Add(immediateRule);
|
||||
|
||||
}
|
||||
|
||||
// 5. 提交新的生命周期配置
|
||||
var putRequest = new PutLifecycleConfigurationRequest
|
||||
{
|
||||
BucketName = awsConfig.BucketName,
|
||||
Configuration = new LifecycleConfiguration { Rules = existingRules }
|
||||
};
|
||||
|
||||
await amazonS3Client.PutLifecycleConfigurationAsync(putRequest);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
}
|
||||
|
||||
/// 解冻指定前缀下的所有归档/冷归档文件
|
||||
/// </summary>
|
||||
/// <param name="prefix">要解冻的文件前缀</param>
|
||||
/// <param name="restoreDays">解冻后文件保持可读的天数(默认3天)</param>
|
||||
/// <param name="restoreTier">解冻优先级(仅AWS有效)</param>
|
||||
/// <param name="batchSize">批量处理大小(默认100)</param>
|
||||
public async Task RestoreFilesByPrefixAsync(string prefix, int restoreDays = 3, int batchSize = 100)
|
||||
{
|
||||
BackBatchGetToken();
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
{
|
||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||
var client = new OssClient(
|
||||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint,
|
||||
AliyunOSSTempToken.AccessKeyId,
|
||||
AliyunOSSTempToken.AccessKeySecret,
|
||||
AliyunOSSTempToken.SecurityToken
|
||||
);
|
||||
|
||||
var bucketName = aliConfig.BucketName;
|
||||
int totalRestored = 0;
|
||||
int totalSkipped = 0;
|
||||
int totalFailed = 0;
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"开始解冻阿里云OSS文件,前缀: {prefix}");
|
||||
|
||||
var allObjects = new List<OssObjectSummary>();
|
||||
|
||||
// 1. 分页列举文件
|
||||
string nextMarker = null;
|
||||
ObjectListing result = null;
|
||||
|
||||
do
|
||||
{
|
||||
var listRequest = new Aliyun.OSS.ListObjectsRequest(bucketName)
|
||||
{
|
||||
Prefix = prefix,
|
||||
Marker = nextMarker,
|
||||
MaxKeys = batchSize
|
||||
};
|
||||
|
||||
result = client.ListObjects(listRequest);
|
||||
|
||||
allObjects.AddRange(result.ObjectSummaries);
|
||||
|
||||
|
||||
|
||||
nextMarker = result.NextMarker;
|
||||
|
||||
} while (result.IsTruncated);
|
||||
|
||||
// 2️⃣ 并行解冻(控制并发)
|
||||
Parallel.ForEach(
|
||||
allObjects,
|
||||
new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 5 // ⭐ 推荐 5~10
|
||||
},
|
||||
obj =>
|
||||
{
|
||||
// 只处理归档
|
||||
if (obj.StorageClass != StorageClass.Archive.ToString())
|
||||
{
|
||||
Interlocked.Increment(ref totalSkipped);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var restoreRequest = new Aliyun.OSS.RestoreObjectRequest(bucketName, obj.Key)
|
||||
{
|
||||
Days = restoreDays
|
||||
};
|
||||
|
||||
client.RestoreObject(restoreRequest);
|
||||
|
||||
Interlocked.Increment(ref totalRestored);
|
||||
Console.WriteLine($"✅ 提交解冻: {obj.Key}");
|
||||
}
|
||||
catch (OssException ex) when (ex.ErrorCode == "RestoreAlreadyInProgress")
|
||||
{
|
||||
// 已在解冻中,算成功
|
||||
Interlocked.Increment(ref totalSkipped);
|
||||
Console.WriteLine($"⚠️ 已在解冻中: {obj.Key}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Interlocked.Increment(ref totalFailed);
|
||||
Console.WriteLine($"❌ 解冻失败: {obj.Key} - {ex.Message}");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 3. 输出统计结果
|
||||
Console.WriteLine("\n================ 解冻完成 ================");
|
||||
Console.WriteLine($"总计处理: {totalRestored + totalSkipped + totalFailed} 个文件");
|
||||
Console.WriteLine($"成功解冻: {totalRestored} 个");
|
||||
Console.WriteLine($"跳过文件: {totalSkipped} 个 (非归档类型)");
|
||||
Console.WriteLine($"解冻失败: {totalFailed} 个");
|
||||
|
||||
if (totalRestored > 0)
|
||||
{
|
||||
Console.WriteLine($"\n📋 解冻说明:");
|
||||
Console.WriteLine($" • 解冻任务已提交,文件将在后台处理");
|
||||
Console.WriteLine($" • 解冻完成后,文件将保持可读状态 {restoreDays} 天");
|
||||
Console.WriteLine($" • 归档文件约需1分钟,冷归档需数小时");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error($"❌ 阿里云解冻操作失败: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||
var credentials = new SessionAWSCredentials(
|
||||
AWSTempToken.AccessKeyId,
|
||||
AWSTempToken.SecretAccessKey,
|
||||
AWSTempToken.SessionToken
|
||||
);
|
||||
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region),
|
||||
UseHttp = true,
|
||||
};
|
||||
|
||||
using var client = new AmazonS3Client(credentials, clientConfig);
|
||||
|
||||
var bucketName = awsConfig.BucketName;
|
||||
int totalRestored = 0;
|
||||
int totalSkipped = 0;
|
||||
int totalFailed = 0;
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"开始解冻AWS S3文件,前缀: {prefix}");
|
||||
|
||||
var allObjects = new List<S3Object>();
|
||||
|
||||
// 1. 分页列举文件
|
||||
string continuationToken = null;
|
||||
ListObjectsV2Response response = null;
|
||||
|
||||
do
|
||||
{
|
||||
var listRequest = new ListObjectsV2Request
|
||||
{
|
||||
BucketName = bucketName,
|
||||
Prefix = prefix,
|
||||
ContinuationToken = continuationToken,
|
||||
MaxKeys = batchSize
|
||||
};
|
||||
|
||||
response = await client.ListObjectsV2Async(listRequest);
|
||||
|
||||
allObjects.AddRange(response.S3Objects);
|
||||
|
||||
|
||||
continuationToken = response.NextContinuationToken;
|
||||
|
||||
} while (response.IsTruncated == true);
|
||||
|
||||
// 2️⃣ 并行解冻(控制并发)
|
||||
await Parallel.ForEachAsync(
|
||||
allObjects,
|
||||
new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 5 // ⭐ 推荐 5~10
|
||||
},
|
||||
async (obj, ct) =>
|
||||
{
|
||||
// 只处理归档
|
||||
if (obj.StorageClass != S3StorageClass.Glacier)
|
||||
{
|
||||
Interlocked.Increment(ref totalSkipped);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var restoreRequest = new Amazon.S3.Model.RestoreObjectRequest
|
||||
{
|
||||
BucketName = bucketName,
|
||||
Key = obj.Key,
|
||||
Days = restoreDays,
|
||||
|
||||
};
|
||||
|
||||
await client.RestoreObjectAsync(restoreRequest);
|
||||
|
||||
Interlocked.Increment(ref totalRestored);
|
||||
Console.WriteLine($"✅ 提交解冻: {obj.Key}");
|
||||
}
|
||||
catch (OssException ex) when (ex.ErrorCode == "RestoreAlreadyInProgress")
|
||||
{
|
||||
// 已在解冻中,算成功
|
||||
Interlocked.Increment(ref totalSkipped);
|
||||
Console.WriteLine($"⚠️ 已在解冻中: {obj.Key}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Interlocked.Increment(ref totalFailed);
|
||||
Console.WriteLine($"❌ 解冻失败: {obj.Key} - {ex.Message}");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 3. 输出统计结果
|
||||
Console.WriteLine("\n================ 解冻完成 ================");
|
||||
Console.WriteLine($"总计处理: {totalRestored + totalSkipped + totalFailed} 个文件");
|
||||
Console.WriteLine($"成功解冻: {totalRestored} 个");
|
||||
Console.WriteLine($"跳过文件: {totalSkipped} 个 (非归档类型)");
|
||||
Console.WriteLine($"解冻失败: {totalFailed} 个");
|
||||
|
||||
if (totalRestored > 0)
|
||||
{
|
||||
Console.WriteLine($"\n📋 AWS解冻说明:");
|
||||
Console.WriteLine($" • 解冻任务已提交到Glacier服务");
|
||||
Console.WriteLine($" • 标准解冻: 3-5小时 (Glacier Flexible Retrieval)");
|
||||
Console.WriteLine($" • 加急解冻: 1-5分钟 (额外收费)");
|
||||
Console.WriteLine($" • 解冻后文件可读 {restoreDays} 天");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error($"❌ AWS解冻操作失败: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 坑方法,会清空之前的规则
|
||||
/// </summary>
|
||||
/// <param name="prefix"></param>
|
||||
/// <param name="ruleId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task SetLifecycle(string prefix, string ruleId = "immediate-archive")
|
||||
{
|
||||
BackBatchGetToken();
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
{
|
||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||
|
||||
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
|
||||
|
||||
ruleId = $"{ruleId}_{prefix}";
|
||||
var rule = new Aliyun.OSS.LifecycleRule
|
||||
{
|
||||
ID = ruleId,
|
||||
Prefix = prefix,
|
||||
Status = RuleStatus.Enabled,
|
||||
Transitions = new Aliyun.OSS.LifecycleRule.LifeCycleTransition[]
|
||||
{
|
||||
new Aliyun.OSS.LifecycleRule.LifeCycleTransition
|
||||
{
|
||||
|
||||
LifeCycleExpiration =
|
||||
{
|
||||
Days = 1
|
||||
},
|
||||
StorageClass = StorageClass.IA
|
||||
},
|
||||
new Aliyun.OSS.LifecycleRule.LifeCycleTransition
|
||||
{
|
||||
|
||||
LifeCycleExpiration =
|
||||
{
|
||||
Days = 30
|
||||
},
|
||||
StorageClass = StorageClass.Archive
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//会清空之前历史的规则,不能用。。。
|
||||
var request = new SetBucketLifecycleRequest(aliConfig.BucketName);
|
||||
request.AddLifecycleRule(rule);
|
||||
|
||||
_ossClient.SetBucketLifecycle(request);
|
||||
|
||||
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||
|
||||
var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
|
||||
|
||||
|
||||
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder
|
||||
@@ -249,8 +765,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -322,9 +838,10 @@ public class OSSService : IOSSService
|
||||
/// <param name="localFilePath"></param>
|
||||
/// <param name="oosFolderPath"></param>
|
||||
/// <param name="isFileNameAddGuid"></param>
|
||||
/// <param name="randomFileName">随机文件名</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true)
|
||||
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false)
|
||||
{
|
||||
BackBatchGetToken();
|
||||
|
||||
@@ -332,6 +849,11 @@ public class OSSService : IOSSService
|
||||
|
||||
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}";
|
||||
|
||||
if (randomFileName)
|
||||
{
|
||||
var fileExtension = localFileName.Split(".").LastOrDefault();
|
||||
ossRelativePath = $"{oosFolderPath}/{Guid.NewGuid()}.{fileExtension}";
|
||||
}
|
||||
|
||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||
{
|
||||
@@ -369,8 +891,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -444,8 +966,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -498,11 +1020,14 @@ public class OSSService : IOSSService
|
||||
|
||||
var result = _ossClient.GetObject(aliConfig.BucketName, ossRelativePath);
|
||||
|
||||
// 将OSS返回的流复制到内存流中并返回
|
||||
var memoryStream = new MemoryStream();
|
||||
await result.Content.CopyToAsync(memoryStream);
|
||||
memoryStream.Position = 0; // 重置位置以便读取
|
||||
return memoryStream;
|
||||
// 直接返回流
|
||||
return result.Content;
|
||||
|
||||
//// 将OSS返回的流复制到内存流中并返回
|
||||
//var memoryStream = new MemoryStream();
|
||||
//await result.Content.CopyToAsync(memoryStream);
|
||||
//memoryStream.Position = 0; // 重置位置以便读取
|
||||
//return memoryStream;
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||
{
|
||||
@@ -514,16 +1039,30 @@ public class OSSService : IOSSService
|
||||
.WithSSL(minIOConfig.UseSSL)
|
||||
.Build();
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
var pipe = new System.IO.Pipelines.Pipe();
|
||||
|
||||
var getObjectArgs = new GetObjectArgs()
|
||||
.WithBucket(minIOConfig.BucketName)
|
||||
.WithObject(ossRelativePath)
|
||||
.WithCallbackStream(stream => stream.CopyToAsync(memoryStream));
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var args = new GetObjectArgs()
|
||||
.WithBucket(minIOConfig.BucketName)
|
||||
.WithObject(ossRelativePath)
|
||||
.WithCallbackStream(stream =>
|
||||
{
|
||||
stream.CopyTo(pipe.Writer.AsStream());
|
||||
});
|
||||
|
||||
await minioClient.GetObjectAsync(getObjectArgs);
|
||||
memoryStream.Position = 0;
|
||||
return memoryStream;
|
||||
await minioClient.GetObjectAsync(args);
|
||||
await pipe.Writer.CompleteAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await pipe.Writer.CompleteAsync(ex);
|
||||
}
|
||||
});
|
||||
|
||||
return pipe.Reader.AsStream();
|
||||
}
|
||||
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||
{
|
||||
@@ -551,10 +1090,13 @@ public class OSSService : IOSSService
|
||||
|
||||
var response = await amazonS3Client.GetObjectAsync(getObjectRequest);
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
await response.ResponseStream.CopyToAsync(memoryStream);
|
||||
memoryStream.Position = 0;
|
||||
return memoryStream;
|
||||
// ⭐ 直接返回流
|
||||
return response.ResponseStream;
|
||||
|
||||
//var memoryStream = new MemoryStream();
|
||||
//await response.ResponseStream.CopyToAsync(memoryStream);
|
||||
//memoryStream.Position = 0;
|
||||
//return memoryStream;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -630,8 +1172,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -892,7 +1434,7 @@ public class OSSService : IOSSService
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除某个目录的文件
|
||||
/// 删除某个目录的文件 (包含单个文件,oss单个文件需要去除前缀/)
|
||||
/// </summary>
|
||||
/// <param name="prefix"></param>
|
||||
/// <returns></returns>
|
||||
@@ -1004,8 +1546,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -1019,7 +1561,7 @@ public class OSSService : IOSSService
|
||||
|
||||
var listObjectsResponse = await amazonS3Client.ListObjectsV2Async(listObjectsRequest);
|
||||
|
||||
if (listObjectsResponse.S3Objects.Count > 0)
|
||||
if (listObjectsResponse.S3Objects?.Count > 0)
|
||||
{
|
||||
// 准备删除请求
|
||||
var deleteObjectsRequest = new Amazon.S3.Model.DeleteObjectsRequest
|
||||
@@ -1049,7 +1591,7 @@ public class OSSService : IOSSService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeleteObjects(List<string> objectKeys)
|
||||
public async Task DeleteObjects(List<string> objectKeys, bool isCache = false)
|
||||
{
|
||||
GetObjectStoreTempToken();
|
||||
|
||||
@@ -1059,9 +1601,23 @@ public class OSSService : IOSSService
|
||||
|
||||
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
|
||||
|
||||
var bucketName = string.Empty;
|
||||
|
||||
if (isCache)
|
||||
{
|
||||
Uri uri = new Uri(aliConfig.ViewEndpoint);
|
||||
string host = uri.Host; // 获取 "zy-irc-test-dev-cache.oss-cn-shanghai.aliyuncs.com"
|
||||
string[] parts = host.Split('.');
|
||||
bucketName = parts[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
bucketName = aliConfig.BucketName;
|
||||
}
|
||||
|
||||
if (objectKeys.Count > 0)
|
||||
{
|
||||
var result = _ossClient.DeleteObjects(new Aliyun.OSS.DeleteObjectsRequest(aliConfig.BucketName, objectKeys, false));
|
||||
var result = _ossClient.DeleteObjects(new Aliyun.OSS.DeleteObjectsRequest(bucketName, objectKeys, false));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1097,8 +1653,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||
@@ -1172,8 +1728,8 @@ public class OSSService : IOSSService
|
||||
//提供awsEndPoint(域名)进行访问配置
|
||||
var clientConfig = new AmazonS3Config
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.USEast1,
|
||||
UseHttp = true,
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsConfig.Region)
|
||||
//,UseHttp = true,
|
||||
};
|
||||
|
||||
var request = new Amazon.S3.Model.GetObjectMetadataRequest
|
||||
@@ -1257,9 +1813,16 @@ public class OSSService : IOSSService
|
||||
{
|
||||
var awsOptions = ObjectStoreServiceOptions.AWS;
|
||||
|
||||
|
||||
// 创建 STS 客户端(考虑使用 RegionEndpoint)
|
||||
var stsConfig = new AmazonSecurityTokenServiceConfig
|
||||
{
|
||||
RegionEndpoint = RegionEndpoint.GetBySystemName(awsOptions.Region)
|
||||
};
|
||||
|
||||
//aws 临时凭证
|
||||
// 创建 STS 客户端
|
||||
var stsClient = new AmazonSecurityTokenServiceClient(awsOptions.AccessKeyId, awsOptions.SecretAccessKey);
|
||||
var stsClient = new AmazonSecurityTokenServiceClient(awsOptions.AccessKeyId, awsOptions.SecretAccessKey, stsConfig);
|
||||
|
||||
// 使用 AssumeRole 请求临时凭证
|
||||
var assumeRoleRequest = new AssumeRoleRequest
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using IdentityModel;
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper.OtherTool;
|
||||
|
||||
|
||||
public class WeComAlert
|
||||
{
|
||||
public string Env { get; set; } = "";
|
||||
public string UserName { get; set; } = "";
|
||||
public string Api { get; set; } = "";
|
||||
public string Message { get; set; } = "";
|
||||
public string? JsonData { get; set; }
|
||||
public string? Stack { get; set; }
|
||||
public bool HasStack => !string.IsNullOrWhiteSpace(Stack);
|
||||
public string[] AtUsers { get; set; } = [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class WeComNotifier
|
||||
{
|
||||
|
||||
public static async Task SendAlertAsync(string webhook, WeComAlert alert)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new RestClient();
|
||||
var request = new RestRequest(webhook, Method.Post);
|
||||
|
||||
var time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// 处理 @
|
||||
var atText = alert.AtUsers != null && alert.AtUsers.Any()
|
||||
? string.Join("", alert.AtUsers.Select(u => $" <@{u}>"))
|
||||
: "";
|
||||
|
||||
// 处理堆栈
|
||||
var stack = alert.Stack;
|
||||
if (!string.IsNullOrWhiteSpace(stack))
|
||||
{
|
||||
stack = stack.Replace("\n", "\n> ");
|
||||
if (stack.Length > 600)
|
||||
stack = stack[..600] + "...(已截断)";
|
||||
}
|
||||
|
||||
var markdown = $@"## 🚨 系统告警
|
||||
> {atText}
|
||||
> **部署环境:** [{alert.Env}]({alert.Env})
|
||||
> **发生时间:** {time}
|
||||
> **操作人:** {alert.UserName}
|
||||
> **接口地址:** {alert.Api}
|
||||
### ❗ 告警信息
|
||||
<font color=""warning"">{alert.Message}</font>";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(alert.JsonData))
|
||||
{
|
||||
markdown += $@"
|
||||
> **📦 请求数据(JSON 格式):**
|
||||
```json
|
||||
{alert.JsonData}
|
||||
```";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(stack))
|
||||
{
|
||||
markdown += $@"
|
||||
### 堆栈信息(部分)
|
||||
<font color=""comment"">{stack}</font>";
|
||||
}
|
||||
|
||||
var payload = new
|
||||
{
|
||||
msgtype = "markdown",
|
||||
markdown = new { content = markdown }
|
||||
};
|
||||
|
||||
request.AddHeader("Content-Type", "application/json");
|
||||
request.AddStringBody(JsonConvert.SerializeObject(payload), DataFormat.Json);
|
||||
|
||||
await client.ExecuteAsync(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error("企业微信告警发送失败: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.11" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2" />
|
||||
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -75,4 +74,8 @@
|
||||
<Folder Include="Service\MinimalApiService\CodeTemplate\FrontTemplate\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Service\TrialSiteUser\TrialStatService.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,21 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace IRaCIS.Core.Application.MassTransit.Command
|
||||
{
|
||||
/// <summary>
|
||||
/// 全量一致性核查
|
||||
/// </summary>
|
||||
public record ConsistenFullCheckCommand
|
||||
{
|
||||
public List<CheckViewModel> ETCList { get; set; } = new List<CheckViewModel>();
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public Guid InspectionFileId { get; set; }
|
||||
}
|
||||
|
||||
public record ConsistenCheckCommand
|
||||
{
|
||||
public List<CheckViewModel> ETCList { get; set; } = new List<CheckViewModel>();
|
||||
@@ -17,13 +30,24 @@ namespace IRaCIS.Core.Application.MassTransit.Command
|
||||
|
||||
public class CheckDBModel : CheckViewModel
|
||||
{
|
||||
|
||||
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
public Guid StudyId { get; set; }
|
||||
}
|
||||
|
||||
public class FullCheckResult: CheckViewModel
|
||||
{
|
||||
public string LatestScanDateStr { get; set; } = string.Empty;
|
||||
public string Modalitys { get; set; } = string.Empty;
|
||||
public DateTime CheckTime { get; set; }
|
||||
|
||||
public string CheckResult { get; set; }
|
||||
|
||||
|
||||
[DictionaryTranslateAttribute("CheckState")]
|
||||
public CheckStateEnum CheckState { get; set; }
|
||||
}
|
||||
|
||||
|
||||
//[ExcelImporter(/*ImportResultFilter = typeof(ImportResultFilteTest),*/ IsLabelingError = true)]
|
||||
@@ -62,8 +86,13 @@ namespace IRaCIS.Core.Application.MassTransit.Command
|
||||
[ExcelColumnName("Modality")]
|
||||
public string Modality { get; set; } = string.Empty;
|
||||
|
||||
#region 全量一致性核查加入
|
||||
[DictionaryTranslateAttribute("Subject_Visit_Status")]
|
||||
public SubjectStatus SubjectStatus { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
|
||||
@@ -1,53 +1,49 @@
|
||||
using AutoMapper;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Application.Interfaces;
|
||||
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts.DTO;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.MassTransit.Command;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
{
|
||||
public class ConsistencyCheckConsumer : IConsumer<ConsistenCheckCommand>
|
||||
public class ConsistencyCheckConsumer(
|
||||
IRepository<DicomStudy> _studyRepository,
|
||||
IUserInfo _userInfo,
|
||||
IRepository<Subject> _subjectRepository,
|
||||
IRepository<NoneDicomStudy> _noneDicomStudyRepository,
|
||||
IRepository<SubjectVisit> _subjectVisitRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IOSSService _oSSService,
|
||||
IMapper _mapper,
|
||||
IDictionaryService _dictionaryService,
|
||||
IRepository<CommonDocument> _commonDocumentRepository,
|
||||
IStringLocalizer _localizer,
|
||||
IWebHostEnvironment _hostEnvironment,
|
||||
IRepository<InspectionFile> _inspectionFileRepository,
|
||||
IOptionsMonitor<SystemEmailSendConfig> _systemEmailSendConfig
|
||||
) : IConsumer<ConsistenCheckCommand>, IConsumer<ConsistenFullCheckCommand>
|
||||
{
|
||||
|
||||
private readonly IRepository<DicomStudy> _studyRepository;
|
||||
private readonly IUserInfo _userInfo;
|
||||
private readonly IRepository<Subject> _subjectRepository;
|
||||
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
|
||||
private readonly IRepository<TrialSite> _trialSiteRepository;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IRepository<NoneDicomStudy> _noneDicomStudyRepository;
|
||||
public IStringLocalizer _localizer { get; set; }
|
||||
|
||||
private readonly SystemEmailSendConfig _systemEmailConfig;
|
||||
|
||||
private readonly IRepository<Dictionary> _dictionaryRepository;
|
||||
/// <summary>
|
||||
/// 构造函数注入
|
||||
/// </summary>
|
||||
private readonly SystemEmailSendConfig _systemEmailConfig = _systemEmailSendConfig.CurrentValue;
|
||||
|
||||
|
||||
public ConsistencyCheckConsumer(IRepository<DicomStudy> studyRepository, IUserInfo userInfo,
|
||||
IRepository<Subject> subjectRepository, IRepository<SubjectVisit> subjectVisitRepository,
|
||||
IRepository<TrialSite> trialSiteRepository, IRepository<NoneDicomStudy> noneDicomStudyRepository,
|
||||
IMapper mapper, IStringLocalizer localizer, IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IRepository<Dictionary> dictionaryRepository)
|
||||
{
|
||||
_noneDicomStudyRepository = noneDicomStudyRepository;
|
||||
_studyRepository = studyRepository;
|
||||
_userInfo = userInfo;
|
||||
_subjectRepository = subjectRepository;
|
||||
_subjectVisitRepository = subjectVisitRepository;
|
||||
_trialSiteRepository = trialSiteRepository;
|
||||
_mapper = mapper;
|
||||
_localizer = localizer;
|
||||
|
||||
_systemEmailConfig = systemEmailConfig.CurrentValue;
|
||||
_dictionaryRepository = dictionaryRepository;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -67,8 +63,8 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
|
||||
//subjectVisitLambda2= subjectVisitLambda2.And(x => x.CheckState == CheckStateEnum.ToCheck && x.AuditState == AuditStateEnum.QCPassed || (x.CheckState == CheckStateEnum.CVIng && x.AuditState == AuditStateEnum.QCPassed));
|
||||
|
||||
Expression<Func<SubjectVisit, bool>> subjectVisitLambda = x => x.TrialId == trialId && x.Subject.IsSubjectQuit == false &&
|
||||
(x.CheckState == CheckStateEnum.ToCheck && x.AuditState == AuditStateEnum.QCPassed || (x.CheckState == CheckStateEnum.CVIng && x.AuditState == AuditStateEnum.QCPassed));
|
||||
Expression<Func<SubjectVisit, bool>> subjectVisitLambda = x => x.TrialId == trialId && x.Subject.IsSubjectQuit == false && x.AuditState == AuditStateEnum.QCPassed &&
|
||||
(x.CheckState == CheckStateEnum.ToCheck || x.CheckState == CheckStateEnum.CVIng);
|
||||
|
||||
var dicomQuery = from sv in _subjectVisitRepository.Where(subjectVisitLambda)
|
||||
join subject in _subjectRepository.AsQueryable() on sv.SubjectId equals subject.Id
|
||||
@@ -117,7 +113,7 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
foreach (var sv in svExcelGroup)
|
||||
{
|
||||
|
||||
//Excel 的数据 在IRC 中可以找到该访视
|
||||
//Excel 的数据 在IRC 中可以找到该访视(一致性核查中,或者待核查)
|
||||
if (dbCheckList.Any(t => t.SubjectCode == sv.SubjectCode && t.SiteCode == sv.SiteCode && t.VisitName == sv.VisitName))
|
||||
{
|
||||
|
||||
@@ -201,7 +197,7 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
var dbExceptExcel = dbVisitStudyList.Except(etcVisitStudyList);
|
||||
|
||||
// excel 存在
|
||||
var excelExceptDB = etcVisitStudyList.Except(dbCheckList);
|
||||
var excelExceptDB = etcVisitStudyList.Except(dbVisitStudyList);
|
||||
|
||||
//ETC 和系统的完全一致 两者没有差别
|
||||
if (dbExceptExcel.Count() == 0 && excelExceptDB.Count() == 0)
|
||||
@@ -301,12 +297,169 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer
|
||||
}
|
||||
await _subjectVisitRepository.SaveChangesAsync();
|
||||
|
||||
//await context.RespondAsync<ConsistenCheckResult>(new
|
||||
//{
|
||||
|
||||
//});
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ConsistenFullCheckCommand> context)
|
||||
{
|
||||
var inspectionFileId = context.Message.InspectionFileId;
|
||||
var trialId = context.Message.TrialId;
|
||||
|
||||
//系统定义MRI 到底是MR 还是MRI
|
||||
var mriModality = await _dictionaryRepository.Where(t => t.Parent.Code == "Modality").Where(t => t.Code == "MRI").Select(t => t.Value).FirstNotNullAsync();
|
||||
|
||||
//处理Excel大小写
|
||||
context.Message.ETCList.ForEach(t => { t.Modality = t.Modality.ToUpper().Trim(); t.StudyDate = Convert.ToDateTime(t.StudyDate).ToString("yyyy-MM-dd"); t.SiteCode = t.SiteCode.ToUpper().Trim(); t.VisitName = t.VisitName.ToUpper().Trim(); t.SubjectCode = t.SubjectCode.ToUpper().Trim(); });
|
||||
var etcList = context.Message.ETCList;
|
||||
|
||||
|
||||
Expression<Func<SubjectVisit, bool>> subjectVisitLambda = x => x.TrialId == trialId /*&& x.Subject.IsSubjectQuit == false*/ && x.AuditState == AuditStateEnum.QCPassed;
|
||||
|
||||
var dicomQuery = from sv in _subjectVisitRepository.Where(subjectVisitLambda)
|
||||
join subject in _subjectRepository.AsQueryable() on sv.SubjectId equals subject.Id
|
||||
join study in _studyRepository.AsQueryable() on sv.Id equals study.SubjectVisitId
|
||||
select new CheckDBModel()
|
||||
{
|
||||
SubjectStatus = sv.Subject.Status,
|
||||
SubjectVisitId = sv.Id,
|
||||
SiteCode = sv.TrialSite.TrialSiteCode,
|
||||
StudyDate = study.StudyTime == null ? string.Empty : ((DateTime)study.StudyTime).ToString("yyyy-MM-dd"),
|
||||
StudyId = study.Id,
|
||||
Modality = study.ModalityForEdit,
|
||||
SubjectCode = subject.Code,
|
||||
VisitName = sv.VisitName,
|
||||
};
|
||||
|
||||
var noneDicomQuey = from sv in _subjectVisitRepository.Where(subjectVisitLambda)
|
||||
join subject in _subjectRepository.AsQueryable() on sv.SubjectId equals subject.Id
|
||||
join noneDicomStudy in _noneDicomStudyRepository.Where(t => t.FileCount > 0) on sv.Id equals noneDicomStudy.SubjectVisitId
|
||||
select new CheckDBModel()
|
||||
{
|
||||
SubjectStatus = sv.Subject.Status,
|
||||
SubjectVisitId = sv.Id,
|
||||
SiteCode = sv.TrialSite.TrialSiteCode,
|
||||
StudyDate = noneDicomStudy.ImageDate.ToString("yyyy-MM-dd"),
|
||||
StudyId = noneDicomStudy.Id,
|
||||
Modality = noneDicomStudy.Modality,
|
||||
SubjectCode = subject.Code,
|
||||
VisitName = sv.VisitName,
|
||||
};
|
||||
|
||||
var dbList = (await dicomQuery.ToListAsync()).Union(await noneDicomQuey.ToListAsync()).ToList();
|
||||
|
||||
//处理数据库 大小写
|
||||
dbList.ForEach(t => { t.Modality = t.Modality.ToUpper().Trim(); t.SiteCode = t.SiteCode.ToUpper().Trim(); t.VisitName = t.VisitName.ToUpper().Trim(); t.SubjectCode = t.SubjectCode.ToUpper().Trim(); });
|
||||
|
||||
var dbCheckList = _mapper.Map<List<CheckViewModel>>(dbList);
|
||||
|
||||
|
||||
//按照Excel数据访视分组 按照数据库的数据 一个个的访视对比
|
||||
var svExcelGroup = etcList.GroupBy(t => new { t.SiteCode, t.SubjectCode, t.VisitName })
|
||||
.Select(g => new { g.Key.SubjectCode, g.Key.VisitName, g.Key.SiteCode, ExcelStudyList = g.ToList() }).ToList();
|
||||
|
||||
var fullCheckResultList = new List<FullCheckResult>();
|
||||
|
||||
|
||||
foreach (var sv in svExcelGroup)
|
||||
{
|
||||
|
||||
//Excel 的数据 在IRC 中可以找到该访视(一致性核查中,或者待核查)
|
||||
if (dbCheckList.Any(t => t.SubjectCode == sv.SubjectCode && t.SiteCode == sv.SiteCode && t.VisitName == sv.VisitName))
|
||||
{
|
||||
|
||||
var dbVisitStudyList = dbList.Where(t => t.SubjectCode == sv.SubjectCode && t.SiteCode == sv.SiteCode && t.VisitName == sv.VisitName).ToList();
|
||||
|
||||
//找到etc 当前visit site 和subject 一致的检查列表
|
||||
var etcVisitStudyList = etcList.Where(t => t.SubjectCode == sv.SubjectCode && t.SiteCode == sv.SiteCode && t.VisitName == sv.VisitName).ToList();
|
||||
|
||||
|
||||
//以我们系统数据库为准 ,判断是MR 还是MRI, 把Excel 里的MR 或者MRI 处理成一致,MR MRI 是一致的
|
||||
foreach (var item in etcVisitStudyList)
|
||||
{
|
||||
if (item.Modality == "MR" || item.Modality == "MRI")
|
||||
{
|
||||
item.Modality = mriModality;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//etc 和数据库 并集
|
||||
var unionList = dbVisitStudyList.Union(etcVisitStudyList);
|
||||
// 数据库存在
|
||||
var dbExceptExcel = dbVisitStudyList.Except(etcVisitStudyList);
|
||||
|
||||
// excel 存在
|
||||
var excelExceptDB = etcVisitStudyList.Except(dbVisitStudyList);
|
||||
|
||||
var dbCurrentVisitFirst = dbVisitStudyList.First();
|
||||
|
||||
//ETC 和系统的完全一致 两者没有差别
|
||||
if (dbExceptExcel.Count() == 0 && excelExceptDB.Count() == 0)
|
||||
{
|
||||
|
||||
|
||||
//每个受试者每个访视加一条记录
|
||||
fullCheckResultList.Add(new FullCheckResult()
|
||||
{
|
||||
SubjectStatus = dbCurrentVisitFirst.SubjectStatus,
|
||||
CheckTime = DateTime.Now,
|
||||
CheckState=CheckStateEnum.CVPassed,
|
||||
SiteCode = dbCurrentVisitFirst.SiteCode,
|
||||
SubjectCode = dbCurrentVisitFirst.SubjectCode,
|
||||
VisitName = dbCurrentVisitFirst.VisitName,
|
||||
Modalitys = string.Join('、', dbVisitStudyList.Select(t => t.Modality)),
|
||||
LatestScanDateStr = dbVisitStudyList.Select(t => t.StudyDate).MaxBy(d => DateTime.Parse(d)) ?? ""
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var checkResult =
|
||||
String.Join(" | ", dbExceptExcel.Select(t => $"{_localizer["ConsistencyVerification_EdcL", t.StudyDate, t.Modality/*, _systemEmailConfig.SystemShortName*/]}")) + " | "
|
||||
+ String.Join(" | ", excelExceptDB.Select(t => $"{_localizer["ConsistencyVerification_IrcLi", t.StudyDate, t.Modality, _systemEmailConfig.SystemShortName]}"));
|
||||
|
||||
//每个受试者每个访视加一条记录
|
||||
fullCheckResultList.Add(new FullCheckResult()
|
||||
{
|
||||
SubjectStatus = dbCurrentVisitFirst.SubjectStatus,
|
||||
CheckState = CheckStateEnum.None,
|
||||
CheckTime = DateTime.Now,
|
||||
SiteCode = dbCurrentVisitFirst.SiteCode,
|
||||
SubjectCode = dbCurrentVisitFirst.SubjectCode,
|
||||
VisitName = dbCurrentVisitFirst.VisitName,
|
||||
Modalitys = string.Join('、', dbVisitStudyList.Select(t => t.Modality)),
|
||||
LatestScanDateStr = dbVisitStudyList.Select(t => t.StudyDate).MaxBy(d => DateTime.Parse(d)) ?? "",
|
||||
CheckResult = checkResult
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//导到Excel 上传oss 回更记录状态
|
||||
|
||||
var list = fullCheckResultList;
|
||||
|
||||
var exportInfo = new ExcelExportInfo();
|
||||
|
||||
exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId);
|
||||
exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId);
|
||||
|
||||
var fileStreamResult = (FileStreamResult)await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialConsistentFUllCheckList_Export, exportInfo, exportInfo.TrialCode, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(FullCheckResult));
|
||||
|
||||
var ossRelativePath = await _oSSService.UploadToOSSAsync(fileStreamResult.FileStream, $"{trialId.ToString()}/InspectionUpload/DataReconciliation", "DataReconciliation");
|
||||
|
||||
|
||||
//var add = await _inspectionFileRepository.FindAsync(inspectionFileId);
|
||||
//add.CheckState = EDCCheckState.Success;
|
||||
//add.ResultPath = ossRelativePath;
|
||||
|
||||
//更新
|
||||
await _inspectionFileRepository.BatchUpdateNoTrackingAsync(t => t.Id == inspectionFileId, u => new InspectionFile() { CheckState = EDCCheckState.Success, ResultPath = ossRelativePath });
|
||||
|
||||
await _subjectVisitRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class ImageConsumer(
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送影像重传相关邮件的通用方法
|
||||
/// 发送影像重传相关邮件的通用方法 已经处理项目
|
||||
/// </summary>
|
||||
private async Task SendImageReuploadEmail(SendImageReuploadEmailInDto inDto)
|
||||
{
|
||||
@@ -339,12 +339,12 @@ public class ImageConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
// 发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
// 添加抄送
|
||||
foreach (var ccUser in ccUserList)
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(String.Empty, ccUser.EMail));
|
||||
messageToSend.Cc.Add(new MailboxAddress(ccUser.FullName, ccUser.EMail));
|
||||
}
|
||||
// 格式化邮件内容
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
||||
@@ -365,9 +365,11 @@ public class ImageConsumer(
|
||||
return (topicStr, htmlBodyStr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(inDto.EmailNoticeConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +436,7 @@ public class ImageConsumer(
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送阅片人筛选相关邮件的通用方法
|
||||
/// 发送阅片人筛选相关邮件的通用方法 已经处理项目
|
||||
/// </summary>
|
||||
private async Task SendReviewerSelectionEmail(EmailNoticeConfig emailNoticeConfig, Guid trialId, List<Guid> enrollIdList)
|
||||
{
|
||||
@@ -472,12 +474,12 @@ public class ImageConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
// 发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
// 添加抄送
|
||||
foreach (var ccUser in ccUserList)
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(String.Empty, ccUser.EMail));
|
||||
messageToSend.Cc.Add(new MailboxAddress(ccUser.FullName, ccUser.EMail));
|
||||
}
|
||||
|
||||
// 格式化邮件内容
|
||||
@@ -500,7 +502,7 @@ public class ImageConsumer(
|
||||
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailNoticeConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class UrgentMedicalReviewAddedEventConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == medicalReview.TrialId);
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -128,7 +128,7 @@ public class UrgentMedicalReviewAddedEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public class UrgentIRRepliedMedicalReviewConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == medicalReview.TrialId);
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -236,7 +236,7 @@ public class UrgentIRRepliedMedicalReviewConsumer(
|
||||
};
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class UrgentMIMRepliedMedicalReviewConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == medicalReview.TrialId);
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -353,8 +353,7 @@ public class UrgentMIMRepliedMedicalReviewConsumer(
|
||||
};
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,7 +418,7 @@ public class UrgentIRApplyedReReadingConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == taskInfo.TrialId);
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -463,7 +462,7 @@ public class UrgentIRApplyedReReadingConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.Vml;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.MassTransit.Command;
|
||||
@@ -55,6 +56,7 @@ public class UserSiteSurveySubmitedEventConsumer(
|
||||
|
||||
if (emailConfig != null)
|
||||
{
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId);
|
||||
|
||||
var trialUserList = await _trialUserRoleRepository.Where(t => t.TrialId == siteSurveyInfo.TrialId && t.TrialUser.IsDeleted == false)
|
||||
.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.SPM || t.UserRole.UserTypeEnum == UserTypeEnum.CPM || t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM)
|
||||
@@ -67,8 +69,8 @@ public class UserSiteSurveySubmitedEventConsumer(
|
||||
|
||||
var toUserName = string.Empty;
|
||||
|
||||
//有SPM
|
||||
if (sPMOrCPMList.Count > 0)
|
||||
//有SPM 并且参与
|
||||
if (trialInfo.IsSPMJoinSiteSurvey && sPMOrCPMList.Count > 0)
|
||||
{
|
||||
foreach (var user in sPMOrCPMList)
|
||||
{
|
||||
@@ -96,7 +98,6 @@ public class UserSiteSurveySubmitedEventConsumer(
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId);
|
||||
|
||||
var siteInfo = await _trialSiteRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.Id == siteSurveyInfo.TrialSiteId, true);
|
||||
|
||||
@@ -122,7 +123,7 @@ public class UserSiteSurveySubmitedEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -205,7 +206,7 @@ public class SiteSurveySPMSubmitedEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +284,7 @@ public class SiteSurverRejectedEventConsumer(
|
||||
{
|
||||
//没有SPM PM驳回到CRC
|
||||
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, siteSurveyInfo.Email));
|
||||
messageToSend.To.Add(new MailboxAddress(siteSurveyInfo.UserName, siteSurveyInfo.Email));
|
||||
}
|
||||
|
||||
//发件地址
|
||||
@@ -319,7 +320,7 @@ public class SiteSurverRejectedEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,14 +89,14 @@ public class CRCSubmitedAndQCToAuditEventConsumer(
|
||||
|
||||
foreach (var userinfo in userinfoList)
|
||||
{
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
}
|
||||
|
||||
var userNames = userinfoList.Select(x => x.FullName).ToList();
|
||||
|
||||
foreach (var pm in pmandAPm)
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(String.Empty, pm.EMail));
|
||||
messageToSend.Cc.Add(new MailboxAddress(pm.FullName, pm.EMail));
|
||||
}
|
||||
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -122,7 +122,7 @@ public class CRCSubmitedAndQCToAuditEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -181,11 +181,11 @@ public class CRCRepliedQCChallengeEventConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
foreach (var pm in pmandAPm)
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(String.Empty, pm.EMail));
|
||||
messageToSend.Cc.Add(new MailboxAddress(pm.FullName, pm.EMail));
|
||||
}
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
|
||||
@@ -221,7 +221,7 @@ public class CRCRepliedQCChallengeEventConsumer(
|
||||
};
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,10 +307,10 @@ public class QCRepliedQCChallengeEventConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
if (craInfo != null)
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(String.Empty, craInfo.EMail));
|
||||
messageToSend.Cc.Add(new MailboxAddress(craInfo.FullName, craInfo.EMail));
|
||||
}
|
||||
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -339,7 +339,7 @@ public class QCRepliedQCChallengeEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,7 +439,7 @@ public class CRCRepliedCheckChallengeEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,10 +517,10 @@ public class PMRepliedCheckChallengeEventConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
if (craInfo != null)
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(String.Empty, craInfo.EMail));
|
||||
messageToSend.Cc.Add(new MailboxAddress(craInfo.FullName, craInfo.EMail));
|
||||
}
|
||||
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -549,7 +549,7 @@ public class PMRepliedCheckChallengeEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -620,7 +620,7 @@ public class CheckStateChangedToAuditEventConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
@@ -648,7 +648,7 @@ public class CheckStateChangedToAuditEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -707,11 +707,11 @@ public class QCClaimTaskEventConsumer(
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
foreach (var pm in pmandAPm)
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(String.Empty, pm.EMail));
|
||||
messageToSend.Cc.Add(new MailboxAddress(pm.FullName, pm.EMail));
|
||||
}
|
||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
|
||||
@@ -757,7 +757,7 @@ public class QCClaimTaskEventConsumer(
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.Helper.OtherTool;
|
||||
using IRaCIS.Core.Domain.BaseModel;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class ConsumeExceptionFilter<T>(ILogger<ConsumeExceptionFilter<T>> _logger) : IFilter<ConsumeContext<T>> where T : DomainEvent
|
||||
public class ConsumeExceptionFilter<T>(ILogger<ConsumeExceptionFilter<T>> _logger, IConfiguration _config) : IFilter<ConsumeContext<T>> where T : DomainEvent
|
||||
{
|
||||
|
||||
public async Task Send(ConsumeContext<T> context, IPipe<ConsumeContext<T>> next)
|
||||
@@ -23,6 +25,44 @@ public class ConsumeExceptionFilter<T>(ILogger<ConsumeExceptionFilter<T>> _logge
|
||||
{
|
||||
var errorInfo = $"Exception: {exception.Message}[{exception.StackTrace}]" + (exception.InnerException != null ? $" InnerException: {exception.InnerException.Message}[{exception.InnerException.StackTrace}]" : "");
|
||||
_logger.LogError(errorInfo);
|
||||
|
||||
try
|
||||
{
|
||||
bool isOpenWeComNotice = _config.GetValue<bool>("WeComNoticeConfig:IsOpenWeComNotice");
|
||||
|
||||
if (isOpenWeComNotice)
|
||||
{
|
||||
string webhook = _config["WeComNoticeConfig:WebhookUrl"] ?? string.Empty;
|
||||
|
||||
var uri = new Uri(_config["SystemEmailSendConfig:SiteUrl"]);
|
||||
var baseUrl = uri.GetLeftPart(UriPartial.Authority);
|
||||
|
||||
var userList = _config.GetSection("WeComNoticeConfig:APINoticeUserList").Get<string[]>();
|
||||
|
||||
|
||||
|
||||
// 🔔 异步告警(不要阻塞请求)
|
||||
_ = WeComNotifier.SendAlertAsync(
|
||||
webhook: webhook,
|
||||
alert: new WeComAlert
|
||||
{
|
||||
Env = baseUrl,
|
||||
UserName = "MassTransit 自动触发邮件",
|
||||
Api = "",
|
||||
Message = $"异常信息:{exception.Message} ",
|
||||
Stack = exception.StackTrace,
|
||||
AtUsers = userList ?? []
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Error($"MassTransit里发送企业微信出现错误:{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
@@ -26,6 +27,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
public class UrgentIRUnReadTaskRecurringEventConsumer(
|
||||
IRepository<ReadingQuestionCriterionTrial> _trialReadingCriterionRepository,
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<Trial> _trialRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IRepository<TrialUserRole> _trialUserRoleRepository,
|
||||
IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigrepository,
|
||||
@@ -35,9 +37,15 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
|
||||
public async Task Consume(ConsumeContext<UrgentIRUnReadTaskRecurringEvent> context)
|
||||
{
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
var isEn_US = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
var trialId = context.Message.TrialId;
|
||||
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId);
|
||||
var scenario = EmailBusinessScenario.ExpeditedReading;
|
||||
var trialEmailConfig = _trialEmailNoticeConfigrepository.Where(t => t.TrialId == trialId && t.BusinessScenarioEnum == scenario && t.IsAutoSend && t.IsEnable).FirstOrDefault();
|
||||
|
||||
@@ -161,7 +169,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
|
||||
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(trialEmailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
|
||||
//处理标记已通知的任务
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public static class OldRecurringEmailHelper
|
||||
public static string EmailNamePlaceholder => StaticData.EmailSend.EmailNamePlaceholder;
|
||||
|
||||
|
||||
|
||||
//发送项目邮件的通用方法 已经处理
|
||||
public static async Task SendTrialEmailAsync(
|
||||
IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigRepository,
|
||||
IRepository<Trial> _trialRepository,
|
||||
@@ -34,6 +34,7 @@ public static class OldRecurringEmailHelper
|
||||
var trialEmailConfig = await _trialEmailNoticeConfigRepository.Where(t => t.TrialId == trialId && t.BusinessScenarioEnum == businessScenario, ignoreQueryFilters: true)
|
||||
.Include(t => t.TrialEmailNoticeUserList).Include(t => t.TrialEmailBlackUserList).FirstOrDefaultAsync();
|
||||
|
||||
var trialInfo=await _trialRepository.Where(t=>t.Id== trialId).FirstOrDefaultAsync();
|
||||
|
||||
if (trialEmailConfig == null || trialEmailConfig.IsAutoSend == false || trialEmailConfig.IsEnable == false)
|
||||
{
|
||||
@@ -162,7 +163,7 @@ public static class OldRecurringEmailHelper
|
||||
if (sendEmailConfig != null)
|
||||
{
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig, trialInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using MassTransit.Scheduling;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -14,7 +15,7 @@ using System.Threading.Tasks;
|
||||
namespace IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
|
||||
|
||||
|
||||
//项目手动选择 周期性邮件
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -34,7 +35,11 @@ public class QCImageQuestionRecurringEventConsumer(IRepository<Trial> _trialRepo
|
||||
{
|
||||
var trialId = context.Message.TrialId;
|
||||
|
||||
var isEn_us = false;
|
||||
var isEn_us = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
var trialInfo = await _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.ResearchProgramNo, t.ExperimentName, t.TrialCode, t.TrialStatusStr }).FirstNotNullAsync();
|
||||
|
||||
@@ -102,7 +107,12 @@ public class CRCImageQuestionRecurringEventConsumer(IRepository<Trial> _trialRep
|
||||
{
|
||||
var trialId = context.Message.TrialId;
|
||||
|
||||
var isEn_us = false;
|
||||
var isEn_us = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
var trialInfo = await _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.ResearchProgramNo, t.ExperimentName, t.TrialCode, t.TrialStatusStr, t.DeclarationTypeEnumList }).FirstNotNullAsync();
|
||||
|
||||
//找到 该项目的IQC 用户Id
|
||||
@@ -173,7 +183,11 @@ public class ImageQCRecurringEventConsumer(IRepository<Trial> _trialRepository,
|
||||
{
|
||||
var trialId=context.Message.TrialId;
|
||||
|
||||
var isEn_us = false;
|
||||
var isEn_us = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
var trialInfo = await _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.ResearchProgramNo, t.ExperimentName, t.TrialCode, t.TrialStatusStr }).FirstNotNullAsync();
|
||||
|
||||
|
||||
@@ -42,7 +42,12 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
Console.WriteLine("发送定时过期提醒");
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
var isEn_US = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
var systemDocQuery =
|
||||
from sysDoc in _systemDocumentRepository.AsQueryable(false)
|
||||
from identityUser in _identityUserRepository.AsQueryable(false).Where(t => t.UserRoleList.Where(t => t.IsUserRoleDisabled == false).Any(t => sysDoc.NeedConfirmedUserTypeList.AsQueryable().Any(c => c.NeedConfirmUserTypeId == t.UserTypeId)))
|
||||
@@ -89,7 +94,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +119,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
if (emailConfig != null)
|
||||
{
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
}
|
||||
|
||||
@@ -150,7 +155,11 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
|
||||
public async Task Consume(ConsumeContext<SystemDocumentPublishEvent> context)
|
||||
{
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
var isEn_US = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
// 记录是否只发送给新增角色的日志
|
||||
if (context.Message.NewUserTypeIds != null && context.Message.NewUserTypeIds.Any())
|
||||
@@ -230,7 +239,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Reactive.Joins;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -52,7 +53,11 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
Console.WriteLine("发送定时项目过期提醒");
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
var isEn_US = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
var trialDocQuery =
|
||||
from trialDoc in _trialDocumentRepository.AsQueryable(true)
|
||||
|
||||
@@ -75,6 +80,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
CurrentStaffTrainDays = trialDoc.CurrentStaffTrainDays,
|
||||
NewStaffTrainDays = trialDoc.NewStaffTrainDays,
|
||||
Id = trialDoc.Id,
|
||||
TrialId= trialDoc.TrialId,
|
||||
IsSystemDoc = false,
|
||||
CreateTime = trialDoc.CreateTime,
|
||||
FullFilePath = trialDoc.Path,
|
||||
@@ -109,10 +115,11 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
{
|
||||
Console.WriteLine($"{index}发送定时过期提醒,邮箱:{userinfo.EMail},姓名{userinfo.UserName}");
|
||||
index++;
|
||||
var trialInfo = _trialRepository.Where(x => x.Id == userinfo.TrialId).FirstOrDefault();
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
|
||||
|
||||
@@ -137,8 +144,8 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
if (emailConfig != null)
|
||||
{
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +169,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<TrialDocument> _trialDocumentRepository,
|
||||
IRepository<IdentityUser> _identityUserRepository,
|
||||
IRepository<Trial> _trialRepository,
|
||||
IRepository<TrialIdentityUser> _trialIdentityUserRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IRepository<TrialUserRole> _trialUserRoleRepository,
|
||||
@@ -173,7 +181,11 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
|
||||
public async Task Consume(ConsumeContext<TrialDocumentPublishEvent> context)
|
||||
{
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
var isEn_US = context.Message.CultureInfoName == StaticData.CultureInfo.en_US;
|
||||
|
||||
//设置当前事件传递过来的语言
|
||||
var culture = context.Message.CultureInfoName;
|
||||
CultureInfo.CurrentCulture = new CultureInfo(culture);
|
||||
|
||||
// 记录是否只发送给新增角色的日志
|
||||
if (context.Message.NewUserTypeIds != null && context.Message.NewUserTypeIds.Any())
|
||||
@@ -198,6 +210,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
{
|
||||
IsSystemDoc = true,
|
||||
Id = trialDoc.Id,
|
||||
TrialId= trialDoc.TrialId,
|
||||
CreateTime = trialDoc.CreateTime,
|
||||
IsDeleted = trialDoc.IsDeleted,
|
||||
SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes,
|
||||
@@ -219,7 +232,9 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
from trialDoc in _trialDocumentRepository.AsQueryable(false).Where(x => context.Message.Ids.Contains(x.Id))
|
||||
join trialIdentityUser in _trialIdentityUserRepository.Where(x => x.IsDeleted == false) on trialDoc.TrialId equals trialIdentityUser.TrialId
|
||||
join trialUserRole in _trialUserRoleRepository.Where(x=>x.IsDeleted==false) on trialIdentityUser.Id equals trialUserRole.TrialUserId
|
||||
join identityUser in _identityUserRepository.AsQueryable(false).Where(u => u.Status == UserStateEnum.Enable)
|
||||
|
||||
join trial in _trialRepository.AsQueryable(false) on trialDoc.TrialId equals trial.Id
|
||||
join identityUser in _identityUserRepository.AsQueryable(false).Where(u => u.Status == UserStateEnum.Enable)
|
||||
on trialIdentityUser.IdentityUserId equals identityUser.Id
|
||||
where trialIdentityUser.TrialUserRoleList.Any(ur => !ur.IsDeleted &&trialDoc.NeedConfirmedUserTypeList.Any(c => c.NeedConfirmUserTypeId == ur.UserRole.UserTypeId))
|
||||
|
||||
@@ -228,6 +243,8 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
{
|
||||
IsSystemDoc = false,
|
||||
Id = trialDoc.Id,
|
||||
TrialId = trialDoc.TrialId,
|
||||
EmailFromName =trial.EmailFromName,
|
||||
CreateTime = trialDoc.CreateTime,
|
||||
IsDeleted = trialDoc.IsDeleted,
|
||||
SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes,
|
||||
@@ -242,6 +259,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
FullFilePath = trialDoc.Path
|
||||
};
|
||||
}
|
||||
|
||||
var datalist = await systemDocQuery.IgnoreQueryFilters().ToListAsync();
|
||||
|
||||
var confirmUserIdList = datalist.Select(t => t.ConfirmUserId).Distinct().ToList();
|
||||
@@ -257,7 +275,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||
messageToSend.To.Add(new MailboxAddress(userinfo.FullName, userinfo.EMail));
|
||||
|
||||
|
||||
|
||||
@@ -283,7 +301,12 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||
{
|
||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailConfig, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
var trial = datalist.Where(x => x.ConfirmUserId == userinfo.Id).FirstOrDefault();
|
||||
|
||||
var trialInfo = await _trialRepository.Where(x=>x.Id==trial.TrialId).FirstNotNullAsync();
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
msg += "发送成功";
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ using MassTransit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Threading.Tasks;
|
||||
using Subject = IRaCIS.Core.Domain.Models.Subject;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.Allocation;
|
||||
@@ -45,6 +47,8 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<DicomSeries> _dicomSeriesRepository,
|
||||
IRepository<SubjectCanceDoctor> _subjectCanceDoctorRepository,
|
||||
IRepository<ReadingTaskQuestionMark> _readingTaskQuestionMarkRepository,
|
||||
IRepository<ReadingNoneDicomMark> _readingNoneDicomMarkRepository,
|
||||
IRepository<ReadingNoneDicomMarkBinding> _readingNoneDicomMarkBindingRepository,
|
||||
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
|
||||
//IRepository<ReadingCustomTag> _readingCustomTagRepository,
|
||||
IRepository<TaskInfluence> _taskInfluenceRepository,
|
||||
@@ -1172,8 +1176,8 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
var visitQuery = _visitTaskRepository.Where(x => x.TrialId == trialId && x.DoctorUserId == _userInfo.UserRoleId && x.TaskState == TaskState.Effect)
|
||||
.WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId)
|
||||
.WhereIf(!string.IsNullOrEmpty(subjectCode), t => (t.Subject.Code.Contains(subjectCode!) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(subjectCode!) && t.IsAnalysisCreate))
|
||||
.WhereIf(critrion.CriterionType == CriterionType.OCT, t => t.ReadingCategory == ReadingCategory.Visit ? t.SourceSubjectVisit.NoneDicomStudyList.SelectMany(t => t.ImageLabelNoneDicomFileList).Any() : true)
|
||||
.WhereIf(critrion.CriterionType == CriterionType.IVUS, t => t.ReadingCategory == ReadingCategory.Visit ? t.SourceSubjectVisit.TaskStudyList.Any() : true);
|
||||
.WhereIf(critrion.CriterionType == CriterionType.OCT, t => t.ReadingCategory == ReadingCategory.Visit ? t.SourceSubjectVisit.NoneDicomStudyList.Where(t => t.Modality == "OCT").SelectMany(t => t.ImageLabelNoneDicomFileList).Any() : true)
|
||||
.WhereIf(critrion.CriterionType == CriterionType.IVUS, t => t.ReadingCategory == ReadingCategory.Visit ? t.SourceSubjectVisit.NoneDicomStudyList.Where(t => t.Modality == "IVUS").SelectMany(t => t.ImageLabelNoneDicomFileList).Any() : true);
|
||||
|
||||
var visitGroupQuery = visitQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode });
|
||||
|
||||
@@ -2083,7 +2087,9 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
{
|
||||
if (origenalTask.ReadingCategory == ReadingCategory.Visit)
|
||||
{
|
||||
CopyForms(newTask, origenalTask);
|
||||
newTask.IsCopyLesionAnswer = true;
|
||||
|
||||
//CopyForms(newTask, origenalTask);
|
||||
}
|
||||
|
||||
|
||||
@@ -2181,7 +2187,6 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
if (origenalTask.ReadingCategory == ReadingCategory.Visit)
|
||||
{
|
||||
CopyForms(newTask, origenalTask);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2191,7 +2196,8 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
{
|
||||
if (origenalTask.ReadingCategory == ReadingCategory.Visit)
|
||||
{
|
||||
CopyForms(newTask, origenalTask);
|
||||
newTask.IsCopyLesionAnswer = true;
|
||||
//CopyForms(newTask, origenalTask);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2216,7 +2222,7 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
|
||||
private void CopyForms(VisitTask newTask, VisitTask origenalTask)
|
||||
{
|
||||
|
||||
newTask.IsCopyLesionAnswer = true;
|
||||
//自定义
|
||||
//var readingCustomTagList = _readingCustomTagRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
|
||||
|
||||
@@ -2258,7 +2264,7 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
|
||||
//ReadingTableAnswerRowInfo ReadingTableQuestionAnswer 一起加
|
||||
var readingTableAnswerRowInfoList = _readingTableAnswerRowInfoRepository.Where(t => t.VisitTaskId == origenalTask.Id).Include(t => t.LesionAnswerList).ToList();
|
||||
|
||||
Dictionary<Guid, Guid> lesionRelationship = new Dictionary<Guid, Guid>() { };
|
||||
foreach (var item in readingTableAnswerRowInfoList)
|
||||
{
|
||||
|
||||
@@ -2266,7 +2272,7 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
var originalFristAddTaskId = item.FristAddTaskId;
|
||||
|
||||
var newRowId = NewId.NextSequentialGuid();
|
||||
|
||||
lesionRelationship.Add(item.Id, newRowId);
|
||||
foreach (var mark in readingTaskQuestionMarkList)
|
||||
{
|
||||
mark.RowId = mark.RowId == item.Id ? newRowId : mark.RowId;
|
||||
@@ -2288,13 +2294,54 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in readingTableAnswerRowInfoList)
|
||||
{
|
||||
if (item.SplitRowId != null && lesionRelationship.ContainsKey(item.SplitRowId.Value))
|
||||
{
|
||||
item.SplitRowId = lesionRelationship[item.SplitRowId.Value];
|
||||
}
|
||||
|
||||
if (item.MergeRowId != null && lesionRelationship.ContainsKey(item.MergeRowId.Value))
|
||||
{
|
||||
item.MergeRowId = lesionRelationship[item.MergeRowId.Value];
|
||||
}
|
||||
}
|
||||
|
||||
_ = _readingTaskQuestionMarkRepository.AddRangeAsync(readingTaskQuestionMarkList).Result;
|
||||
_ = _readingTableAnswerRowInfoRepository.AddRangeAsync(readingTableAnswerRowInfoList).Result;
|
||||
|
||||
|
||||
var noneMarkList = _readingNoneDicomMarkRepository.Where(x => x.VisitTaskId == origenalTask.Id).ToList();
|
||||
|
||||
var noneMarkBindingList = _readingNoneDicomMarkBindingRepository.Where(x => x.VisitTaskId == origenalTask.Id).ToList();
|
||||
|
||||
|
||||
foreach (var item in noneMarkList)
|
||||
{
|
||||
var newid = NewId.NextSequentialGuid();
|
||||
|
||||
item.MeasureData = item.MeasureData.Replace(origenalTask.Id.ToString(), newTask.Id.ToString());
|
||||
item.VisitTaskId = newTask.Id;
|
||||
foreach (var item1 in noneMarkBindingList)
|
||||
{
|
||||
if (item1.NoneDicomMarkId == item.Id)
|
||||
{
|
||||
item1.NoneDicomMarkId = newid;
|
||||
}
|
||||
}
|
||||
|
||||
item.Id = newid;
|
||||
}
|
||||
|
||||
|
||||
foreach (var item in noneMarkBindingList)
|
||||
{
|
||||
item.Id = NewId.NextSequentialGuid();
|
||||
item.VisitTaskId = newTask.Id;
|
||||
}
|
||||
|
||||
_ = _readingNoneDicomMarkRepository.AddRangeAsync(noneMarkList).Result;
|
||||
_ = _readingNoneDicomMarkBindingRepository.AddRangeAsync(noneMarkBindingList).Result;
|
||||
}
|
||||
|
||||
|
||||
@@ -2387,6 +2434,10 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
//另一个阅片人的任务根据任务进度自动进入PM退回或PM申请重阅
|
||||
filterExpression = filterExpression.And(t => t.VisitTaskNum >= task.VisitTaskNum);
|
||||
|
||||
//退回只影响有序的后续所有的,无序的当前访视
|
||||
filterExpression = filterExpression.And(t => (t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.InOrder) ||
|
||||
(t.TrialReadingCriterion.IsReadingTaskViewInOrder != ReadingOrder.InOrder && t.SourceSubjectVisitId == task.SourceSubjectVisitId));
|
||||
|
||||
|
||||
var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
|
||||
|
||||
@@ -2544,9 +2595,12 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
|
||||
//删除序列数据
|
||||
await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && t.SubjectVisitId == task.SourceSubjectVisitId);
|
||||
|
||||
otherVisitIdList = otherVisitIdList.Where(t => t != task.SourceSubjectVisitId.Value).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//BM后续访视 ,筛选状态不变,任务生成状态重置(实际该访视任务状态 可能是重阅重置了或者失效了,需要后续生成,或者取消分配了,需要后续重新分配)
|
||||
await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && otherVisitIdList.Contains(t.SubjectVisitId),
|
||||
t => new SubjectCriteriaEvaluationVisitFilter()
|
||||
@@ -2708,6 +2762,13 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
|
||||
//默认影响的都是该标准的任务
|
||||
filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId);
|
||||
}
|
||||
|
||||
//退回只影响有序的后续所有的,无序的当前访视
|
||||
if (isReReading == false)
|
||||
{
|
||||
filterExpression = filterExpression.And(t => (t.TrialReadingCriterion.IsReadingTaskViewInOrder == ReadingOrder.InOrder) ||
|
||||
(t.TrialReadingCriterion.IsReadingTaskViewInOrder != ReadingOrder.InOrder && t.SourceSubjectVisitId == filterObj.SourceSubjectVisitId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-28 06:22:47Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
|
||||
public class GetReSendEmailInDto : PageInput
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
|
||||
public DateTime? EmailStartDate { get; set; }
|
||||
|
||||
public DateTime? EmailEndDate { get; set; }
|
||||
|
||||
public EmailState? EmailStateEnum { get; set; }
|
||||
|
||||
public string ToRecipientName { get; set; } = string.Empty;
|
||||
|
||||
public string CcRecipientName { get; set; } = string.Empty;
|
||||
}
|
||||
public class EmailLogView : EmailLogAddOrEdit
|
||||
{
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
public List<EmailRecipientLogView> RecipientList { get; set; }
|
||||
|
||||
public List<EmaliAttachmentInfo> AttachmentList { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class EmaliAttachmentInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 附件名称
|
||||
/// </summary>
|
||||
public string AttachmentName { get; set; }
|
||||
/// <summary>
|
||||
/// 附件路径
|
||||
/// </summary>
|
||||
public string AttachmentPath { get; set; }
|
||||
}
|
||||
|
||||
public class EmailRecipientLogView
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮件Id
|
||||
/// </summary>
|
||||
public Guid EmailLogId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收件人姓名
|
||||
/// </summary>
|
||||
public string RecipientName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收件人地址
|
||||
/// </summary>
|
||||
public string RecipientAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收件人类型
|
||||
/// </summary>
|
||||
public RecipientType RecipientTypeEnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class EmailLogAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮件Id
|
||||
/// </summary>
|
||||
public string MessageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 唯一Id
|
||||
/// </summary>
|
||||
public string UniqueId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮件主题
|
||||
/// </summary>
|
||||
public string EmailSubject { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
public DateTime? EmailDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string ErrorInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发件人地址
|
||||
/// </summary>
|
||||
public string SenderAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发件人姓名
|
||||
/// </summary>
|
||||
public string SenderName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮件内容
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮件状态
|
||||
/// </summary>
|
||||
public EmailState EmailStateEnum { get; set; }
|
||||
}
|
||||
|
||||
public class GetEmailInfoOutDto:EmailLogView
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class GetEmailInfoInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid? TrialId { get; set; }
|
||||
}
|
||||
|
||||
public class SynchronizationEmailInDto
|
||||
{
|
||||
public Guid? TrialId { get; set; }
|
||||
}
|
||||
|
||||
public class ResendEmailInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid? TrialId { get; set; }
|
||||
}
|
||||
|
||||
public class EmailAuthorization
|
||||
{
|
||||
public string FromEmail { get; set; } = string.Empty;
|
||||
|
||||
public string AuthorizationCode { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class EmailLogQuery:PageInput
|
||||
{
|
||||
|
||||
public Guid? TrialId { get; set; }
|
||||
|
||||
public DateTime? EmailStartDate { get; set; }
|
||||
|
||||
public DateTime? EmailEndDate { get; set; }
|
||||
|
||||
public EmailState? EmailStateEnum { get; set; }
|
||||
|
||||
public string ToRecipientName { get; set; } = string.Empty;
|
||||
|
||||
public string CcRecipientName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -159,6 +159,12 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
public class FrontAuditConfigAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 适用的标准
|
||||
/// </summary>
|
||||
public List<CriterionType> ApplyCriterionList { get; set; } = new List<CriterionType>() { };
|
||||
|
||||
public string Value { get; set; } = string.Empty;
|
||||
public string ValueCN { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.Common.DTO
|
||||
{
|
||||
//public class MailModel
|
||||
//{
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,768 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-28 06:22:42Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using IdentityModel.Client;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using MailKit;
|
||||
using MailKit.Net.Imap;
|
||||
using MailKit.Search;
|
||||
using MailKit.Security;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
using Panda.DynamicWebApi.Attributes;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Threading.Tasks;
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
/// <summary>
|
||||
/// 邮件日志
|
||||
/// </summary>
|
||||
/// <param name="_emailLogRepository"></param>
|
||||
/// <param name="systemEmailConfig"></param>
|
||||
/// <param name="_mapper"></param>
|
||||
/// <param name="_userInfo"></param>
|
||||
/// <param name="_localizer"></param>
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
||||
IRepository<Trial> _trialRepository,
|
||||
IRepository<EmailAttachmentLog> _emailAttachmentLogRepository,
|
||||
IOSSService oSSService,
|
||||
IRepository<EmailReSendLog> _emailReSendLog,
|
||||
|
||||
IRepository<EmailRecipientLog> _emailRecipientLogRepository,
|
||||
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IEmailLogService
|
||||
{
|
||||
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
||||
|
||||
/// <summary>
|
||||
/// 获取邮件日志列表
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<EmailLogView>> GetEmailLogList(EmailLogQuery inDto)
|
||||
{
|
||||
var emailFromName = await _trialRepository.Where(x=>x.Id==inDto.TrialId).Select(x=>x.EmailFromName).FirstOrDefaultAsync();
|
||||
|
||||
if (emailFromName.IsNullOrEmpty())
|
||||
{
|
||||
emailFromName = _systemEmailConfig.FromName;
|
||||
}
|
||||
var emailLogQueryable = _emailLogRepository
|
||||
.Where(x=>x.SenderName== emailFromName)
|
||||
.WhereIf(inDto.EmailStartDate.HasValue, x => x.EmailDate >= inDto.EmailStartDate.Value)
|
||||
.WhereIf(inDto.EmailEndDate.HasValue, x => x.EmailDate <= inDto.EmailEndDate.Value)
|
||||
.WhereIf(inDto.EmailStateEnum.HasValue, x => x.EmailStateEnum == inDto.EmailStateEnum.Value)
|
||||
.WhereIf(inDto.CcRecipientName.IsNotNullOrEmpty(),x=>x.EmailRecipientLogList.Any(x=>x.RecipientTypeEnum==RecipientType.Cc&&x.RecipientName.Contains(inDto.CcRecipientName)))
|
||||
.WhereIf(inDto.ToRecipientName.IsNotNullOrEmpty(), x => x.EmailRecipientLogList.Any(x => x.RecipientTypeEnum == RecipientType.To && x.RecipientName.Contains(inDto.ToRecipientName)))
|
||||
.ProjectTo<EmailLogView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var defalutSortArray = new string[] { nameof(EmailLogView.EmailDate) + " desc" };
|
||||
var pageList = await emailLogQueryable.ToPagedListAsync(inDto, defalutSortArray);
|
||||
|
||||
return pageList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取重发信息
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<EmailLogView>> GetReSendEmail(GetReSendEmailInDto inDto)
|
||||
{
|
||||
var messageId = await _emailLogRepository.Where(x => x.Id == inDto.Id).Select(x => x.MessageId).FirstOrDefaultAsync();
|
||||
|
||||
var reSendMessagelist = await _emailReSendLog.Where(x => x.MainMailMessageId == messageId).Select(x => x.ReMailMessageId).ToListAsync();
|
||||
var emailLogQueryable = _emailLogRepository
|
||||
|
||||
.Where(x => reSendMessagelist.Contains(x.MessageId))
|
||||
.WhereIf(inDto.EmailStartDate.HasValue, x => x.EmailDate >= inDto.EmailStartDate.Value)
|
||||
.WhereIf(inDto.EmailEndDate.HasValue, x => x.EmailDate <= inDto.EmailEndDate.Value)
|
||||
.WhereIf(inDto.EmailStateEnum.HasValue, x => x.EmailStateEnum == inDto.EmailStateEnum.Value)
|
||||
.WhereIf(inDto.CcRecipientName.IsNotNullOrEmpty(), x => x.EmailRecipientLogList.Any(x => x.RecipientTypeEnum == RecipientType.Cc && x.RecipientName.Contains(inDto.CcRecipientName)))
|
||||
.WhereIf(inDto.ToRecipientName.IsNotNullOrEmpty(), x => x.EmailRecipientLogList.Any(x => x.RecipientTypeEnum == RecipientType.To && x.RecipientName.Contains(inDto.ToRecipientName)))
|
||||
.ProjectTo<EmailLogView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var defalutSortArray = new string[] { nameof(EmailLogView.EmailDate) + " desc" };
|
||||
var pageList = await emailLogQueryable.ToPagedListAsync(inDto, defalutSortArray);
|
||||
|
||||
return pageList;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取单条邮件日志详情
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<GetEmailInfoOutDto> GetEmailInfo(GetEmailInfoInDto inDto)
|
||||
{
|
||||
|
||||
var emailInfo=await _emailLogRepository
|
||||
.Where(x => x.Id == inDto.Id).Include(x=>x.EmailRecipientLogList)
|
||||
.ProjectTo<GetEmailInfoOutDto>(_mapper.ConfigurationProvider).AsNoTracking()
|
||||
.FirstNotNullAsync();
|
||||
|
||||
if (emailInfo.UniqueId.IsNotNullOrEmpty())
|
||||
{
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
await AuthenticateImap(client,inDto.TrialId);
|
||||
var sentFolder = OpenSentFolder(client);
|
||||
var uid = new UniqueId(uint.Parse(emailInfo.UniqueId));
|
||||
var message = sentFolder.GetMessage(uid);
|
||||
emailInfo.Content = message.HtmlBody ?? message.TextBody ?? string.Empty;
|
||||
|
||||
|
||||
if (emailInfo.AttachmentList.Count == 0)
|
||||
{
|
||||
List< EmaliAttachmentInfo > attachmentInfos = new List<EmaliAttachmentInfo>();
|
||||
foreach (var att in message.Attachments)
|
||||
{
|
||||
EmaliAttachmentInfo emaliAttachmentInfo = new EmaliAttachmentInfo();
|
||||
emaliAttachmentInfo.AttachmentName = att.ContentDisposition?.FileName ?? att.ContentType.Name ?? "unknown";
|
||||
|
||||
// 2. 解码后的流直接上传,不落盘
|
||||
if (att is MimePart part)
|
||||
{
|
||||
// 重要:每次上传新建一个独立流,否则迭代过程中流位置会乱
|
||||
await using var decodeStream = new MemoryStream();
|
||||
await part.Content.DecodeToAsync(decodeStream);
|
||||
decodeStream.Position = 0;
|
||||
|
||||
|
||||
emaliAttachmentInfo.AttachmentPath = await oSSService.UploadToOSSAsync(
|
||||
fileStream: decodeStream,
|
||||
oosFolderPath: $"EmailAttachment/{emailInfo.Id}", // OSS 虚拟目录
|
||||
fileRealName: emaliAttachmentInfo.AttachmentName,
|
||||
isFileNameAddGuid: true); // 让方法自己在文件名前加 Guid
|
||||
|
||||
attachmentInfos.Add(emaliAttachmentInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<EmailAttachmentLog> emailAttachmentLog = attachmentInfos.Select(x => new EmailAttachmentLog()
|
||||
{
|
||||
EmailLogId = emailInfo.Id.Value,
|
||||
AttachmentName = x.AttachmentName,
|
||||
AttachmentPath = x.AttachmentPath,
|
||||
}).ToList();
|
||||
|
||||
await _emailAttachmentLogRepository.AddRangeAsync(emailAttachmentLog);
|
||||
await _emailAttachmentLogRepository.SaveChangesAsync();
|
||||
|
||||
emailInfo.AttachmentList = attachmentInfos;
|
||||
}
|
||||
|
||||
|
||||
sentFolder.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, $"{trialId.ToString()}/InspectionUpload/DataReconciliation", realFileName);
|
||||
|
||||
return emailInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重发邮件
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> ResendEmail(ResendEmailInDto inDto)
|
||||
{
|
||||
var emailInfo = await _emailLogRepository
|
||||
.Where(x => x.Id == inDto.Id)
|
||||
.ProjectTo<GetEmailInfoOutDto>(_mapper.ConfigurationProvider)
|
||||
.FirstNotNullAsync();
|
||||
|
||||
if (emailInfo.UniqueId.IsNotNullOrEmpty())
|
||||
{
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
await AuthenticateImap(client,inDto.TrialId);
|
||||
var sentFolder = OpenSentFolder(client);
|
||||
var uid = new UniqueId(uint.Parse(emailInfo.UniqueId));
|
||||
var message = sentFolder.GetMessage(uid);
|
||||
emailInfo.Content = message.HtmlBody ?? message.TextBody ?? string.Empty;
|
||||
sentFolder.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
// 发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(emailInfo.SenderName, emailInfo.SenderAddress));
|
||||
|
||||
foreach (var item in emailInfo.RecipientList.Where(x => x.RecipientTypeEnum == RecipientType.To))
|
||||
{
|
||||
messageToSend.To.Add(new MailboxAddress(item.RecipientName, item.RecipientAddress));
|
||||
}
|
||||
foreach (var item in emailInfo.RecipientList.Where(x => x.RecipientTypeEnum == RecipientType.Cc))
|
||||
{
|
||||
messageToSend.Cc.Add(new MailboxAddress(item.RecipientName, item.RecipientAddress));
|
||||
}
|
||||
|
||||
|
||||
messageToSend.Subject = emailInfo.EmailSubject;
|
||||
|
||||
var builder = new BodyBuilder();
|
||||
|
||||
builder.HtmlBody = emailInfo.Content;
|
||||
|
||||
messageToSend.Body = builder.ToMessageBody();
|
||||
|
||||
SystemEmailSendConfig sendConfig = new SystemEmailSendConfig()
|
||||
{
|
||||
};
|
||||
|
||||
if (inDto.TrialId != null)
|
||||
{
|
||||
sendConfig = await _trialRepository.Where(x => x.Id == inDto.TrialId.Value).Select(x => new SystemEmailSendConfig()
|
||||
{
|
||||
Host = _systemEmailConfig.Host,
|
||||
Port = _systemEmailConfig.Port,
|
||||
FromEmail = x.EmailFromEmail,
|
||||
AuthorizationCode = x.EmailAuthorizationCode
|
||||
}).FirstNotNullAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sendConfig = _systemEmailConfig;
|
||||
}
|
||||
|
||||
var msgid= await SendEmailHelper.SendEmailAsync(messageToSend, sendConfig);
|
||||
|
||||
|
||||
await _emailReSendLog.AddAsync(new EmailReSendLog()
|
||||
{
|
||||
MainMailMessageId= emailInfo.MessageId,
|
||||
ReMailMessageId= msgid
|
||||
});
|
||||
|
||||
await _emailReSendLog.SaveChangesAsync();
|
||||
|
||||
await SynchronizationEmail(new SynchronizationEmailInDto() {
|
||||
|
||||
TrialId= inDto.TrialId
|
||||
});
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步邮件
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SynchronizationEmail(SynchronizationEmailInDto inDto)
|
||||
{
|
||||
|
||||
var fromEmail = _systemEmailConfig.FromEmail;
|
||||
|
||||
|
||||
if (inDto.TrialId != null)
|
||||
{
|
||||
fromEmail= await _trialRepository.Where(x => x.Id == inDto.TrialId.Value).Select(x => x.EmailFromEmail).FirstNotNullAsync();
|
||||
|
||||
}
|
||||
|
||||
var maxTime = await _emailLogRepository.Where(x=>x.SenderAddress== fromEmail).MaxAsync(t => t.EmailDate);
|
||||
var startDate = maxTime ?? DateTime.MinValue;
|
||||
List<EmailLog> emailList = new List<EmailLog>();
|
||||
List<EmailRecipientLog> EmailRecipientLogList = new List<EmailRecipientLog>();
|
||||
|
||||
// 第一步:同步发件箱邮件
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
await AuthenticateImap(client, inDto.TrialId);
|
||||
var sentFolder = OpenSentFolder(client);
|
||||
|
||||
var searchQuery = SearchQuery.All.And(SearchQuery.DeliveredAfter(startDate));
|
||||
var uids = sentFolder.Search(searchQuery).ToList();
|
||||
|
||||
foreach (var uid in uids)
|
||||
{
|
||||
try
|
||||
{
|
||||
var message = sentFolder.GetMessage(uid);
|
||||
if (message.Date.DateTime <= startDate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var emaillog = new EmailLog
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
UniqueId = uid.ToString(),
|
||||
MessageId = message.MessageId ?? string.Empty,
|
||||
EmailSubject = message.Subject ?? string.Empty,
|
||||
EmailDate = message.Date.DateTime,
|
||||
EmailStateEnum = EmailState.Success,
|
||||
};
|
||||
|
||||
var fromMailbox = message.From.Mailboxes.FirstOrDefault();
|
||||
if (fromMailbox != null)
|
||||
{
|
||||
emaillog.SenderAddress = fromMailbox.Address;
|
||||
emaillog.SenderName = fromMailbox.Name ?? string.Empty;
|
||||
}
|
||||
|
||||
List<EmailRecipientLog> recipientLogs = new List<EmailRecipientLog>();
|
||||
|
||||
int sort = 0;
|
||||
message.To.Mailboxes.ForEach(x =>
|
||||
{
|
||||
recipientLogs.Add(new EmailRecipientLog()
|
||||
{
|
||||
RecipientName = x.Name ?? string.Empty,
|
||||
RecipientAddress = x.Address,
|
||||
EmailLogId = emaillog.Id,
|
||||
RecipientTypeEnum = RecipientType.To,
|
||||
Sort = sort++,
|
||||
});
|
||||
});
|
||||
sort = 0;
|
||||
message.Cc.Mailboxes.ForEach(x =>
|
||||
{
|
||||
recipientLogs.Add(new EmailRecipientLog()
|
||||
{
|
||||
RecipientName = x.Name ?? string.Empty,
|
||||
RecipientAddress = x.Address,
|
||||
EmailLogId = emaillog.Id,
|
||||
RecipientTypeEnum = RecipientType.Cc,
|
||||
Sort = sort++,
|
||||
});
|
||||
});
|
||||
emailList.Add(emaillog);
|
||||
EmailRecipientLogList.AddRange(recipientLogs);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"处理邮件 {uid} 失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
sentFolder.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"同步发件箱邮件时出错: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存同步的发件箱邮件
|
||||
await _emailLogRepository.AddRangeAsync(emailList);
|
||||
await _emailRecipientLogRepository.AddRangeAsync(EmailRecipientLogList);
|
||||
await _emailLogRepository.SaveChangesAsync();
|
||||
|
||||
// 第二步:处理收件箱中的邮件发送失败通知
|
||||
try
|
||||
{
|
||||
await ProcessInboxFailureNotifications(startDate,inDto.TrialId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"处理收件箱失败通知邮件时出错: {ex.Message}");
|
||||
Console.WriteLine($"异常堆栈: {ex.StackTrace}");
|
||||
// 即使处理失败通知邮件出错,也不影响整体同步操作的成功
|
||||
// 记录警告但不中断主流程
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
private IMailFolder OpenSentFolder(ImapClient client)
|
||||
{
|
||||
IMailFolder folder = null;
|
||||
try
|
||||
{
|
||||
folder = client.GetFolder(SpecialFolder.Sent);
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (folder == null)
|
||||
{
|
||||
var candidates = new[] { "已发送", "已发送邮件", "Sent", "Sent Items", "[Gmail]/Sent Mail" };
|
||||
foreach (var name in candidates)
|
||||
{
|
||||
try
|
||||
{
|
||||
var f = client.GetFolder(name);
|
||||
if (f != null)
|
||||
{
|
||||
folder = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
if (folder == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var personal = client.GetFolder(client.PersonalNamespaces.FirstOrDefault());
|
||||
if (personal != null)
|
||||
{
|
||||
foreach (var sub in personal.GetSubfolders(false))
|
||||
{
|
||||
if (string.Equals(sub.FullName, "Sent", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(sub.FullName, "Sent Items", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
folder = sub;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (folder == null)
|
||||
throw new InvalidOperationException("未找到已发送文件夹");
|
||||
|
||||
folder.Open(FolderAccess.ReadOnly);
|
||||
return folder;
|
||||
}
|
||||
|
||||
private IMailFolder OpenInboxFolder(ImapClient client)
|
||||
{
|
||||
IMailFolder folder = null;
|
||||
try
|
||||
{
|
||||
folder = client.GetFolder(SpecialFolder.All);
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (folder == null)
|
||||
{
|
||||
var candidates = new[] { "收件箱", "Inbox" };
|
||||
foreach (var name in candidates)
|
||||
{
|
||||
try
|
||||
{
|
||||
var f = client.GetFolder(name);
|
||||
if (f != null)
|
||||
{
|
||||
folder = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
if (folder == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var personal = client.GetFolder(client.PersonalNamespaces.FirstOrDefault());
|
||||
if (personal != null)
|
||||
{
|
||||
foreach (var sub in personal.GetSubfolders(false))
|
||||
{
|
||||
if (string.Equals(sub.FullName, "Inbox", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
folder = sub;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (folder == null)
|
||||
throw new InvalidOperationException("未找到收件箱文件夹");
|
||||
|
||||
folder.Open(FolderAccess.ReadOnly);
|
||||
return folder;
|
||||
}
|
||||
|
||||
private async Task AuthenticateImap(ImapClient client, Guid? trialId)
|
||||
{
|
||||
try
|
||||
{
|
||||
EmailAuthorization authorization = new EmailAuthorization()
|
||||
{
|
||||
FromEmail = _systemEmailConfig.FromEmail,
|
||||
AuthorizationCode = _systemEmailConfig.AuthorizationCode,
|
||||
};
|
||||
|
||||
if (trialId != null)
|
||||
{
|
||||
authorization = await _trialRepository.Where(x => x.Id == trialId.Value).Select(x => new EmailAuthorization()
|
||||
{
|
||||
AuthorizationCode = x.EmailAuthorizationCode,
|
||||
FromEmail = x.EmailFromEmail
|
||||
}).FirstNotNullAsync();
|
||||
}
|
||||
|
||||
client.Connect(_systemEmailConfig.Imap, _systemEmailConfig.ImapPort, SecureSocketOptions.SslOnConnect);
|
||||
client.Authenticate(authorization.FromEmail, authorization.AuthorizationCode);
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{
|
||||
//if (_systemEmailConfig.UseOAuth2 && _systemEmailConfig.OAuth2AccessToken.IsNotNullOrEmpty())
|
||||
//{
|
||||
// var sasl = new SaslMechanismOAuth2(_systemEmailConfig.FromEmail, _systemEmailConfig.OAuth2AccessToken);
|
||||
// client.Authenticate(sasl);
|
||||
// return;
|
||||
//}
|
||||
//if (_systemEmailConfig.OAuth2AccessToken.IsNullOrEmpty())
|
||||
//{
|
||||
// var token = AcquireOAuth2TokenByPassword();
|
||||
// if (token.IsNotNullOrEmpty())
|
||||
// {
|
||||
// _systemEmailConfig.OAuth2AccessToken = token;
|
||||
// var sasl = new SaslMechanismOAuth2(_systemEmailConfig.FromEmail, token);
|
||||
// client.Authenticate(sasl);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理收件箱中的邮件发送失败通知
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task ProcessInboxFailureNotifications(DateTime startTime, Guid? trialId)
|
||||
{
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
await AuthenticateImap(client, trialId);
|
||||
var inboxFolder = OpenInboxFolder(client);
|
||||
|
||||
// 搜索可能包含失败通知的邮件
|
||||
// 通常失败通知邮件会包含"失败"、"错误"、"undeliverable"、"delivery failed"等关键词
|
||||
var searchQuery = SearchQuery.All.Or(SearchQuery.SubjectContains("失败"))
|
||||
.Or(SearchQuery.SubjectContains("错误"))
|
||||
.Or(SearchQuery.SubjectContains("undeliverable"))
|
||||
.Or(SearchQuery.SubjectContains("delivery failed"))
|
||||
.Or(SearchQuery.SubjectContains("Delivery Status Notification"))
|
||||
.Or(SearchQuery.BodyContains("失败"))
|
||||
.Or(SearchQuery.BodyContains("错误"))
|
||||
.Or(SearchQuery.BodyContains("undeliverable"))
|
||||
.Or(SearchQuery.BodyContains("delivery failed")).And(SearchQuery.DeliveredAfter(startTime));
|
||||
|
||||
var uids = inboxFolder.Search(searchQuery).ToList();
|
||||
var processedCount = 0;
|
||||
var updatedCount = 0;
|
||||
|
||||
foreach (var uid in uids)
|
||||
{
|
||||
try
|
||||
{
|
||||
var message = inboxFolder.GetMessage(uid);
|
||||
|
||||
// 尝试从邮件内容中提取原始邮件的Message-Id或相关信息
|
||||
var originalMessageId = ExtractOriginalMessageId(message);
|
||||
if (!string.IsNullOrEmpty(originalMessageId))
|
||||
{
|
||||
// 查找对应的EmailLog记录
|
||||
var emailLog = await _emailLogRepository
|
||||
.Where(x => x.MessageId == originalMessageId)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
await _emailLogRepository.BatchUpdateNoTrackingAsync(x => x.MessageId == originalMessageId, x => new EmailLog()
|
||||
{
|
||||
EmailStateEnum = EmailState.Error,
|
||||
ErrorInfo = message.TextBody
|
||||
|
||||
});
|
||||
|
||||
updatedCount++;
|
||||
}
|
||||
|
||||
processedCount++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inboxFolder.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"连接收件箱处理失败通知邮件时出错: {ex.Message}");
|
||||
Console.WriteLine($"异常堆栈: {ex.StackTrace}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"断开IMAP客户端连接时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从失败通知邮件中提取原始邮件的Message-Id
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
private string ExtractOriginalMessageId(MimeMessage message)
|
||||
{
|
||||
// 首先检查邮件头中是否有原始Message-Id
|
||||
var originalMessageId = message.Headers["Original-Message-ID"] ??
|
||||
message.Headers["X-Original-Message-ID"] ??
|
||||
message.Headers["In-Reply-To"];
|
||||
|
||||
if (!string.IsNullOrEmpty(originalMessageId))
|
||||
{
|
||||
// 清理Message-Id格式(移除尖括号)
|
||||
originalMessageId = originalMessageId.Trim('<', '>');
|
||||
return originalMessageId;
|
||||
}
|
||||
|
||||
// 检查邮件附件中是否包含.eml文件(这是最常见的失败通知格式)
|
||||
foreach (var attachment in message.Attachments)
|
||||
{
|
||||
if (attachment is MessagePart messagePart)
|
||||
{
|
||||
// 直接获取嵌入的邮件消息
|
||||
var originalMessageIdFromAttachment = messagePart.Message?.MessageId;
|
||||
if (!string.IsNullOrEmpty(originalMessageIdFromAttachment))
|
||||
{
|
||||
return originalMessageIdFromAttachment.Trim('<', '>');
|
||||
}
|
||||
}
|
||||
else if (attachment is MimePart mimePart)
|
||||
{
|
||||
// 检查文件扩展名是否为.eml
|
||||
var fileName = mimePart.FileName ?? mimePart.ContentType.Name;
|
||||
if (!string.IsNullOrEmpty(fileName) &&
|
||||
(fileName.EndsWith(".eml", StringComparison.OrdinalIgnoreCase) ||
|
||||
mimePart.ContentType.MimeType.Equals("message/rfc822", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
try
|
||||
{
|
||||
// 解析.eml附件内容
|
||||
using var memoryStream = new MemoryStream();
|
||||
mimePart.Content.DecodeTo(memoryStream);
|
||||
memoryStream.Position = 0;
|
||||
|
||||
var originalMessage = MimeMessage.Load(memoryStream);
|
||||
if (!string.IsNullOrEmpty(originalMessage?.MessageId))
|
||||
{
|
||||
return originalMessage.MessageId.Trim('<', '>');
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"解析.eml附件时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果邮件头和附件中都没有,尝试从邮件正文中提取
|
||||
var content = message.HtmlBody ?? message.TextBody ?? string.Empty;
|
||||
|
||||
// 尝试匹配常见的Message-Id格式
|
||||
var messageIdPattern = @"(?:Message-ID|Message-Id|message-id):\s*<?([^>\s]+)>?";
|
||||
var match = System.Text.RegularExpressions.Regex.Match(content, messageIdPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
if (match.Success)
|
||||
{
|
||||
return match.Groups[1].Value;
|
||||
}
|
||||
|
||||
// 尝试从邮件引用部分提取
|
||||
var referencePattern = @"^>.*Message-ID:\s*<?([^>\s]+)>?";
|
||||
var matches = System.Text.RegularExpressions.Regex.Matches(content, referencePattern, System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
if (matches.Count > 0)
|
||||
{
|
||||
return matches[0].Groups[1].Value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateEmailLog(EmailLogAddOrEdit addOrEditEmailLog)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var entity = await _emailLogRepository.InsertOrUpdateAsync(addOrEditEmailLog, true);
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpDelete("{emailLogId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteEmailLog(Guid emailLogId)
|
||||
{
|
||||
var success = await _emailLogRepository.DeleteFromQueryAsync(t => t.Id == emailLogId,true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,18 @@
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MailKit;
|
||||
using MailKit.Net.Imap;
|
||||
using MailKit.Search;
|
||||
using MailKit.Security;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -17,8 +26,75 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class EmailNoticeConfigService(IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
||||
IRepository<EmailNoticeUserType> _emailNoticeUserTypeRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IEmailNoticeConfigService
|
||||
IRepository<EmailNoticeUserType> _emailNoticeUserTypeRepository,
|
||||
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IEmailNoticeConfigService
|
||||
{
|
||||
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
||||
|
||||
/// <summary>
|
||||
/// 获取邮件列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<object> GetEmailList()
|
||||
{
|
||||
|
||||
List<IMessageSummary> emailList = new List<IMessageSummary>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// 连接阿里邮箱 IMAP 服务器(使用 SSL)
|
||||
client.Connect(_systemEmailConfig.Imap, 993, SecureSocketOptions.SslOnConnect);
|
||||
|
||||
// 登录
|
||||
client.Authenticate(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode);
|
||||
|
||||
// 3. 获取发件箱文件夹 - 使用你找到的“已发送”
|
||||
var sentFolder = client.GetFolder("已发送");
|
||||
sentFolder.Open(FolderAccess.ReadOnly);
|
||||
|
||||
// 4. 搜索所有邮件(你可以在这里添加更精确的搜索条件)
|
||||
var uids = sentFolder.Search(SearchQuery.All);
|
||||
Console.WriteLine($"找到 {uids.Count} 封已发送邮件");
|
||||
|
||||
// 5. 遍历并处理邮件(示例中处理前10封)
|
||||
foreach (var uid in uids.Take(10))
|
||||
{
|
||||
var message = sentFolder.GetMessage(uid);
|
||||
|
||||
// 输出邮件基本信息
|
||||
Console.WriteLine($"主题: {message.Subject}");
|
||||
Console.WriteLine($"收件人: {string.Join(", ", message.To.Mailboxes.Select(m => m.Address))}");
|
||||
Console.WriteLine($"日期: {message.Date.LocalDateTime:yyyy-MM-dd HH:mm:ss}");
|
||||
Console.WriteLine($"发件人: {message.From}");
|
||||
Console.WriteLine("----------------------------------");
|
||||
}
|
||||
|
||||
sentFolder.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"操作失败: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<EmailNoticeConfigView>> GetEmailNoticeConfigList(EmailNoticeConfigQuery inQuery)
|
||||
|
||||
@@ -125,7 +125,23 @@ public class TumorExportBaseModel : TU_TR_RSBaseModel
|
||||
public string VisitNote { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 肿瘤学结果
|
||||
|
||||
|
||||
public List<OncologyExportInfo> OncologyResultList { get; set; }
|
||||
|
||||
//public string OncologyUserName { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class OncologyExportInfo
|
||||
{
|
||||
public decimal? VisitTaskNum { get; set; }
|
||||
public string VisitName { get; set; }
|
||||
public string OncologyResult { get; set; } = string.Empty;
|
||||
|
||||
public string OncologyReason { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+438
-14
@@ -22,6 +22,8 @@ using System.ComponentModel.Design;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using static IRaCIS.Core.Application.Service.ExcelExportHelper;
|
||||
using IDictionaryService = IRaCIS.Application.Interfaces.IDictionaryService;
|
||||
using TrialIdentityUser = IRaCIS.Core.Domain.Models.TrialIdentityUser;
|
||||
@@ -32,6 +34,8 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class ExcelExportService(IRepository<TrialUserRole> _trialUserRoleRepository,
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IRepository<Internationalization> _internationalizationRepository,
|
||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
||||
IRepository<SystemDocNeedConfirmedUserType> _systemDocNeedConfirmedUserTypeRepository,
|
||||
IRepository<DicomStudy> _dicomStudyRepository,
|
||||
@@ -467,7 +471,10 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName))
|
||||
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.IsDeleted == false) && t.IsDeleted == false)
|
||||
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP,
|
||||
t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.IsDeleted == false
|
||||
&& t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false))
|
||||
&& t.IsDeleted == false)
|
||||
.WhereIf(inQuery.CriterionType != null, o => o.TrialReadingCriterionList.Any(t => t.CriterionType == inQuery.CriterionType && t.IsSigned && t.IsConfirm))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserRoleList.Any(t => t.UserRole.IdentityUser.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM)))
|
||||
.Select(t => new TrialToBeDoneDto()
|
||||
@@ -1619,6 +1626,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
|
||||
exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId);
|
||||
|
||||
|
||||
if (inQuery.IsRandomOrderList == true)
|
||||
{
|
||||
list = list.OrderBy(t => t.RandomOrder).ToList();
|
||||
@@ -1757,6 +1765,80 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
var list = taskMedicalReviewQueryable.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitTaskNum).ToList();
|
||||
|
||||
|
||||
#region 处理翻译对话 by he wen tao
|
||||
|
||||
Dictionary<string, string> i18NKeys = new Dictionary<string, string>()
|
||||
{
|
||||
{ "Msg1","trials:medicalFeedback:message:msg1"},
|
||||
{ "Msg2","trials:medicalFeedback:message:msg2"},
|
||||
{ "Msg3","trials:medicalFeedback:message:msg3"},
|
||||
{ "Msg4", "trials:medicalFeedback:message:msg4"},
|
||||
{ "Msg5", "trials:medicalFeedback:message:msg5"},
|
||||
{ "CloseReasonEnum", "trials:medicalFeedback:title:closeReasonEnum"},
|
||||
{ "IsEndorse", "trials:medicalFeedback:title:isEndorse"},
|
||||
{ "Reason", "trials:medicalFeedback:title:reason"},
|
||||
{ "IsRequestReread", "trials:medicalFeedback:title:isRequestReread"},
|
||||
};
|
||||
|
||||
var i18Values = i18NKeys.Select(x => x.Value).ToList();
|
||||
var i18nList = await _internationalizationRepository.Where(x => i18Values.Contains(x.Code))
|
||||
.Select(x => new
|
||||
{
|
||||
Code = x.Code,
|
||||
Value = _userInfo.IsEn_Us ? x.Value : x.ValueCN
|
||||
}).ToListAsync();
|
||||
|
||||
List<string> dictionaryCodeList = new List<string>()
|
||||
{
|
||||
"AuditAdvice",
|
||||
"MedicalDialogCloseEnum",
|
||||
"MedicalReviewDoctorUserIdea",
|
||||
"YesOrNo",
|
||||
};
|
||||
|
||||
var dictionadParents = await _dictionaryRepository.Where(x => dictionaryCodeList.Contains(x.Parent.Code))
|
||||
.Select(x => new
|
||||
{
|
||||
ParentCode = x.Parent.Code,
|
||||
Code = x.Code,
|
||||
Value = _userInfo.IsEn_Us ? x.Value : x.ValueCN
|
||||
}).ToListAsync();
|
||||
|
||||
JointMedicalReviewI18n i18N = new JointMedicalReviewI18n() { };
|
||||
foreach (var kv in i18NKeys)
|
||||
{
|
||||
PropertyInfo? pi = i18N.GetType().GetProperty(kv.Key);
|
||||
if (pi != null && pi.CanWrite)
|
||||
{
|
||||
var value = i18nList.Where(x => x.Code == kv.Value).Select(x => x.Value).FirstOrDefault() ?? string.Empty;
|
||||
object safeValue = Convert.ChangeType(value, pi.PropertyType);
|
||||
pi.SetValue(i18N, safeValue);
|
||||
}
|
||||
}
|
||||
foreach (var item in dictionaryCodeList)
|
||||
{
|
||||
PropertyInfo? pi = i18N.GetType().GetProperty(item);
|
||||
if (pi != null && pi.CanWrite)
|
||||
{
|
||||
var value = dictionadParents.Where(x => x.ParentCode == item).ToDictionary(x => x.Code, x => x.Value);
|
||||
object safeValue = Convert.ChangeType(value, pi.PropertyType);
|
||||
pi.SetValue(i18N, safeValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
foreach (var dialog in item.DialogList)
|
||||
{
|
||||
dialog.ResultContent = JointMedicalReviewDialog(dialog, i18N);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo<ExcelExportInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId);
|
||||
@@ -1766,6 +1848,88 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialMedicalReviewList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(TaskMedicalReviewExportDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取医学审核对话拼接内容
|
||||
/// </summary>
|
||||
/// <param name="record"></param>
|
||||
/// <param name="i18NAndDic"></param>
|
||||
/// <returns></returns>
|
||||
private string JointMedicalReviewDialog(GetMedicalReviewDialogOutDto record, JointMedicalReviewI18n i18NAndDic)
|
||||
{
|
||||
StringBuilder str = new StringBuilder() { };
|
||||
var userTypes = new List<int>() { 14, 30 };
|
||||
|
||||
// 这里userTypes.Contains(record.UserTypeEnumInt) 可以提出来 但是还是按照前端写吧 免得不好对照
|
||||
|
||||
// v-if="[14, 30].includes(record.UserTypeEnumInt) && record.Questioning
|
||||
if (userTypes.Contains(record.UserTypeEnumInt) && record.Questioning.IsNotNullOrEmpty())
|
||||
{
|
||||
// <!-- 您好,根据医学审核反馈,该阅片任务的评估有如下问题需要您确认或澄清: -->
|
||||
str.AppendLine(i18NAndDic.Msg1);
|
||||
|
||||
str.AppendLine(record.Questioning);
|
||||
|
||||
if (record.FileList.Count() > 0)
|
||||
{
|
||||
str.AppendLine(i18NAndDic.Msg2);
|
||||
record.FileList.ForEach(x =>
|
||||
{
|
||||
str.AppendLine(x.FileName);
|
||||
});
|
||||
}
|
||||
|
||||
str.AppendLine(i18NAndDic.Msg3);
|
||||
|
||||
str.AppendLine(i18NAndDic.AuditAdvice[record.AuditAdviceEnum.GetEnumInt()]);
|
||||
|
||||
str.AppendLine(i18NAndDic.Msg4);
|
||||
}
|
||||
|
||||
//v-if="[14, 30].includes(record.UserTypeEnumInt) && record.MedicalDialogCloseEnum!== null"
|
||||
if (userTypes.Contains(record.UserTypeEnumInt) && record.MedicalDialogCloseEnum != null)
|
||||
{
|
||||
str.AppendLine(i18NAndDic.CloseReasonEnum + i18NAndDic.MedicalDialogCloseEnum[record.MedicalDialogCloseEnum.Value.GetEnumInt()]);
|
||||
}
|
||||
|
||||
// v-if="[14, 30].includes(record.UserTypeEnumInt) && record.Content
|
||||
if (userTypes.Contains(record.UserTypeEnumInt) && record.Content.IsNotNullOrEmpty())
|
||||
{
|
||||
str.AppendLine(record.Content);
|
||||
}
|
||||
|
||||
// v-if="[13].includes(record.UserTypeEnumInt)"
|
||||
|
||||
if (13 == record.UserTypeEnumInt)
|
||||
{
|
||||
str.AppendLine(i18NAndDic.IsEndorse + i18NAndDic.MedicalReviewDoctorUserIdea[record.DoctorUserIdeaEnum.GetEnumInt()]);
|
||||
|
||||
// v-if="record.DoctorUserIdeaEnum===2"
|
||||
if ((int)record.DoctorUserIdeaEnum == 2)
|
||||
{
|
||||
str.AppendLine(i18NAndDic.Reason + record.DisagreeReason);
|
||||
}
|
||||
|
||||
// record.MedicalDialogCloseEnum!== null
|
||||
|
||||
if (record.MedicalDialogCloseEnum != null)
|
||||
{
|
||||
str.AppendLine(i18NAndDic.IsRequestReread + i18NAndDic.YesOrNo[record.IsApplyHeavyReading.ToString()]);
|
||||
}
|
||||
|
||||
// v-if="record.FileList && record.FileList.length > 0"
|
||||
|
||||
if (record.FileList.Count() > 0)
|
||||
{
|
||||
record.FileList.ForEach(x =>
|
||||
{
|
||||
str.AppendLine(x.FileName);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return str.ToString();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 影像下载记录表
|
||||
@@ -2310,8 +2474,263 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
|
||||
#region 通用阅片结果导出
|
||||
|
||||
/// <summary>
|
||||
/// 一致性分析结果导出 7 8 分别是自身 和组件一致性
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <param name="_commonDocumentRepository"></param>
|
||||
/// <param name="_dictionaryService"></param>
|
||||
/// <param name="_trialRepository"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> GetAnalysisTaskList_Export(VisitTaskQuery inQuery,
|
||||
[FromServices] IRepository<CommonDocument> _commonDocumentRepository,
|
||||
[FromServices] IDictionaryService _dictionaryService,
|
||||
[FromServices] IRepository<Trial> _trialRepository)
|
||||
{
|
||||
//每次查询必须是单标准的
|
||||
var criterion = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId).Select(t => new { t.CriterionType, t.CriterionName, t.ArbitrationRule }).FirstNotNullAsync();
|
||||
|
||||
|
||||
var query = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.TaskAllocationState == TaskAllocationState.Allocated && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze))
|
||||
|
||||
//一致性分析
|
||||
.WhereIf(inQuery.ReadingExportType == ExportResult.DetailedTableOfIntraReaderAnalysisResults, t => t.IsSelfAnalysis == true || t.IsSelfAnalysis == null)
|
||||
.WhereIf(inQuery.ReadingExportType == ExportResult.DetailedTableOfIntraReaderAnalysisResults, t => t.IsSelfAnalysis == null ? t.Subject.SubjectVisitTaskList.Any(u => u.IsSelfAnalysis == true && u.VisitTaskNum == t.VisitTaskNum && u.DoctorUserId == t.DoctorUserId && u.TrialReadingCriterionId == t.TrialReadingCriterionId) : true)
|
||||
.WhereIf(inQuery.ReadingExportType == ExportResult.DetailedTableOfInterReaderAnalysisResults, t => t.IsSelfAnalysis == false || t.IsSelfAnalysis == null)
|
||||
|
||||
//访视和全局查询已签名完成的,裁判可以是未签名,未完成的
|
||||
.Where(t => (t.ReadingTaskState == ReadingTaskState.HaveSigned && (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global)) || t.ReadingCategory == ReadingCategory.Judge)
|
||||
.WhereIf(inQuery.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
|
||||
.WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId)
|
||||
|
||||
.WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent)
|
||||
.WhereIf(inQuery.DoctorUserId != null, t => t.DoctorUserId == inQuery.DoctorUserId)
|
||||
.WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
|
||||
//.WhereIf(inQuery.ReadingTaskState != null, t => t.ReadingTaskState == inQuery.ReadingTaskState)
|
||||
.WhereIf(inQuery.TaskAllocationState != null, t => t.TaskAllocationState == inQuery.TaskAllocationState)
|
||||
.WhereIf(inQuery.ArmEnum != null, t => t.ArmEnum == inQuery.ArmEnum)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.IsAnalysisCreate == false))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.Subject.Code.Contains(inQuery.SubjectCode))
|
||||
.WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime > inQuery.BeginAllocateDate)
|
||||
.WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime < inQuery.EndAllocateDate);
|
||||
|
||||
var list = await query.ProjectTo<AnalysisDynamicCommonExport>(_mapper.ConfigurationProvider,
|
||||
new
|
||||
{
|
||||
readingExportType = inQuery.ReadingExportType,
|
||||
criterionType = criterion.CriterionType,
|
||||
trialReadingCriterionId = inQuery.TrialReadingCriterionId,
|
||||
isEn_Us = _userInfo.IsEn_Us
|
||||
}).ToListAsync();
|
||||
|
||||
list = list.OrderBy(t => t.SubjectCode).ThenBy(t => t.ArmEnum).ThenBy(t => t.VisitTaskNum).ToList();
|
||||
|
||||
|
||||
var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo<ExcelExportInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
exportInfo.CriterionName = criterion.CriterionName;
|
||||
|
||||
#region 处理系统标准存在疾病和整体肿瘤合并
|
||||
|
||||
//如果是以合并后的找翻译字典,会少,所以必须放在前面
|
||||
var translateDicNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList();
|
||||
|
||||
//针对1.1 整体肿瘤评估 有的两列要合并一列
|
||||
if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
//处理合并表头
|
||||
|
||||
var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.Tumor;
|
||||
|
||||
var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault();
|
||||
|
||||
if (findItem != null)
|
||||
{
|
||||
findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估";
|
||||
}
|
||||
|
||||
|
||||
if (item.IsBaseline == true)
|
||||
{
|
||||
item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.Tumor).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET)
|
||||
{
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
//处理合并表头
|
||||
|
||||
var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.ImgOncology;
|
||||
|
||||
var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault();
|
||||
|
||||
if (findItem != null)
|
||||
{
|
||||
findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估";
|
||||
}
|
||||
|
||||
if (item.IsBaseline == true)
|
||||
{
|
||||
item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ImgOncology).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (criterion.CriterionType == CriterionType.PCWG3)
|
||||
{
|
||||
|
||||
}
|
||||
else if (criterion.CriterionType == CriterionType.SelfDefine)
|
||||
{
|
||||
//自定义的又问题名称重复 所以统一加上组名
|
||||
|
||||
//有重复的就加,没有重复的就不加
|
||||
if (list.Any(t => t.QuestionAnswerList.Select(t => t.QuestionName).Count() != t.QuestionAnswerList.Select(t => t.QuestionName).Distinct().Count()))
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
foreach (var qs in item.QuestionAnswerList)
|
||||
{
|
||||
qs.QuestionName = qs.Group + "_" + qs.QuestionName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var export_Template = StaticData.Export.TrialSelfAnalysisList_Export;
|
||||
|
||||
#region 自身一致性分析和组间一致性分析
|
||||
|
||||
if (inQuery.ReadingExportType == ExportResult.DetailedTableOfIntraReaderAnalysisResults)
|
||||
{
|
||||
//找到非一致性分析的任务
|
||||
var selfExportList = list.Where(t => t.IsSelfAnalysis == null).ToList();
|
||||
|
||||
//处理一致性分析结果是否和原始阅片是否一致
|
||||
foreach (var item in selfExportList)
|
||||
{
|
||||
//找到一致性分析的结果
|
||||
var selfAnalysisTask = list.Where(t => t.IsSelfAnalysis == true && t.SubjectCode == item.SubjectCode && t.VisitTaskNum == item.VisitTaskNum && t.TaskName == t.TaskName && t.UserName == item.UserName).FirstOrDefault();
|
||||
|
||||
//将自身一致性分析的字段 赋值到访视任务这个字段
|
||||
item.IsAnalysisDiffToOriginalData = selfAnalysisTask?.IsAnalysisDiffToOriginalData;
|
||||
|
||||
//处理再次阅片人的结果
|
||||
if (selfAnalysisTask != null)
|
||||
{
|
||||
var cloneQuestionAnswerList = selfAnalysisTask.QuestionAnswerList.Clone();
|
||||
|
||||
foreach (var qItem in cloneQuestionAnswerList)
|
||||
{
|
||||
qItem.QuestionName = qItem.QuestionName + $"{(_userInfo.IsEn_Us ? "(Again)" : "(再次)")}";
|
||||
}
|
||||
|
||||
item.QuestionAnswerList = item.QuestionAnswerList.Union(cloneQuestionAnswerList).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
list = selfExportList;
|
||||
}
|
||||
else
|
||||
{
|
||||
export_Template = StaticData.Export.TrialGroupAnalysisList_Export;
|
||||
|
||||
var newList = new List<AnalysisDynamicCommonExport>();
|
||||
|
||||
foreach (var group in list.GroupBy(t => new { t.SubjectCode, t.VisitTaskNum, t.TaskName }).OrderBy(g => g.Key.SubjectCode).ThenBy(g => g.Key.VisitTaskNum))
|
||||
{
|
||||
var subjectVisitGroupList = group.ToList();
|
||||
|
||||
|
||||
//找到当前访视组间一致性分析的任务结果
|
||||
|
||||
var groupOtherTaskList = subjectVisitGroupList.Where(t => t.IsSelfAnalysis == false).ToList();
|
||||
|
||||
foreach (var subjectVisitTaskArm in subjectVisitGroupList.Where(t => t.IsSelfAnalysis == null).OrderBy(t => t.ArmEnum))
|
||||
{
|
||||
foreach (var otherTask in groupOtherTaskList)
|
||||
{
|
||||
//非一致性分析任务
|
||||
var cloneObj = subjectVisitTaskArm.Clone();
|
||||
|
||||
var otherTaskQuestionAnserList = otherTask.QuestionAnswerList.Clone();
|
||||
|
||||
foreach (var qItem in otherTaskQuestionAnserList)
|
||||
{
|
||||
qItem.QuestionName = qItem.QuestionName + $"{(_userInfo.IsEn_Us ? "(Again)" : "(再次)")}";
|
||||
}
|
||||
|
||||
//处理 再次阅片人,再次阅片人角色 两列
|
||||
var addQuestionList = new List<CommonQuesionInfo>();
|
||||
|
||||
addQuestionList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Reviwer(Again)" : "阅片人(再次)", QuestionValue = otherTask.UserName });
|
||||
addQuestionList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Reviwer Role(Again)" : "阅片人角色(再次)", QuestionValue = ((int)otherTask.ArmEnum).ToString(), TranslateDicName = "ArmEnum" });
|
||||
|
||||
|
||||
cloneObj.QuestionAnswerList = cloneObj.QuestionAnswerList.Union(addQuestionList).Union(otherTaskQuestionAnserList).ToList();
|
||||
|
||||
|
||||
cloneObj.IsGroupAnalysisDiffToOriginalData = cloneObj.ArmEnum == Arm.DoubleReadingArm1 ? otherTask.IsGroupDiffArm1 : otherTask.IsGroupDiffArm2;
|
||||
|
||||
newList.Add(cloneObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
translateDicNameList.Add("ArmEnum");
|
||||
|
||||
list = newList;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList();
|
||||
|
||||
exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list.Where(t => t.ReadingCategory != ReadingCategory.Global).ToList(), _userInfo.TimeZoneId);
|
||||
exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId);
|
||||
|
||||
var dynamicColumnConfig = new DynamicColumnConfig()
|
||||
{
|
||||
//可读的列表名行索引,不是{{}} 模板行索引
|
||||
AutoColumnTitleRowIndex = 2,
|
||||
AutoColumnStartIndex = 5,
|
||||
TempalteLastColumnIndex = 4,
|
||||
DynamicItemDicName = "TranslateDicName",
|
||||
DynamicItemValueName = "QuestionValue",
|
||||
DynamicItemTitleName = "QuestionName",
|
||||
DynamicListName = "QuestionAnswerList",
|
||||
RemoveColunmIndexList = new List<int>() { },
|
||||
ColumnIdNameList = columNameList.Select(t => new DynamicColumnConfig.ColumItem() { Id = Guid.Empty, Name = t }).ToList(),
|
||||
TranslateDicNameList = translateDicNameList ?? new List<string>()
|
||||
};
|
||||
|
||||
|
||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(AnalysisDynamicCommonExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
|
||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取阅片标准可以导出的列表
|
||||
@@ -2341,6 +2760,11 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.ReadingLession_Export, ExportCatogory = ExportResult.DetailedTableOfLesions });
|
||||
}
|
||||
|
||||
if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.Lugano2014)
|
||||
{
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.TumorCDISC_Export, ExportCatogory = ExportResult.TumorCDISC_Export });
|
||||
}
|
||||
|
||||
if (criterion.CriterionType == CriterionType.OCT)
|
||||
{
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.OCT_ReadingLession_Export, ExportCatogory = ExportResult.OCT_ReadingLession_Export });
|
||||
@@ -2350,9 +2774,9 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
{
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.IVUS_CDISC_Export, ExportCatogory = ExportResult.IVUS_CDISC_Export });
|
||||
}
|
||||
//else if (criterion.CriterionType == CriterionType.SelfDefine)
|
||||
if (criterion.CriterionGroup != CriterionGroup.Tumor && criterion.CriterionType != CriterionType.OCT && criterion.CriterionType != CriterionType.IVUS)
|
||||
{
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.CDISC_Reading_Export, ExportCatogory = ExportResult.CDISC });
|
||||
list.Add(new ExportDocumentDes() { Code = StaticData.Export.CDISC_Reading_Export, ExportCatogory = ExportResult.NoneTumorCDISC });
|
||||
}
|
||||
|
||||
switch (criterion.ArbitrationRule)
|
||||
@@ -2479,7 +2903,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
//阅片结果表
|
||||
export_Template = StaticData.Export.CommonReading_Export;
|
||||
}
|
||||
|
||||
//斑块表
|
||||
else if (inQuery.ReadingExportType == ExportResult.OCT_ReadingLession_Export)
|
||||
{
|
||||
//OCT
|
||||
@@ -2533,7 +2957,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
}
|
||||
// 非肿瘤标准 包括自定义,以及系统非肿瘤 会配置到表格层级 问题名称是 表格名称_表格子问题名
|
||||
else if (
|
||||
criterion.CriterionGroup == CriterionGroup.Nontumorous && inQuery.ReadingExportType != ExportResult.CDISC
|
||||
criterion.CriterionGroup == CriterionGroup.Nontumorous && inQuery.ReadingExportType != ExportResult.NoneTumorCDISC
|
||||
)
|
||||
{
|
||||
|
||||
@@ -2550,7 +2974,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
|
||||
}
|
||||
// CDISC 导出 只管到 外层问题层级 和阅片结果表是保持一致
|
||||
else if (inQuery.ReadingExportType == ExportResult.CDISC)
|
||||
else if (inQuery.ReadingExportType == ExportResult.NoneTumorCDISC)
|
||||
{
|
||||
|
||||
if (criterion.CriterionGroup == CriterionGroup.Tumor)
|
||||
@@ -2618,7 +3042,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
#endregion
|
||||
|
||||
|
||||
if (inQuery.ReadingExportType != ExportResult.CDISC)
|
||||
if (inQuery.ReadingExportType != ExportResult.NoneTumorCDISC)
|
||||
{
|
||||
//最终EXCEL 列
|
||||
var configCoumNameList = new List<DynamicColumnConfig.ColumItem>();
|
||||
@@ -2746,7 +3170,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
addLessionInfoList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Lesion Type" : "病灶类型", QuestionValue = lession.LessionType, TranslateDicName = "LesionType" });
|
||||
}
|
||||
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, OptionTypeEnum = t.OptionTypeEnum, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName });
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, OptionTypeEnum = t.OptionTypeEnum, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName ,Unit=t.Unit});
|
||||
|
||||
//有三部分组成 外层问题+ 没有配置病灶编号和类型+ 动态的表格问题
|
||||
var dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList();
|
||||
@@ -2774,7 +3198,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
#endregion
|
||||
|
||||
#region 不管是list 还是taskList 最终处理的数据都是list 处理好数据后合并
|
||||
if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB
|
||||
if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB
|
||||
|| criterion.CriterionType == CriterionType.IRECIST1Point1 || criterion.CriterionType == CriterionType.mRECISTHCC)
|
||||
{
|
||||
//针对1.1 整体肿瘤评估 有的两列要合并一列
|
||||
@@ -2894,14 +3318,14 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
|
||||
addLessionInfoList.Add(new CommonQuesionInfo() { QuestionId = Guid.Empty, QuestionName = _userInfo.IsEn_Us ? "Table Name" : "表格名称", QuestionValue = firstLessionAnser.TableName });
|
||||
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, OptionTypeEnum = t.OptionTypeEnum, QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, OptionTypeEnum = t.OptionTypeEnum, QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode, Unit = t.Unit });
|
||||
|
||||
//有三部分组成 外层问题+ 固定列表格名称 + 动态的表格问题
|
||||
dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, OptionTypeEnum = t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, OptionTypeEnum = t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode, Unit = t.Unit });
|
||||
|
||||
//两部分组成 外层问题+ 动态的表格问题
|
||||
dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList();
|
||||
@@ -2948,7 +3372,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
TranslateDicNameList = translateDicNameList
|
||||
};
|
||||
|
||||
if (export_Template == StaticData.Export.ReadingLession_Export || export_Template == StaticData.Export.CommonJudgeReadingDetail_Export)
|
||||
if (export_Template == StaticData.Export.ReadingLession_Export || export_Template == StaticData.Export.CommonJudgeReadingDetail_Export || export_Template== StaticData.Export.OCT_ReadingLession_Export)
|
||||
{
|
||||
dynamicColumnConfig.TempalteLastColumnIndex = 8;
|
||||
}
|
||||
@@ -3011,7 +3435,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
var dynamicLessionInfoList = new List<CommonQuesionInfo>();
|
||||
|
||||
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId,OptionTypeEnum=t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
|
||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId,OptionTypeEnum=t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode, Unit = t.Unit });
|
||||
|
||||
//两部分组成 外层问题+ 动态的表格问题
|
||||
dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList();
|
||||
@@ -3224,7 +3648,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||
|
||||
string fileName = "";
|
||||
|
||||
if (inQuery.ReadingExportType == ExportResult.CDISC)
|
||||
if (inQuery.ReadingExportType == ExportResult.NoneTumorCDISC)
|
||||
{
|
||||
(memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
|
||||
@@ -410,7 +410,33 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
|
||||
//靶段
|
||||
var target = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegment).FirstOrDefault();
|
||||
|
||||
ivus.TARGETV = translateDataList[target?.TranslateDicName].Where(t => t.Code.ToLower() == target?.QuestionValue?.ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||
var itemValue = target?.QuestionValue??string.Empty;
|
||||
//多选
|
||||
int[] enumValues = new int[0];
|
||||
// 1. 反序列化 JSON 数组 (字符串枚举)
|
||||
if (!itemValue.StartsWith("[") || !itemValue.EndsWith("]"))
|
||||
{
|
||||
enumValues = new int[1] { int.Parse(itemValue) };
|
||||
}
|
||||
else
|
||||
{
|
||||
enumValues = JsonConvert.DeserializeObject<int[]>(itemValue) ?? new int[0];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 2. 翻译每一项并输出逗号拼接字符串
|
||||
var translatedItemData = string.Join(",",
|
||||
enumValues.OrderBy(t=>t).Select(code =>
|
||||
translateDataList[target?.TranslateDicName]
|
||||
.FirstOrDefault(t =>
|
||||
string.Equals(code.ToString(), t.Code, StringComparison.OrdinalIgnoreCase)
|
||||
) is var r && r != null
|
||||
? (isEn_Us ? r.Value : r.ValueCN)
|
||||
: string.Empty
|
||||
));
|
||||
|
||||
ivus.TARGETV = translatedItemData;
|
||||
|
||||
|
||||
var marks = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegmentRemarks).FirstOrDefault()?.QuestionValue ?? string.Empty;
|
||||
@@ -451,6 +477,11 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
|
||||
|
||||
ivus.PAV = findPAVLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.PAV).FirstOrDefault()?.QuestionValue ?? string.Empty;
|
||||
|
||||
if (ivus.PAV.IsNotNullOrEmpty())
|
||||
{
|
||||
ivus.PAV = ivus.PAV + "%";
|
||||
}
|
||||
|
||||
|
||||
ivus.DOST = findPAVLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.PlaqueToOstiumDistance).FirstOrDefault()?.QuestionValue ?? string.Empty;
|
||||
|
||||
@@ -743,8 +774,33 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
|
||||
|
||||
var target = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegment).FirstOrDefault();
|
||||
|
||||
oct.TARGETV = translateDataList[target?.TranslateDicName].Where(t => t.Code.ToLower() == target?.QuestionValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
||||
var itemValue = target?.QuestionValue ?? string.Empty;
|
||||
//多选
|
||||
int[] enumValueArray = new int[0];
|
||||
// 1. 反序列化 JSON 数组 (字符串枚举)
|
||||
if (!itemValue.StartsWith("[") || !itemValue.EndsWith("]"))
|
||||
{
|
||||
enumValueArray = new int[1] { int.Parse(itemValue) };
|
||||
}
|
||||
else
|
||||
{
|
||||
enumValueArray = JsonConvert.DeserializeObject<int[]>(itemValue) ?? new int[0];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 2. 翻译每一项并输出逗号拼接字符串
|
||||
var translatedItemData = string.Join(",",
|
||||
enumValueArray.OrderBy(t => t).Select(code =>
|
||||
translateDataList[target?.TranslateDicName]
|
||||
.FirstOrDefault(t =>
|
||||
string.Equals(code.ToString(), t.Code, StringComparison.OrdinalIgnoreCase)
|
||||
) is var r && r != null
|
||||
? (isEn_US ? r.Value : r.ValueCN)
|
||||
: string.Empty
|
||||
));
|
||||
|
||||
oct.TARGETV = translatedItemData;
|
||||
|
||||
var marks = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegmentRemarks).FirstOrDefault()?.QuestionValue ?? string.Empty;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-28 06:22:47Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
namespace IRaCIS.Core.Application.Interfaces;
|
||||
|
||||
public interface IEmailLogService
|
||||
{
|
||||
|
||||
Task<PageOutput<EmailLogView>> GetEmailLogList(EmailLogQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateEmailLog(EmailLogAddOrEdit addOrEditEmailLog);
|
||||
|
||||
Task<IResponseOutput> DeleteEmailLog(Guid emailLogId);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,16 @@ using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using MailKit;
|
||||
using MailKit.Net.Imap;
|
||||
using MailKit.Search;
|
||||
using MailKit.Security;
|
||||
using Medallion.Threading;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
using System.Net.Mail;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
@@ -48,7 +53,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
public interface IMailVerificationService
|
||||
{
|
||||
|
||||
Task AnolymousSendEmail(string researchProgramNo, string emailAddress, int verificationCode);
|
||||
Task AnolymousSendEmail(Guid trialId, string emailAddress, int verificationCode);
|
||||
|
||||
Task SendEmailVerification(string emailAddress, int verificationCode);
|
||||
|
||||
@@ -61,7 +66,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
Task AddUserSendEmailAsync(Guid userId, string baseUrl, string routeUrl);
|
||||
|
||||
Task AdminResetPwdSendEmailAsync(Guid userId, string pwdNotMd5 = "123456");
|
||||
Task AdminResetPwdSendEmailAsync(Guid userId, string pwdNotMd5 = "123456", string baseUrl="");
|
||||
|
||||
Task SiteSurveyUserJoinEmail(Guid trialId, Guid userId, string userTypes, string baseUrl, string rootUrl);
|
||||
|
||||
@@ -70,8 +75,14 @@ namespace IRaCIS.Core.Application.Service
|
||||
Task<(Guid identityUserId, Guid userRoleId)> DoctorJoinTrialEmail(Guid trialId, Guid doctorId, string baseUrl, string rootUrl);
|
||||
|
||||
Task UserFeedBackMail(Guid feedBackId);
|
||||
}
|
||||
|
||||
Task AfterUserModifyPasswordSendEmailAsync(Guid userId);
|
||||
|
||||
Task SiteSuervyCheckUser(Guid trialId, string email, string name);
|
||||
|
||||
Task SiteSuervyUpdateUser(Guid trialSiteId, string email, string name, string url);
|
||||
}
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class MailVerificationService(IRepository<VerificationCode> _verificationCodeRepository,
|
||||
IRepository<SystemBasicData> _systemBasicDatarepository,
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
@@ -86,12 +97,14 @@ namespace IRaCIS.Core.Application.Service
|
||||
IRepository<UserType> _userTypeRepository,
|
||||
IRepository<Doctor> _doctorTypeRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
|
||||
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
||||
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
|
||||
IDistributedLockProvider _distributedLockProvider, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IMailVerificationService
|
||||
{
|
||||
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
||||
|
||||
|
||||
|
||||
private async Task<EmailNoticeConfig> GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario scenario, MimeMessage messageToSend,
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailFunc)
|
||||
@@ -176,6 +189,14 @@ namespace IRaCIS.Core.Application.Service
|
||||
return str;
|
||||
}
|
||||
|
||||
private string ReplacePlatformName(string needDealtxt)
|
||||
{
|
||||
var platformName = _userInfo.IsEn_Us ? _systemEmailConfig.PlatformName : _systemEmailConfig.PlatformNameCN;
|
||||
|
||||
var str = needDealtxt.Replace("{platformName}", platformName);
|
||||
return str;
|
||||
}
|
||||
|
||||
//MFA
|
||||
public async Task SenMFAVerifyEmail(Guid userId, string userName, string emailAddress, int verificationCode, UserMFAType mfaType = UserMFAType.Login)
|
||||
{
|
||||
@@ -263,10 +284,13 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
//中心调研 登陆 发送验证码
|
||||
public async Task AnolymousSendEmail(string researchProgramNo, string emailAddress, int verificationCode)
|
||||
public async Task AnolymousSendEmail(Guid trialId, string emailAddress, int verificationCode)
|
||||
{
|
||||
//throw new BusinessValidationFailedException("模拟邮件取数据或者发送异常!!!");
|
||||
|
||||
|
||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId);
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
@@ -279,7 +303,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
||||
{
|
||||
var topicStr = string.Format(input.topicStr, companyName, researchProgramNo);
|
||||
var topicStr = string.Format(input.topicStr, companyName, trialInfo.ResearchProgramNo);
|
||||
|
||||
var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr),
|
||||
|
||||
@@ -299,7 +323,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress);
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo, sucessHandle);
|
||||
|
||||
}
|
||||
|
||||
@@ -330,7 +354,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
var domain = baseUrl.Substring(0, baseUrl.IndexOf("/login"));
|
||||
|
||||
var redirectUrl = $"{domain}/api/User/UserRedirect?url={System.Web.HttpUtility.UrlEncode(routeUrl)}";
|
||||
|
||||
|
||||
|
||||
var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
|
||||
@@ -357,7 +381,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
}
|
||||
|
||||
//管理员重置密码发送邮件
|
||||
public async Task AdminResetPwdSendEmailAsync(Guid userId, string pwdNotMd5 = "123456")
|
||||
public async Task AdminResetPwdSendEmailAsync(Guid userId, string pwdNotMd5 = "123456", string baseUrl = "")
|
||||
{
|
||||
var sysUserInfo = (await _identityUserRepository.Where(t => t.Id == userId).Include(t => t.UserRoleList).ThenInclude(c => c.UserTypeRole).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
@@ -380,7 +404,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
sysUserInfo.FullName,
|
||||
sysUserInfo.UserName,
|
||||
//string.Join(',', sysUserInfo.UserRoleList.Select(t => t.UserTypeRole.UserTypeShortName)),
|
||||
pwdNotMd5
|
||||
pwdNotMd5,
|
||||
baseUrl
|
||||
|
||||
);
|
||||
|
||||
return (topicStr, htmlBodyStr);
|
||||
@@ -520,8 +546,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.SiteUseOrExternalUserFirstrJoinTrial : EmailBusinessScenario.SiteUserOrExternalUserExistJoinTrial, messageToSend, emailConfigFunc);
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, null);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo, null);
|
||||
|
||||
}
|
||||
|
||||
@@ -580,8 +605,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.SiteUseOrExternalUserFirstrJoinTrial : EmailBusinessScenario.SiteUserOrExternalUserExistJoinTrial, messageToSend, emailConfigFunc);
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
|
||||
}
|
||||
|
||||
@@ -710,8 +734,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.DoctorUserFirstJoinTrial : EmailBusinessScenario.DoctorUserExistJoinTrial, messageToSend, emailConfigFunc);
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, null);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo, null);
|
||||
|
||||
//创建账号 和创建角色 一条,更新的时候才记录更新角色
|
||||
if (isNeedCreateNewUser == false)
|
||||
@@ -737,6 +760,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
var isHaveTrialId = feedBack.TrialId != null;
|
||||
|
||||
var trialinfo = await _trialRepository.Where(x => x.Id == feedBack.TrialId).FirstOrDefaultAsync();
|
||||
|
||||
var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
|
||||
var emialScenario = feedBack.VisitTaskId != null ? EmailBusinessScenario.IRImageError : (feedBack.SubjectVisitId != null ? EmailBusinessScenario.TrialSubjectVisitFeedBack : (feedBack.TrialId != null ? EmailBusinessScenario.TrialFeedBack : EmailBusinessScenario.SysFeedBack));
|
||||
@@ -871,8 +896,122 @@ namespace IRaCIS.Core.Application.Service
|
||||
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysFeedBack, messageToSend, emailConfigFunc);
|
||||
}
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
if (trialinfo == null)
|
||||
{
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialinfo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//用户修改密码发送邮件
|
||||
public async Task AfterUserModifyPasswordSendEmailAsync(Guid userId)
|
||||
{
|
||||
|
||||
var sysUserInfo = (await _identityUserRepository.Where(t => t.Id == userId).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(sysUserInfo.FullName, sysUserInfo.EMail));
|
||||
//主题
|
||||
//---[来自展影IRC] 关于重置邮箱的提醒
|
||||
|
||||
var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
||||
{
|
||||
var topicStr = string.Format(input.topicStr, companyName);
|
||||
|
||||
var htmlBodyStr = string.Format(ReplacePlatformName(ReplaceCompanyName(input.htmlBodyStr)) ,
|
||||
|
||||
sysUserInfo.FullName
|
||||
);
|
||||
|
||||
return (topicStr, htmlBodyStr);
|
||||
};
|
||||
|
||||
|
||||
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.IdentityUser_ModifyPassword, messageToSend, emailConfigFunc);
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||
}
|
||||
|
||||
//中心调研核对人员提醒
|
||||
public async Task SiteSuervyCheckUser(Guid trialId, string email, string name)
|
||||
{
|
||||
var trialInfo = await _trialRepository.Where(t => t.Id == trialId).FirstOrDefaultAsync();
|
||||
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(name, email));
|
||||
//主题
|
||||
//---[来自展影IRC] 关于重置邮箱的提醒
|
||||
|
||||
var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
||||
{
|
||||
|
||||
var topicStr = string.Format(input.topicStr, companyName, trialInfo.ResearchProgramNo);
|
||||
|
||||
var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr),
|
||||
name,
|
||||
trialInfo.TrialCode,
|
||||
trialInfo.ResearchProgramNo
|
||||
);
|
||||
|
||||
return (topicStr, htmlBodyStr);
|
||||
};
|
||||
|
||||
|
||||
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurvey_CheckUser, messageToSend, emailConfigFunc);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
public async Task SiteSuervyUpdateUser(Guid trialSiteId, string email, string name, string url)
|
||||
{
|
||||
var siteInfo = await _trialSiteRepository.Where(t => t.Id == trialSiteId).Include(x=>x.Trial).FirstOrDefaultAsync();
|
||||
|
||||
var trialInfo = siteInfo.Trial;
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(name, email));
|
||||
//主题
|
||||
//---[来自展影IRC] 关于重置邮箱的提醒
|
||||
|
||||
var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
||||
{
|
||||
|
||||
var topicStr = string.Format(input.topicStr, companyName, trialInfo.ResearchProgramNo);
|
||||
|
||||
var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr),
|
||||
name,
|
||||
trialInfo.TrialCode,
|
||||
siteInfo.TrialSiteCode,
|
||||
siteInfo.TrialSiteName,
|
||||
url
|
||||
);
|
||||
|
||||
return (topicStr, htmlBodyStr);
|
||||
};
|
||||
|
||||
|
||||
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurvey_UpdateUser, messageToSend, emailConfigFunc);
|
||||
await SendEmailHelper.SendEmailAsync(messageToSend, trialInfo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,18 @@ namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
public CommonConfig()
|
||||
{
|
||||
// 在此处拷贝automapper 映射
|
||||
CreateMap<EmailAttachmentLog, EmaliAttachmentInfo>();
|
||||
CreateMap<EmailRecipientLog, EmailRecipientLogView>();
|
||||
CreateMap<EmailLog, EmailLogView>()
|
||||
.ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList))
|
||||
.ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList));
|
||||
|
||||
CreateMap<EmailLog, GetEmailInfoOutDto>()
|
||||
.ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList))
|
||||
.ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList));
|
||||
|
||||
CreateMap<EmailLog, EmailLogAddOrEdit>().ReverseMap();
|
||||
|
||||
CreateMap<FrontAuditConfig, FrontAuditConfigAddOrEdit>().ReverseMap();
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@ namespace IRaCIS.Application.Contracts
|
||||
|
||||
public class SelectionReviewerDTO : DoctorDTO
|
||||
{
|
||||
public bool IsVacation { get; set; }
|
||||
public int DoctorTrialState { get; set; }
|
||||
|
||||
public bool IsEnroll { get; set; } = false;
|
||||
|
||||
@@ -133,6 +133,29 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维护 医生基本信息 Code
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task ServiceDoctorBasicInfo()
|
||||
{
|
||||
var doctorList = await _doctorRepository.Where(t => t.Code == 0 && t.TrialId == null).ToListAsync();
|
||||
|
||||
var code = await _doctorRepository.Select(t => t.Code).DefaultIfEmpty().MaxAsync();
|
||||
|
||||
foreach (var doctorItem in doctorList)
|
||||
{
|
||||
code++;
|
||||
doctorItem.Code = code;
|
||||
doctorItem.ReviewerCode = AppSettings.GetCodeStr(doctorItem.Code, nameof(Doctor));
|
||||
await _doctorRepository.BatchUpdateNoTrackingAsync(x => x.Id == doctorItem.Id, x => new Doctor()
|
||||
{
|
||||
Code = doctorItem.Code,
|
||||
ReviewerCode = doctorItem.ReviewerCode
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增修改 医生基本信息和工作
|
||||
/// </summary>
|
||||
|
||||
@@ -131,6 +131,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
#region 医生基本信息
|
||||
CreateMap<Doctor, SelectionReviewerDTO>()
|
||||
.ForMember(d => d.IsVacation, u => u.MapFrom(t => t.VacationList.Any(x=>x.StartDate<DateTime.Now&&x.EndDate>DateTime.Now)))
|
||||
.ForMember(d => d.DoctorUserName, u => u.MapFrom(t => t.UserRole.IdentityUser.UserName));
|
||||
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||
.WhereIf(inQuery.IdentityUserName.IsNotNullOrEmpty(), t => t.AuditRecordIdentityUserList.Any(c => c.IdentityUser.UserName.Contains(inQuery.IdentityUserName) || c.IdentityUser.FullName.Contains(inQuery.IdentityUserName)))
|
||||
.WhereIf(inQuery.CompanyName.IsNotNullOrEmpty(), t => t.CompanyName.Contains(inQuery.CompanyName))
|
||||
.WhereIf(inQuery.AuditContent.IsNotNullOrEmpty(), t => t.AuditContent.Contains(inQuery.AuditContent))
|
||||
.WhereIf(inQuery.IsViewTrainingRecord != null, t => t.IsViewTrainingRecord == inQuery.IsViewTrainingRecord)
|
||||
.ProjectTo<AuditRecordView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await auditRecordQueryable.ToPagedListAsync(inQuery);
|
||||
@@ -667,7 +668,7 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||
#endregion
|
||||
|
||||
|
||||
// 不能自动到自己父类这个文件夹
|
||||
// 不能移动到自己父类这个文件夹
|
||||
if (await _auditDocumentRepository.AnyAsync(x => x.ParentId == inDto.ParentId && inDto.Ids.Contains(x.Id)))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMoveToParent"]);
|
||||
@@ -693,7 +694,7 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||
public async Task<IResponseOutput> CopyFileOrFolder(MovieFileOrFolderInDto inDto)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
foreach (var item in inDto.Ids)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,8 @@ public class AuditRecordAddOrEdit
|
||||
|
||||
public AuditType AuditType { get; set; }
|
||||
|
||||
public bool IsViewTrainingRecord { get; set; }
|
||||
|
||||
//public List<Guid> IdnetityUserIdList { get; set; }
|
||||
}
|
||||
|
||||
@@ -85,6 +87,8 @@ public class AuditRecordQuery : PageInput
|
||||
public DateTime? EndCreateTime { get; set; }
|
||||
|
||||
public string? IdentityUserName { get; set; }
|
||||
|
||||
public bool? IsViewTrainingRecord { get; set; }
|
||||
}
|
||||
|
||||
public class SetAuditRecordPermissionCommand
|
||||
|
||||
@@ -92,11 +92,16 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public class UnionDocumentWithConfirmInfoView : UnionDocumentView
|
||||
{
|
||||
public DocUserSignType SysDocUserSignType { get; set; }
|
||||
|
||||
public bool IsConfirmIdentityUserInner { get; set; }
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public bool IsNeedSendEmial { get; set; }
|
||||
public DateTime UserCreateTime { get; set; }
|
||||
|
||||
|
||||
public string EmailFromName { get; set; }
|
||||
|
||||
public DateTime? ConfirmTime { get; set; }
|
||||
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public bool? IsPublish { get; set; }
|
||||
|
||||
public string? FileTypeCode { get; set; }
|
||||
|
||||
}
|
||||
|
||||
///<summary> TrialDocumentAddOrEdit 列表查询参数模型</summary>
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
public new List<UserTypeEnum> CopyUserTypeList => TrialEmailNoticeUserList.Where(t => t.EmailUserType == EmailUserType.Copy).Select(t => t.UserType).ToList();
|
||||
|
||||
public List<CriterionType>? SysCriterionTypeList { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +98,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public string EmailTopic { get; set; } = string.Empty;
|
||||
|
||||
public EmailBusinessScenario? BusinessScenarioEnum { get; set; }
|
||||
|
||||
public CriterionType? CriterionTypeEnum { get; set; }
|
||||
@@ -125,7 +128,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
{
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
public Guid TrialReadingCriterionId { get; set; }
|
||||
public CriterionType CriterionType { get; set; }
|
||||
|
||||
public EmailBusinessScenario BusinessScenarioEnum { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-20 06:17:15Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.Service.DTO;
|
||||
|
||||
public class UserAgreementView : UserAgreementAddOrEdit
|
||||
{
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class UserAgreementAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
public DateTime EffectiveDate { get; set; }
|
||||
|
||||
public string FileContent { get; set; }
|
||||
|
||||
public string FileEnContent { get; set; }
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string FileVersion { get; set; }
|
||||
|
||||
public bool IsCurrentVersion { get; set; }
|
||||
|
||||
public DateTime UpdateDate { get; set; }
|
||||
|
||||
public UserAgreementType UserAgreementTypeEnum { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SetUserAgreementCurrentVersionInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
||||
public class GetUserAgreementByIdInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
||||
public class UserAgreementQuery:PageInput
|
||||
{
|
||||
public DateTime? StartEffectiveDate { get; set; }
|
||||
|
||||
public DateTime? EndEffectiveDate { get; set; }
|
||||
|
||||
public string? FileContent { get; set; }
|
||||
|
||||
public string? FileName { get; set; }
|
||||
|
||||
public string? FileVersion { get; set; }
|
||||
|
||||
public bool? IsCurrentVersion { get; set; }
|
||||
|
||||
public DateTime? StartUpdateDate { get; set; }
|
||||
|
||||
public DateTime? EndUpdateDate { get; set; }
|
||||
|
||||
public UserAgreementType? UserAgreementTypeEnum { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
//入组确认/PD确认
|
||||
|
||||
|
||||
public async Task SendEnrollOrPdEmail(Guid visitTaskId, bool? isEnrollment, bool? isPDConfirm)
|
||||
{
|
||||
EmailBusinessScenario businessScenarioEnum;
|
||||
@@ -109,8 +110,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
if (sendEmailConfig != null)
|
||||
{
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
var trialInfo = await _trialRepository.Where(t => t.Id == trialId).FirstOrDefaultAsync();
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig, trialInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
Task<IResponseOutput> UserConfirm(UserConfirmCommand userConfirmCommand);
|
||||
Task<List<TrialUserDto>> GetTrialUserSelect(Guid trialId);
|
||||
|
||||
Task<IResponseOutput<PageOutput<UnionDocumentWithConfirmInfoView>>> GetSysDocumentConfirmList(SystemDocQuery inQuery);
|
||||
|
||||
|
||||
//Task<PageOutput<DocumentUnionWithUserStatView>> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument);
|
||||
//List<TrialUserUnionDocumentView> GetTrialUserDocumentList(Guid trialId);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-20 06:17:15Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.Service.DTO;
|
||||
namespace IRaCIS.Core.Application.Service.Interface;
|
||||
|
||||
public interface IUserAgreementService
|
||||
{
|
||||
|
||||
Task<PageOutput<UserAgreementView>> GetUserAgreementList(UserAgreementQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateUserAgreement(UserAgreementAddOrEdit addOrEditUserAgreement);
|
||||
|
||||
Task<IResponseOutput> DeleteUserAgreement(Guid userAgreementId);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
await _systemDocumentRepository.BatchUpdateNoTrackingAsync(x => inDto.Ids.Contains(x.Id), x => new SystemDocument()
|
||||
{
|
||||
IsPublish = true,
|
||||
PublishDate= DateTime.Now,
|
||||
IsDeleted = false,
|
||||
});
|
||||
|
||||
@@ -286,7 +287,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
var isInternal = _userInfo.IsZhiZhun;
|
||||
|
||||
var query = from sysDoc in _systemDocumentRepository.AsQueryable(true)
|
||||
var query = from sysDoc in _systemDocumentRepository.Where(t=>t.IsPublish)
|
||||
.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name))
|
||||
//外部人员 只签署 外部需要签署的
|
||||
@@ -301,6 +302,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
AttachmentCount=sysDoc.SystemDocumentAttachmentList.Where(z=>!z.OffLine).Count(),
|
||||
IsSystemDoc = true,
|
||||
IsPublish=sysDoc.IsPublish,
|
||||
CurrentStaffTrainDays=sysDoc.CurrentStaffTrainDays,
|
||||
NewStaffTrainDays = sysDoc.NewStaffTrainDays,
|
||||
Id = sysDoc.Id,
|
||||
@@ -326,6 +328,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
//UserTypeShortName = user.UserTypeRole.UserTypeShortName
|
||||
};
|
||||
|
||||
|
||||
var list = await query
|
||||
//过滤掉删除的,并且没有签名的
|
||||
.Where(t => !(t.IsDeleted == true && t.ConfirmTime == null))
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
[ApiExplorerSettings(GroupName = "Trial")]
|
||||
public class TrialDocumentService(IRepository<TrialDocument> _trialDocumentRepository,
|
||||
IRepository<Trial> _trialRepository,
|
||||
IRepository<AuditRecord> _auditRecordRepository,
|
||||
IRepository<TrialDocumentAttachment> _trialDocumentAttachmentRepository,
|
||||
ISystemDocumentService _systemDocumentService,
|
||||
IRepository<SystemDocConfirmedIdentityUser> _systemDocConfirmedUserRepository,
|
||||
@@ -53,9 +54,9 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
var trialDocumentAttachmentQueryable = _trialDocumentAttachmentRepository
|
||||
.WhereIf(inQuery.TrialDocumentId != null, x => x.TrialDocumentId == inQuery.TrialDocumentId)
|
||||
.WhereIf(inQuery.Name != null, x => x.Name.Contains(inQuery.Name))
|
||||
.WhereIf(inQuery.FileFormat != null, x => x.FileFormat == inQuery.FileFormat)
|
||||
.ProjectTo<TrialDocumentAttachmentView>(_mapper.ConfigurationProvider);
|
||||
.WhereIf(inQuery.Name != null, x => x.Name.Contains(inQuery.Name))
|
||||
.WhereIf(inQuery.FileFormat != null, x => x.FileFormat == inQuery.FileFormat)
|
||||
.ProjectTo<TrialDocumentAttachmentView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await trialDocumentAttachmentQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
@@ -100,8 +101,9 @@ namespace IRaCIS.Core.Application.Services
|
||||
await _trialDocumentRepository.UpdatePartialFromQueryAsync(x => inDto.Ids.Contains(x.Id), x => new TrialDocument()
|
||||
{
|
||||
IsPublish = true,
|
||||
PublishDate = DateTime.Now,
|
||||
IsDeleted = false,
|
||||
});
|
||||
}, false, true);
|
||||
await _trialDocumentRepository.SaveChangesAsync();
|
||||
Console.WriteLine("开始 发布项目文档");
|
||||
|
||||
@@ -149,7 +151,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
// 从新作用域解析服务
|
||||
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
|
||||
await mediator.Publish(new ImageQCRecurringEvent { TrialId= Guid.Parse("08de2254-5d7d-581a-0242-0a0001000000") });
|
||||
await mediator.Publish(new ImageQCRecurringEvent { TrialId = Guid.Parse("08de2254-5d7d-581a-0242-0a0001000000") });
|
||||
}
|
||||
});
|
||||
return ResponseOutput.Result(true);
|
||||
@@ -167,8 +169,10 @@ namespace IRaCIS.Core.Application.Services
|
||||
var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == inQuery.TrialId)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name))
|
||||
.WhereIf(inQuery.FileTypeId != null, t => t.FileTypeId == inQuery.FileTypeId)
|
||||
.WhereIf(inQuery.UserTypeId != null, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == inQuery.UserTypeId))
|
||||
.WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted)
|
||||
.WhereIf(inQuery.UserTypeId != null, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == inQuery.UserTypeId))
|
||||
.WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted)
|
||||
.WhereIf(inQuery.IsPublish != null, t => t.IsPublish == inQuery.IsPublish)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.FileTypeCode), t => t.FileType.Code == inQuery.FileTypeCode)
|
||||
.ProjectTo<TrialDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us = _userInfo.IsEn_Us });
|
||||
|
||||
return await trialDocumentQueryable.ToPagedListAsync(inQuery);
|
||||
@@ -177,7 +181,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<TrialSignDocView>> GetTrialSignDocumentList(TrialDocQuery inQuery)
|
||||
{
|
||||
var trialDocQueryable = from trialDoc in _trialDocumentRepository.AsQueryable(true)
|
||||
var trialDocQueryable = from trialDoc in _trialDocumentRepository.Where(t => t.IsPublish)
|
||||
.WhereIf(inQuery.TrialId != null, t => t.TrialId == inQuery.TrialId)
|
||||
.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
|
||||
@@ -350,7 +354,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
#region 统一用户修改
|
||||
|
||||
var systemDocQuery =
|
||||
from sysDoc in _systemDocumentRepository.AsQueryable(true).Where(t => t.NeedConfirmedUserTypeList.Any(c => c.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
from sysDoc in _systemDocumentRepository.Where(t => t.IsPublish).Where(t => t.NeedConfirmedUserTypeList.Any(c => c.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
//外部人员 只签署 外部需要签署的
|
||||
.WhereIf(isInternal == false, t => t.DocUserSignType == DocUserSignType.InnerAndOuter)
|
||||
from trialUser in _trialIdentityUserRepository.AsQueryable(false)
|
||||
@@ -389,7 +393,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
//项目文档查询
|
||||
var trialDocQuery =
|
||||
from trialDoc in _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == inQuery.TrialId).Where(t => t.NeedConfirmedUserTypeList.Any(c => c.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
from trialDoc in _trialDocumentRepository.Where(t => t.IsPublish).Where(t => t.TrialId == inQuery.TrialId).Where(t => t.NeedConfirmedUserTypeList.Any(c => c.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
from trialUser in _trialIdentityUserRepository.AsQueryable(false).Where(t => t.TrialId == inQuery.TrialId && t.IdentityUserId == _userInfo.IdentityUserId
|
||||
&& t.TrialUserRoleList.Any(t => trialDoc.NeedConfirmedUserTypeList.Any(c => c.NeedConfirmUserTypeId == t.UserRole.UserTypeId)))
|
||||
|
||||
@@ -579,13 +583,14 @@ namespace IRaCIS.Core.Application.Services
|
||||
#endregion
|
||||
|
||||
|
||||
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == inQuery.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped)
|
||||
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.IsPublish)
|
||||
.Where(t => t.TrialId == inQuery.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped)
|
||||
.Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId)))
|
||||
.Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.CountAsync();
|
||||
|
||||
|
||||
var needSignSystemDocCount = await _systemDocumentRepository.AsQueryable(true)
|
||||
var needSignSystemDocCount = await _systemDocumentRepository.AsQueryable(true).Where(t => t.IsPublish)
|
||||
.WhereIf(isInternal == false, t => t.DocUserSignType == DocUserSignType.InnerAndOuter)
|
||||
.Where(t => t.IsDeleted == false && !t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.CountAsync();
|
||||
@@ -618,7 +623,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
var trialInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId, ignoreQueryFilters: true).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync());
|
||||
|
||||
var trialDocQuery =
|
||||
from trialDoc in _trialDocumentRepository.AsQueryable(false).Where(t => t.TrialId == inQuery.TrialId)
|
||||
from trialDoc in _trialDocumentRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsPublish)
|
||||
.Where(t => inQuery.UserTypeId != null ? t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == inQuery.UserTypeId) : true)
|
||||
from trialUser in _trialIdentityUserRepository.AsQueryable(false).Where(t => t.TrialId == inQuery.TrialId
|
||||
&& t.TrialUserRoleList.AsQueryable().Any(t => trialDoc.NeedConfirmedUserTypeList.Any(c => c.NeedConfirmUserTypeId == t.UserRole.UserTypeId))
|
||||
@@ -709,7 +714,8 @@ namespace IRaCIS.Core.Application.Services
|
||||
.WhereIf(inQuery.BeginCreateTime != null, t => t.CreateTime >= inQuery.BeginCreateTime)
|
||||
.WhereIf(inQuery.EndCreateTime != null, t => t.CreateTime <= inQuery.EndCreateTime)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.UserName), t => t.UserName.Contains(inQuery.UserName))
|
||||
.WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted);
|
||||
.WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted)
|
||||
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.EA, t => t.ConfirmTime != null);
|
||||
|
||||
var result = await unionQuery.ToPagedListAsync(inQuery);
|
||||
|
||||
@@ -919,6 +925,12 @@ namespace IRaCIS.Core.Application.Services
|
||||
//EA 只能查看内部人员文档
|
||||
var isEA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.EA;
|
||||
|
||||
//EA 但是没有在进行的培训记录查看权限,那么返回空数据
|
||||
if (isEA && !_auditRecordRepository.Any(t => t.IsViewTrainingRecord && t.AuditState == AuditState.Ongoing && t.AuditRecordIdentityUserList.Any(c => c.IdentityUserId == _userInfo.IdentityUserId)))
|
||||
{
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
var list = _systemDocConfirmedUserRepository.Where(t => t.ConfirmTime != null)
|
||||
.WhereIf(isEA, t => t.ConfirmUser.IsZhiZhun == true)
|
||||
.Select(t => new { t.ConfirmUserId, t.ConfirmUser.UserName, t.ConfirmUser.FullName }).Distinct().ToList();
|
||||
@@ -934,10 +946,19 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
var isEA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.EA;
|
||||
|
||||
//EA 但是没有在进行的培训记录查看权限,那么返回空数据
|
||||
if (isEA && !_auditRecordRepository.Any(t => t.IsViewTrainingRecord && t.AuditState == AuditState.Ongoing && t.AuditRecordIdentityUserList.Any(c => c.IdentityUserId == _userInfo.IdentityUserId)))
|
||||
{
|
||||
return ResponseOutput.Ok(new PageOutput<UnionDocumentWithConfirmInfoView>());
|
||||
}
|
||||
|
||||
|
||||
var systemDocQuery =
|
||||
from sysDoc in _systemDocumentRepository.AsQueryable(false)
|
||||
from sysDoc in _systemDocumentRepository.Where(t => t.IsPublish)
|
||||
.Where(t => inQuery.UserTypeId != null ? t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == inQuery.UserTypeId) : true)
|
||||
from identityUser in _identityUserRepository.AsQueryable(false).Where(t => t.Status == UserStateEnum.Enable && t.UserRoleList.Where(t => t.IsUserRoleDisabled == false).Any(t => sysDoc.NeedConfirmedUserTypeList.AsQueryable().Any(c => c.NeedConfirmUserTypeId == t.UserTypeId)))
|
||||
from identityUser in _identityUserRepository.AsQueryable(false)
|
||||
|
||||
.Where(t => t.Status == UserStateEnum.Enable && t.UserRoleList.Where(t => t.IsUserRoleDisabled == false).Any(t => sysDoc.NeedConfirmedUserTypeList.AsQueryable().Any(c => c.NeedConfirmUserTypeId == t.UserTypeId)))
|
||||
.Where(t => inQuery.UserId != null ? t.Id == inQuery.UserId : true)
|
||||
.Where(t => inQuery.UserTypeId != null ? t.UserRoleList.Any(t => t.UserTypeId == inQuery.UserTypeId && t.IsUserRoleDisabled == false) : true)
|
||||
.Where(t => isEA ? t.IsZhiZhun == true : true) //EA 只能查看内部人员文档
|
||||
@@ -946,6 +967,9 @@ namespace IRaCIS.Core.Application.Services
|
||||
select new UnionDocumentWithConfirmInfoView()
|
||||
{
|
||||
IsSystemDoc = true,
|
||||
SysDocUserSignType = sysDoc.DocUserSignType,
|
||||
IsConfirmIdentityUserInner = identityUser.IsZhiZhun,
|
||||
IsPublish=sysDoc.IsPublish,
|
||||
Id = sysDoc.Id,
|
||||
CreateTime = sysDoc.CreateTime,
|
||||
IsDeleted = sysDoc.IsDeleted,
|
||||
@@ -977,14 +1001,16 @@ namespace IRaCIS.Core.Application.Services
|
||||
};
|
||||
|
||||
var unionQuery = systemDocQuery.IgnoreQueryFilters().Where(t => !(t.IsDeleted == true && t.ConfirmTime == null))
|
||||
//外部人员 只签署 外部需要签署的
|
||||
.Where(t => t.IsConfirmIdentityUserInner == false ? t.SysDocUserSignType == DocUserSignType.InnerAndOuter : true)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name))
|
||||
.WhereIf(inQuery.FileTypeId != null, t => t.FileTypeId == inQuery.FileTypeId)
|
||||
.WhereIf(inQuery.IsConfirmed == true, t => t.ConfirmTime != null)
|
||||
.WhereIf(inQuery.IsConfirmed == false, t => t.ConfirmTime == null)
|
||||
.WhereIf(inQuery.StartConfirmTime != null, t => t.ConfirmTime >= inQuery.StartConfirmTime.Value)
|
||||
.WhereIf(inQuery.EndConfirmTime != null, t => t.ConfirmTime <= inQuery.EndConfirmTime.Value)
|
||||
.WhereIf(inQuery.BeginCreateTime != null, t => t.CreateTime >= inQuery.BeginCreateTime)
|
||||
.WhereIf(inQuery.EndCreateTime != null, t => t.CreateTime <= inQuery.EndCreateTime)
|
||||
.WhereIf(inQuery.BeginCreateTime != null, t => t.CreateTime >= inQuery.BeginCreateTime)
|
||||
.WhereIf(inQuery.EndCreateTime != null, t => t.CreateTime <= inQuery.EndCreateTime)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.UserName), t => t.UserName.Contains(inQuery.UserName))
|
||||
.WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted)
|
||||
.WhereIf(isInternal == false, t => t.ConfirmTime != null); //不是内部的人,看有签名时间的
|
||||
@@ -1076,6 +1102,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
return ResponseOutput.NotOk(_localizer["TrialD_DuplicateFileInProject"]);
|
||||
}
|
||||
|
||||
entity.IsDeleted = true;
|
||||
//entity.Id = NewId.NextGuid();
|
||||
await _trialDocumentRepository.AddAsync(entity, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
@@ -1088,7 +1115,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
return ResponseOutput.NotOk(_localizer["TrialD_DuplicateFileInProject"]);
|
||||
}
|
||||
|
||||
var document = (await _trialDocumentRepository.Where(t => t.Id == addOrEditTrialDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
var document = (await _trialDocumentRepository.Where(t => t.Id == addOrEditTrialDocument.Id, true,true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
bool beforeIsPublish = document.IsPublish;
|
||||
bool beforeIsDeleted = document.IsDeleted;
|
||||
@@ -1096,6 +1123,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
_mapper.Map(addOrEditTrialDocument, document);
|
||||
document.UpdateTime = DateTime.Now;
|
||||
|
||||
#region 不区分路径了
|
||||
|
||||
//if (document.FileTypeId != addOrEditTrialDocument.FileTypeId)
|
||||
|
||||
@@ -13,6 +13,7 @@ using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Domain.Share.Common;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
@@ -617,8 +618,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
FileStream = File.OpenRead(phyPath),
|
||||
});
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
var trialInfo = await _trialRepository.Where(t => t.Id == taskInfo.TrialId).FirstOrDefaultAsync();
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig, trialInfo);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
@@ -733,8 +734,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
FileStream = pdfMemoryStream
|
||||
});
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
var trialInfo = await _trialRepository.Where(t => t.Id == taskInfo.TrialId).FirstOrDefaultAsync();
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig, trialInfo);
|
||||
|
||||
}
|
||||
|
||||
@@ -772,10 +773,12 @@ namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
var subjectId = generateEmailCommand.SubjectId;
|
||||
var businessScenarioEnum = generateEmailCommand.BusinessScenarioEnum;
|
||||
var trialReadingCriterionId = generateEmailCommand.TrialReadingCriterionId;
|
||||
var criterionType = generateEmailCommand.CriterionType;
|
||||
|
||||
|
||||
var trialConfig = await _subjectRepository.Where(t => t.Id == subjectId).Select(t => new { t.Trial.IsEnrollementQualificationConfirm, t.Trial.IsPDProgressView }).FirstNotNullAsync();
|
||||
|
||||
var trialConfig = await _subjectRepository.Where(t => t.Id == subjectId).Select(t => new { t.Trial.IsEnrollementQualificationConfirm, t.Trial.IsPDProgressView, t.TrialId }).FirstNotNullAsync();
|
||||
var trialReadingCriterionId = _readingQuestionCriterionTrialRepository.Where(t => t.CriterionType == criterionType && t.TrialId == trialConfig.TrialId).Select(t => t.Id).FirstOrDefault();
|
||||
|
||||
//找到入组确认 或者Pd 进展 已生成任务的 访视
|
||||
var subjectVisitList = await _subjectVisitRepository.Where(t => t.SubjectId == subjectId & t.CheckState == CheckStateEnum.CVPassed && (t.IsEnrollmentConfirm == true || t.PDState == PDStateEnum.PDProgress)).ToListAsync();
|
||||
@@ -1670,9 +1673,10 @@ x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.LesionNumber && x.Readi
|
||||
{
|
||||
//await SyncSystemEmainCofigDocListAsync(inQuery.TrialId);
|
||||
|
||||
var trialConfig = _trialRepository.Where(t => t.Id == inQuery.TrialId).Select(t => new { t.IsEnrollementQualificationConfirm, t.IsPDProgressView }).First();
|
||||
var trialConfig = _trialRepository.Where(t => t.Id == inQuery.TrialId).Select(t => new { t.IsEnrollementQualificationConfirm, t.IsPDProgressView, TrialCriterionTypeList = t.TrialReadingCriterionList.Where(t => t.IsSigned).Select(t => t.CriterionType).ToList() }).First();
|
||||
|
||||
var trialEmailNoticeConfigQueryable = _trialEmailNoticeConfigRepository.Where(t => t.TrialId == inQuery.TrialId)
|
||||
.WhereIf(inQuery.EmailTopic.IsNotNullOrEmpty(), t => t.EmailTopic.Contains(inQuery.EmailTopic) || t.EmailTopicCN.Contains(inQuery.EmailTopic))
|
||||
.WhereIf(inQuery.IsDistinguishCriteria == false, t => t.IsDistinguishCriteria == false)
|
||||
.WhereIf(inQuery.IsDistinguishCriteria == true, t => t.IsDistinguishCriteria == true)
|
||||
.WhereIf(inQuery.CriterionTypeEnum != null, t => t.CriterionTypeList.Any(c => c == inQuery.CriterionTypeEnum))
|
||||
@@ -1690,6 +1694,7 @@ x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.LesionNumber && x.Readi
|
||||
var orderQuery = inQuery.Asc ? trialEmailNoticeConfigQueryable.OrderBy(sortField) : trialEmailNoticeConfigQueryable.OrderBy(sortField + " desc");
|
||||
var list = await orderQuery.ToListAsync();
|
||||
|
||||
|
||||
return ResponseOutput.Ok(list, trialConfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-20 06:17:11Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Application.Service.Interface;
|
||||
using IRaCIS.Core.Application.Service.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
/// <summary>
|
||||
/// 用户协议和隐私采集服务
|
||||
/// </summary>
|
||||
/// <param name="_userAgreementRepository"></param>
|
||||
/// <param name="_mapper"></param>
|
||||
/// <param name="_userInfo"></param>
|
||||
/// <param name="_localizer"></param>
|
||||
[ApiExplorerSettings(GroupName = "FileRecord")]
|
||||
public class UserAgreementService(IRepository<UserAgreement> _userAgreementRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IUserAgreementService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户协议和隐私采集列表
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<UserAgreementView>> GetUserAgreementList(UserAgreementQuery inQuery)
|
||||
{
|
||||
var userAgreementQueryable =_userAgreementRepository
|
||||
.WhereIf(inQuery.StartEffectiveDate.HasValue, t => t.EffectiveDate >= inQuery.StartEffectiveDate.Value)
|
||||
.WhereIf(inQuery.EndEffectiveDate.HasValue, t => t.EffectiveDate <= inQuery.EndEffectiveDate.Value)
|
||||
.WhereIf(inQuery.FileContent != null, t => t.FileContent.Contains(inQuery.FileContent))
|
||||
.WhereIf(inQuery.FileName != null, t => t.FileName.Contains(inQuery.FileName))
|
||||
.WhereIf(inQuery.FileVersion != null, t => t.FileVersion.Contains(inQuery.FileVersion))
|
||||
.WhereIf(inQuery.IsCurrentVersion != null, t => t.IsCurrentVersion==inQuery.IsCurrentVersion)
|
||||
.WhereIf(inQuery.UserAgreementTypeEnum != null, t => t.UserAgreementTypeEnum == inQuery.UserAgreementTypeEnum)
|
||||
.WhereIf(inQuery.StartUpdateDate.HasValue, t => t.UpdateDate >= inQuery.StartUpdateDate.Value)
|
||||
.WhereIf(inQuery.EndUpdateDate.HasValue, t => t.UpdateDate <= inQuery.EndUpdateDate.Value)
|
||||
.ProjectTo<UserAgreementView>(_mapper.ConfigurationProvider);
|
||||
var pageList= await userAgreementQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前版本的用户协议和隐私采集
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public async Task<List<UserAgreementView>> GetCurrentVersionUserAgreements()
|
||||
{
|
||||
var userAgreementList = await _userAgreementRepository.Where(x=>x.IsCurrentVersion)
|
||||
.ProjectTo<UserAgreementView>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
return userAgreementList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id获取用户协议和隐私采集
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public async Task<UserAgreementView> GetUserAgreementById(GetUserAgreementByIdInDto inDto)
|
||||
{
|
||||
var userAgreement = await _userAgreementRepository.Where(x => x.Id == inDto.Id)
|
||||
.ProjectTo<UserAgreementView>(_mapper.ConfigurationProvider)
|
||||
.FirstNotNullAsync();
|
||||
return userAgreement;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置为当前版本
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SetCurrentVersion(SetUserAgreementCurrentVersionInDto inDto)
|
||||
{
|
||||
var userAgreement=await _userAgreementRepository.Where(x=>x.Id==inDto.Id).FirstNotNullAsync();
|
||||
await _userAgreementRepository.UpdatePartialFromQueryAsync(
|
||||
x => x.UserAgreementTypeEnum== userAgreement.UserAgreementTypeEnum&&x.IsCurrentVersion,
|
||||
x => new UserAgreement { IsCurrentVersion = false },true);
|
||||
|
||||
await _userAgreementRepository.UpdatePartialFromQueryAsync(
|
||||
inDto.Id,
|
||||
x => new UserAgreement { IsCurrentVersion = true },true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增或者修改用户协议和隐私采集
|
||||
/// </summary>
|
||||
/// <param name="addOrEditUserAgreement"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateUserAgreement(UserAgreementAddOrEdit addOrEditUserAgreement)
|
||||
{
|
||||
var entity = await _userAgreementRepository.InsertOrUpdateAsync(addOrEditUserAgreement, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户协议和隐私采集
|
||||
/// </summary>
|
||||
/// <param name="userAgreementId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{userAgreementId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteUserAgreement(Guid userAgreementId)
|
||||
{
|
||||
var success = await _userAgreementRepository.DeleteFromQueryAsync(t => t.Id == userAgreementId,true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace IRaCIS.Core.Application.Service
|
||||
var userId = Guid.Empty;
|
||||
var isEn_Us = false;
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
|
||||
CreateMap<UserAgreement, UserAgreementView>();
|
||||
CreateMap<UserAgreement, UserAgreementAddOrEdit>().ReverseMap();
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
CreateMap<TrialDocumentAttachment, TrialDocumentAttachmentView>();
|
||||
CreateMap<TrialDocumentAttachment, TrialDocumentAttachmentAddOrEdit>().ReverseMap();
|
||||
|
||||
@@ -117,4 +117,10 @@ namespace IRaCIS.Core.Application.Contracts.Dicom.DTO
|
||||
public bool HasLabel { get; set; } = false;
|
||||
public bool KeySeries { get; set; } = false;
|
||||
}
|
||||
public class UpdateImageResizeDTO
|
||||
{
|
||||
public Guid SeriesId { get; set; }
|
||||
|
||||
public string ImageResizePath { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public string Bodypart { get; set; } = string.Empty;
|
||||
|
||||
public string BodyPartForEditOther { get; set; } = string.Empty;
|
||||
|
||||
public DateTime? StudyTime { get; set; }
|
||||
|
||||
|
||||
@@ -329,13 +331,26 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public string BodyPartExamined { get; set; } = string.Empty;
|
||||
|
||||
public string DicomStudyDate { get; set; }
|
||||
public string DicomStudyDate { get; set; } = string.Empty;
|
||||
|
||||
public string DicomStudyTime { get; set; }
|
||||
public string DicomStudyTime { get; set; } = string.Empty;
|
||||
|
||||
public List<AddOrUpdateSeriesDto> SeriesList { get; set; }
|
||||
|
||||
#region 模态支持增加字段
|
||||
|
||||
public string Manufacturer { get; set; } = string.Empty;
|
||||
|
||||
public string ManufacturerModelName { get; set; } = string.Empty;
|
||||
|
||||
public string DeviceSerialNumber { get; set; } = string.Empty;
|
||||
public string DeviceUID { get; set; } = string.Empty;
|
||||
|
||||
public string SoftwareVersions { get; set; } = string.Empty;
|
||||
|
||||
public string PatientWeight { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -363,14 +378,22 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public string ImageResizePath { get; set; } = string.Empty;
|
||||
|
||||
public string DicomSeriesDate { get; set; }
|
||||
public string DicomSeriesDate { get; set; } = string.Empty;
|
||||
|
||||
public string DicomSeriesTime { get; set; }
|
||||
public string DicomSeriesTime { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public List<AddInstanceDto> InstanceList { get; set; }
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
|
||||
#region 模态增加
|
||||
|
||||
public string RadiopharmaceuticalInformationSequence { get; set; } = string.Empty;
|
||||
|
||||
public string AcquisitionDate { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -403,15 +426,46 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public long FileSize { get; set; }
|
||||
|
||||
public string SOPClassUID { get; set; }
|
||||
public string SOPClassUID { get; set; } = string.Empty;
|
||||
|
||||
public string MediaStorageSOPClassUID { get; set; }
|
||||
public string MediaStorageSOPClassUID { get; set; } = string.Empty;
|
||||
|
||||
public string TransferSytaxUID { get; set; }
|
||||
public string TransferSytaxUID { get; set; } = string.Empty;
|
||||
|
||||
public string MediaStorageSOPInstanceUID { get; set; }
|
||||
public string MediaStorageSOPInstanceUID { get; set; } = string.Empty;
|
||||
|
||||
public bool IsEncapsulated => DicomTransferSyntax.Lookup(DicomUID.Parse(TransferSytaxUID)).IsEncapsulated;
|
||||
public bool IsEncapsulated => !string.IsNullOrEmpty(TransferSytaxUID) ? DicomTransferSyntax.Lookup(DicomUID.Parse(TransferSytaxUID)).IsEncapsulated : false;
|
||||
|
||||
#region 模态支持增加字段
|
||||
|
||||
public string PhotometricInterpretation { get; set; } = string.Empty;
|
||||
|
||||
public int BitsAllocated { get; set; }
|
||||
|
||||
public string PixelRepresentation { get; set; } = string.Empty;
|
||||
|
||||
public string RescaleIntercept { get; set; } = string.Empty;
|
||||
|
||||
public string RescaleSlope { get; set; } = string.Empty;
|
||||
|
||||
public string ImagePositionPatient { get; set; } = string.Empty;
|
||||
public string ImageOrientationPatient { get; set; } = string.Empty;
|
||||
|
||||
//可能大
|
||||
public string SequenceOfUltrasoundRegions { get; set; } = string.Empty;
|
||||
|
||||
public string FrameTime { get; set; } = string.Empty;
|
||||
|
||||
public string CorrectedImage { get; set; } = string.Empty;
|
||||
|
||||
public string Units { get; set; } = string.Empty;
|
||||
public string DecayCorrection { get; set; } = string.Empty;
|
||||
|
||||
public string EncapsulatedDocument { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -548,7 +602,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public string TaskBlindName { get; set; }
|
||||
|
||||
|
||||
|
||||
public Guid VisitId { get; set; }
|
||||
|
||||
public List<DownloadDicomStudyDto> StudyList { get; set; }
|
||||
@@ -567,14 +621,14 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
public string StudyInstanceUid { get; set; }
|
||||
public string StudyDIRPath { get; set; }
|
||||
|
||||
public List<DownloadDicomSeriesDto> SeriesList { get; set; }
|
||||
public List<DownloadDicomSeriesDto> SeriesList { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadDicomSeriesDto
|
||||
{
|
||||
public string Modality { get; set; }
|
||||
|
||||
public List<DownloadDicomInstanceDto> InstanceList { get; set; }
|
||||
public List<DownloadDicomInstanceDto> InstanceList { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadDicomInstanceDto
|
||||
@@ -755,7 +809,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
? $"{TotalReadingImageSize.Value / 1024d / 1024d:F3} MB"
|
||||
: "0.000 MB";
|
||||
|
||||
public string ImageTypeStr => $"{(IsHaveDicom ? "DICOM" : "")}{(IsHaveNoneDicom&&IsHaveDicom?" , ":"")}{(IsHaveNoneDicom ? "Non-DICOM" : "")}";
|
||||
public string ImageTypeStr => $"{(IsHaveDicom ? "DICOM" : "")}{(IsHaveNoneDicom && IsHaveDicom ? " , " : "")}{(IsHaveNoneDicom ? "Non-DICOM" : "")}";
|
||||
|
||||
public bool IsHaveDicom { get; set; }
|
||||
|
||||
@@ -929,7 +983,9 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
public int? VisitCount { get; set; }
|
||||
|
||||
|
||||
public int? MarkVisitCount { get; set; }
|
||||
public int? MarkIVUSVisitCount { get; set; }
|
||||
|
||||
public int? MarkOCTVisitCount { get; set; }
|
||||
|
||||
|
||||
public int? DicomStudyCount { get; set; }
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
IDistributedLockProvider _distributedLockProvider,
|
||||
IRepository<TrialImageDownload> _trialImageDownloadRepository,
|
||||
IRepository<Subject> _subjectRepository,
|
||||
IRepository<DicomInstance> _instanceRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IDownloadAndUploadService
|
||||
{
|
||||
|
||||
@@ -159,7 +160,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
if (inQuery.IsImageSegmentLabel == true)
|
||||
{
|
||||
var querySV = _subjectVisitRepository.WhereIf(inQuery.SubjectVisitId != null, t => t.Id == inQuery.SubjectVisitId)
|
||||
var querySV = _subjectVisitRepository.Where(t => t.CheckState == CheckStateEnum.CVPassed)
|
||||
.WhereIf(inQuery.SubjectVisitId != null, t => t.Id == inQuery.SubjectVisitId)
|
||||
.WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
|
||||
.Select(u => new SubjectVisitMarkUploadDto()
|
||||
{
|
||||
@@ -230,7 +232,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
|
||||
|
||||
var query = _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SourceSubjectVisitId != null
|
||||
var query = _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SourceSubjectVisit.CheckState == CheckStateEnum.CVPassed
|
||||
&& t.DoctorUserId == _userInfo.UserRoleId && t.TaskState == TaskState.Effect)
|
||||
//满足 有序,或者随机只看到当前任务的dicom 非dicom检查
|
||||
.WhereIf(criterionInfo.IsReadingTaskViewInOrder != ReadingOrder.SubjectRandom && inQuery.VisitTaskId != null, t => t.Id == inQuery.VisitTaskId)
|
||||
@@ -255,7 +257,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
OrginalStudyList = u.SourceSubjectVisit.StudyList
|
||||
.Where(t => u.TrialReadingCriterion.IsImageFilter ? ("|" + u.TrialReadingCriterion.CriterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|") : true)
|
||||
.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "OCT" : true)
|
||||
.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "OCT" : true)
|
||||
.Select(t => new StudyBasicInfo()
|
||||
{
|
||||
Id = t.Id,
|
||||
@@ -989,7 +991,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
|
||||
|
||||
var list = _noneDicomStudyReposiotry.Where(t => t.SubjectId == subjectId)
|
||||
var list = _noneDicomStudyReposiotry.Where(t => t.SubjectId == subjectId && t.SubjectVisit.CheckState == CheckStateEnum.CVPassed)
|
||||
.WhereIf(inQuery.SubjectVisitId != null, t => t.SubjectVisitId == inQuery.SubjectVisitId)
|
||||
//.WhereIf(info.IsImageFilter, t => ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|"))
|
||||
.Select(u => new TaskNoneDicomStudyDTO()
|
||||
@@ -1047,7 +1049,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
else
|
||||
{
|
||||
var query = from u in _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId
|
||||
&& t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect)
|
||||
&& t.SourceSubjectVisit.CheckState == CheckStateEnum.CVPassed && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect)
|
||||
//满足 有序,或者随机只看到当前任务的dicom 非dicom检查
|
||||
.WhereIf(info.IsReadingTaskViewInOrder != ReadingOrder.SubjectRandom && inQuery.VisitTaskId != null, t => t.Id == inQuery.VisitTaskId)
|
||||
join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == subjectId).WhereIf(info.IsImageFilter, t => ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|"))
|
||||
@@ -1137,8 +1139,11 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
var dirDic = new Dictionary<string, string>();
|
||||
#region DIR处理导出文件名,并将对应关系上传到OSS里面存储
|
||||
|
||||
var info = await _subjectVisitRepository.Where(t => t.Id == inQuery.SubjectVisitId).Select(t => new { t.Trial.TrialCode }).FirstOrDefaultAsync();
|
||||
|
||||
//有传输语法值的导出 才生成DIR
|
||||
if (_subjectVisitRepository.Where(t => t.Id == inQuery.SubjectVisitId).SelectMany(t => t.StudyList.SelectMany(t => t.InstanceList)).All(c => c.TransferSytaxUID != string.Empty))
|
||||
//if (_subjectVisitRepository.Where(t => t.Id == inQuery.SubjectVisitId).SelectMany(t => t.StudyList.SelectMany(t => t.InstanceList)).All(c => c.TransferSytaxUID != string.Empty))
|
||||
if (!_instanceRepository.Where(t => inQuery.SubjectVisitId == t.SubjectVisitId).Any(c => c.TransferSytaxUID == string.Empty))
|
||||
{
|
||||
var list = _subjectVisitRepository.Where(t => t.Id == inQuery.SubjectVisitId).SelectMany(t => t.StudyList)
|
||||
.Where(t => isQueryDicom ? inQuery.DicomStudyIdList.Contains(t.Id) : false)
|
||||
@@ -1148,7 +1153,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
DicomStudyId = t.DicomStudy.Id,
|
||||
|
||||
PatientId = t.DicomStudy.PatientId,
|
||||
PatientId = info.TrialCode + "-" + t.DicomStudy.Subject.Code,
|
||||
PatientName = t.DicomStudy.PatientName,
|
||||
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
||||
PatientSex = t.DicomStudy.PatientSex,
|
||||
@@ -1182,6 +1187,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
foreach (var item in list.GroupBy(t => new { t.StudyInstanceUid, t.DicomStudyId }))
|
||||
{
|
||||
|
||||
var studyUid = item.Key.StudyInstanceUid;
|
||||
|
||||
var ossFolder = $"{pathInfo.TrialId}/Image/{pathInfo.SubjectId}/{pathInfo.VisitId}/{item.Key.StudyInstanceUid}";
|
||||
|
||||
var isSucess = await SafeBussinessHelper.RunAsync(async () => await DicomDIRHelper.GenerateStudyDIRAndUploadAsync(item.ToList(), dirDic, ossFolder, _oSSService));
|
||||
@@ -1189,7 +1197,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
if (isSucess)
|
||||
{
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/{dirDic[$"{studyUid}_DICOMDIR"]}" });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1329,7 +1337,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
if (inQuery.IsImageSegmentLabel == true)
|
||||
{
|
||||
var list = await _subjectVisitRepository
|
||||
var list = await _subjectVisitRepository.Where(t => t.CheckState == CheckStateEnum.CVPassed)
|
||||
.WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
|
||||
.ProjectTo<SubjectVisitMarkStudyDto>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
@@ -1404,7 +1412,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
}
|
||||
|
||||
var query = _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId
|
||||
&& t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId)
|
||||
&& t.SourceSubjectVisit.CheckState == CheckStateEnum.CVPassed && t.DoctorUserId == doctorUserId)
|
||||
//满足 有序,或者随机只看到当前任务的dicom 非dicom检查
|
||||
.WhereIf(inQuery.VisitTaskId == null, t => t.TaskState == TaskState.Effect)//从待阅列表进入,要筛选出有效的,任务可能重阅了,也要看到该任务的
|
||||
.WhereIf(criterionInfo.IsReadingTaskViewInOrder != ReadingOrder.SubjectRandom && inQuery.VisitTaskId != null, t => t.Id == inQuery.VisitTaskId)
|
||||
@@ -1431,7 +1439,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
var dicomList = item.DicomStudyList.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "OCT" : true).ToList();
|
||||
var dicomList = item.DicomStudyList.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" || t.ModalityForEdit == "OCT" : true).ToList();
|
||||
|
||||
//dicomList.AddRange(preDicomStudyList.Where(t => t.SubjectVisitId == item.SourceSubjectVisitId).ToList());
|
||||
|
||||
@@ -1508,7 +1516,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
public async Task<IResponseOutput> GetIRReadingDownloadStudyInfo(IRDownloadQuery inQuery)
|
||||
{
|
||||
var info = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId)
|
||||
.Select(t => new { t.IsImageFilter, t.CriterionModalitys, t.TrialId, t.IsReadingTaskViewInOrder }).FirstNotNullAsync();
|
||||
.Select(t => new { t.IsImageFilter, t.CriterionModalitys, t.TrialId, t.IsReadingTaskViewInOrder, t.Trial.TrialCode }).FirstNotNullAsync();
|
||||
|
||||
var isQueryDicom = inQuery.DicomStudyIdList.Count > 0;
|
||||
var isQueryNoneDicom = inQuery.NoneDicomStudyIdList.Count > 0;
|
||||
@@ -1526,12 +1534,12 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
#region 在下载前先处理DIR文件
|
||||
|
||||
//有传输语法值的导出 才生成DIR
|
||||
if (_subjectVisitRepository.Where(t => t.SubjectId == inQuery.SubjectId).SelectMany(t => t.StudyList.SelectMany(t => t.InstanceList)).All(c => c.TransferSytaxUID != string.Empty))
|
||||
if (_subjectVisitRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.CheckState == CheckStateEnum.CVPassed).SelectMany(t => t.StudyList.SelectMany(t => t.InstanceList)).All(c => c.TransferSytaxUID != string.Empty))
|
||||
{
|
||||
var dirInfolist = _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id))).SelectMany(t => t.StudyList)
|
||||
.Where(t => isQueryDicom ? inQuery.DicomStudyIdList.Contains(t.Id) : false)
|
||||
.Where(t => info.IsImageFilter && inQuery.IsImageSegmentLabel == null ? ("|" + info.CriterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|") : true)
|
||||
.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "OCT" : true)
|
||||
.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" : true)
|
||||
.SelectMany(t => t.InstanceList.Where(t => t.IsReading && t.DicomSerie.IsReading))
|
||||
.Select(t => new StudyDIRInfo()
|
||||
{
|
||||
@@ -1539,7 +1547,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
DicomStudyId = t.DicomStudy.Id,
|
||||
|
||||
PatientId = t.DicomStudy.PatientId,
|
||||
PatientId = info.TrialCode + "-" + t.DicomStudy.PatientId,
|
||||
PatientName = t.DicomStudy.PatientName,
|
||||
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
||||
PatientSex = t.DicomStudy.PatientSex,
|
||||
@@ -1579,7 +1587,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
DicomStudyId = t.TaskStudy.Id,
|
||||
|
||||
PatientId = t.TaskStudy.PatientId,
|
||||
PatientId = info.TrialCode + "-" + t.TaskStudy.Subject.Code,
|
||||
PatientName = t.TaskStudy.PatientName,
|
||||
PatientBirthDate = t.TaskStudy.PatientBirthDate,
|
||||
PatientSex = t.TaskStudy.PatientSex,
|
||||
@@ -1622,6 +1630,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
var ossFolder = $"{pathInfo.TrialId}/Image/{pathInfo.SubjectId}/{visitId}/{item.Key.StudyInstanceUid}";
|
||||
|
||||
var studyUid = item.Key.StudyInstanceUid;
|
||||
|
||||
var isSucess = await SafeBussinessHelper.RunAsync(async () => await DicomDIRHelper.GenerateStudyDIRAndUploadAsync(item.ToList(), dirDic, ossFolder, _oSSService));
|
||||
|
||||
|
||||
@@ -1629,11 +1639,11 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
if (isTaskStudy)
|
||||
{
|
||||
await _taskStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new TaskStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
await _taskStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new TaskStudy() { StudyDIRPath = $"/{ossFolder}/{dirDic[$"{studyUid}_DICOMDIR"]}" });
|
||||
}
|
||||
else
|
||||
{
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/{dirDic[$"{studyUid}_DICOMDIR"]}" });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1642,7 +1652,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
#endregion
|
||||
|
||||
var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id)))
|
||||
var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id) && t.CheckState == CheckStateEnum.CVPassed))
|
||||
//一致性分析,导致查询出来两条数据
|
||||
join visitTask in _visitTaskRepository.Where(t => taskIdList.Contains(t.Id)) on sv.Id equals visitTask.SourceSubjectVisitId into cc
|
||||
from leftVisitTask in cc.DefaultIfEmpty()
|
||||
@@ -1658,7 +1668,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
TaskBlindName = leftVisitTask.TaskBlindName,
|
||||
StudyList = sv.StudyList.Where(t => isQueryDicom ? inQuery.DicomStudyIdList.Contains(t.Id) : false)
|
||||
.Where(t => info.IsImageFilter && inQuery.IsImageSegmentLabel == null ? ("|" + info.CriterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|") : true)
|
||||
.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "OCT" : true)
|
||||
.Where(t => inQuery.IsImageSegmentLabel == false ? t.ModalityForEdit == "XA" || t.ModalityForEdit == "DSA" : true)
|
||||
.Select(u => new DownloadDicomStudyDto()
|
||||
{
|
||||
PatientId = u.PatientId,
|
||||
@@ -2248,11 +2258,15 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#region 在下载前先处理DIR文件
|
||||
|
||||
//sql 超时
|
||||
//_subjectVisitRepository.Where(t => inCommand.SubjectVisitIdList.Contains(t.Id))
|
||||
// .SelectMany(t => t.StudyList.SelectMany(t => t.InstanceList.Where(t => isExportReading ? (t.IsReading && t.DicomSerie.IsReading) : true)))
|
||||
// .All(c => c.TransferSytaxUID != string.Empty)
|
||||
//有传输语法值的导出 才生成DIR
|
||||
if (_subjectVisitRepository.Where(t => inCommand.SubjectVisitIdList.Contains(t.Id)).SelectMany(t => t.StudyList.SelectMany(t => t.InstanceList.Where(t => isExportReading ? (t.IsReading && t.DicomSerie.IsReading) : true))).All(c => c.TransferSytaxUID != string.Empty))
|
||||
if (!_instanceRepository.Where(t => isExportReading ? (t.IsReading && t.DicomSerie.IsReading) : true)
|
||||
.Where(t => inCommand.SubjectVisitIdList.Contains(t.SubjectVisitId)).Any(c => c.TransferSytaxUID == string.Empty))
|
||||
{
|
||||
var dirInfolist = _subjectVisitRepository.Where(t => inCommand.SubjectVisitIdList.Contains(t.Id)).SelectMany(t => t.StudyList)
|
||||
.SelectMany(t => t.InstanceList.Where(t => isExportReading ? (t.IsReading && t.DicomSerie.IsReading) : true))
|
||||
@@ -2263,7 +2277,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
DicomStudyId = t.DicomStudy.Id,
|
||||
|
||||
PatientId = t.DicomStudy.PatientId,
|
||||
PatientId = t.Trial.TrialCode + "-" + t.DicomStudy.Subject.Code,
|
||||
PatientName = t.DicomStudy.PatientName,
|
||||
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
||||
PatientSex = t.DicomStudy.PatientSex,
|
||||
@@ -2301,6 +2315,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
var subjectId = item.First().SubjectId;
|
||||
|
||||
var studyUid = item.Key.StudyInstanceUid;
|
||||
|
||||
var ossFolder = $"{inCommand.TrialId}/Image/{subjectId}/{visitId}/{item.Key.StudyInstanceUid}";
|
||||
|
||||
@@ -2308,7 +2323,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
if (isSucess)
|
||||
{
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/{dirDic[$"{studyUid}_DICOMDIR"]}" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2405,14 +2420,18 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
SubjectId = t.Id,
|
||||
SubjectCode = t.Code,
|
||||
IsUrgent = t.IsUrgent,
|
||||
VisitCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).Count(),
|
||||
MarkVisitCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).Count(t => t.TaskStudyList.Any()),
|
||||
|
||||
DicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).SelectMany(t => t.StudyList).Count(),
|
||||
MarkDicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).SelectMany(t => t.TaskStudyList).Count(),
|
||||
VisitCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted && t.CheckState == CheckStateEnum.CVPassed).Count(),
|
||||
|
||||
NoneDicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).SelectMany(t => t.NoneDicomStudyList).Count(),
|
||||
MarkNoneDicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).SelectMany(t => t.NoneDicomStudyList).Where(t => t.ImageLabelNoneDicomFileList.Any()).Count(),
|
||||
MarkIVUSVisitCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted && t.CheckState == CheckStateEnum.CVPassed).Count(t => t.NoneDicomStudyList.Where(t => t.Modality == "IVUS").SelectMany(c => c.ImageLabelNoneDicomFileList).Any()),
|
||||
|
||||
MarkOCTVisitCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted && t.CheckState == CheckStateEnum.CVPassed).Count(t => t.NoneDicomStudyList.Where(t => t.Modality == "OCT").SelectMany(c => c.ImageLabelNoneDicomFileList).Any()),
|
||||
|
||||
DicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted && t.CheckState == CheckStateEnum.CVPassed).SelectMany(t => t.StudyList).Count(),
|
||||
//MarkDicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).SelectMany(t => t.TaskStudyList).Count(),
|
||||
|
||||
NoneDicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted && t.CheckState == CheckStateEnum.CVPassed).SelectMany(t => t.NoneDicomStudyList).Count(),
|
||||
//MarkNoneDicomStudyCount = t.SubjectVisitList.Where(t => t.SubmitState == SubmitStateEnum.Submitted).SelectMany(t => t.NoneDicomStudyList).Where(t => t.ImageLabelNoneDicomFileList.Any()).Count(),
|
||||
}).ToPagedListAsync(inQuery);
|
||||
|
||||
return ResponseOutput.Ok(list);
|
||||
|
||||
@@ -47,6 +47,10 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
//质控过程中并且不是IQC时,可以看到删除的(不需要忽略过滤器) 质控中iqc 也需要看到删除的
|
||||
var isViewDelete = !isQCFinished;
|
||||
|
||||
var isFilterIVUSNoneDicom = false;
|
||||
|
||||
CriterionType? criterionType = null;
|
||||
|
||||
IQueryable<NoneDicomStudyView> noneDicomStudyQueryable = default;
|
||||
if (visitTaskId == null || visitTaskId == Guid.Empty)
|
||||
{
|
||||
@@ -71,10 +75,18 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
}
|
||||
|
||||
|
||||
//ivus-在访视的时候visitTaskId==null 需要过滤掉空检查 ,但是在靶段标注的查看访视级别的时候不能过滤
|
||||
if (_subjectVisitRepository.Where(t => t.Id == subjectVisitId).SelectMany(t => t.Trial.TrialReadingCriterionList)
|
||||
.Where(t => t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT).Distinct().Count() == 2
|
||||
&& visitTaskId == null)
|
||||
{
|
||||
isFilterIVUSNoneDicom = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Select(t => new { t.BlindSubjectCode, t.TrialReadingCriterionId, t.TrialReadingCriterion.CriterionType, t.TrialReadingCriterion.IsImageFilter, t.TrialReadingCriterion.CriterionModalitys }).FirstNotNullAsync();
|
||||
criterionType = taskinfo.CriterionType;
|
||||
|
||||
if ((taskinfo.CriterionType == CriterionType.IVUS || taskinfo.CriterionType == CriterionType.OCT) && isImageSegmentLabel == false)
|
||||
{
|
||||
@@ -97,18 +109,12 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
}
|
||||
|
||||
var isFilterIVUSNoneDicom = false;
|
||||
if (_subjectVisitRepository.Where(t => t.Id == subjectVisitId).SelectMany(t => t.Trial.TrialReadingCriterionList)
|
||||
.Where(t => t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT).Distinct().Count() == 2
|
||||
)
|
||||
{
|
||||
isFilterIVUSNoneDicom = true;
|
||||
}
|
||||
|
||||
|
||||
var list = await noneDicomStudyQueryable.Where(t => isFilterIVUSNoneDicom ? t.Modality != "IVUS" : true)
|
||||
.OrderBy(x => x.ImageDate).ThenBy(x => x.CreateTime).ToListAsync();
|
||||
|
||||
var config = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => new { t.Trial.ImageFormatList, t.Trial.StudyNameList, t.Trial.IsShowStudyName, AuditState = qcAuditState }).FirstOrDefaultAsync();
|
||||
var config = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => new { t.Trial.ImageFormatList, t.Trial.StudyNameList, t.Trial.IsShowStudyName, AuditState = qcAuditState, CriterionType=criterionType }).FirstOrDefaultAsync();
|
||||
return ResponseOutput.Ok(list, config);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,18 @@ namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新缩略图路径
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> UpdateImageResizePath(UpdateImageResizeDTO dto)
|
||||
{
|
||||
await _seriesRepository.UpdatePartialFromQueryAsync(t => t.Id == dto.SeriesId, u => new DicomSeries() { ImageResizePath = dto.ImageResizePath }, true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
//医生读片那一块有耦合,关键序列 这里暂时留存
|
||||
/// <summary> 指定资源Id,获取Dicom检查所属序列信息列表 </summary>
|
||||
|
||||
@@ -382,7 +382,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
Id = t.Id,
|
||||
|
||||
Bodypart = t.BodyPartExamined,
|
||||
Bodypart = t.BodyPartForEdit,
|
||||
BodyPartForEditOther = t.BodyPartForEditOther,
|
||||
|
||||
Modalities = t.Modalities,
|
||||
|
||||
@@ -433,6 +434,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
Id = t.Id,
|
||||
|
||||
Bodypart = t.BodyPart,
|
||||
BodyPartForEditOther=t.BodyPartForEditOther,
|
||||
|
||||
Modalities = t.Modality,
|
||||
|
||||
|
||||
@@ -92,6 +92,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
CreateMap<DicomSeries, DicomSeriesDTO>()
|
||||
.ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.SubjectVisit.Subject.Code))
|
||||
.ForMember(o => o.VisitName, t => t.MapFrom(u => u.SubjectVisit.VisitName));
|
||||
CreateMap<TaskSeries, DicomSeriesDTO>()
|
||||
.ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.SubjectVisit.Subject.Code))
|
||||
.ForMember(o => o.VisitName, t => t.MapFrom(u => u.SubjectVisit.VisitName));
|
||||
CreateMap<SCPSeries, DicomSeriesDTO>();
|
||||
|
||||
|
||||
|
||||
@@ -372,7 +372,10 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO
|
||||
public string ModuleTypeName { get; set; } = string.Empty;
|
||||
public string ModuleTypeNameCN { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 标准枚举
|
||||
/// </summary>
|
||||
public CriterionType? CriterionType { get; set; }
|
||||
public string SignText { get; set; } = string.Empty;
|
||||
|
||||
public decimal? VisitNum { get; set; }
|
||||
|
||||
@@ -1263,6 +1263,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
from leftObjectTypeIdtemp in ObjectTypeIdtemp.DefaultIfEmpty()
|
||||
select new FrontAuditConfigView()
|
||||
{
|
||||
ApplyCriterionList=data.ApplyCriterionList,
|
||||
IsShowParent = data.IsShowParent,
|
||||
ChildrenTypeId = data.ChildrenTypeId,
|
||||
Code = data.Code,
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||
public class InspectionService(IRepository<DataInspection> _dataInspectionRepository,
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IRepository<TrialSign> _trialSignRepository,
|
||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
||||
IRepository<IdentityUser> _identityUserRepository,
|
||||
IRepository<TrialAuditShow> _trialAuditShowRepository,
|
||||
IRepository<UserRole> _userRoleRepository,
|
||||
@@ -102,6 +103,9 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||
join trial in _trialRepository.Where().IgnoreQueryFilters() on data.TrialId equals trial.Id into trialtemp
|
||||
from leftrial in trialtemp.DefaultIfEmpty()
|
||||
|
||||
join readingQuestionCriterionTrial in _readingQuestionCriterionTrialRepository.Where().IgnoreQueryFilters() on data.TrialReadingCriterionId equals readingQuestionCriterionTrial.Id into readingQuestionCriterionTrialtemp
|
||||
from leftreadingQuestionCriterionTrial in readingQuestionCriterionTrialtemp.DefaultIfEmpty()
|
||||
|
||||
|
||||
join trialSite in _trialSiteRepository.Where().IgnoreQueryFilters() on data.TrialSiteId equals trialSite.Id into trialSitetemp
|
||||
from lefttrialSite in trialSitetemp.DefaultIfEmpty()
|
||||
@@ -136,6 +140,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||
{
|
||||
IsShow = lefttrialShow != null ? lefttrialShow.IsShow : leftfrontAuditConfig.IsDefaultChoice,
|
||||
CreateTime = data.CreateTime,
|
||||
CriterionType= leftreadingQuestionCriterionTrial==null? null: leftreadingQuestionCriterionTrial.CriterionType,
|
||||
CreateUserId = data.CreateUserId,
|
||||
ModuleTypeId = leftmoduleTypec.Id,
|
||||
BlindName = data.VisitTask.TaskBlindName,
|
||||
|
||||
@@ -94,6 +94,10 @@ namespace IRaCIS.Application.Contracts
|
||||
public string UserCode { get; set; }
|
||||
public string EMail { get; set; }
|
||||
|
||||
public string HiddenEmail { get; set; }
|
||||
|
||||
|
||||
|
||||
public int Status { get; set; }
|
||||
public bool IsTestUser { get; set; }
|
||||
public bool IsZhiZhun { get; set; }
|
||||
@@ -112,7 +116,15 @@ namespace IRaCIS.Application.Contracts
|
||||
/// </summary>
|
||||
public DateTime? LastChangePassWordTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户协议Id
|
||||
/// </summary>
|
||||
public Guid? UserAgreementId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 隐私政策Id
|
||||
/// </summary>
|
||||
public Guid? PrivacyPolicyId { get; set; }
|
||||
}
|
||||
|
||||
public class MenuFuncTreeNodeView
|
||||
@@ -271,8 +283,15 @@ namespace IRaCIS.Application.Contracts
|
||||
public string OldPassWord { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class AdminResetUserPwdCommand
|
||||
{
|
||||
public Guid IdentityUserId { get; set; }
|
||||
|
||||
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
public string RouteUrl { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class UserAccountDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
@@ -11,12 +11,12 @@ namespace IRaCIS.Core.Application.Service
|
||||
//Task<UserDetailDTO> GetUser(Guid id);
|
||||
//Task<PageOutput<UserListDTO>> GetUserList(UserListQueryDTO param);
|
||||
//Task<IResponseOutput<LoginReturnDTO>> Login(string userName, string password);
|
||||
Task<IResponseOutput> VerifyMFACodeAsync(string Code);
|
||||
Task<IResponseOutput> VerifyMFACodeAsync(string Code,bool isRemember);
|
||||
|
||||
Task<IResponseOutput> SendMFAEmail(SendMfaCommand sendMfa);
|
||||
Task<UserBasicInfo> GetUserBasicInfo(Guid userId, string pwd);
|
||||
Task<IResponseOutput> ModifyPassword(EditPasswordCommand editPwModel);
|
||||
Task<IResponseOutput> ResetPassword(Guid userId);
|
||||
Task<IResponseOutput> ResetPassword(AdminResetUserPwdCommand inCommand);
|
||||
|
||||
Task<IResponseOutput> UpdateUser(UserCommand model);
|
||||
//Task<IResponseOutput> UpdateUserState(Guid userId, UserStateEnum state);
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
public class UserService(IRepository<UserRole> _userRoleRepository,
|
||||
IMailVerificationService _mailVerificationService,
|
||||
IRepository<VerificationCode> _verificationCodeRepository,
|
||||
IRepository<UserAgreement> _userAgreementRepository,
|
||||
IRepository<TrialUserRole> _userTrialRepository,
|
||||
IRepository<UserLog> _userLogRepository,
|
||||
IRepository<UserPassWordLog> _userPassWordLogRepository,
|
||||
@@ -40,7 +41,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
IRepository<Doctor> _doctorRepository,
|
||||
ISearcher _searcher, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IUserService
|
||||
{
|
||||
|
||||
private ServiceVerifyConfigOption _serviceVerifyConfigConfig = _verifyConfig.CurrentValue;
|
||||
private SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
||||
|
||||
private async Task VerifyUserNameAsync(Guid? identityUserId, string userName)
|
||||
@@ -285,17 +286,17 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// <summary>
|
||||
/// 重置密码为 默认密码
|
||||
/// </summary>
|
||||
/// <param name="identityUserId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{identityUserId:guid}")]
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> ResetPassword(Guid identityUserId)
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> ResetPassword(AdminResetUserPwdCommand inCommand)
|
||||
{
|
||||
var identityUserId = inCommand.IdentityUserId;
|
||||
|
||||
var pwd = IRCEmailPasswordHelper.GenerateRandomPassword(10);
|
||||
|
||||
|
||||
await _mailVerificationService.AdminResetPwdSendEmailAsync(identityUserId, pwd);
|
||||
await _mailVerificationService.AdminResetPwdSendEmailAsync(identityUserId, pwd, inCommand.BaseUrl);
|
||||
|
||||
await _identityUserRepository.UpdatePartialFromQueryAsync(t => t.Id == identityUserId, u => new IdentityUser()
|
||||
{
|
||||
@@ -307,6 +308,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await _fusionCache.RemoveAsync(CacheKeys.UserLoginError(userName));
|
||||
|
||||
await _fusionCache.RemoveByTagAsync(CacheKeys.UserMFATag(identityUserId));
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.ResetPassword }, true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
@@ -315,7 +318,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置密码发邮件 (未登陆修改)
|
||||
/// 重置密码发邮件 (未登陆修改-忘记密码)
|
||||
/// </summary>
|
||||
/// <param name="email"></param>
|
||||
/// <returns></returns>
|
||||
@@ -356,6 +359,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await _mailVerificationService.AnolymousSendEmailForResetAccount(email, verificationCode);
|
||||
|
||||
await _fusionCache.RemoveByTagAsync(CacheKeys.UserMFATag(existUser.Id));
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
@@ -435,6 +440,11 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.UnloginModifyPasswoed }, true);
|
||||
|
||||
await _mailVerificationService.AfterUserModifyPasswordSendEmailAsync(identityUserId);
|
||||
|
||||
|
||||
var find = await _identityUserRepository.FindAsync(identityUserId);
|
||||
await _fusionCache.RemoveAsync(CacheKeys.UserLoginError(find.UserName));
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
@@ -481,6 +491,10 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = _userInfo.IdentityUserId, OptType = UserOptType.LoginModifyPassword }, true);
|
||||
|
||||
await _mailVerificationService.AfterUserModifyPasswordSendEmailAsync(_userInfo.IdentityUserId);
|
||||
|
||||
await _fusionCache.RemoveByTagAsync(CacheKeys.UserMFATag(_userInfo.IdentityUserId));
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
|
||||
|
||||
@@ -822,9 +836,10 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// 验证MFA 邮件
|
||||
/// </summary>
|
||||
/// <param name="Code"></param>
|
||||
/// <param name="isRemember"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task<IResponseOutput> VerifyMFACodeAsync(string Code)
|
||||
public async Task<IResponseOutput> VerifyMFACodeAsync(string Code, bool isRemember)
|
||||
{
|
||||
var identityUserId = _userInfo.IdentityUserId;
|
||||
|
||||
@@ -854,6 +869,14 @@ namespace IRaCIS.Core.Application.Service
|
||||
}
|
||||
}
|
||||
|
||||
if (isRemember)
|
||||
{
|
||||
await _fusionCache.SetAsync(CacheKeys.UserMFAVerifyPass(identityUserId, _userInfo.BrowserFingerprint), _userInfo.BrowserFingerprint,
|
||||
TimeSpan.FromMinutes(_serviceVerifyConfigConfig.UserMFAVerifyMinutes), new[] { CacheKeys.UserMFATag(identityUserId) });
|
||||
Log.Logger.Warning($"MFA登录记录:{_userInfo.UserName} 浏览器标识: {_userInfo.BrowserFingerprint} 设置缓存分钟{_serviceVerifyConfigConfig.UserMFAVerifyMinutes}");
|
||||
}
|
||||
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
@@ -913,13 +936,23 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
public async Task<IResponseOutput> LoginOut(Guid identityUserId, Guid userRoleId)
|
||||
public async Task<IResponseOutput> LoginOut(Guid identityUserId, Guid? userRoleId)
|
||||
{
|
||||
await _fusionCache.RemoveAsync(CacheKeys.UserToken(identityUserId));
|
||||
|
||||
var userName = await _userRoleRepository.Where(t => t.Id == userRoleId).Select(t => t.IdentityUser.UserName).FirstOrDefaultAsync();
|
||||
if (_identityUserRepository.Any(t => t.Id == identityUserId) && userRoleId != null)
|
||||
{
|
||||
|
||||
var userName = await _userRoleRepository.Where(t => t.Id == userRoleId).Select(t => t.IdentityUser.UserName).FirstOrDefaultAsync();
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = userName, OptType = UserOptType.LoginOut }, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = null, ActionUserName = _userInfo.UserName, OptType = UserOptType.LoginOut }, true);
|
||||
}
|
||||
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = userName, OptType = UserOptType.LoginOut }, true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
@@ -967,14 +1000,6 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
var userLog = new UserLog();
|
||||
|
||||
if (failCount >= maxFailures)
|
||||
{
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.TempLockLogin }, true);
|
||||
|
||||
//$"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。"
|
||||
throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]);
|
||||
}
|
||||
|
||||
var userLoginReturnModel = new IRCLoginReturnDTO();
|
||||
|
||||
|
||||
@@ -986,7 +1011,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
var isLoginUncommonly = false;
|
||||
|
||||
#region //登录用户是系统用户的时候,就要要记录异地登录
|
||||
#region 登录用户是系统用户的时候,就要要记录异地登录
|
||||
|
||||
//账号在系统存在
|
||||
if (isExistAccount || loginUser != null)
|
||||
@@ -1029,7 +1054,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
var lastLoginIPRegion = await _userLogRepository.Where(t => t.ActionUserName == actionUserName && userOptTypes.Contains(t.OptType))
|
||||
.OrderByDescending(t => t.CreateTime).Select(t => t.IPRegion).FirstOrDefaultAsync();
|
||||
|
||||
if (lastLoginIPRegion != string.Empty)
|
||||
if (lastLoginIPRegion != null && lastLoginIPRegion != string.Empty)
|
||||
{
|
||||
// 与上一次区域不一致
|
||||
//if (SplitAndConcatenate(existUserLoginInfo.LastLoginIP) != SplitAndConcatenate(iPRegion))
|
||||
@@ -1044,7 +1069,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
//异地登录
|
||||
loginUser.LoginState = 2;
|
||||
|
||||
|
||||
await _fusionCache.RemoveByTagAsync(CacheKeys.UserMFATag(loginUser.IdentityUserId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1060,6 +1085,14 @@ namespace IRaCIS.Core.Application.Service
|
||||
//错误次数累加
|
||||
failCount++;
|
||||
|
||||
if (failCount >= maxFailures)
|
||||
{
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.TempLockLogin }, true);
|
||||
|
||||
//$"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。"
|
||||
throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]);
|
||||
}
|
||||
|
||||
await _fusionCache.SetAsync(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes));
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError, IsLoginUncommonly = isLoginUncommonly }, true);
|
||||
@@ -1080,6 +1113,53 @@ namespace IRaCIS.Core.Application.Service
|
||||
//登录成功 清除缓存
|
||||
await _fusionCache.SetAsync(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes));
|
||||
|
||||
// 记录同意用户协议以及隐私政策
|
||||
#region 记录同意用户协议以及隐私政策
|
||||
|
||||
var userAgreementList = await _userAgreementRepository.Where(t => t.IsCurrentVersion).OrderByDescending(t => t.CreateTime).ToListAsync();
|
||||
|
||||
var userAgreement = userAgreementList.FirstOrDefault(t => t.UserAgreementTypeEnum == UserAgreementType.UserAgreement);
|
||||
|
||||
if (userAgreement != null && loginUser.UserAgreementId != userAgreement.Id)
|
||||
{
|
||||
await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser()
|
||||
{
|
||||
UserAgreementId = userAgreement.Id,
|
||||
});
|
||||
|
||||
var obj = new
|
||||
{
|
||||
UserAgreementTypeEnum = UserAgreementType.UserAgreement,
|
||||
FileVersion = userAgreement.FileVersion,
|
||||
UserAgreementId = userAgreement.Id,
|
||||
IsEn_Us = _userInfo.IsEn_Us,
|
||||
};
|
||||
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.AcceptUserAgreement, JsonObj = obj.ToJsonStr() }, true);
|
||||
|
||||
}
|
||||
|
||||
var privacyCollection = userAgreementList.FirstOrDefault(t => t.UserAgreementTypeEnum == UserAgreementType.PrivacyCollection);
|
||||
|
||||
if (privacyCollection != null && loginUser.PrivacyPolicyId != privacyCollection.Id)
|
||||
{
|
||||
await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser()
|
||||
{
|
||||
PrivacyPolicyId = privacyCollection.Id,
|
||||
});
|
||||
|
||||
var obj = new
|
||||
{
|
||||
UserAgreementTypeEnum = UserAgreementType.PrivacyCollection,
|
||||
FileVersion = privacyCollection.FileVersion,
|
||||
UserAgreementId = privacyCollection.Id
|
||||
};
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.AcceptPrivacyPolicy, JsonObj = obj.ToJsonStr() }, true);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.Login, IsLoginUncommonly = isLoginUncommonly }, true);
|
||||
|
||||
@@ -1107,22 +1187,35 @@ namespace IRaCIS.Core.Application.Service
|
||||
if (_verifyConfig.CurrentValue.OpenLoginMFA)
|
||||
{
|
||||
|
||||
//MFA 发送邮件
|
||||
|
||||
userLoginReturnModel.IsMFA = true;
|
||||
if ((await _fusionCache.GetOrDefaultAsync(CacheKeys.UserMFAVerifyPass(identityUserId, _userInfo.BrowserFingerprint), "")) == _userInfo.BrowserFingerprint)
|
||||
{
|
||||
userLoginReturnModel.IsMFA = false;
|
||||
|
||||
Log.Logger.Warning($"MFA登录:{userName} 浏览器标识: {_userInfo.BrowserFingerprint},判断缓存里存在 ");
|
||||
}
|
||||
else
|
||||
{
|
||||
//MFA 发送邮件
|
||||
|
||||
userLoginReturnModel.IsMFA = true;
|
||||
|
||||
Log.Logger.Warning($"MFA登录:{userName} 浏览器标识: {_userInfo.BrowserFingerprint} 判断缓存已经不存在");
|
||||
}
|
||||
|
||||
var email = userLoginReturnModel.BasicInfo.EMail;
|
||||
|
||||
var hiddenEmail = IRCEmailPasswordHelper.MaskEmail(email);
|
||||
|
||||
userLoginReturnModel.BasicInfo.EMail = hiddenEmail;
|
||||
userLoginReturnModel.BasicInfo.HiddenEmail = hiddenEmail;
|
||||
|
||||
//修改密码 || 90天修改密码再mfa 之前
|
||||
if (userLoginReturnModel.BasicInfo.IsFirstAdd || userLoginReturnModel.BasicInfo.NeedChangePassWord)
|
||||
{
|
||||
//移动到上面去了
|
||||
//userLoginReturnModel.JWTStr = _tokenService.GetToken(userLoginReturnModel.BasicInfo);
|
||||
}
|
||||
else
|
||||
else if (userLoginReturnModel.IsMFA == true)
|
||||
{
|
||||
//正常登录才发送邮件
|
||||
await SendMFAEmail(new SendMfaCommand() { IdentityUserId = identityUserId, MFAType = UserMFAType.Login });
|
||||
@@ -1130,6 +1223,10 @@ namespace IRaCIS.Core.Application.Service
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
userLoginReturnModel.BasicInfo.HiddenEmail = userLoginReturnModel.BasicInfo.EMail;
|
||||
}
|
||||
|
||||
|
||||
await _fusionCache.SetAsync(CacheKeys.UserToken(identityUserId), userLoginReturnModel.JWTStr, TimeSpan.FromDays(7));
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
public bool IsBeMark { get; set; }
|
||||
|
||||
public DateTime? MarkTime { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -148,44 +148,25 @@ namespace IRaCIS.Core.Application.Contracts.DTO
|
||||
}
|
||||
|
||||
|
||||
public class GetUserUploadFileDto/*: ConsistencyCheckFile*/
|
||||
public class GetUserUploadFileDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
/// </summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 相对路径
|
||||
/// </summary>
|
||||
public string RelativePath { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public Guid CreateUserId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目ID
|
||||
/// </summary>
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者名称
|
||||
/// </summary>
|
||||
public string CreateUserName { get; set; }
|
||||
|
||||
#region 一致性核查额外增加字段
|
||||
|
||||
public EDCCheckState? CheckState { get; set; }
|
||||
|
||||
public string ResultPath { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -284,6 +265,7 @@ namespace IRaCIS.Core.Application.Contracts.DTO
|
||||
{
|
||||
public bool ExistsManual { get; set; }
|
||||
public bool IsHaveStudyClinicalData { get; set; }
|
||||
public bool QCRiskControl { get; set; }
|
||||
public SubjectClinicalDataDto SubjectClinicalData { get; set; } = new SubjectClinicalDataDto();
|
||||
|
||||
public List<NoneDicomStudyView> NoneDicomStudyList { get; set; } = new List<NoneDicomStudyView>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson;
|
||||
using IRaCIS.Core.Application.Contracts.DTO;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
@@ -989,6 +990,13 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
/// </summary>
|
||||
[DictionaryTranslateAttribute("YesOrNo")]
|
||||
public bool IsInvalid { get; set; }
|
||||
|
||||
|
||||
|
||||
public List<GetMedicalReviewDialogOutDto> DialogList { get; set; }
|
||||
|
||||
public string DialogStr => string.Join("\n\n", DialogList.OrderBy(t => t.CreateTime).Select(c => c.CreateUserName + " (" + ExportExcelConverterDate.DateTimeInternationalToString(c.CreateTime) + ") :" + c.ResultContent));
|
||||
|
||||
}
|
||||
|
||||
public class TrialImageDownloadExportDto
|
||||
@@ -1148,7 +1156,9 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public class SelftAnalysisExport : AnalysisExortCommon
|
||||
{
|
||||
//自身一致性分析任务特有
|
||||
//自身
|
||||
//
|
||||
//任务特有
|
||||
|
||||
[DictionaryTranslateAttribute("YesOrNo")]
|
||||
public bool? IsAnalysisDiffToOriginalData { get; set; }
|
||||
@@ -1248,6 +1258,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
public OptionType OptionTypeEnum { get; set; }
|
||||
|
||||
public ValueUnit? Unit { get; set; }
|
||||
|
||||
|
||||
public Guid QuestionId { get; set; }
|
||||
public string QuestionName { get; set; }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user