From e10251cf6399f7570676bf570a07ab1e52fcfd47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=A87=E6=A5=BC?= <31154238+RayWangQvQ@users.noreply.github.com> Date: Sun, 26 Mar 2023 15:31:35 +0800 Subject: [PATCH] =?UTF-8?q?Feature[#513]=E8=BF=81=E7=A7=BB=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=9F=BA=E7=A1=80=E7=BB=84=E4=BB=B6=E5=92=8C=E6=8A=BD?= =?UTF-8?q?=E8=B1=A1=E5=88=B0nuget=20(#514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat[#513]: migrate Ray.Serilog.Sinks to * feat[#513]:migrate componets to nuget * chore: update change log --- CHANGELOG.md | 4 +- Ray.BiliBiliTool.sln | 84 +---- common.props | 2 +- .../Ray.BiliBiliTool.Agent.csproj | 2 +- .../VipBigPointAppService.cs | 22 +- .../Ray.BiliBiliTool.Config.csproj | 2 +- .../Ray.BiliBiliTool.Console.csproj | 23 +- .../AccountDomainService.cs | 2 +- .../ChargeDomainService.cs | 2 +- .../LoginDomainService.cs | 16 +- .../Extensions/DateTimeExtension.cs | 44 --- .../Extensions/ObjectExtensions.cs | 293 ------------------ .../Extensions/StringExtensions.cs | 19 -- .../Ray.BiliBiliTool.Infrastructure.csproj | 2 +- .../Ray.Serilog.Sinks.Batched/BatchedSink.cs | 196 ------------ .../BoundedConcurrentQueue.cs | 80 ----- .../Ray.Serilog.Sinks.Batched/Constants.cs | 16 - .../Ray.Serilog.Sinks.Batched/PushService.cs | 53 ---- .../Ray.Serilog.Sinks.Batched.csproj | 11 - .../CoolPushApiClient.cs | 41 --- .../CoolPushBatchedSink.cs | 35 --- .../CoolPushLoggerConfigurationExtensions.cs | 26 -- .../Ray.Serilog.Sinks.CoolPushBatched.csproj | 12 - .../DingTalkApiClient.cs | 97 ------ .../DingTalkBatchedSink.cs | 36 --- .../DingTalkLoggerConfigurationExtensions.cs | 27 -- .../Ray.Serilog.Sinks.DingTalkBatched.csproj | 12 - .../GotifyApiClient.cs | 46 --- .../GotifyBatchedSink.cs | 39 --- .../GotifyConfigurationExtensions.cs | 41 --- .../Ray.Serilog.Sinks.GotifyBatched.csproj | 14 - .../MicrosoftTeamsApiClient.cs | 37 --- .../MicrosoftTeamsBatchedSink.cs | 37 --- .../MicrosoftTeamsConfigurationExtensions.cs | 39 --- ...Serilog.Sinks.MicrosoftTeamsBatched.csproj | 13 - .../OtherApiBatchedSink.cs | 45 --- .../OtherApiClient.cs | 40 --- .../OtherApiLoggerConfigurationExtensions.cs | 32 -- .../Ray.Serilog.Sinks.OtherApiBatched.csproj | 12 - .../PushPlusApiClient.cs | 95 ------ .../PushPlusBatchedSink.cs | 50 --- .../PushPlusLoggerConfigurationExtensions.cs | 46 --- .../Ray.Serilog.Sinks.PushPlusBatched.csproj | 12 - ...Ray.Serilog.Sinks.ServerChanBatched.csproj | 16 - .../ServerChanApiClient.cs | 52 ---- .../ServerChanBatchedSink.cs | 46 --- ...ServerChanLoggerConfigurationExtensions.cs | 27 -- .../ServerChanTurboApiClient.cs | 45 --- .../Ray.Serilog.Sinks.TelegramBatched.csproj | 16 - .../TelegramApiClient.cs | 122 -------- .../TelegramBatchedSink.cs | 50 --- .../TelegramLoggerConfigurationExtensions.cs | 29 -- ....Serilog.Sinks.WorkWeiXinAppBatched.csproj | 13 - .../WorkWeiXinAppApiClient.cs | 92 ------ .../WorkWeiXinAppBatchedSink.cs | 59 ---- .../WorkWeiXinAppConfigurationExtensions.cs | 50 --- .../WorkWeiXinAppTokenResponse.cs | 19 -- ...Ray.Serilog.Sinks.WorkWeiXinBatched.csproj | 16 - .../WorkWeiXinApiClient.cs | 67 ---- .../WorkWeiXinBatchedSink.cs | 36 --- ...WorkWeiXinLoggerConfigurationExtensions.cs | 27 -- test/ConfigTest/TestDonateCoinStatusConfig.cs | 2 +- test/ConfigTest/TestExpConfig.cs | 2 +- test/ConfigTest/UnitTest1.cs | 8 +- test/LogTest/LogTest.csproj | 1 - 65 files changed, 47 insertions(+), 2505 deletions(-) delete mode 100644 src/Ray.BiliBiliTool.Infrastructure/Extensions/DateTimeExtension.cs delete mode 100644 src/Ray.BiliBiliTool.Infrastructure/Extensions/ObjectExtensions.cs delete mode 100644 src/Ray.BiliBiliTool.Infrastructure/Extensions/StringExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BoundedConcurrentQueue.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Constants.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/PushService.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Ray.Serilog.Sinks.Batched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushLoggerConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/Ray.Serilog.Sinks.CoolPushBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkLoggerConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/Ray.Serilog.Sinks.DingTalkBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/Ray.Serilog.Sinks.GotifyBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiLoggerConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/Ray.Serilog.Sinks.OtherApiBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusLoggerConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/Ray.Serilog.Sinks.PushPlusBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/Ray.Serilog.Sinks.ServerChanBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanLoggerConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanTurboApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/Ray.Serilog.Sinks.TelegramBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/Ray.Serilog.Sinks.WorkWeiXinAppBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppConfigurationExtensions.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppTokenResponse.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/Ray.Serilog.Sinks.WorkWeiXinBatched.csproj delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinApiClient.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinBatchedSink.cs delete mode 100644 src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinLoggerConfigurationExtensions.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index bf39e86a8..65a105d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,4 +112,6 @@ - Merge PR #472 : add reverse proxy host for telegram notification - Merge PR #483 : update login field for entrypoint ## 1.0.3 -- Fix #486 : fix release zip error \ No newline at end of file +- Fix #486 : fix release zip error +## 2.0.0 +- Feature[#513]锛氬皢鍩虹缁勪欢鍜屾娊璞¤縼绉诲埌nuget鍖呬腑 diff --git a/Ray.BiliBiliTool.sln b/Ray.BiliBiliTool.sln index 4ef6f646a..1d6b5bd3f 100644 --- a/Ray.BiliBiliTool.sln +++ b/Ray.BiliBiliTool.sln @@ -70,29 +70,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{A93210 docker\README.md = docker\README.md EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ray.Serilog.Sinks", "Ray.Serilog.Sinks", "{4BAFC980-7A73-45C3-9460-8B8CCB87939B}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{2F1CB892-336C-4672-8A0A-FBAEB4B9EA8A}" ProjectSection(SolutionItems) = preProject docker\sample\docker-compose.yml = docker\sample\docker-compose.yml EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.Batched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj", "{46EF6150-5D68-46B5-AA89-4198185FAF1A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.CoolPushBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.CoolPushBatched\Ray.Serilog.Sinks.CoolPushBatched.csproj", "{8CEDF9C9-03CC-4B4F-8D67-9368E5969E21}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.DingTalkBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.DingTalkBatched\Ray.Serilog.Sinks.DingTalkBatched.csproj", "{043B065E-1CDF-43DA-A14D-3CDCB039EC24}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.OtherApiBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.OtherApiBatched\Ray.Serilog.Sinks.OtherApiBatched.csproj", "{02383C93-308C-4DAD-99AB-5348B4432512}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.PushPlusBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.PushPlusBatched\Ray.Serilog.Sinks.PushPlusBatched.csproj", "{C6C3A486-2B1B-47B7-814E-4A5DBF1EA788}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.ServerChanBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.ServerChanBatched\Ray.Serilog.Sinks.ServerChanBatched.csproj", "{0BF3E821-AFD3-4AE4-A155-BA04F3269327}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.TelegramBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.TelegramBatched\Ray.Serilog.Sinks.TelegramBatched.csproj", "{566DE314-E766-4C75-B8A8-27EDBB8F06D8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.WorkWeiXinBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.WorkWeiXinBatched\Ray.Serilog.Sinks.WorkWeiXinBatched.csproj", "{F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{C0173851-1515-4BE1-A018-84E0B64A6877}" ProjectSection(SolutionItems) = preProject docs\configuration.md = docs\configuration.md @@ -147,15 +129,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{75A9CC5C docker\build\buildImage_arm64.cmd = docker\build\buildImage_arm64.cmd EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.WorkWeiXinAppBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.WorkWeiXinAppBatched\Ray.Serilog.Sinks.WorkWeiXinAppBatched.csproj", "{099C4E10-1114-495C-A664-63A15E77B31A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.MicrosoftTeamsBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.MicrosoftTeamsBatched\Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj", "{FB9A43DE-00F0-42C4-BF92-AF61D752CCA2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.GotifyBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.GotifyBatched\Ray.Serilog.Sinks.GotifyBatched.csproj", "{B00FF75D-4C48-45ED-9A24-5C0D383317EE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppServiceTest", "test\AppServiceTest\AppServiceTest.csproj", "{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppServiceTest", "test\AppServiceTest\AppServiceTest.csproj", "{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainServiceTest", "test\DomainServiceTest\DomainServiceTest.csproj", "{26B21C30-7358-4E7B-A73E-2272F10A6CA8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DomainServiceTest", "test\DomainServiceTest\DomainServiceTest.csproj", "{26B21C30-7358-4E7B-A73E-2272F10A6CA8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -199,54 +175,10 @@ Global {7105652A-B1C1-4F9E-BA38-8034BC8B26B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {7105652A-B1C1-4F9E-BA38-8034BC8B26B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {7105652A-B1C1-4F9E-BA38-8034BC8B26B4}.Release|Any CPU.Build.0 = Release|Any CPU - {46EF6150-5D68-46B5-AA89-4198185FAF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {46EF6150-5D68-46B5-AA89-4198185FAF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {46EF6150-5D68-46B5-AA89-4198185FAF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {46EF6150-5D68-46B5-AA89-4198185FAF1A}.Release|Any CPU.Build.0 = Release|Any CPU - {8CEDF9C9-03CC-4B4F-8D67-9368E5969E21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8CEDF9C9-03CC-4B4F-8D67-9368E5969E21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8CEDF9C9-03CC-4B4F-8D67-9368E5969E21}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8CEDF9C9-03CC-4B4F-8D67-9368E5969E21}.Release|Any CPU.Build.0 = Release|Any CPU - {043B065E-1CDF-43DA-A14D-3CDCB039EC24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {043B065E-1CDF-43DA-A14D-3CDCB039EC24}.Debug|Any CPU.Build.0 = Debug|Any CPU - {043B065E-1CDF-43DA-A14D-3CDCB039EC24}.Release|Any CPU.ActiveCfg = Release|Any CPU - {043B065E-1CDF-43DA-A14D-3CDCB039EC24}.Release|Any CPU.Build.0 = Release|Any CPU - {02383C93-308C-4DAD-99AB-5348B4432512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {02383C93-308C-4DAD-99AB-5348B4432512}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02383C93-308C-4DAD-99AB-5348B4432512}.Release|Any CPU.ActiveCfg = Release|Any CPU - {02383C93-308C-4DAD-99AB-5348B4432512}.Release|Any CPU.Build.0 = Release|Any CPU - {C6C3A486-2B1B-47B7-814E-4A5DBF1EA788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C6C3A486-2B1B-47B7-814E-4A5DBF1EA788}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C6C3A486-2B1B-47B7-814E-4A5DBF1EA788}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C6C3A486-2B1B-47B7-814E-4A5DBF1EA788}.Release|Any CPU.Build.0 = Release|Any CPU - {0BF3E821-AFD3-4AE4-A155-BA04F3269327}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0BF3E821-AFD3-4AE4-A155-BA04F3269327}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0BF3E821-AFD3-4AE4-A155-BA04F3269327}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0BF3E821-AFD3-4AE4-A155-BA04F3269327}.Release|Any CPU.Build.0 = Release|Any CPU - {566DE314-E766-4C75-B8A8-27EDBB8F06D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {566DE314-E766-4C75-B8A8-27EDBB8F06D8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {566DE314-E766-4C75-B8A8-27EDBB8F06D8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {566DE314-E766-4C75-B8A8-27EDBB8F06D8}.Release|Any CPU.Build.0 = Release|Any CPU - {F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}.Release|Any CPU.Build.0 = Release|Any CPU {F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Release|Any CPU.ActiveCfg = Release|Any CPU {F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Release|Any CPU.Build.0 = Release|Any CPU - {099C4E10-1114-495C-A664-63A15E77B31A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {099C4E10-1114-495C-A664-63A15E77B31A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {099C4E10-1114-495C-A664-63A15E77B31A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {099C4E10-1114-495C-A664-63A15E77B31A}.Release|Any CPU.Build.0 = Release|Any CPU - {FB9A43DE-00F0-42C4-BF92-AF61D752CCA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FB9A43DE-00F0-42C4-BF92-AF61D752CCA2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FB9A43DE-00F0-42C4-BF92-AF61D752CCA2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FB9A43DE-00F0-42C4-BF92-AF61D752CCA2}.Release|Any CPU.Build.0 = Release|Any CPU - {B00FF75D-4C48-45ED-9A24-5C0D383317EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B00FF75D-4C48-45ED-9A24-5C0D383317EE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B00FF75D-4C48-45ED-9A24-5C0D383317EE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B00FF75D-4C48-45ED-9A24-5C0D383317EE}.Release|Any CPU.Build.0 = Release|Any CPU {1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -276,25 +208,13 @@ Global {73DD457B-E06E-45ED-A6BA-7E3C02F8BDF1} = {F3DE0D72-426B-4AD9-B3ED-3343CF4223F1} {61613EF4-3644-42D4-A620-70547291FB38} = {73DD457B-E06E-45ED-A6BA-7E3C02F8BDF1} {A93210FD-27B6-40E4-B08D-391F96CA2754} = {F3DE0D72-426B-4AD9-B3ED-3343CF4223F1} - {4BAFC980-7A73-45C3-9460-8B8CCB87939B} = {110D3D21-8E9B-45AB-9667-6DA1DB3862AC} {2F1CB892-336C-4672-8A0A-FBAEB4B9EA8A} = {A93210FD-27B6-40E4-B08D-391F96CA2754} - {46EF6150-5D68-46B5-AA89-4198185FAF1A} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {8CEDF9C9-03CC-4B4F-8D67-9368E5969E21} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {043B065E-1CDF-43DA-A14D-3CDCB039EC24} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {02383C93-308C-4DAD-99AB-5348B4432512} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {C6C3A486-2B1B-47B7-814E-4A5DBF1EA788} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {0BF3E821-AFD3-4AE4-A155-BA04F3269327} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {566DE314-E766-4C75-B8A8-27EDBB8F06D8} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {F2AFCE4C-42A2-4EB1-873B-7C9EB062C002} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} {DD86F293-AE70-46CF-837C-8870D8F51237} = {F3DE0D72-426B-4AD9-B3ED-3343CF4223F1} {1C6CC38A-A5D5-41EF-9072-70AEEEA211F7} = {F3DE0D72-426B-4AD9-B3ED-3343CF4223F1} {DE60A16C-CA3B-45E9-8A9D-0E91ACEBDEE0} = {1C6CC38A-A5D5-41EF-9072-70AEEEA211F7} {830361B7-BCC1-4853-879A-761B0FD86826} = {73DD457B-E06E-45ED-A6BA-7E3C02F8BDF1} {F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF} {75A9CC5C-DF92-4D72-A14C-625AA902855B} = {A93210FD-27B6-40E4-B08D-391F96CA2754} - {099C4E10-1114-495C-A664-63A15E77B31A} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {FB9A43DE-00F0-42C4-BF92-AF61D752CCA2} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} - {B00FF75D-4C48-45ED-9A24-5C0D383317EE} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B} {1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF} {26B21C30-7358-4E7B-A73E-2272F10A6CA8} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF} EndGlobalSection diff --git a/common.props b/common.props index 0d2aeb38a..bd970f30b 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ <Project> <PropertyGroup> <Authors>Ray</Authors> - <Version>1.0.3</Version> + <Version>2.0.0</Version> <NoWarn>$(NoWarn);CS1591;CS0436</NoWarn> </PropertyGroup> </Project> diff --git a/src/Ray.BiliBiliTool.Agent/Ray.BiliBiliTool.Agent.csproj b/src/Ray.BiliBiliTool.Agent/Ray.BiliBiliTool.Agent.csproj index 8c3c6d1fd..cb5bbf08c 100644 --- a/src/Ray.BiliBiliTool.Agent/Ray.BiliBiliTool.Agent.csproj +++ b/src/Ray.BiliBiliTool.Agent/Ray.BiliBiliTool.Agent.csproj @@ -5,7 +5,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" /> + <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.3" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" /> <PackageReference Include="Scrutor" Version="4.2.0" /> diff --git a/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs b/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs index f1e709d2a..fd7a8c197 100644 --- a/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs +++ b/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs @@ -46,7 +46,7 @@ public override async Task DoTaskAsync(CancellationToken cancellationToken) var re = await _vipApi.GetTaskList(); - if (re.Code != 0) throw new Exception(re.ToJson()); + if (re.Code != 0) throw new Exception(re.ToJsonStr()); VipTaskInfo taskInfo = re.Data; taskInfo.LogInfo(_logger); @@ -103,11 +103,11 @@ private async Task<VipTaskInfo> Sign(VipTaskInfo info) } var re = await _vipApi.Sign(new SignRequest()); - if (re.Code != 0) throw new Exception(re.ToJson()); + if (re.Code != 0) throw new Exception(re.ToJsonStr()); //纭 var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJson()); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); info = infoResult.Data; _logger.LogInformation("浠婃棩鍙幏寰楃鍒扮Н鍒嗭細{score}", info.Task_info.Sing_task_item.TodayHistory?.Score); @@ -143,7 +143,7 @@ private async Task<VipTaskInfo> Bonus(VipTaskInfo info) if (re) { var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJson()); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); info = infoResult.Data; bonusTask = GetTarget(info); @@ -186,7 +186,7 @@ private async Task<VipTaskInfo> Privilege(VipTaskInfo info) if (re) { var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJson()); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); info = infoResult.Data; privilegeTask = GetTarget(info); @@ -231,7 +231,7 @@ private async Task<VipTaskInfo> ViewAnimate(VipTaskInfo info) if (re) { var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJson()); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); info = infoResult.Data; targetTask = GetTarget(info); @@ -276,7 +276,7 @@ private async Task<VipTaskInfo> ViewFilmChannel(VipTaskInfo info) if (re) { var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJson()); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); info = infoResult.Data; targetTask = GetTarget(info); @@ -433,12 +433,12 @@ private async Task TryReceive(string taskCode) if (re.Code == 0) _logger.LogInformation("棰嗗彇浠诲姟鎴愬姛"); else - _logger.LogInformation("棰嗗彇浠诲姟澶辫触锛歿msg}", re.ToJson()); + _logger.LogInformation("棰嗗彇浠诲姟澶辫触锛歿msg}", re.ToJsonStr()); } catch (Exception e) { _logger.LogError("棰嗗彇浠诲姟寮傚父"); - _logger.LogError(e.Message + re?.ToJson()); + _logger.LogError(e.Message + re?.ToJsonStr()); } } @@ -454,7 +454,7 @@ private async Task<bool> Complete(string taskCode) else { - _logger.LogInformation("澶辫触锛歿msg}", re.ToJson()); + _logger.LogInformation("澶辫触锛歿msg}", re.ToJsonStr()); return false; } } @@ -474,7 +474,7 @@ private async Task<bool> CompleteView(string code) else { - _logger.LogInformation("娴忚澶辫触锛歿msg}", re.ToJson()); + _logger.LogInformation("娴忚澶辫触锛歿msg}", re.ToJsonStr()); return false; } } diff --git a/src/Ray.BiliBiliTool.Config/Ray.BiliBiliTool.Config.csproj b/src/Ray.BiliBiliTool.Config/Ray.BiliBiliTool.Config.csproj index ff4851aa8..1295b7399 100644 --- a/src/Ray.BiliBiliTool.Config/Ray.BiliBiliTool.Config.csproj +++ b/src/Ray.BiliBiliTool.Config/Ray.BiliBiliTool.Config.csproj @@ -7,7 +7,7 @@ <ItemGroup> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" /> - <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" /> + <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" /> <PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" /> diff --git a/src/Ray.BiliBiliTool.Console/Ray.BiliBiliTool.Console.csproj b/src/Ray.BiliBiliTool.Console/Ray.BiliBiliTool.Console.csproj index bbe041128..7900ba23f 100644 --- a/src/Ray.BiliBiliTool.Console/Ray.BiliBiliTool.Console.csproj +++ b/src/Ray.BiliBiliTool.Console/Ray.BiliBiliTool.Console.csproj @@ -31,7 +31,7 @@ <ItemGroup> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" /> - <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" /> + <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" /> <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" /> @@ -46,6 +46,16 @@ <PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> <PackageReference Include="System.Collections" Version="4.3.0" /> + <PackageReference Include="Ray.Serilog.Sinks.CoolPushBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.DingTalkBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.GotifyBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.MicrosoftTeamsBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.OtherApiBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.PushPlusBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.ServerChanBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.TelegramBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.WorkWeiXinAppBatched" Version="0.0.1" /> + <PackageReference Include="Ray.Serilog.Sinks.WorkWeiXinBatched" Version="0.0.1" /> </ItemGroup> <ItemGroup> @@ -55,17 +65,6 @@ <ProjectReference Include="..\Ray.BiliBiliTool.Config\Ray.BiliBiliTool.Config.csproj" /> <ProjectReference Include="..\Ray.BiliBiliTool.DomainService\Ray.BiliBiliTool.DomainService.csproj" /> <ProjectReference Include="..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.CoolPushBatched\Ray.Serilog.Sinks.CoolPushBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.DingTalkBatched\Ray.Serilog.Sinks.DingTalkBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.GotifyBatched\Ray.Serilog.Sinks.GotifyBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.MicrosoftTeamsBatched\Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.OtherApiBatched\Ray.Serilog.Sinks.OtherApiBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.PushPlusBatched\Ray.Serilog.Sinks.PushPlusBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.ServerChanBatched\Ray.Serilog.Sinks.ServerChanBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.TelegramBatched\Ray.Serilog.Sinks.TelegramBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.WorkWeiXinAppBatched\Ray.Serilog.Sinks.WorkWeiXinAppBatched.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks\Ray.Serilog.Sinks.WorkWeiXinBatched\Ray.Serilog.Sinks.WorkWeiXinBatched.csproj" /> </ItemGroup> <ItemGroup> diff --git a/src/Ray.BiliBiliTool.DomainService/AccountDomainService.cs b/src/Ray.BiliBiliTool.DomainService/AccountDomainService.cs index 4d0197321..efa7f6e68 100644 --- a/src/Ray.BiliBiliTool.DomainService/AccountDomainService.cs +++ b/src/Ray.BiliBiliTool.DomainService/AccountDomainService.cs @@ -94,7 +94,7 @@ public async Task<DailyTaskInfo> GetDailyTaskStatus() } else { - _logger.LogWarning("鑾峰彇浠婃棩浠诲姟瀹屾垚鐘舵€佸け璐ワ細{result}", apiResponse.ToJson()); + _logger.LogWarning("鑾峰彇浠婃棩浠诲姟瀹屾垚鐘舵€佸け璐ワ細{result}", apiResponse.ToJsonStr()); result = (await _dailyTaskApi.GetDailyTaskRewardInfo()).Data; //todo:鍋跺彂鎬ц姹傚け璐ワ紝鍐嶈姹備竴娆★紝杩欎箞鍐欏緢涓戦檵锛屽緟鐢╬olly鍐嶆鏋跺眰闈㈠疄鐜� } diff --git a/src/Ray.BiliBiliTool.DomainService/ChargeDomainService.cs b/src/Ray.BiliBiliTool.DomainService/ChargeDomainService.cs index f717ff7f9..37fec6205 100644 --- a/src/Ray.BiliBiliTool.DomainService/ChargeDomainService.cs +++ b/src/Ray.BiliBiliTool.DomainService/ChargeDomainService.cs @@ -105,7 +105,7 @@ public async Task Charge(UserInfo userInfo) else { _logger.LogInformation("銆愬厖鐢电粨鏋溿€戝け璐�"); - _logger.LogError("銆愬師鍥犮€憑reason}", response.ToJson()); + _logger.LogError("銆愬師鍥犮€憑reason}", response.ToJsonStr()); } } else diff --git a/src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs b/src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs index f3111788d..6a834650c 100644 --- a/src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs +++ b/src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs @@ -56,7 +56,7 @@ public async Task<BiliCookie> LoginByQrCodeAsync(CancellationToken cancellationT var re = await _passportApi.GenerateQrCode(); if (re.Code != 0) { - _logger.LogWarning("鑾峰彇浜岀淮鐮佸け璐ワ細{msg}", re.ToJson()); + _logger.LogWarning("鑾峰彇浜岀淮鐮佸け璐ワ細{msg}", re.ToJsonStr()); return null; } @@ -86,7 +86,7 @@ public async Task<BiliCookie> LoginByQrCodeAsync(CancellationToken cancellationT var content = JsonConvert.DeserializeObject<BiliApiResponse<TokenDto>>(await check.Content.ReadAsStringAsync(cancellationToken)); if (content.Code != 0) { - _logger.LogWarning("璋冪敤妫€娴嬫帴鍙e紓甯革細{msg}", check.ToJson()); + _logger.LogWarning("璋冪敤妫€娴嬫帴鍙e紓甯革細{msg}", check.ToJsonStr()); break; } @@ -127,12 +127,12 @@ public async Task<BiliCookie> SetCookieAsync(BiliCookie biliCookie, Cancellation _logger.LogInformation("SetCookie鎴愬姛"); return biliCookie; } - _logger.LogError("璁块棶涓荤珯澶辫触锛歿msg}", homePage.ToJson()); + _logger.LogError("璁块棶涓荤珯澶辫触锛歿msg}", homePage.ToJsonStr()); } catch (Exception e) { //buvid鍙奖鍝嶅垎浜拰鎶曞竵锛屽彲浠ュ悶鎺夊紓甯� - _logger.LogError(e.ToJson()); + _logger.LogError(e.ToJsonStr()); } return biliCookie; @@ -217,11 +217,11 @@ public async Task SaveCookieToQinLongAsync(BiliCookie ckInfo, CancellationToken if (re.Code != 200) { - _logger.LogInformation($"鏌ヨ鐜鍙橀噺澶辫触锛歿re}", re.ToJson()); + _logger.LogInformation($"鏌ヨ鐜鍙橀噺澶辫触锛歿re}", re.ToJsonStr()); return; } - _logger.LogDebug(re.Data.ToJson()); + _logger.LogDebug(re.Data.ToJsonStr()); _logger.LogDebug(ckInfo.ToString()); var list = re.Data.Where(x => x.name.StartsWith("Ray_BiliBiliCookies__")).ToList(); @@ -242,7 +242,7 @@ public async Task SaveCookieToQinLongAsync(BiliCookie ckInfo, CancellationToken }; var updateRe = await _qingLongApi.UpdateEnvs(update, token); - _logger.LogInformation(updateRe.Code == 200 ? "鏇存柊鎴愬姛锛�" : updateRe.ToJson()); + _logger.LogInformation(updateRe.Code == 200 ? "鏇存柊鎴愬姛锛�" : updateRe.ToJsonStr()); return; } @@ -268,7 +268,7 @@ public async Task SaveCookieToQinLongAsync(BiliCookie ckInfo, CancellationToken remarks = $"bili-{ckInfo.UserId}" }; var addRe = await _qingLongApi.AddEnvs(new List<AddQingLongEnv> { add }, token); - _logger.LogInformation(addRe.Code == 200 ? "鏂板鎴愬姛锛�" : addRe.ToJson()); + _logger.LogInformation(addRe.Code == 200 ? "鏂板鎴愬姛锛�" : addRe.ToJsonStr()); } #region private diff --git a/src/Ray.BiliBiliTool.Infrastructure/Extensions/DateTimeExtension.cs b/src/Ray.BiliBiliTool.Infrastructure/Extensions/DateTimeExtension.cs deleted file mode 100644 index b882dd11f..000000000 --- a/src/Ray.BiliBiliTool.Infrastructure/Extensions/DateTimeExtension.cs +++ /dev/null @@ -1,44 +0,0 @@ -锘縩amespace System -{ - public static class DateTimeExtension - { - /// <summary> - /// 鑾峰彇褰撳墠鏈堜唤鐨勬渶鍚庝竴澶� - /// </summary> - /// <param name="dateTime"></param> - /// <returns></returns> - public static DateTime LastDayOfMonth(this DateTime dateTime) - { - return dateTime.AddDays(1 - dateTime.Day) - .AddMonths(1) - .AddDays(-1); - } - - #region 鏃堕棿鎴� - /// <summary> - /// 鏃堕棿鎴宠鏃跺紑濮嬫椂闂� - /// </summary> - private static readonly DateTime TimeStampStartTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - /// <summary> - /// DateTime杞崲涓�10浣嶆椂闂存埑锛堝崟浣嶏細绉掞級 - /// </summary> - /// <param name="dateTime"> DateTime</param> - /// <returns>10浣嶆椂闂存埑锛堝崟浣嶏細绉掞級</returns> - public static long ToTimeStamp(this DateTime dateTime) - { - return (long)(dateTime.ToUniversalTime() - TimeStampStartTime).TotalSeconds; - } - - /// <summary> - /// DateTime杞崲涓�13浣嶆椂闂存埑锛堝崟浣嶏細姣锛� - /// </summary> - /// <param name="dateTime"> DateTime</param> - /// <returns>13浣嶆椂闂存埑锛堝崟浣嶏細姣锛�</returns> - public static long ToLongTimeStamp(this DateTime dateTime) - { - return (long)(dateTime.ToUniversalTime() - TimeStampStartTime).TotalMilliseconds; - } - #endregion - } -} diff --git a/src/Ray.BiliBiliTool.Infrastructure/Extensions/ObjectExtensions.cs b/src/Ray.BiliBiliTool.Infrastructure/Extensions/ObjectExtensions.cs deleted file mode 100644 index d3ae83629..000000000 --- a/src/Ray.BiliBiliTool.Infrastructure/Extensions/ObjectExtensions.cs +++ /dev/null @@ -1,293 +0,0 @@ -锘縰sing System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; -using Newtonsoft.Json; - -namespace System -{ - public static class ObjectExtensions - { - public static string ToJson<T>(this T obj, JsonSerializerSettings settings = null) - { - if (settings == null) - { - return JsonConvert.SerializeObject(obj); - } - else - { - return JsonConvert.SerializeObject(obj, settings); - } - } - - #region CheckNull - - /// <summary> - /// 妫€鏌ュ弬鏁版槸鍚︿负null锛屼负null鏃舵姏鍑哄紓甯� - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="obj"> 瑕佹鏌ョ殑瀵硅薄</param> - /// <param name="paramName">鎶涘嚭寮傚父鏃�,鏄剧ず鐨勫弬鏁板悕</param> - /// <exception cref="ArgumentNullException"><paramref name="obj" /> 涓簄ull鏃舵姏鍑�</exception> - public static void CheckNullWithException<T>(this T obj, string paramName) - where T : class - { - if (obj == null) throw new ArgumentNullException(paramName); - } - - /// <summary> - /// 妫€鏌ュ弬鏁版槸鍚︿负null锛屼负null鏃舵姏鍑哄紓甯� - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="obj"> 瑕佹鏌ョ殑瀵硅薄</param> - /// <param name="paramName">鎶涘嚭寮傚父鏃�,鏄剧ず鐨勫弬鏁板悕</param> - /// <param name="message"> 鎶涘嚭寮傚父鏃�,鏄剧ず鐨勯敊璇俊鎭�</param> - /// <exception cref="ArgumentNullException"><paramref name="obj" /> 涓簄ull鏃舵姏鍑�</exception> - public static void CheckNullWithException<T>(this T obj, string paramName, string message) - where T : class - { - if (obj == null) throw new ArgumentNullException(paramName, message); - } - - /// <summary> - /// 妫€鏌ュ弬鏁版槸鍚︿负null鎴杄mtpy锛屼负null鎴杄mtpy鏃舵姏鍑哄紓甯� - /// </summary> - /// <param name="obj"> 瑕佹鏌ョ殑瀵硅薄</param> - /// <param name="paramName">鎶涘嚭寮傚父鏃�,鏄剧ず鐨勫弬鏁板悕</param> - /// <exception cref="ArgumentNullException"><paramref name="obj" /> 涓簄ull鎴杄mtpy鏃舵姏鍑�</exception> - public static void CheckNullOrEmptyWithException(this IEnumerable obj, string paramName) - { - if (obj.IsNullOrEmpty()) throw new ArgumentNullException(paramName); - } - - /// <summary> - /// 妫€鏌ュ弬鏁版槸鍚︿负null鎴杄mtpy锛屼负null鎴杄mtpy鏃舵姏鍑哄紓甯� - /// </summary> - /// <param name="obj"> 瑕佹鏌ョ殑瀵硅薄</param> - /// <param name="paramName">鎶涘嚭寮傚父鏃�,鏄剧ず鐨勫弬鏁板悕</param> - /// <param name="message"> 鎶涘嚭寮傚父鏃�,鏄剧ず鐨勯敊璇俊鎭�</param> - /// <exception cref="ArgumentNullException"><paramref name="obj" /> 涓簄ull鎴杄mtpy鏃舵姏鍑�</exception> - public static void CheckNullOrEmptyWithException(this IEnumerable obj, string paramName, string message) - { - if (obj.IsNullOrEmpty()) throw new ArgumentNullException(paramName, message); - } - - #endregion CheckNull - - #region IsNull and IsNullOrEmpty - - /// <summary> - /// 鍒ゆ柇null锛宯ull鎴�0闀垮害閮借繑鍥瀟rue - /// </summary> - /// <typeparam name="T">瀵硅薄绫诲瀷</typeparam> - /// <param name="value">瑕佸垽鏂殑瀵硅薄</param> - /// <returns>鍒ゆ柇缁撴灉,null鎴�0闀垮害杩斿洖true,鍚﹀垯杩斿洖false</returns> - public static bool IsNullOrEmpty<T>(this T value) - where T : class - { - #region 1.瀵硅薄绾у埆 - - //寮曠敤涓簄ull - bool isObjectNull = value == null; - if (isObjectNull == true) return true; - - //鍒ゆ柇鏄惁涓洪泦鍚� - IEnumerator tempEnumerator = (value as IEnumerable)?.GetEnumerator(); - if (tempEnumerator == null) return false;//杩欓噷鍑哄幓浠h〃鏄璞� 涓� 寮曠敤涓嶄负null.鎵€浠ヤ负false - - #endregion 1.瀵硅薄绾у埆 - - #region 2.闆嗗悎绾у埆 - - //鍒拌繖閲屽氨浠h〃鏄泦鍚堜笖寮曠敤涓嶄负绌猴紝鍒ゆ柇闀垮害 - //MoveNext鏂规硶杩斿洖tue浠h〃闆嗗悎涓嚦灏戞湁涓€涓暟鎹�,杩斿洖false灏变唬琛�0闀垮害 - bool isZeroLenth = tempEnumerator.MoveNext() == false; - if (isZeroLenth == true) return true; - - return isZeroLenth; - - #endregion 2.闆嗗悎绾у埆 - } - - /// <summary> - /// 鍒ゆ柇null - /// </summary> - /// <param name="value">瑕佸垽鏂殑瀵硅薄</param> - /// <returns>鍒ゆ柇缁撴灉,null杩斿洖true,鍚﹀垯杩斿洖false</returns> - public static bool IsNull(this object value) - { - return value == null; - } - - /// <summary> - /// 鍒ゆ柇null,绌烘暟缁� - /// </summary> - /// <typeparam name="T">瀵硅薄绫诲瀷</typeparam> - /// <param name="value">瑕佸垽鏂殑鏁扮粍</param> - /// <returns>鍒ゆ柇缁撴灉,null鎴栫┖鏁扮粍杩斿洖true,鍚﹀垯杩斿洖false</returns> - public static bool IsNullOrEmpty<T>(this T[] value) - { - return value == null || value.Length == 0; - } - - /// <summary> - /// 鍒ゆ柇null,绌洪泦鍚� - /// </summary> - /// <typeparam name="T">瀵硅薄绫诲瀷</typeparam> - /// <param name="value">瑕佸垽鏂殑闆嗗悎</param> - /// <returns>鍒ゆ柇缁撴灉,null鎴栫┖闆嗗悎杩斿洖true,鍚﹀垯杩斿洖false</returns> - public static bool IsNullOrEmpty<T>(this IList<T> value) - { - return value == null || value.Count == 0; - } - - /// <summary> - /// 鍒ゆ柇null,绌哄瓧鍏� - /// </summary> - /// <typeparam name="T">瀵硅薄绫诲瀷</typeparam> - /// <param name="value">瑕佸垽鏂殑瀛楀吀</param> - /// <returns>鍒ゆ柇缁撴灉,null鎴栫┖瀛楀吀杩斿洖true,鍚﹀垯杩斿洖false</returns> - public static bool IsNullOrEmpty<T>(this IDictionary value) - { - return value == null || value.Keys.Count == 0; - } - - /// <summary> - /// 鍒ゆ柇null,绌烘灇涓惧櫒 - /// </summary> - /// <param name="value">瑕佸垽鏂殑瀛楀吀</param> - /// <returns>鍒ゆ柇缁撴灉,null鎴栫┖鏋氫妇鍣ㄨ繑鍥瀟rue,鍚﹀垯杩斿洖false</returns> - public static bool IsNullOrEmpty(this IEnumerable value) - { - return value == null - || !value.GetEnumerator().MoveNext(); - } - - #endregion IsNull and IsNullOrEmpty - - #region IsNotNull and IsNotNullOrEmpty - - /// <summary> - /// 鍒ゆ柇闈瀗ull锛岄潪0闀垮害 - /// </summary> - /// <typeparam name="T">瀵硅薄绫诲瀷</typeparam> - /// <param name="value">瑕佸垽鏂殑瀵硅薄</param> - /// <returns>鍒ゆ柇缁撴灉,闈瀗ull锛岄潪0闀垮害杩斿洖true,鍚﹀垯杩斿洖false</returns> - /// <returns></returns> - public static bool IsNotNullOrEmpty<T>(this T value) - where T : class - { - //IsNullOrEmpty鍙栧弽 - return !value.IsNullOrEmpty(); - } - - /// <summary> - /// 鍒ゆ柇闈瀗ull - /// </summary> - /// <param name="value">瑕佸垽鏂殑瀵硅薄</param> - /// <returns>鍒ゆ柇缁撴灉,闈瀗ull杩斿洖true,鍚﹀垯杩斿洖false</returns> - public static bool IsNotNull(this object value) - { - return !value.IsNull(); - } - - /// <summary> - /// 鍒ゆ柇闈瀗ull,闈炵┖鏁扮粍 - /// </summary> - /// <typeparam name="T">瀵硅薄绫诲瀷</typeparam> - /// <param name="value">瑕佸垽鏂殑鏁扮粍</param> - /// <returns>鍒ゆ柇缁撴灉,闈瀗ull鍜岄潪绌烘暟缁勮繑鍥瀟rue,鍚﹀垯涓篺alse</returns> - public static bool IsNotNullOrEmpty<T>(this T[] value) - { - return !value.IsNullOrEmpty(); - } - - /// <summary> - /// 鍒ゆ柇闈瀗ull,闈炵┖闆嗗悎 - /// </summary> - /// <typeparam name="T">瀵硅薄绫诲瀷</typeparam> - /// <param name="value">瑕佸垽鏂殑闆嗗悎</param> - /// <returns>鍒ゆ柇缁撴灉,闈瀗ull鍜岄潪绌洪泦鍚堣繑鍥瀟rue,鍚﹀垯涓篺alse</returns> - public static bool IsNotNullOrEmpty<T>(this IList<T> value) - { - return !value.IsNullOrEmpty(); - } - - /// <summary> - /// 鍒ゆ柇闈瀗ull,闈炵┖瀛楀吀 - /// </summary> - /// <param name="value">瑕佸垽鏂殑瀛楀吀</param> - /// <returns>鍒ゆ柇缁撴灉,闈瀗ull鍜岄潪绌哄瓧鍏歌繑鍥瀟rue,鍚﹀垯涓篺alse</returns> - public static bool IsNotNullOrEmpty(this IDictionary value) - { - return !value.IsNullOrEmpty(); - } - - /// <summary> - /// 鍒ゆ柇闈瀗ull,闈炵┖鏋氫妇鍣� - /// </summary> - /// <param name="value">瑕佸垽鏂殑瀛楀吀</param> - /// <returns>鍒ゆ柇缁撴灉,null鎴栫┖鏋氫妇鍣ㄨ繑鍥瀟rue,鍚﹀垯杩斿洖false</returns> - public static bool IsNotNullOrEmpty(this IEnumerable value) - { - return !value.IsNullOrEmpty(); - } - - #endregion IsNotNull and IsNotNullOrEmpty - - /// <summary>鑾峰彇鏋氫妇鍙橀噺鍊肩殑 Description 灞炴€�</summary> - /// <param name="obj">鏋氫妇鍙橀噺</param> - /// <param name="isTop">鏄惁鏀瑰彉涓鸿繑鍥炶绫汇€佹灇涓剧被鍨嬬殑澶� Description 灞炴€э紝鑰屼笉鏄綋鍓嶇殑灞炴€ф垨鏋氫妇鍙橀噺鍊肩殑 Description 灞炴€�</param> - /// <returns>濡傛灉鍖呭惈 Description 灞炴€э紝鍒欒繑鍥� Description 灞炴€х殑鍊硷紝鍚﹀垯杩斿洖鏋氫妇鍙橀噺鍊肩殑鍚嶇О</returns> - public static string Description(this object obj, bool isTop = false) - { - if (obj == null) - return string.Empty; - try - { - Type type = obj.GetType(); - DescriptionAttribute descriptionAttribute = !isTop - ? (DescriptionAttribute)Attribute.GetCustomAttribute( - type.GetField(Enum.GetName(type, obj)), typeof(DescriptionAttribute)) - : (DescriptionAttribute)Attribute.GetCustomAttribute(type, typeof(DescriptionAttribute)); - if (descriptionAttribute != null) - { - if (!string.IsNullOrEmpty(descriptionAttribute.Description)) - return descriptionAttribute.Description; - } - } - catch - { - //ignore - } - return obj.ToString(); - } - - /// <summary>鑾峰彇鏋氫妇鍙橀噺鍊肩殑 DefaultValue 灞炴€�</summary> - /// <param name="obj">鏋氫妇鍙橀噺</param> - /// <param name="isTop">鏄惁鏀瑰彉涓鸿繑鍥炶绫汇€佹灇涓剧被鍨嬬殑澶� Description 灞炴€э紝鑰屼笉鏄綋鍓嶇殑灞炴€ф垨鏋氫妇鍙橀噺鍊肩殑 Description 灞炴€�</param> - /// <returns>濡傛灉鍖呭惈 Description 灞炴€э紝鍒欒繑鍥� Description 灞炴€х殑鍊硷紝鍚﹀垯杩斿洖鏋氫妇鍙橀噺鍊肩殑鍚嶇О</returns> - public static string DefaultValue(this object obj, bool isTop = false) - { - if (obj == null) - return string.Empty; - try - { - Type type = obj.GetType(); - DefaultValueAttribute defaultValueAttribute = !isTop - ? (DefaultValueAttribute)Attribute.GetCustomAttribute(type.GetField(Enum.GetName(type, obj)), typeof(DefaultValueAttribute)) - : (DefaultValueAttribute)Attribute.GetCustomAttribute(type, typeof(DefaultValueAttribute)); - if (defaultValueAttribute != null) - { - if (!string.IsNullOrEmpty(defaultValueAttribute.Value.ToString())) - return defaultValueAttribute.Value.ToString(); - } - } - catch - { - //ignore - } - return obj.ToString(); - } - } -} diff --git a/src/Ray.BiliBiliTool.Infrastructure/Extensions/StringExtensions.cs b/src/Ray.BiliBiliTool.Infrastructure/Extensions/StringExtensions.cs deleted file mode 100644 index 95b88f57b..000000000 --- a/src/Ray.BiliBiliTool.Infrastructure/Extensions/StringExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -锘縰sing Newtonsoft.Json; - -namespace System -{ - public static class StringExtensions - { - public static T ToObject<T>(this string str, JsonSerializerSettings settings = null) - { - if (settings == null) - { - return JsonConvert.DeserializeObject<T>(str); - } - else - { - return JsonConvert.DeserializeObject<T>(str, settings); - } - } - } -} diff --git a/src/Ray.BiliBiliTool.Infrastructure/Ray.BiliBiliTool.Infrastructure.csproj b/src/Ray.BiliBiliTool.Infrastructure/Ray.BiliBiliTool.Infrastructure.csproj index 25976c9a6..ce2d959f5 100644 --- a/src/Ray.BiliBiliTool.Infrastructure/Ray.BiliBiliTool.Infrastructure.csproj +++ b/src/Ray.BiliBiliTool.Infrastructure/Ray.BiliBiliTool.Infrastructure.csproj @@ -8,6 +8,6 @@ <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" /> - <PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> + <PackageReference Include="Ray.Infrastructure" Version="0.0.2" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BatchedSink.cs deleted file mode 100644 index 9f83862da..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BatchedSink.cs +++ /dev/null @@ -1,196 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using Serilog.Core; -using Serilog.Debugging; -using Serilog.Events; -using Serilog.Formatting; -using Serilog.Formatting.Display; - -namespace Ray.Serilog.Sinks.Batched -{ - public abstract class BatchedSink : ILogEventSink, IDisposable - { - private readonly LogEventLevel _minimumLogEventLevel; - private readonly Predicate<LogEvent> _predicate; - private readonly bool _sendBatchesAsOneMessages; - private readonly ITextFormatter _formatter; - - private readonly BoundedConcurrentQueue<LogEvent> _queue = new BoundedConcurrentQueue<LogEvent>(); - - public BatchedSink( - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel) - : this(predicate, sendBatchesAsOneMessages, null, formatProvider, minimumLogEventLevel) - { - } - - public BatchedSink( - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - string outputTemplate = "{Message:lj}{NewLine}{Exception}", - IFormatProvider formatProvider = null, - LogEventLevel minimumLogEventLevel = LogEventLevel.Verbose) - { - _predicate = predicate ?? (x => true); - _minimumLogEventLevel = minimumLogEventLevel; - _sendBatchesAsOneMessages = sendBatchesAsOneMessages; - - outputTemplate = string.IsNullOrWhiteSpace(outputTemplate) - ? Constants.DefaultOutputTemplate - : outputTemplate; - _formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); - } - - public virtual void Emit(LogEvent logEvent) - { - if (logEvent == null) throw new ArgumentNullException("logEvent"); - - try - { - if (logEvent.Level < _minimumLogEventLevel) return; - _queue.TryEnqueue(logEvent); - - if (_predicate(logEvent)) - { - var waitingBatch = new Queue<LogEvent>(); - while (_queue.TryDequeue(out LogEvent item)) - { - waitingBatch.Enqueue(item); - } - var pushTitle = GetPushTitle(logEvent); - EmitBatch(waitingBatch, pushTitle); - } - } - catch (Exception ex) - { - SelfLog.WriteLine("Exception while emitting periodic batch from {0}: {1}", this, ex.Message); - } - } - - protected virtual void EmitBatch(IEnumerable<LogEvent> events, string pushTitle = "") - { - if (_sendBatchesAsOneMessages) - { - var sb = new StringBuilder(); - foreach (var logEvent in events) - { - string message = RenderMessage(logEvent); - sb.Append(message); - } - sb.AppendLine(Environment.NewLine); - - var messageToSend = sb.ToString(); - PushMessage(messageToSend, pushTitle); - } - else - { - foreach (var logEvent in events) - { - var message = RenderMessage(logEvent); - PushMessage(message); - } - } - } - - protected abstract PushService PushService { get; } - - protected virtual void PushMessage(string message, string title = "Bili鎺ㄩ€�") - { - //SelfLog.WriteLine($"Trying to send message: '{message}'."); - var result = PushService.PushMessage(message, title); - if (result != null) - { - SelfLog.WriteLine($"Response status: {result.StatusCode}."); - try - { - var content = result.Content.ReadAsStringAsync() - .GetAwaiter().GetResult() - .Replace("{", "{{") - .Replace("}", "}}"); - SelfLog.WriteLine($"Response content: {content}.{Environment.NewLine}"); - } - catch (Exception e) - { - SelfLog.WriteLine(e.Message + Environment.NewLine); - } - } - } - - protected virtual string RenderMessage(LogEvent logEvent) - { - string msg = ""; - using (StringWriter stringWriter = new StringWriter()) - { - this._formatter.Format(logEvent, (TextWriter)stringWriter); - msg = stringWriter.ToString(); - } - - //msg = $"{GetEmoji(logEvent)} {msg}"; - - if (msg.Contains("缁忛獙+") && msg.Contains("鈭�")) - msg = msg.Replace('鈭�', '鉁�'); - - return msg; - - /* - if (logEvent.Exception == null) - { - return msg; - } - - var sb = new StringBuilder(); - sb.AppendLine(msg); - sb.AppendLine($"\n*{logEvent.Exception.Message}*\n"); - sb.AppendLine($"Message: `{logEvent.Exception.Message}`"); - sb.AppendLine($"Type: `{logEvent.Exception.GetType().Name}`\n"); - sb.AppendLine($"Stack Trace\n```{logEvent.Exception}```"); - - return sb.ToString(); - */ - } - - protected virtual string GetEmoji(LogEvent log) - { - switch (log.Level) - { - case LogEventLevel.Verbose: - return "鈿�"; - case LogEventLevel.Debug: - return "馃憠"; - case LogEventLevel.Information: - return "鈩�"; - case LogEventLevel.Warning: - return "鈿�"; - case LogEventLevel.Error: - return "鉂�"; - case LogEventLevel.Fatal: - return "鈥�"; - default: - return string.Empty; - } - } - - protected virtual string GetPushTitle(LogEvent triggerLogEvent) - { - var title = "Bili"; - - var msg = RenderMessage(triggerLogEvent).Replace(Environment.NewLine, ""); - var list = msg.Split('路').ToList(); - - for (int i = 2; i < list.Count; i++) - { - if (!string.IsNullOrWhiteSpace(list[i])) - title += $"-{list[i]}"; - } - - return title; - } - - public abstract void Dispose(); - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BoundedConcurrentQueue.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BoundedConcurrentQueue.cs deleted file mode 100644 index f56fab8fb..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/BoundedConcurrentQueue.cs +++ /dev/null @@ -1,80 +0,0 @@ -锘縰sing System; -using System.Collections.Concurrent; -using System.Threading; - -namespace Ray.Serilog.Sinks.Batched -{ - internal class BoundedConcurrentQueue<T> - { - public const int Unbounded = -1; - - private readonly ConcurrentQueue<T> _queue = new ConcurrentQueue<T>(); - - private readonly int _queueLimit; - - private int _counter; - - public int Count => _queue.Count; - - public BoundedConcurrentQueue(int? queueLimit = null) - { - if (queueLimit.HasValue && queueLimit <= 0) - { - throw new ArgumentOutOfRangeException("queueLimit", "Queue limit must be positive, or `null` to indicate unbounded."); - } - - _queueLimit = (queueLimit ?? (-1)); - } - - public bool TryDequeue(out T item) - { - if (_queueLimit == -1) - { - return _queue.TryDequeue(out item); - } - - bool result = false; - try - { - } - finally - { - if (_queue.TryDequeue(out item)) - { - Interlocked.Decrement(ref _counter); - result = true; - } - } - - return result; - } - - public bool TryEnqueue(T item) - { - if (_queueLimit == -1) - { - _queue.Enqueue(item); - return true; - } - - bool result = true; - try - { - } - finally - { - if (Interlocked.Increment(ref _counter) <= _queueLimit) - { - _queue.Enqueue(item); - } - else - { - Interlocked.Decrement(ref _counter); - result = false; - } - } - - return result; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Constants.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Constants.cs deleted file mode 100644 index 10c428be7..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Constants.cs +++ /dev/null @@ -1,16 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Ray.Serilog.Sinks.Batched -{ - public static class Constants - { - public const string DefaultOutputTemplate = - "{Message:lj}{NewLine}{Exception}"; - - public const string DefaultContainsTrigger = "路寮€濮嬫帹閫伮�"; - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/PushService.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/PushService.cs deleted file mode 100644 index 6c3cbfefc..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/PushService.cs +++ /dev/null @@ -1,53 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Serilog.Debugging; - -namespace Ray.Serilog.Sinks.Batched -{ - public abstract class PushService - { - /// <summary> - /// 鎺ㄩ€佺/鎺ㄩ€佸钩鍙板悕绉� - /// </summary> - public abstract string ClientName { get; } - - public string Msg { get; set; } - - public string Title { get; set; } - - protected virtual string NewLineStr { get; } - - public virtual HttpResponseMessage PushMessage(string message, string title = "") - { - this.Msg = message; - this.Title = title; - - SelfLog.WriteLine($"寮€濮嬫帹閫佸埌:{ClientName}"); - - BuildMsg(); - - return DoSend(); - } - - /// <summary> - /// 鏋勫缓娑堟伅 - /// </summary> - /// <returns></returns> - public virtual void BuildMsg() - { - //濡傛灉鎸囧畾鎹㈣绗︼紝鍒欐浛鎹紱涓嶆寚瀹氾紝涓嶆浛鎹� - if (!string.IsNullOrEmpty(NewLineStr)) - this.Msg = Msg.Replace(Environment.NewLine, this.NewLineStr); - } - - /// <summary> - /// 瀹為檯鍙戦€� - /// </summary> - /// <returns></returns> - public abstract HttpResponseMessage DoSend(); - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Ray.Serilog.Sinks.Batched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Ray.Serilog.Sinks.Batched.csproj deleted file mode 100644 index a08684877..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.Batched/Ray.Serilog.Sinks.Batched.csproj +++ /dev/null @@ -1,11 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Serilog" Version="2.12.0" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushApiClient.cs deleted file mode 100644 index 15c099f31..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushApiClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -锘縰sing System; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.CoolPushBatched -{ - public class CoolPushApiClient : PushService - { - private const string Host = "https://push.xuthus.cc/send"; - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - - public CoolPushApiClient(string sKey) - { - _apiUrl = new Uri($"{Host}/{sKey}"); - } - - public override string ClientName => "閰锋帹"; - - protected override string NewLineStr => Environment.NewLine + Environment.NewLine; - - public override void BuildMsg() - { - //闄勫姞鏍囬 - Msg = Title + Environment.NewLine + Msg; - - base.BuildMsg(); - } - - public override HttpResponseMessage DoSend() - { - var content = new StringContent(Msg, Encoding.UTF8, "application/json"); - - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushBatchedSink.cs deleted file mode 100644 index 023437460..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushBatchedSink.cs +++ /dev/null @@ -1,35 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.CoolPushBatched -{ - public class CoolPushBatchedSink : BatchedSink - { - private readonly string _sKey; - - public CoolPushBatchedSink( - string sKey, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) : base(predicate, sendBatchesAsOneMessages, formatProvider, minimumLogEventLevel) - { - _sKey = sKey; - } - - public override void Emit(LogEvent logEvent) - { - if (_sKey.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new CoolPushApiClient(_sKey); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushLoggerConfigurationExtensions.cs deleted file mode 100644 index 480bb98af..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/CoolPushLoggerConfigurationExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.CoolPushBatched -{ - public static class CoolPushLoggerConfigurationExtensions - { - public static LoggerConfiguration CoolPushBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string sKey, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink(new CoolPushBatchedSink(sKey, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/Ray.Serilog.Sinks.CoolPushBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/Ray.Serilog.Sinks.CoolPushBatched.csproj deleted file mode 100644 index 10abdba2e..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.CoolPushBatched/Ray.Serilog.Sinks.CoolPushBatched.csproj +++ /dev/null @@ -1,12 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkApiClient.cs deleted file mode 100644 index db5bae5ac..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkApiClient.cs +++ /dev/null @@ -1,97 +0,0 @@ -锘縰sing System; -using System.Net.Http; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.DingTalkBatched -{ - public class DingTalkApiClient : PushService - { - //https://developers.dingtalk.com/document/app/overview-of-group-robots - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - - public DingTalkApiClient(string webHookUrl) - { - if (null != webHookUrl && webHookUrl.Contains("secret=")) - { - _apiUrl = new Uri(ToGetSignUrl(webHookUrl)); - } - else - { - _apiUrl = new Uri(webHookUrl); - } - } - - public override string ClientName => "閽夐拤鏈哄櫒浜�"; - - /// <summary> - /// <br/>鎹㈣鏃犳晥 - /// 鏂囨。閲屾槸\n鎹㈣ - /// 鍙兘鎹�1琛� - /// </summary> - protected override string NewLineStr => Environment.NewLine + Environment.NewLine; - - public override void BuildMsg() - { - //闄勫姞鏍囬 - Msg = $"## {Title} {Environment.NewLine}{Msg}"; - base.BuildMsg(); - } - - public override HttpResponseMessage DoSend() - { - var json = new - { - msgtype = DingMsgType.markdown.ToString(), - markdown = new - { - title = Title, - text = Msg - } - }.ToJson(); - var content = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - // hmac256鍔犲瘑骞惰繑鍥瀊ase64 - public static string ToBase64hmac(string strText, string strKey) - { - HMACSHA256 myHMACSHA256 = new HMACSHA256(Encoding.UTF8.GetBytes(strKey)); - byte[] byteText = myHMACSHA256.ComputeHash(Encoding.UTF8.GetBytes(strText)); - return System.Convert.ToBase64String(byteText); - } - // 鎺ㄩ€侀拤閽夋秷鎭痷rl鍔犱笂绛惧悕 - public static string ToGetSignUrl(string webHookUrl) - { - var secret = ""; - var temp = webHookUrl.Replace("https://oapi.dingtalk.com/robot/send?", ""); - string[] vs = temp.Split("&"); - for (int i = 0; i < vs.Length; i++) - { - if (vs[i].StartsWith("secret=")) - { - secret = vs[i].Replace("secret=", ""); - break; - } - } - var current = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; - var string_to_sign = current + "\n" + secret; - var sign = ToBase64hmac(string_to_sign, secret); - return webHookUrl + "×tamp=" + current + "&sign=" + sign; - } - } - - public enum DingMsgType - { - text, - markdown, - actionCard, - feedCard, - empty - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkBatchedSink.cs deleted file mode 100644 index 18eefc110..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkBatchedSink.cs +++ /dev/null @@ -1,36 +0,0 @@ -锘縰sing System; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.DingTalkBatched -{ - public class DingTalkBatchedSink : BatchedSink - { - private readonly string _webHookUrl; - - public DingTalkBatchedSink( - string webHookUrl, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) : base(predicate, sendBatchesAsOneMessages, formatProvider, minimumLogEventLevel) - { - _webHookUrl = webHookUrl; - } - - public override void Emit(LogEvent logEvent) - { - if (_webHookUrl.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new DingTalkApiClient(_webHookUrl); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkLoggerConfigurationExtensions.cs deleted file mode 100644 index 8f75b28d9..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/DingTalkLoggerConfigurationExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Ray.Serilog.Sinks.DingTalkBatched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.DingTalkBatched -{ - public static class DingTalkLoggerConfigurationExtensions - { - public static LoggerConfiguration DingTalkBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string webHookUrl, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink(new DingTalkBatchedSink(webHookUrl, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/Ray.Serilog.Sinks.DingTalkBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/Ray.Serilog.Sinks.DingTalkBatched.csproj deleted file mode 100644 index 10abdba2e..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.DingTalkBatched/Ray.Serilog.Sinks.DingTalkBatched.csproj +++ /dev/null @@ -1,12 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyApiClient.cs deleted file mode 100644 index 9f29700f8..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyApiClient.cs +++ /dev/null @@ -1,46 +0,0 @@ -锘縰sing System; -using System.Text; -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json.Linq; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.MicrosoftTeamsBatched -{ - public class GotifyApiClient : PushService - { - //https://gotify.net/docs - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - private readonly string _token; - - public GotifyApiClient( - string host, - string token - ) - { - _token = token; - _apiUrl = new Uri($"{host}/message"); - } - - public override string ClientName => "Gotify"; - - protected override string NewLineStr => "\n"; - - public override HttpResponseMessage DoSend() - { - var json = new - { - title = Title, - message = Msg, - extras = "{\"extras\":{\"client::display\":{\"contentType\":\"text/markdown\"}}}".ToObject<JObject>() - }.ToJson(); - - var content = new StringContent(json, Encoding.UTF8, "application/json"); - content.Headers.Add("X-Gotify-Key", _token); - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - response.Content = new StringContent(""); - return response; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyBatchedSink.cs deleted file mode 100644 index acf01efbb..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyBatchedSink.cs +++ /dev/null @@ -1,39 +0,0 @@ -锘縰sing Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.MicrosoftTeamsBatched -{ - public class GotifyBatchedSink : BatchedSink - { - private readonly string _host; - private readonly string _token; - - public GotifyBatchedSink( - string host, - string token, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - string outputTemplate, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) - : base(predicate, sendBatchesAsOneMessages, outputTemplate, formatProvider, minimumLogEventLevel) - { - _host = host; - _token = token; - } - - public override void Emit(LogEvent logEvent) - { - if (_host.IsNullOrEmpty() || _token.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new GotifyApiClient(_host, _token); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyConfigurationExtensions.cs deleted file mode 100644 index 7d0287d1d..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/GotifyConfigurationExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -锘縰sing Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.MicrosoftTeamsBatched -{ - public static class GotifyConfigurationExtensions - { - public static LoggerConfiguration GotifyBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string host, - string token, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - string outputTemplate = Constants.DefaultOutputTemplate, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (loggerSinkConfiguration == null) - throw new ArgumentNullException(nameof(loggerSinkConfiguration)); - if (outputTemplate == null) - throw new ArgumentNullException(nameof(outputTemplate)); - - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink( - new GotifyBatchedSink( - host, - token, - predicate, - sendBatchesAsOneMessages, - outputTemplate, - formatProvider, - restrictedToMinimumLevel), - restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/Ray.Serilog.Sinks.GotifyBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/Ray.Serilog.Sinks.GotifyBatched.csproj deleted file mode 100644 index ebfaae80a..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.GotifyBatched/Ray.Serilog.Sinks.GotifyBatched.csproj +++ /dev/null @@ -1,14 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <ImplicitUsings>enable</ImplicitUsings> - <!--<Nullable>enable</Nullable>--> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsApiClient.cs deleted file mode 100644 index fec744259..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsApiClient.cs +++ /dev/null @@ -1,37 +0,0 @@ -锘縰sing System.Text; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.MicrosoftTeamsBatched -{ - public class MicrosoftTeamsApiClient : PushService - { - //https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - - public MicrosoftTeamsApiClient( - string webhook - ) - { - _apiUrl = new Uri(webhook); - } - - public override string ClientName => "MicrosoftTeams"; - - protected override string NewLineStr => "<br/>"; - - public override HttpResponseMessage DoSend() - { - var json = new - { - text=Msg - }.ToJson(); - - var content = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsBatchedSink.cs deleted file mode 100644 index f71ef6b7b..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsBatchedSink.cs +++ /dev/null @@ -1,37 +0,0 @@ -锘縰sing Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.MicrosoftTeamsBatched -{ - public class MicrosoftTeamsBatchedSink : BatchedSink - { - private readonly string _webhook; - - public MicrosoftTeamsBatchedSink( - string webhook, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - string outputTemplate, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) - : base(predicate, sendBatchesAsOneMessages, outputTemplate, formatProvider, minimumLogEventLevel) - { - _webhook = webhook; - } - - public override void Emit(LogEvent logEvent) - { - if (_webhook.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new MicrosoftTeamsApiClient( - webhook: _webhook); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsConfigurationExtensions.cs deleted file mode 100644 index 3eb8dde5a..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/MicrosoftTeamsConfigurationExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -锘縰sing Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.MicrosoftTeamsBatched -{ - public static class MicrosoftTeamsConfigurationExtensions - { - public static LoggerConfiguration MicrosoftTeamsBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string webhook = "", - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - string outputTemplate = Constants.DefaultOutputTemplate, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (loggerSinkConfiguration == null) - throw new ArgumentNullException(nameof(loggerSinkConfiguration)); - if (outputTemplate == null) - throw new ArgumentNullException(nameof(outputTemplate)); - - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink( - new MicrosoftTeamsBatchedSink( - webhook, - predicate, - sendBatchesAsOneMessages, - outputTemplate, - formatProvider, - restrictedToMinimumLevel), - restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj deleted file mode 100644 index 8c31e019d..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.MicrosoftTeamsBatched/Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj +++ /dev/null @@ -1,13 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <ImplicitUsings>enable</ImplicitUsings> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiBatchedSink.cs deleted file mode 100644 index 260744a92..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiBatchedSink.cs +++ /dev/null @@ -1,45 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.OtherApiBatched -{ - public class OtherApiBatchedSink : BatchedSink - { - private readonly string _api; - private readonly string _jsonTemplate; - private readonly string _placeholder; - - public OtherApiBatchedSink( - string api, - string jsonTemplate, - string placeholder, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) : base(predicate, sendBatchesAsOneMessages, formatProvider, minimumLogEventLevel) - { - _api = api; - _jsonTemplate = jsonTemplate; - _placeholder = placeholder; - } - - public override void Emit(LogEvent logEvent) - { - if (_api.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new OtherApiClient(_api, _jsonTemplate, _placeholder); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiClient.cs deleted file mode 100644 index 154fdca3f..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiClient.cs +++ /dev/null @@ -1,40 +0,0 @@ -锘縰sing System; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.OtherApiBatched -{ - public class OtherApiClient : PushService - { - private readonly Uri _apiUri; - private string _json; - private readonly string _placeholder; - - private readonly HttpClient _httpClient = new HttpClient(); - - - public OtherApiClient(string apiUrl, string json, string placeholder) - { - _json = json; - _placeholder = placeholder; - _apiUri = new Uri(apiUrl); - } - - public override string ClientName => "鑷畾涔�"; - - public override void BuildMsg() - { - base.BuildMsg(); - _json = _json.Replace(_placeholder, Msg.ToJson()); - } - - public override HttpResponseMessage DoSend() - { - var content = new StringContent(_json, Encoding.UTF8, "application/json"); - var response = this._httpClient.PostAsync(_apiUri, content).GetAwaiter().GetResult(); - return response; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiLoggerConfigurationExtensions.cs deleted file mode 100644 index b580cef75..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/OtherApiLoggerConfigurationExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.OtherApiBatched -{ - public static class OtherApiLoggerConfigurationExtensions - { - public static LoggerConfiguration OtherApiBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string api, - string bodyJsonTemplate, - string placeholder, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink(new OtherApiBatchedSink(api, bodyJsonTemplate, placeholder, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/Ray.Serilog.Sinks.OtherApiBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/Ray.Serilog.Sinks.OtherApiBatched.csproj deleted file mode 100644 index 10abdba2e..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.OtherApiBatched/Ray.Serilog.Sinks.OtherApiBatched.csproj +++ /dev/null @@ -1,12 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusApiClient.cs deleted file mode 100644 index 277fd82ea..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusApiClient.cs +++ /dev/null @@ -1,95 +0,0 @@ -锘縰sing System; -using System.Net.Http; -using System.Text; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.PushPlusBatched -{ - public class PushPlusApiClient : PushService - { - //http://www.pushplus.plus/doc/ - - private const string Host = "http://www.pushplus.plus/send"; - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - private readonly string _token; - private readonly string _topic; - private readonly string _channel; - private readonly string _webhook; - - public PushPlusApiClient( - string token, - string topic = null, - string channel = "", - string webhook = "" - ) - { - _apiUrl = new Uri(Host); - _token = token; - _topic = topic; - _channel = channel; - _webhook = webhook; - } - - public override string ClientName => "PushPlus"; - - private PushPlusChannelType ChannelType - { - get - { - var re = PushPlusChannelType.wechat; - - if (_channel.IsNullOrEmpty()) return re; - - bool suc = Enum.TryParse<PushPlusChannelType>(_channel, true, out PushPlusChannelType channel); - if (suc) re = channel; - - return re; - } - } - - protected override string NewLineStr => "<br/>"; - - public override HttpResponseMessage DoSend() - { - var json = new - { - token = _token, - - topic = _topic, - channel = this.ChannelType.ToString(), - webhook = _webhook, - - title = Title, - content = Msg, - - template = PushPlusMsgType.html.ToString() - }.ToJson(); - - var content = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - } - - public enum PushPlusMsgType - { - html, - json, - markdown, - cloudMonitor, - jenkins, - route - } - - public enum PushPlusChannelType - { - wechat, - webhook, - cp, - sms, - mail - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusBatchedSink.cs deleted file mode 100644 index 4ed8ffb96..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusBatchedSink.cs +++ /dev/null @@ -1,50 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.PushPlusBatched -{ - public class PushPlusBatchedSink : BatchedSink - { - private readonly string _token; - private readonly string _topic; - private readonly string _channel; - private readonly string _webhook; - - public PushPlusBatchedSink( - string token, - string topic, - string channel, - string webhook, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - string outputTemplate, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) - : base(predicate, sendBatchesAsOneMessages, outputTemplate, formatProvider, minimumLogEventLevel) - { - _token = token; - _topic = topic; - _channel = channel; - _webhook = webhook; - } - - public override void Emit(LogEvent logEvent) - { - if (_token.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new PushPlusApiClient( - _token, - _topic, - channel: _channel, - webhook: _webhook); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusLoggerConfigurationExtensions.cs deleted file mode 100644 index 21de054cd..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/PushPlusLoggerConfigurationExtensions.cs +++ /dev/null @@ -1,46 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.PushPlusBatched -{ - public static class PushPlusLoggerConfigurationExtensions - { - public static LoggerConfiguration PushPlusBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string token, - string topic = "", - string channel = "", - string webhook = "", - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - string outputTemplate = Constants.DefaultOutputTemplate, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (loggerSinkConfiguration == null) - throw new ArgumentNullException(nameof(loggerSinkConfiguration)); - if (outputTemplate == null) - throw new ArgumentNullException(nameof(outputTemplate)); - - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink( - new PushPlusBatchedSink( - token, - topic, - channel, - webhook, - predicate, - sendBatchesAsOneMessages, - outputTemplate, - formatProvider, - restrictedToMinimumLevel), - restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/Ray.Serilog.Sinks.PushPlusBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/Ray.Serilog.Sinks.PushPlusBatched.csproj deleted file mode 100644 index 27935ff85..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/Ray.Serilog.Sinks.PushPlusBatched.csproj +++ /dev/null @@ -1,12 +0,0 @@ -锘�<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/Ray.Serilog.Sinks.ServerChanBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/Ray.Serilog.Sinks.ServerChanBatched.csproj deleted file mode 100644 index f945703ea..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/Ray.Serilog.Sinks.ServerChanBatched.csproj +++ /dev/null @@ -1,16 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanApiClient.cs deleted file mode 100644 index 01eb31317..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanApiClient.cs +++ /dev/null @@ -1,52 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.ServerChanBatched -{ - public class ServerChanApiClient : PushService - { - //http://sc.ftqq.com/9.version - - private const string Host = "http://sc.ftqq.com"; - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - - public ServerChanApiClient(string scKey) - { - _apiUrl = new Uri($"{Host}/{scKey}.send"); - } - - public override string ClientName => "Server閰�"; - - /// <summary> - /// 闇€瑕佷袱涓墠鍙互鎹㈣ - /// 鍙兘鎹㈠崟琛� - /// <br/>鏃犳晥 - /// </summary> - protected override string NewLineStr => Environment.NewLine + Environment.NewLine; - - public override void BuildMsg() - { - Msg += $"{Environment.NewLine}### 妫€娴嬪埌褰撳墠涓鸿€佺増Server閰�,鍗冲皢澶辨晥,寤鸿鏇存崲鍏朵粬鎺ㄩ€佹柟寮忔垨鏇存柊鑷砈erver閰盩urbo鐗�"; - - base.BuildMsg(); - } - - public override HttpResponseMessage DoSend() - { - var dic = new Dictionary<string, string> - { - {"text", Title}, - {"desp", Msg} - }; - var content = new FormUrlEncodedContent(dic); - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanBatchedSink.cs deleted file mode 100644 index 4100b4481..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanBatchedSink.cs +++ /dev/null @@ -1,46 +0,0 @@ -锘縰sing System; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.ServerChanBatched -{ - public class ServerChanBatchedSink : BatchedSink - { - private readonly string _scKey; - private readonly string _turboScKey; - - public ServerChanBatchedSink( - string scKey, - string turboScKey, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) : base(predicate, sendBatchesAsOneMessages, formatProvider, minimumLogEventLevel) - { - _scKey = scKey; - _turboScKey = turboScKey; - } - - public override void Emit(LogEvent logEvent) - { - if (_scKey.IsNullOrEmpty() && _turboScKey.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService - { - get - { - if (_turboScKey.IsNotNullOrEmpty()) return new ServerChanTurboApiClient(_turboScKey); - return new ServerChanApiClient(_scKey); - } - } - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanLoggerConfigurationExtensions.cs deleted file mode 100644 index 7eba90db4..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanLoggerConfigurationExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.ServerChanBatched -{ - public static class ServerChanLoggerConfigurationExtensions - { - public static LoggerConfiguration ServerChanBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string scKey, - string turboScKey, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink(new ServerChanBatchedSink(scKey, turboScKey, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanTurboApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanTurboApiClient.cs deleted file mode 100644 index 30df2940b..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/ServerChanTurboApiClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.ServerChanBatched -{ - public class ServerChanTurboApiClient : PushService - { - //http://sc.ftqq.com/9.version - - private const string Host = "https://sctapi.ftqq.com"; - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - - public ServerChanTurboApiClient(string scKey) - { - _apiUrl = new Uri($"{Host}/{scKey}.send"); - } - - public override string ClientName => "Server閰盩urbo鐗�"; - - /// <summary> - /// 闇€瑕佷袱涓墠鍙互鎹㈣ - /// 鍙兘鎹㈠崟琛� - /// <br/>鏃犳晥 - /// </summary> - protected override string NewLineStr => Environment.NewLine + Environment.NewLine; - - public override HttpResponseMessage DoSend() - { - var dic = new Dictionary<string, string> - { - {"title", Title},//鏍囬蹇呭~ - {"desp", Msg} - }; - var content = new FormUrlEncodedContent(dic); - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/Ray.Serilog.Sinks.TelegramBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/Ray.Serilog.Sinks.TelegramBatched.csproj deleted file mode 100644 index b9a3aa956..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/Ray.Serilog.Sinks.TelegramBatched.csproj +++ /dev/null @@ -1,16 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Serilog" Version="2.12.0" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs deleted file mode 100644 index 67442a3d6..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramApiClient.cs +++ /dev/null @@ -1,122 +0,0 @@ -锘縰sing System; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; -using Serilog.Debugging; - -namespace Ray.Serilog.Sinks.TelegramBatched -{ - public class TelegramApiClient : PushService - { - //https://core.telegram.org/bots/api#available-methods - - private readonly string _chatId; - private readonly string _proxy; - private const string DefaultTelegramBotApiHost = "https://api.telegram.org"; - - /// <summary> - /// The API URL. - /// </summary> - private readonly Uri _apiUrl; - - /// <summary> - /// The HTTP client. - /// </summary> - private readonly HttpClient _httpClient = new HttpClient(); - - /// <summary> - /// Initializes a new instance of the <see cref="TelegramApiClient"/> class. - /// </summary> - /// <param name="botToken">The Telegram bot token.</param> - /// <param name="timeoutSeconds">The timeout seconds.</param> - /// <exception cref="ArgumentException">Thrown if the bot token is null or empty.</exception> - public TelegramApiClient(string botToken, string chatId, string proxy = "", string apiHost = "", int timeoutSeconds = 10) - { - if (string.IsNullOrWhiteSpace(botToken)) - { - SelfLog.WriteLine("The bot token mustn't be empty."); - throw new ArgumentException("The bot token mustn't be empty.", nameof(botToken)); - } - - _chatId = chatId; - _proxy = proxy; - - var botApiHost = string.IsNullOrWhiteSpace(apiHost)? DefaultTelegramBotApiHost:apiHost; - this._apiUrl = new Uri($"{botApiHost}/bot{botToken}/sendMessage"); - - if (proxy.IsNotNullOrEmpty()) - { - var webProxy = GetWebProxy(proxy); - var proxyHttpClientHandler = new HttpClientHandler - { - Proxy = webProxy, - UseProxy = true, - }; - _httpClient = new HttpClient(proxyHttpClientHandler); - } - - this._httpClient.Timeout = TimeSpan.FromSeconds(timeoutSeconds); - } - - public override string ClientName => "Telegram鏈哄櫒浜�"; - - public override HttpResponseMessage DoSend() - { - SelfLog.WriteLine($"浣跨敤浠g悊锛歿_proxy.IsNotNullOrEmpty()}"); - - var json = new - { - chat_id = _chatId, - text = Msg, - parse_mode = TeleMsgType.HTML.ToString(), - disable_web_page_preview = true - }.ToJson(); - var content = new StringContent(json, Encoding.UTF8, "application/json"); - var response = this._httpClient.PostAsync(this._apiUrl, content).GetAwaiter().GetResult(); - return response; - } - - public override void BuildMsg() - { - //闄勫姞鏍囬 - Msg = $"<b>{Title}</b>{Environment.NewLine}{Environment.NewLine}{Msg}"; - - base.BuildMsg(); - } - - private WebProxy GetWebProxy(string proxyAddress) - { - //todo:鎶借薄鍒板叕鍏辨柟娉曞簱 - WebProxy webProxy; - - //user:password@host:port http proxy only .Tested with tinyproxy-1.11.0-rc1 - if (proxyAddress.Contains("@")) - { - string userPass = proxyAddress.Split("@")[0]; - string address = proxyAddress.Split("@")[1]; - - string proxyUser = userPass.Split(":")[0]; - string proxyPass = userPass.Split(":")[1]; - - var credentials = new NetworkCredential(proxyUser, proxyPass); - - webProxy = new WebProxy(address, true, null, credentials); - } - else - { - webProxy = new WebProxy(proxyAddress, true); - } - - return webProxy; - } - } - - public enum TeleMsgType - { - MarkdownV2, - HTML, - Markdown, - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs deleted file mode 100644 index 4fa7d2b2e..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramBatchedSink.cs +++ /dev/null @@ -1,50 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; -using Serilog.Core; -using Serilog.Debugging; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.TelegramBatched -{ - public class TelegramBatchedSink : BatchedSink - { - private readonly string _botToken; - private readonly string _chatId; - private readonly string _proxy; - private readonly string _apiHost; - - public TelegramBatchedSink( - string botToken, - string chatId, - string proxy, - string apiHost, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) : base(predicate, sendBatchesAsOneMessages, formatProvider, minimumLogEventLevel) - { - _botToken = botToken; - _chatId = chatId; - _proxy = proxy; - _apiHost = apiHost; - } - - public override void Emit(LogEvent logEvent) - { - if (_botToken.IsNullOrEmpty() | _chatId.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new TelegramApiClient(_botToken, _chatId, _proxy, _apiHost, 5); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs deleted file mode 100644 index 9b4ca8d51..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.TelegramBatched/TelegramLoggerConfigurationExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.TelegramBatched -{ - public static class TelegramLoggerConfigurationExtensions - { - public static LoggerConfiguration TelegramBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string botToken, - string chatId, - string proxy, - string apiHost, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink(new TelegramBatchedSink(botToken, chatId, proxy, apiHost, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/Ray.Serilog.Sinks.WorkWeiXinAppBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/Ray.Serilog.Sinks.WorkWeiXinAppBatched.csproj deleted file mode 100644 index 03f0eaef1..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/Ray.Serilog.Sinks.WorkWeiXinAppBatched.csproj +++ /dev/null @@ -1,13 +0,0 @@ -锘�<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - <ImplicitUsings>enable</ImplicitUsings> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppApiClient.cs deleted file mode 100644 index b5df26b41..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppApiClient.cs +++ /dev/null @@ -1,92 +0,0 @@ -锘縰sing System.Text; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.WorkWeiXinAppBatched -{ - public class WorkWeiXinAppApiClient : PushService - { - // https://developer.work.weixin.qq.com/tutorial/application-message - // https://developer.work.weixin.qq.com/document/34479 - // https://github.com/JeffreySu/WeiXinMPSDK - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - private readonly string _corpId; - private readonly string _agentId; - private readonly string _secret; - - private readonly string _toUser; - private readonly string _toParty; - private readonly string _toTag; - - public WorkWeiXinAppApiClient( - string corpid, - string agentId, - string secret, - string toUser = "", - string toParty = "", - string toTag = "" - ) - { - - _corpId = corpid; - _agentId = agentId; - _secret = secret; - _toUser = toUser; - _toParty = toParty; - _toTag = toTag; - - // token - var token = GetAccessToken(corpid, secret); - _apiUrl = new Uri($"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={token}"); - } - - public override string ClientName => "WorkWeiXinApp"; - - protected override string NewLineStr => "\n"; - - public override HttpResponseMessage DoSend() - { - var json = new - { - touser = _toUser, - toparty = _toParty, - totag = _toTag, - agentid = _agentId, - msgtype = "text", - text = new - { - content = Msg - } - }.ToJson(); - - var content = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - - private string GetAccessToken(string corpId, string secret) - { - var token = ""; - - try - { - var uri = new Uri($"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}"); - var response = _httpClient.GetAsync(uri).GetAwaiter().GetResult(); - var content = response.Content.ReadAsStringAsync() - .GetAwaiter().GetResult(); - - var re = content.ToObject<WorkWeiXinAppTokenResponse>(); - - if (re.errcode == 0) return re.access_token; - } - catch (Exception) - { - //ignore - } - - return token; - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppBatchedSink.cs deleted file mode 100644 index f837d4f2f..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppBatchedSink.cs +++ /dev/null @@ -1,59 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.WorkWeiXinAppBatched -{ - public class WorkWeiXinAppBatchedSink : BatchedSink - { - private readonly string _corpId; - private readonly string _agentId; - private readonly string _secret; - - private readonly string _toUser; - private readonly string _toParty; - private readonly string _toTag; - - public WorkWeiXinAppBatchedSink( - string corpId, - string agentId, - string secret, - string toUser, - string toParty, - string toTag, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - string outputTemplate, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) - : base(predicate, sendBatchesAsOneMessages, outputTemplate, formatProvider, minimumLogEventLevel) - { - _corpId = corpId; - _agentId = agentId; - _secret = secret; - _toUser = toUser; - _toParty = toParty; - _toTag = toTag; - } - - public override void Emit(LogEvent logEvent) - { - if (_corpId.IsNullOrEmpty()||_secret.IsNullOrEmpty()||_agentId.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new WorkWeiXinAppApiClient( - _corpId, - _agentId, - _secret, - _toUser, - _toParty, - _toTag); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppConfigurationExtensions.cs deleted file mode 100644 index f2566e14d..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppConfigurationExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.WorkWeiXinAppBatched -{ - public static class WorkWeiXinAppConfigurationExtensions - { - public static LoggerConfiguration WorkWeiXinAppBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string corpId, - string agentId, - string secret, - string toUser, - string toParty, - string toTag, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - string outputTemplate = Constants.DefaultOutputTemplate, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (loggerSinkConfiguration == null) - throw new ArgumentNullException(nameof(loggerSinkConfiguration)); - if (outputTemplate == null) - throw new ArgumentNullException(nameof(outputTemplate)); - - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink( - new WorkWeiXinAppBatchedSink( - corpId, - agentId, - secret, - toUser, - toParty, - toTag, - predicate, - sendBatchesAsOneMessages, - outputTemplate, - formatProvider, - restrictedToMinimumLevel), - restrictedToMinimumLevel); - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppTokenResponse.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppTokenResponse.cs deleted file mode 100644 index 382421e70..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinAppBatched/WorkWeiXinAppTokenResponse.cs +++ /dev/null @@ -1,19 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Ray.Serilog.Sinks.WorkWeiXinAppBatched -{ - public class WorkWeiXinAppTokenResponse - { - public int errcode { get; set; } - - public string errmsg { get; set; } - - public string access_token { get; set; } - - public int expires_in { get; set; } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/Ray.Serilog.Sinks.WorkWeiXinBatched.csproj b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/Ray.Serilog.Sinks.WorkWeiXinBatched.csproj deleted file mode 100644 index f945703ea..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/Ray.Serilog.Sinks.WorkWeiXinBatched.csproj +++ /dev/null @@ -1,16 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>net6.0</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\..\Ray.BiliBiliTool.Infrastructure\Ray.BiliBiliTool.Infrastructure.csproj" /> - <ProjectReference Include="..\Ray.Serilog.Sinks.Batched\Ray.Serilog.Sinks.Batched.csproj" /> - </ItemGroup> - -</Project> diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinApiClient.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinApiClient.cs deleted file mode 100644 index be13a34e4..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinApiClient.cs +++ /dev/null @@ -1,67 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; - -namespace Ray.Serilog.Sinks.WorkWeiXinBatched -{ - public class WorkWeiXinApiClient : PushService - { - //https://work.weixin.qq.com/api/doc/90000/90136/91770 - - private readonly Uri _apiUrl; - private readonly HttpClient _httpClient = new HttpClient(); - - public WorkWeiXinApiClient(string webHookUrl) - { - _apiUrl = new Uri(webHookUrl); - } - - public override string ClientName => "浼佷笟寰俊鏈哄櫒浜�"; - - /// <summary> - /// 鎹㈣绗� - /// 锛堢粡娴嬭瘯锛屼娇鐢╘r\n鍙互姝e父鎹㈠琛岋紝浣跨敤\n浠呭彲浠ユ崲鍗曡锛� - /// 涓嶈兘鐢�<br/>鎹㈣ - /// </summary> - protected override string NewLineStr => "\r\n"; - - public override void BuildMsg() - { - //闄勫姞鏍囬 - Msg = $"## {Title} {Environment.NewLine}{Environment.NewLine}{Msg}"; - - base.BuildMsg(); - } - - public override HttpResponseMessage DoSend() - { - var json = new - { - msgtype = WorkWeiXinMsgType.markdown.ToString(), - markdown = new - { - content = Msg - } - }.ToJson(); - var content = new StringContent(json, Encoding.UTF8, "application/json"); - - var response = _httpClient.PostAsync(_apiUrl, content).GetAwaiter().GetResult(); - return response; - } - } - - - public enum WorkWeiXinMsgType - { - text, - markdown, - image, - news, - file - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinBatchedSink.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinBatchedSink.cs deleted file mode 100644 index 5aed7db71..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinBatchedSink.cs +++ /dev/null @@ -1,36 +0,0 @@ -锘縰sing System; -using System.Threading.Tasks; -using Ray.Serilog.Sinks.Batched; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.WorkWeiXinBatched -{ - public class WorkWeiXinBatchedSink : BatchedSink - { - private readonly string _webHookUrl; - - public WorkWeiXinBatchedSink( - string webHookUrl, - Predicate<LogEvent> predicate, - bool sendBatchesAsOneMessages, - IFormatProvider formatProvider, - LogEventLevel minimumLogEventLevel - ) : base(predicate, sendBatchesAsOneMessages, formatProvider, minimumLogEventLevel) - { - _webHookUrl = webHookUrl; - } - - public override void Emit(LogEvent logEvent) - { - if (_webHookUrl.IsNullOrEmpty()) return; - base.Emit(logEvent); - } - - protected override PushService PushService => new WorkWeiXinApiClient(_webHookUrl); - - public override void Dispose() - { - //todo - } - } -} diff --git a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinLoggerConfigurationExtensions.cs b/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinLoggerConfigurationExtensions.cs deleted file mode 100644 index 2cce2017b..000000000 --- a/src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.WorkWeiXinBatched/WorkWeiXinLoggerConfigurationExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -锘縰sing System; -using Ray.Serilog.Sinks.Batched; -using Ray.Serilog.Sinks.WorkWeiXinBatched; -using Serilog; -using Serilog.Configuration; -using Serilog.Events; - -namespace Ray.Serilog.Sinks.WorkWeiXinBatched -{ - public static class WorkWeiXinLoggerConfigurationExtensions - { - public static LoggerConfiguration WorkWeiXinBatched( - this LoggerSinkConfiguration loggerSinkConfiguration, - string webHookUrl, - string containsTrigger = Constants.DefaultContainsTrigger, - bool sendBatchesAsOneMessages = true, - IFormatProvider formatProvider = null, - LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose - ) - { - if (containsTrigger.IsNullOrEmpty()) containsTrigger = Constants.DefaultContainsTrigger; - Predicate<LogEvent> predicate = x => x.MessageTemplate.Text.Contains(containsTrigger); - - return loggerSinkConfiguration.Sink(new WorkWeiXinBatchedSink(webHookUrl, predicate, sendBatchesAsOneMessages, formatProvider, restrictedToMinimumLevel), restrictedToMinimumLevel); - } - } -} diff --git a/test/ConfigTest/TestDonateCoinStatusConfig.cs b/test/ConfigTest/TestDonateCoinStatusConfig.cs index dd696b50f..ddce8db0f 100644 --- a/test/ConfigTest/TestDonateCoinStatusConfig.cs +++ b/test/ConfigTest/TestDonateCoinStatusConfig.cs @@ -25,7 +25,7 @@ public void Test1() var options = scope.ServiceProvider.GetRequiredService<IOptionsMonitor<Dictionary<string, string>>>(); var dic = options.Get(Constants.OptionsNames.DonateCoinCanContinueStatusDictionaryName); - Debug.WriteLine(dic.ToJson()); + Debug.WriteLine(dic.ToJsonStr()); Assert.True(dic.Count > 0); } diff --git a/test/ConfigTest/TestExpConfig.cs b/test/ConfigTest/TestExpConfig.cs index 94c2d3c8d..a981af91d 100644 --- a/test/ConfigTest/TestExpConfig.cs +++ b/test/ConfigTest/TestExpConfig.cs @@ -25,7 +25,7 @@ public void Test1() var options = scope.ServiceProvider.GetRequiredService<IOptionsMonitor<Dictionary<string, int>>>(); var dic = options.Get(Constants.OptionsNames.ExpDictionaryName); - Debug.WriteLine(dic.ToJson()); + Debug.WriteLine(dic.ToJsonStr()); Assert.True(dic.Count > 0); } diff --git a/test/ConfigTest/UnitTest1.cs b/test/ConfigTest/UnitTest1.cs index 2a13ea4d4..f643a9039 100644 --- a/test/ConfigTest/UnitTest1.cs +++ b/test/ConfigTest/UnitTest1.cs @@ -23,7 +23,7 @@ public void WebProxyTest() Program.CreateHost(new string[] { }); string proxyAddress = Global.ConfigurationRoot["Security:WebProxy"]; - if (proxyAddress.IsNotNullOrEmpty()) + if (!proxyAddress.IsNullOrEmpty()) { WebProxy webProxy = new WebProxy(); @@ -128,7 +128,7 @@ public void TestSetConfiguration() Program.CreateHost(new string[] { }); var options = Global.ServiceProviderRoot.GetRequiredService<IOptionsMonitor<BiliBiliCookieOptions>>(); - Debug.WriteLine(options.CurrentValue.ToJson()); + Debug.WriteLine(options.CurrentValue.ToJsonStr()); //手动赋值 //RayConfiguration.Root["BiliBiliCookie:UserId"] = "123456"; @@ -136,10 +136,10 @@ public void TestSetConfiguration() Debug.WriteLine($"从Configuration读取:{Global.ConfigurationRoot["BiliBiliCookie:UserId"]}"); - Debug.WriteLine($"从老options读取:{options.CurrentValue.ToJson()}"); + Debug.WriteLine($"从老options读取:{options.CurrentValue.ToJsonStr()}"); var optionsNew = Global.ServiceProviderRoot.GetRequiredService<IOptionsMonitor<BiliBiliCookieOptions>>(); - Debug.WriteLine($"从新options读取:{optionsNew.CurrentValue.ToJson()}"); + Debug.WriteLine($"从新options读取:{optionsNew.CurrentValue.ToJsonStr()}"); } /// <summary> diff --git a/test/LogTest/LogTest.csproj b/test/LogTest/LogTest.csproj index 4be2b3b3a..71444b237 100644 --- a/test/LogTest/LogTest.csproj +++ b/test/LogTest/LogTest.csproj @@ -21,7 +21,6 @@ <ItemGroup> <ProjectReference Include="..\..\src\Ray.BiliBiliTool.Console\Ray.BiliBiliTool.Console.csproj" /> - <ProjectReference Include="..\..\src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.MicrosoftTeamsBatched\Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj" /> </ItemGroup> </Project>