refactor: DataAccess 消灭警告信息
This commit is contained in:
parent
986c6c7ab4
commit
2da0738339
|
@ -74,10 +74,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
var psi = new ProcessStartInfo("powershell", $"{file} \"{folder}\"");
|
var psi = new ProcessStartInfo("powershell", $"{file} \"{folder}\"");
|
||||||
var p = Process.Start(psi);
|
var p = Process.Start(psi);
|
||||||
p.WaitForExit();
|
p!.WaitForExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<PackageReference Include="Longbow.GitHubAuth" Version="5.0.0" />
|
<PackageReference Include="Longbow.GitHubAuth" Version="5.0.0" />
|
||||||
<PackageReference Include="Longbow.OAuth" Version="5.0.0" />
|
<PackageReference Include="Longbow.OAuth" Version="5.0.0" />
|
||||||
<PackageReference Include="Longbow.PetaPoco" Version="5.0.0" />
|
<PackageReference Include="Longbow.PetaPoco" Version="5.0.0" />
|
||||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.1" />
|
<PackageReference Include="Longbow.Security.Cryptography" Version="5.0.0" />
|
||||||
<PackageReference Include="Longbow.Tasks" Version="5.0.0" />
|
<PackageReference Include="Longbow.Tasks" Version="5.0.0" />
|
||||||
<PackageReference Include="Longbow.TencentAuth" Version="5.0.0" />
|
<PackageReference Include="Longbow.TencentAuth" Version="5.0.0" />
|
||||||
<PackageReference Include="Longbow.Web" Version="5.0.0" />
|
<PackageReference Include="Longbow.Web" Version="5.0.0" />
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Bootstrap.DataAccess
|
||||||
db.OnCommandExecuted(async provider =>
|
db.OnCommandExecuted(async provider =>
|
||||||
{
|
{
|
||||||
var context = provider.GetRequiredService<IHttpContextAccessor>();
|
var context = provider.GetRequiredService<IHttpContextAccessor>();
|
||||||
var userName = context.HttpContext?.User.Identity.Name;
|
var userName = context.HttpContext?.User.Identity?.Name;
|
||||||
var log = new DBLog()
|
var log = new DBLog()
|
||||||
{
|
{
|
||||||
LogTime = DateTime.Now,
|
LogTime = DateTime.Now,
|
||||||
|
|
|
@ -52,10 +52,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw e;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -113,10 +113,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -140,10 +140,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Bootstrap.DataAccess
|
||||||
public static bool Log(this HttpContext context, string userName, bool auth)
|
public static bool Log(this HttpContext context, string userName, bool auth)
|
||||||
{
|
{
|
||||||
var ipLocator = context.RequestServices.GetRequiredService<IIPLocatorProvider>();
|
var ipLocator = context.RequestServices.GetRequiredService<IIPLocatorProvider>();
|
||||||
var ip = context.Connection.RemoteIpAddress.ToIPv4String();
|
var ip = context.Connection.RemoteIpAddress?.ToIPv4String() ?? "";
|
||||||
var userAgent = context.Request.Headers["User-Agent"];
|
var userAgent = context.Request.Headers["User-Agent"];
|
||||||
var agent = new UserAgent(userAgent);
|
var agent = new UserAgent(userAgent);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Bootstrap.DataAccess
|
||||||
var webhookUrls = config.GetSection<TOptions>().GetValue("StarredUrl", "").SpanSplit(";", StringSplitOptions.RemoveEmptyEntries);
|
var webhookUrls = config.GetSection<TOptions>().GetValue("StarredUrl", "").SpanSplit(";", StringSplitOptions.RemoveEmptyEntries);
|
||||||
foreach (var webhookUrl in webhookUrls)
|
foreach (var webhookUrl in webhookUrls)
|
||||||
{
|
{
|
||||||
var webhookParameters = new Dictionary<string, string>()
|
var webhookParameters = new Dictionary<string, string?>()
|
||||||
{
|
{
|
||||||
{ "access_token", context.AccessToken }
|
{ "access_token", context.AccessToken }
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,12 +66,12 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
var ret = new QueryAppOption() { AppCode = key };
|
var ret = new QueryAppOption() { AppCode = key };
|
||||||
var dicts = DictHelper.RetrieveDicts();
|
var dicts = DictHelper.RetrieveDicts();
|
||||||
ret.AppName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == key).Name ?? "";
|
ret.AppName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == key)?.Name ?? "";
|
||||||
ret.AppUrl = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == key).Code ?? "";
|
ret.AppUrl = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == key)?.Code ?? "";
|
||||||
ret.AppTitle = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站标题").Code ?? "";
|
ret.AppTitle = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站标题")?.Code ?? "";
|
||||||
ret.AppFooter = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站页脚").Code ?? "";
|
ret.AppFooter = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站页脚")?.Code ?? "";
|
||||||
ret.AppFavicon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站图标").Code ?? "";
|
ret.AppFavicon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站图标")?.Code ?? "";
|
||||||
ret.AppIcon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "favicon").Code ?? "";
|
ret.AppIcon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "favicon")?.Code ?? "";
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="v"></param>
|
/// <param name="v"></param>
|
||||||
public static void Save(HttpContext context, OnlineUser v)
|
public static void Save(HttpContext context, OnlineUser v)
|
||||||
{
|
{
|
||||||
if (context.User.Identity.IsAuthenticated)
|
if (context.User.Identity!.IsAuthenticated)
|
||||||
{
|
{
|
||||||
var user = UserHelper.RetrieveUserByUserName(context.User.Identity.Name);
|
var user = UserHelper.RetrieveUserByUserName(context.User.Identity.Name);
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -87,10 +87,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -103,10 +103,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -170,10 +170,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -207,10 +207,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,10 +172,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -203,10 +203,10 @@ namespace Bootstrap.DataAccess
|
||||||
if (ret) db.Execute("delete from ResetUsers where UserName = @0", userName);
|
if (ret) db.Execute("delete from ResetUsers where UserName = @0", userName);
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -242,10 +242,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -297,10 +297,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -335,10 +335,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -373,10 +373,10 @@ namespace Bootstrap.DataAccess
|
||||||
db.CompleteTransaction();
|
db.CompleteTransaction();
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
db.AbortTransaction();
|
db.AbortTransaction();
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue