更新KJD 项目改为SDK模板,增加调试环境
This commit is contained in:
1 parent
e1b208ca05
commit
95e995a71c
9 files changed
+809
-2220
No files matched your search
@@ -153,9 +153,7 @@
|
||||
<Compile Include="AdslHelper.cs" />
|
||||
<Compile Include="AutoSizeFormClass.cs" />
|
||||
<Compile Include="Base64Encode.cs" />
|
||||
<Compile Include="BaseClass.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="BaseClass.cs" />
|
||||
<Compile Include="BaseEncrypt.cs" />
|
||||
<Compile Include="BaseRegex.cs" />
|
||||
<Compile Include="BaseWork.cs" />
|
||||
@@ -172,6 +170,7 @@
|
||||
<Compile Include="GetProxyHtml.cs" />
|
||||
<Compile Include="Helper\CommonSimRequest.cs" />
|
||||
<Compile Include="Helper\DataOpenSSL.cs" />
|
||||
<Compile Include="Helper\EnvironmentHelper.cs" />
|
||||
<Compile Include="Helper\FissionDataBaseConfig.cs" />
|
||||
<Compile Include="Helper\GB18030EncodingProvider.cs" />
|
||||
<Compile Include="Helper\GlobalConfig.cs" />
|
||||
|
||||
@@ -137,10 +137,10 @@ namespace AllBase
|
||||
public static int TimeOut = 60;
|
||||
public static int ThreadCount = 3;
|
||||
public static int MainCatId = 0;
|
||||
/// <summary>
|
||||
/// 用户分组
|
||||
/// </summary>
|
||||
public static int GroupId = 0;
|
||||
/// <summary>
|
||||
/// 用户分组 3主号 4客服 5加盟 8登录 9采购 10加盟 11上货
|
||||
/// </summary>
|
||||
public static int GroupId = 0;
|
||||
public static bool DarenYaoyue = false;
|
||||
public static bool DyProductCollect = false;
|
||||
public static bool IsCloudBuyOrder = false;
|
||||
@@ -321,8 +321,11 @@ namespace AllBase
|
||||
/// 子账号所属主账号
|
||||
/// </summary>
|
||||
public static string ParentUserName { get; set; }
|
||||
//public static bool IsSa;
|
||||
public static int SaLevel = 0;
|
||||
//public static bool IsSa;
|
||||
/// <summary>
|
||||
/// 超管等级 0 普通用户 1 超级管理员
|
||||
/// </summary>
|
||||
public static int SaLevel = 0;
|
||||
public static string UserAuthority = "";
|
||||
public static string ParentAuthority = "";
|
||||
public static string ForbiddenPage = "";
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Helper
|
||||
{
|
||||
public class EnvironmentHelper
|
||||
{
|
||||
private static string _currentEnvironment;
|
||||
|
||||
// 获取当前环境
|
||||
public static string CurrentEnvironment
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_currentEnvironment == null)
|
||||
{
|
||||
_currentEnvironment = DetermineEnvironment();
|
||||
}
|
||||
return _currentEnvironment;
|
||||
}
|
||||
}
|
||||
public static bool IsTest => CurrentEnvironment.Equals("Test", StringComparison.OrdinalIgnoreCase);
|
||||
public static bool IsDevelopment => CurrentEnvironment.Equals("Development", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static bool IsProduction => CurrentEnvironment.Equals("Production", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static string DetermineEnvironment()
|
||||
{
|
||||
#if RELEASE
|
||||
// Release 构建:只允许生产环境,不允许其他环境
|
||||
return "Production";
|
||||
#else
|
||||
// 1. 检查环境变量
|
||||
var envVar = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ??
|
||||
Environment.GetEnvironmentVariable("ENVIRONMENT");
|
||||
|
||||
if (!string.IsNullOrEmpty(envVar))
|
||||
{
|
||||
return envVar;
|
||||
}
|
||||
|
||||
|
||||
// 检查当前机器名
|
||||
string machineName = Environment.MachineName.ToLower();
|
||||
if (machineName.Contains("dev") ||
|
||||
machineName.Contains("test"))
|
||||
{
|
||||
return machineName.Contains("TEST") ? "Test" : "Development";
|
||||
}
|
||||
|
||||
// 4. 默认返回 Production
|
||||
return "Production";
|
||||
#endif
|
||||
}
|
||||
|
||||
// 获取环境描述
|
||||
public static string EnvironmentDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsTest) return "测试环境";
|
||||
if (IsDevelopment) return "开发环境";
|
||||
if (IsProduction) return "生产环境";
|
||||
return $"未知环境 ({CurrentEnvironment})";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user