refactor: DataAccess 消灭警告信息

This commit is contained in:
Argo-Cloud 2020-11-18 14:50:15 +08:00
parent 986c6c7ab4
commit 2da0738339
12 changed files with 44 additions and 44 deletions

View File

@ -74,10 +74,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}

View File

@ -78,7 +78,7 @@ namespace Bootstrap.DataAccess
{
var psi = new ProcessStartInfo("powershell", $"{file} \"{folder}\"");
var p = Process.Start(psi);
p.WaitForExit();
p!.WaitForExit();
}
}
}

View File

@ -15,7 +15,7 @@
<PackageReference Include="Longbow.GitHubAuth" Version="5.0.0" />
<PackageReference Include="Longbow.OAuth" 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.TencentAuth" Version="5.0.0" />
<PackageReference Include="Longbow.Web" Version="5.0.0" />

View File

@ -30,7 +30,7 @@ namespace Bootstrap.DataAccess
db.OnCommandExecuted(async provider =>
{
var context = provider.GetRequiredService<IHttpContextAccessor>();
var userName = context.HttpContext?.User.Identity.Name;
var userName = context.HttpContext?.User.Identity?.Name;
var log = new DBLog()
{
LogTime = DateTime.Now,

View File

@ -52,10 +52,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception e)
catch (Exception)
{
db.AbortTransaction();
throw e;
throw;
}
return ret;
}
@ -113,10 +113,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -140,10 +140,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}

View File

@ -24,7 +24,7 @@ namespace Bootstrap.DataAccess
public static bool Log(this HttpContext context, string userName, bool auth)
{
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 agent = new UserAgent(userAgent);

View File

@ -33,7 +33,7 @@ namespace Bootstrap.DataAccess
var webhookUrls = config.GetSection<TOptions>().GetValue("StarredUrl", "").SpanSplit(";", StringSplitOptions.RemoveEmptyEntries);
foreach (var webhookUrl in webhookUrls)
{
var webhookParameters = new Dictionary<string, string>()
var webhookParameters = new Dictionary<string, string?>()
{
{ "access_token", context.AccessToken }
};

View File

@ -66,12 +66,12 @@ namespace Bootstrap.DataAccess
{
var ret = new QueryAppOption() { AppCode = key };
var dicts = DictHelper.RetrieveDicts();
ret.AppName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == key).Name ?? "";
ret.AppUrl = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == key).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.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.AppName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == key)?.Name ?? "";
ret.AppUrl = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == key)?.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.AppFavicon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站图标")?.Code ?? "";
ret.AppIcon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "favicon")?.Code ?? "";
return ret;
}
}

View File

@ -20,7 +20,7 @@ namespace Bootstrap.DataAccess
/// <param name="v"></param>
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);

View File

@ -30,10 +30,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -87,10 +87,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}

View File

@ -65,10 +65,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -103,10 +103,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -170,10 +170,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -207,10 +207,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}

View File

@ -172,10 +172,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -203,10 +203,10 @@ namespace Bootstrap.DataAccess
if (ret) db.Execute("delete from ResetUsers where UserName = @0", userName);
db.CompleteTransaction();
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -242,10 +242,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -297,10 +297,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -335,10 +335,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}
@ -373,10 +373,10 @@ namespace Bootstrap.DataAccess
db.CompleteTransaction();
ret = true;
}
catch (Exception ex)
catch (Exception)
{
db.AbortTransaction();
throw ex;
throw;
}
return ret;
}