diff --git a/CommandLine/Danmu.CommandLine.csproj b/CommandLine/Danmu.CommandLine.csproj
index 3c53b25..addd3fd 100644
--- a/CommandLine/Danmu.CommandLine.csproj
+++ b/CommandLine/Danmu.CommandLine.csproj
@@ -8,26 +8,11 @@
1.0.0
-
-
-
-
-
-
-
-
-
-
-
-
-
- Never
-
-
-
-
+
+
+
@@ -35,18 +20,9 @@
-
- True
- True
- Resources.resx
-
-
-
-
-
- PublicResXFileCodeGenerator
- Resources.Designer.cs
-
+
+ Always
+
diff --git a/CommandLine/Program.cs b/CommandLine/Program.cs
index e7000de..579587b 100644
--- a/CommandLine/Program.cs
+++ b/CommandLine/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
+using System.Threading.Tasks;
using CommandLine;
using Danmu.CommandLine.Utils;
@@ -10,6 +11,9 @@ internal class Program
{
private static void Main(string[] args)
{
+ //系统信息查询
+ Start.StartCommandLine();
+
Parser.Default.ParseArguments(args)
.WithParsed(RunOptions)
.WithNotParsed(HandleParseError);
@@ -22,7 +26,7 @@ private static void RunOptions(Options opts)
.GetCustomAttribute().InformationalVersion);
if (opts.Menu)
{
- Menu.MainMenu();
+ _ = Menu.MainMenu().Result;
}
}
diff --git a/CommandLine/Properties/Resources.Designer.cs b/CommandLine/Properties/Resources.Designer.cs
deleted file mode 100644
index 208a937..0000000
--- a/CommandLine/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 此代码由工具生成。
-// 运行时版本:4.0.30319.42000
-//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将会丢失。
-//
-//------------------------------------------------------------------------------
-
-namespace Danmu.CommandLine.Properties {
- using System;
-
-
- ///
- /// 一个强类型的资源类,用于查找本地化的字符串等。
- ///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// 返回此类使用的缓存的 ResourceManager 实例。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Danmu.CommandLine.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// 重写当前线程的 CurrentUICulture 属性
- /// 重写当前线程的 CurrentUICulture 属性。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// 查找类似
- /// 的本地化字符串。
- ///
- public static string MainMenu {
- get {
- return ResourceManager.GetString("MainMenu", resourceCulture);
- }
- }
- }
-}
diff --git a/CommandLine/Properties/Resources.resx b/CommandLine/Properties/Resources.resx
deleted file mode 100644
index fe9bb77..0000000
--- a/CommandLine/Properties/Resources.resx
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- ..\Resources\MainMenu.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312
-
-
\ No newline at end of file
diff --git a/CommandLine/Resources/MainMenu.txt b/CommandLine/Resources/MainMenu.txt
deleted file mode 100644
index 8b13789..0000000
--- a/CommandLine/Resources/MainMenu.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/CommandLine/Scripts/Menu/MainMenu.txt b/CommandLine/Scripts/Menu/MainMenu.txt
new file mode 100644
index 0000000..bfd90b0
--- /dev/null
+++ b/CommandLine/Scripts/Menu/MainMenu.txt
@@ -0,0 +1,9 @@
+============================ Danmu.Server ============================
+
+A 查看最新版本 B
+
+
+
+X 退出
+
+======================================================================
diff --git a/CommandLine/TrimmerRoots.xml b/CommandLine/TrimmerRoots.xml
index f5fd0c4..bfbeeb0 100644
--- a/CommandLine/TrimmerRoots.xml
+++ b/CommandLine/TrimmerRoots.xml
@@ -1,3 +1,5 @@
-
-
+
+
+
+
\ No newline at end of file
diff --git a/CommandLine/Utils/GlobalConstant.cs b/CommandLine/Utils/GlobalConstant.cs
new file mode 100644
index 0000000..f97ca97
--- /dev/null
+++ b/CommandLine/Utils/GlobalConstant.cs
@@ -0,0 +1,11 @@
+namespace Danmu.CommandLine.Utils
+{
+ public static class GlobalConstant
+ {
+ public const string GithubUserName = "MonoLogueChi";
+ public const string GithubRepoName = "Danmu.Server";
+
+ public const string ReleasesLatestUrl =
+ "https://api.github.com/repos/" + GithubUserName + "/" + GithubRepoName + "/releases/latest";
+ }
+}
\ No newline at end of file
diff --git a/CommandLine/Utils/Menu.cs b/CommandLine/Utils/Menu.cs
index 223546a..367d913 100644
--- a/CommandLine/Utils/Menu.cs
+++ b/CommandLine/Utils/Menu.cs
@@ -1,37 +1,77 @@
-
using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using Medallion.Shell;
+using ShellProgressBar;
+using static System.Console;
+using static Danmu.CommandLine.Utils.GlobalConstant;
+using static Danmu.CommandLine.Utils.Utils;
namespace Danmu.CommandLine.Utils
{
public static class Menu
{
- public static void MainMenu()
+ public static async Task MainMenu()
{
- var menu = Properties.Resources.MainMenu;
- Console.Write(menu);
- var key = Console.ReadKey();
- Console.WriteLine(key.Key.Equals(ConsoleKey.A));
-
+ var menu = LoadMenuAsync("MainMenu.txt");
+ Utils.Clear();
+ Write(await menu);
+ var key = ReadKey();
switch (key.Key)
{
+ case ConsoleKey.A:
+ await A();
+ break;
case ConsoleKey.X:
X();
break;
default:
- MainMenu();
+ await MainMenu();
break;
}
+
+ return 0;
}
- public static void A()
+ ///
+ /// 查询最新版本
+ ///
+ ///
+ private static async Task A()
{
- Console.ReadKey();
- MainMenu();
+ Utils.Clear();
+ var options = new ProgressBarOptions
+ {
+ ForegroundColor = ConsoleColor.Yellow,
+ ForegroundColorDone = ConsoleColor.DarkGreen,
+ BackgroundColor = ConsoleColor.DarkGray,
+ BackgroundCharacter = '\u2593',
+ DisplayTimeInRealTime = false,
+ ProgressBarOnBottom = true
+ };
+ using var pbar = new ProgressBar(10, "正在查询", options);
+ pbar.Tick(1);
+ pbar.Tick("正在查询相关数据");
+ var releases = GitHub.Repository.Release.GetAll(GithubUserName, GithubRepoName).Result;
+ var latest = releases[0];
+ pbar.Tick(8);
+ pbar.Tick("查询完成");
+ Thread.Sleep(200);
+ pbar.Tick(10);
+ Thread.Sleep(100);
+ WriteLine("\r\n \r\n ");
+ WriteLine($"最新版本:{latest.TagName}");
+ WriteLine("\r\n按任意键继续");
+ ReadKey();
+ await MainMenu();
}
- public static void X()
+ private static void X()
{
- Console.WriteLine("再见");
+ Utils.Clear();
+ WriteLine("再见");
}
}
-}
+}
\ No newline at end of file
diff --git a/CommandLine/Utils/Start.cs b/CommandLine/Utils/Start.cs
new file mode 100644
index 0000000..d34ad03
--- /dev/null
+++ b/CommandLine/Utils/Start.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Danmu.CommandLine.Utils
+{
+ public class Start
+ {
+ public static void StartCommandLine()
+ {
+ Console.WriteLine(Environment.Is64BitProcess);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CommandLine/Utils/Utils.cs b/CommandLine/Utils/Utils.cs
new file mode 100644
index 0000000..00269ee
--- /dev/null
+++ b/CommandLine/Utils/Utils.cs
@@ -0,0 +1,25 @@
+using System;
+using System.IO;
+using System.Threading.Tasks;
+using Medallion.Shell;
+using Octokit;
+
+namespace Danmu.CommandLine.Utils
+{
+ public static class Utils
+ {
+ public static GitHubClient GitHub
+ => new GitHubClient(new ProductHeaderValue("Awesome-Octocat-App"));
+
+ public static async Task LoadMenuAsync(string name)
+ {
+ return await File.ReadAllTextAsync($"{AppDomain.CurrentDomain.BaseDirectory}/Scripts/Menu/{name}");
+ }
+
+ public static void Clear()
+ {
+ var a = Command.Run("clear").StandardOutput.ReadToEnd();
+ Console.Write(a);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Danmu.sln.DotSettings.user b/Danmu.sln.DotSettings.user
index a03fe8e..48f40c4 100644
--- a/Danmu.sln.DotSettings.user
+++ b/Danmu.sln.DotSettings.user
@@ -17,6 +17,7 @@
<Assembly Path="C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.1.0\ref\netcoreapp3.1\Microsoft.AspNetCore.HttpOverrides.dll" />
<Assembly Path="C:\Users\MonoLogueChi\.nuget\packages\microsoft.extensions.caching.abstractions\3.1.2\lib\netcoreapp3.1\Microsoft.Extensions.Caching.Abstractions.dll" />
<Assembly Path="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.15\System.Private.CoreLib.dll" />
+ <Assembly Path="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.2\System.Net.Http.dll" />
</AssemblyExplorer>
True
True
diff --git a/Danmu/Controllers/Danmu/ArtPlayer/V1/BiliBiliController.cs b/Danmu/Controllers/Danmu/ArtPlayer/V1/BiliBiliController.cs
index dd4e739..c3615ec 100644
--- a/Danmu/Controllers/Danmu/ArtPlayer/V1/BiliBiliController.cs
+++ b/Danmu/Controllers/Danmu/ArtPlayer/V1/BiliBiliController.cs
@@ -29,7 +29,7 @@ public async Task Get(int cid, int aid, int p, string format)
cid = await Bilibili.GetCidAsync(aid, p);
}
- return await Bilibili.GetDanmuRawByCidTask(cid);
+ return await Bilibili.GetDanmuRawByCidTaskAsync(cid);
}
var danmu = await Bilibili.GetDanmuAsync(cid, aid, p, date);
diff --git a/Danmu/Controllers/Danmu/Common/V1/BiliBiliController.cs b/Danmu/Controllers/Danmu/Common/V1/BiliBiliController.cs
index ae9cf31..e12359f 100644
--- a/Danmu/Controllers/Danmu/Common/V1/BiliBiliController.cs
+++ b/Danmu/Controllers/Danmu/Common/V1/BiliBiliController.cs
@@ -28,7 +28,7 @@ public async Task Get(int cid, int aid, int p, string format)
}
HttpContext.Response.ContentType = "application/xml; charset=utf-8";
- return await Bilibili.GetDanmuRawByCidTask(cid);
+ return await Bilibili.GetDanmuRawByCidTaskAsync(cid);
}
var danmu = await Bilibili.GetDanmuAsync(cid, aid, p, date);
diff --git a/Danmu/Model/DataTable/HttpClientCacheTable.cs b/Danmu/Model/DataTable/HttpClientCacheTable.cs
index eeb04b0..eb75753 100644
--- a/Danmu/Model/DataTable/HttpClientCacheTable.cs
+++ b/Danmu/Model/DataTable/HttpClientCacheTable.cs
@@ -11,15 +11,12 @@ public class HttpClientCacheTable
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
- [Column("Data", TypeName = "jsonb")]
[Required]
- public CacheData Data { get; set; }
- }
-
- public class CacheData
- {
public string Key { get; set; }
+
public byte[] Value { get; set; }
+
+ [Required]
public long TimeStamp { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
}
}
diff --git a/Danmu/Model/DbContext/DanmuContext.cs b/Danmu/Model/DbContext/DanmuContext.cs
index 8a8977c..74379fc 100644
--- a/Danmu/Model/DbContext/DanmuContext.cs
+++ b/Danmu/Model/DbContext/DanmuContext.cs
@@ -16,6 +16,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity().Property(p => p.IsDelete).HasDefaultValue(false);
modelBuilder.Entity().HasIndex(d => new {d.Vid, d.IsDelete});
+
+ modelBuilder.Entity().HasIndex(h => h.Key).HasMethod("hash");
}
}
}
diff --git a/Danmu/Utils/BiliBili/BiliBiliHelp.Http.cs b/Danmu/Utils/BiliBili/BiliBiliHelp.Http.cs
index 3ef9a0c..71aa211 100644
--- a/Danmu/Utils/BiliBili/BiliBiliHelp.Http.cs
+++ b/Danmu/Utils/BiliBili/BiliBiliHelp.Http.cs
@@ -1,5 +1,4 @@
using System;
-using System.IO;
using System.Threading.Tasks;
using Danmu.Utils.Common;
using static Danmu.Utils.Global.VariableDictionary;
@@ -11,19 +10,18 @@ public partial class BiliBiliHelp
///
/// 获取视频的Page原始数据
///
- /// 视频的aid
+ ///
///
- private async Task GetBiliBiliPageRawAsync(int aid)
+ private async Task GetBiliBiliPageRawAsync(string url)
{
- return await _cache.GetOrCreateCache($"aid{aid}", TimeSpan.FromMinutes(_setting.CidCacheTime),
- async s =>
- {
- var gzipClient = _httpClientFactory.CreateClient(Gzip);
- var response =
- await gzipClient.GetAsync($"https://www.bilibili.com/widget/getPageList?aid={aid}");
- if (response.IsSuccessStatusCode) return await response.Content.ReadAsByteArrayAsync();
- return new byte[0];
- });
+ var key = Md5.GetMd5(url);
+ return await _cache.GetOrCreateCache(key, TimeSpan.FromMinutes(_setting.CidCacheTime), async () =>
+ {
+ var gzipClient = _httpClientFactory.CreateClient(Gzip);
+ var response = await gzipClient.GetAsync(url);
+ if (response.IsSuccessStatusCode) return await response.Content.ReadAsByteArrayAsync();
+ return new byte[0];
+ });
}
///
@@ -31,22 +29,20 @@ private async Task GetBiliBiliPageRawAsync(int aid)
///
/// url
///
- private async Task GetDanmuRawAsync(string url)
+ private async Task GetDanmuRawAsync(string url)
{
var key = Md5.GetMd5(url);
- var result = await _cache.GetOrCreateCache(key, TimeSpan.FromMinutes(_setting.CidCacheTime), async s =>
+ return await _cache.GetOrCreateCache(key, TimeSpan.FromMinutes(_setting.CidCacheTime), async () =>
{
- var response = await _deflateClient.GetAsync(url);
+ var deflateClient = _httpClientFactory.CreateClient(Deflate);
+ if (!string.IsNullOrEmpty(_setting.Cookie))
+ {
+ deflateClient.DefaultRequestHeaders.Add("Cookie", _setting.Cookie);
+ }
+ var response = await deflateClient.GetAsync(url);
if (response.IsSuccessStatusCode) return await response.Content.ReadAsByteArrayAsync();
return new byte[0];
});
-
- return result.Length == 0 ? Stream.Null : new MemoryStream(result);
- }
-
- public Task GetDanmuRawByCidTask(int cid)
- {
- return GetDanmuRawAsync($"https://api.bilibili.com/x/v1/dm/list.so?oid={cid}");
}
}
}
diff --git a/Danmu/Utils/BiliBili/BiliBiliHelp.Page.cs b/Danmu/Utils/BiliBili/BiliBiliHelp.Page.cs
index 622eaeb..7eca8c9 100644
--- a/Danmu/Utils/BiliBili/BiliBiliHelp.Page.cs
+++ b/Danmu/Utils/BiliBili/BiliBiliHelp.Page.cs
@@ -1,9 +1,7 @@
-using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using Danmu.Model.Danmu.BiliBili;
-using Microsoft.Extensions.Caching.Memory;
namespace Danmu.Utils.BiliBili
{
@@ -17,10 +15,9 @@ public partial class BiliBiliHelp
/// cid
public async Task GetCidAsync(int aid, int p)
{
-
- var pages = await GetBiliBiliPageAsync(aid);
- return GetCid(pages, p);
- }
+ var pages = await GetBiliBiliPageAsync(aid);
+ return GetCid(pages, p);
+ }
///
/// 获取视频Cid和分P信息
@@ -29,7 +26,7 @@ public async Task GetCidAsync(int aid, int p)
/// Page数据
private async Task GetBiliBiliPageAsync(int aid)
{
- var raw = await GetBiliBiliPageRawAsync(aid);
+ var raw = await GetBiliBiliPageRawAsync($"https://www.bilibili.com/widget/getPageList?aid={aid}");
if (raw.Length != 0)
{
var pages = JsonSerializer.DeserializeAsync(new MemoryStream(raw));
diff --git a/Danmu/Utils/BiliBili/BiliBiliHelp.cs b/Danmu/Utils/BiliBili/BiliBiliHelp.cs
index c2a9a96..f14f4f8 100644
--- a/Danmu/Utils/BiliBili/BiliBiliHelp.cs
+++ b/Danmu/Utils/BiliBili/BiliBiliHelp.cs
@@ -1,3 +1,4 @@
+using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
@@ -5,7 +6,6 @@
using Danmu.Model.Danmu.BiliBili;
using Danmu.Utils.Configuration;
using Danmu.Utils.Dao;
-using Microsoft.Extensions.Caching.Memory;
using static Danmu.Utils.Global.VariableDictionary;
namespace Danmu.Utils.BiliBili
@@ -13,7 +13,6 @@ namespace Danmu.Utils.BiliBili
public partial class BiliBiliHelp
{
private readonly bool _canGetHistory;
- private readonly HttpClient _deflateClient;
private readonly IHttpClientFactory _httpClientFactory;
private readonly HttpClientCacheDao _cache;
private readonly BiliBiliSetting _setting;
@@ -21,14 +20,8 @@ public partial class BiliBiliHelp
public BiliBiliHelp(AppConfiguration appConfiguration, IHttpClientFactory httpClientFactory, HttpClientCacheDao biliBiliCache)
{
_httpClientFactory = httpClientFactory;
- _deflateClient = httpClientFactory.CreateClient(Deflate);
_setting = appConfiguration.GetAppSetting().BiliBiliSetting;
- if (!string.IsNullOrEmpty(_setting.Cookie))
- {
- _canGetHistory = true;
- _deflateClient.DefaultRequestHeaders.Add("Cookie", _setting.Cookie);
- }
-
+ _canGetHistory = !string.IsNullOrEmpty(_setting.Cookie);
_cache = biliBiliCache;
}
@@ -36,11 +29,11 @@ public BiliBiliHelp(AppConfiguration appConfiguration, IHttpClientFactory httpCl
/// 获取B站弹幕
///
/// 视频的cid
- /// B站弹幕
- public async Task GetDanmuAsync(int cid)
+ /// B站弹幕数据流
+ public async Task GetDanmuRawByCidTaskAsync(int cid)
{
- var raw = GetDanmuRawByCidTask(cid);
- return new DanmuDataBiliBili(await raw);
+ var r = await GetDanmuRawAsync($"https://api.bilibili.com/x/v1/dm/list.so?oid={cid}");
+ return r.Length == 0 ? Stream.Null : new MemoryStream(r);
}
///
@@ -51,12 +44,13 @@ public async Task GetDanmuAsync(int cid)
///
public async Task GetDanmuAsync(int cid, string[] date)
{
- if (!_canGetHistory) return new DanmuDataBiliBili();
+ if (!_canGetHistory) return await GetDanmuAsync(cid, 0, 1, new string[0]);
var a = Task.Run(() => date.Select(async s =>
{
var b = await GetDanmuRawAsync(
$"https://api.bilibili.com/x/v2/dm/history?type=1&oid={cid}&date={s}");
- return new DanmuDataBiliBili(b);
+ var c = b.Length == 0 ? Stream.Null : new MemoryStream(b);
+ return new DanmuDataBiliBili(c);
}).SelectMany(s => s.Result.D));
return new DanmuDataBiliBili
{
@@ -83,7 +77,7 @@ public async Task GetDanmuAsync(int cid, int aid, int p, stri
return cid == 0
? new DanmuDataBiliBili()
: date.Length == 0
- ? await GetDanmuAsync(cid)
+ ? new DanmuDataBiliBili(await GetDanmuRawByCidTaskAsync(cid))
: await GetDanmuAsync(cid, date);
}
}
diff --git a/Danmu/Utils/Dao/HttpClientCacheDao.cs b/Danmu/Utils/Dao/HttpClientCacheDao.cs
index b6b5a19..c3bbd18 100644
--- a/Danmu/Utils/Dao/HttpClientCacheDao.cs
+++ b/Danmu/Utils/Dao/HttpClientCacheDao.cs
@@ -23,36 +23,32 @@ public HttpClientCacheDao(DanmuContext con)
///
///
///
- public async Task GetOrCreateCache(string key, TimeSpan expireTime, Func> factory)
+ public async Task GetOrCreateCache(string key, TimeSpan expireTime, Func> factory)
{
- var a = _con.HttpClientCache.Where(e => e.Data.Key.Equals(key));
+ var a = _con.HttpClientCache.Where(e => e.Key.Equals(key));
if (await a.CountAsync() > 0)
{
var b = await a.FirstOrDefaultAsync();
- if (DateTimeOffset.UtcNow.ToUnixTimeSeconds() - b.Data.TimeStamp > expireTime.TotalSeconds)
+ if (DateTimeOffset.UtcNow.ToUnixTimeSeconds() - b.TimeStamp > expireTime.TotalSeconds)
{
- var c = await factory(key);
- b.Data.Value = c;
- b.Data.TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
+ var c = await factory();
+ b.Value = c;
+ b.TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
_con.HttpClientCache.Update(b);
await _con.SaveChangesAsync();
}
- return b.Data.Value;
+ return b.Value;
}
var d = new HttpClientCacheTable
{
- Data = new CacheData
- {
- Key = key,
- Value = await factory(key),
- TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
- }
+ Key = key,
+ Value = await factory()
};
await _con.HttpClientCache.AddAsync(d);
await _con.SaveChangesAsync();
- return d.Data.Value;
+ return d.Value;
}
}
}
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index bbc4ced..1d1d862 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -57,11 +57,11 @@ steps:
arguments: "-c Release-Linux64 -r linux-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu64-R2R"
zipAfterPublish: False
- #开启程序集链接
- - task: CmdLine@2
- inputs:
- script: |
- sed -i "s/false/true/g" $(Build.SourcesDirectory)/Danmu/Danmu.csproj
+ # #开启程序集链接
+ # - task: CmdLine@2
+ # inputs:
+ # script: |
+ # sed -i "s/false/true/g" $(Build.SourcesDirectory)/Danmu/Danmu.csproj
- task: DotNetCoreCLI@2
inputs:
command: publish
@@ -122,10 +122,10 @@ steps:
#编译非SCD版
#关闭程序集链接
- - task: CmdLine@2
- inputs:
- script: |
- sed -i "s/true/false/g" $(Build.SourcesDirectory)/Danmu/Danmu.csproj
+ # - task: CmdLine@2
+ # inputs:
+ # script: |
+ # sed -i "s/true/false/g" $(Build.SourcesDirectory)/Danmu/Danmu.csproj
- task: DotNetCoreCLI@2
inputs:
command: publish