设置
This commit is contained in:
parent
2fc06708dd
commit
63322f39d7
@ -20,6 +20,8 @@ namespace AiSportsMicrospaceDB.DBContext
|
||||
|
||||
public DbSet<SixGroupPoints> SixGroupPoints { get; set; }
|
||||
public DbSet<JumpLongPoints> JumpLongPoints { get; set; }
|
||||
public DbSet<AppVersion> AppVersion { get; set; }
|
||||
public DbSet<DeviceAssocSchool> DeviceAssocSchool { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
48
AiSportsMicrospaceDB/Entities/AppVersion.cs
Normal file
48
AiSportsMicrospaceDB/Entities/AppVersion.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AiSportsMicrospaceDB.Entities
|
||||
{
|
||||
[Table("AppVersion")]
|
||||
public class AppVersion
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 应用类型
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int AppType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[Column(TypeName = "nvarchar(2000)")]
|
||||
public string? Remarks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
[Column(TypeName = "nvarchar(200)")]
|
||||
public string? Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下载地址
|
||||
/// </summary>
|
||||
[Column(TypeName = "nvarchar(2000)")]
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime CreateDate { get; set; } = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,10 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
@ -11,6 +13,7 @@ namespace Common
|
||||
public static string Code;
|
||||
public static string SchoolCode;
|
||||
public static string BackendUrl;
|
||||
public static string Version;
|
||||
|
||||
|
||||
public static void Init(IConfiguration configuration)
|
||||
@ -18,6 +21,48 @@ namespace Common
|
||||
Code = configuration["Code"] ?? "";
|
||||
SchoolCode = configuration["SchoolCode"] ?? "";
|
||||
BackendUrl = configuration["BackendUrl"] ?? "";
|
||||
Version = configuration["Version"] ?? "";
|
||||
}
|
||||
|
||||
public static void UpdateCodeAndSchool(string filePath, string code, string schoolCode)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
throw new FileNotFoundException("appsettings.json not found", filePath);
|
||||
|
||||
// 读取 JSON
|
||||
var json = File.ReadAllText(filePath);
|
||||
var jsonDoc = JsonSerializer.Deserialize<Dictionary<string, object>>(json);
|
||||
|
||||
if (jsonDoc == null)
|
||||
throw new Exception("Failed to parse JSON");
|
||||
|
||||
// 更新值
|
||||
jsonDoc["Code"] = code;
|
||||
jsonDoc["SchoolCode"] = schoolCode;
|
||||
|
||||
// 写回文件,缩进美化
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
File.WriteAllText(filePath, JsonSerializer.Serialize(jsonDoc, options));
|
||||
}
|
||||
|
||||
public static void UpdateVersion(string filePath, string version)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
throw new FileNotFoundException("appsettings.json not found", filePath);
|
||||
|
||||
// 读取 JSON
|
||||
var json = File.ReadAllText(filePath);
|
||||
var jsonDoc = JsonSerializer.Deserialize<Dictionary<string, object>>(json);
|
||||
|
||||
if (jsonDoc == null)
|
||||
throw new Exception("Failed to parse JSON");
|
||||
|
||||
// 更新值
|
||||
jsonDoc["Version"] = version;
|
||||
|
||||
// 写回文件,缩进美化
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
File.WriteAllText(filePath, JsonSerializer.Serialize(jsonDoc, options));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -502,4 +502,10 @@
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="version.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -4,5 +4,6 @@
|
||||
},
|
||||
"Code": "04-68-74-3F-87-72",
|
||||
"SchoolCode": "202501060001",
|
||||
"Version": "1.0.0",
|
||||
"BackendUrl": "http://localhost:9991/api/StudentFace"
|
||||
}
|
||||
1
Wpf_AiSportsMicrospace/version.txt
Normal file
1
Wpf_AiSportsMicrospace/version.txt
Normal file
@ -0,0 +1 @@
|
||||
v1.0.0
|
||||
Loading…
x
Reference in New Issue
Block a user