我知道至少有十几个问题.我正在尝试使用Regex对街道地址的输入进行简单验证,我在输入条目中检查至少两个空格.原因?在大多数情况下,我们的地址至少有3个部分,街道号码,街道名称,类型(车道,车道,大道,街道等)
我想提醒用户,如果条目至少不匹配,如果它有三个以上的空格,这意味着它在地址中有更多的名称,这很好,但最低要求不需要警报.我的最新努力在下面,并没有奏效.
var addregex = new RegExp("^\d{1,6}\040([A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,})$|^\d{1,6}\040([A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,})$|^\d{1,6}\040([A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,})$");
if (addregex.test($(this).val())) {
alert('is valid');
address.addClass('isvalid');
address.css("border", "1px solid lightgray");
} else {
address.css("border", "2px solid red");
alert("Are you sure this is a valid street address?");
address.focus();
}
Run Code Online (Sandbox Code Playgroud) .ToDictionary的正确语法是将以下内容作为Dictionary(Of String,String)返回,其中ShortDesc是键,CurrentFrontSymbol是值
Dim dicQuery As Dictionary(Of String, String) = (From d In toolkitEntities.currentfrontcommoditysymbols
Select d.ShortDesc, d.CurrentFrontSymbol)
Run Code Online (Sandbox Code Playgroud)
更新
并且以下函数可以查询和跟踪For Each循环成为一个LINQ查询吗?
Public Shared Function GetRangeProjectionPerformance(Optional daysToRetrieve As Integer = 100) As Dictionary(Of Integer, List(Of ProjectionPerformance))
Dim todaysDate As Date = DateTime.Now.Date
Dim lookbackDate As Date = todaysDate.AddDays(daysToRetrieve * -1)
Dim temp As New Dictionary(Of Integer, List(Of ProjectionPerformance))
Using ctx As New ProjectionsEntities()
Dim query = (From d In ctx.projections
Where d.SymbolId <= 42 AndAlso d.Date >= lookbackDate
Join t In ctx.symbols On …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Asp.Net Core 2.0.1,EF 2.0.1和MVC 6在多项目解决方案中将Serilog设置为我的记录器.
我已经设置了Serilog,主要是遵循这个博客文章 Set up Serilog post的指导
该帖子中的json存在问题,我已经更正并在此处显示
appsettings.json文件
{
"ApplicationConfiguration": {
"ConnectionStrings": {
"DevelopmentConnection": "Server=(localdb)\\mssqllocaldb;Database=TestingConfigurationNetCoreTwo_Development;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"ApplicationInfo": {
"VersionNumber": "1.0.0",
"Author": "Jimbo",
"ApplicationName": "CustomTemplate",
"CreatedOn": "November 20, 2017"
},
"Serilog": {
"Using": [
"Serilog.Sinks.RollingFile",
"Serilog.Sinks.Async",
"Serilog.Sinks.ApplicationInsights",
"Serilog.Sinks.Console",
"Serilog.Sinks.Seq"
],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning"
}
},
"WriteTo": [
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "RollingFile",
"Args": { "pathFormat": "Logs/log-{Date}.log" }
}
]
}
}
],
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"],
"Properties": …Run Code Online (Sandbox Code Playgroud) 任何人都可以解释为什么具有个人用户标识的默认Asp.Net Web应用程序模板在管理控制器中出现错误?
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SendVerificationEmail(IndexViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
var email = user.Email;
await _emailSender.SendEmailConfirmationAsync(email, callbackUrl);
StatusMessage = "Verification email sent. Please check your email.";
return RedirectToAction(nameof(Index));
}
Run Code Online (Sandbox Code Playgroud)
在这个代码行中;
return View(model);
Run Code Online (Sandbox Code Playgroud)
视图为红色,因为没有SendVerificationEmail视图.这是正常的吗?这可以解决吗?
我可以指定一个路由到喜欢的视图
if (!ModelState.IsValid)
{
return View(nameof(Index),model);
}
Run Code Online (Sandbox Code Playgroud)
但这真的是Asp.Net团队打算从这里开始的吗?
过去相对容易的事情,现在变得不那么容易了。在我搜索过的几十次中,我很少找到这种情况的答案,我认为这在大多数项目结构中都是普遍存在的。
我有标准的 Core 2.0 Web 应用程序,现在,为了简单起见,还有一个基础设施项目和一个单元测试项目。我有一个很好的想法如何完成测试场景,因为测试项目没有运行 asp.net,我有一个关于如何完成它的很棒的视频教程。
问题在于如何访问我的基础设施项目中的 DbContext。(.Net Core 类库)
DbContext 在 Startup 中设置得非常好
var connString = Configuration.GetSection("ApplicationConfiguration:ConnectionStrings:DefaultConnection").Value;
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(connString));
Run Code Online (Sandbox Code Playgroud)
在控制器中我可以访问它
private ApplicationDbContext _context;
private IConfiguration Configuration { get; set; }
public HomeController(IConfiguration configuration, ApplicationDbContext context)
{
_context = context;
Configuration = configuration;
}
public IActionResult Index()
{
// gets users from the DI injected context in the controller
var users = _context.AppUsers.ToList();
// if GetUsers is defined statically, this doesn't work because the injected context is always …Run Code Online (Sandbox Code Playgroud) c# dependency-injection entity-framework-core asp.net-core-2.0
我正在尝试使用dotnet核心应用程序中的WebAPI为请求指定Web代理.当我定位实际的clr(dnx46)时,这段代码曾经工作但是,现在我正在尝试使用rc2的东西,说支持的框架是netcoreapp1.0和netstandard1.5.
var clientHandler = new HttpClientHandler{
Proxy = string.IsNullOrWhiteSpace(this._clientSettings.ProxyUrl) ? null : new WebProxy (this._clientSettings.ProxyUrl, this._clientSettings.BypassProxyOnLocal),
UseProxy = !string.IsNullOrWhiteSpace(this._clientSettings.ProxyUrl)
};
Run Code Online (Sandbox Code Playgroud)
我想知道WebProxy类去了哪里.我无法在任何地方找到它,甚至在github存储库中也找不到它.如果它从WebProxy改变了,它改变了什么?我需要能够将代理设置为特定请求的特定URL,因此使用"全局Internet Explorer"方式不能满足我的需求.这主要用于调试Web请求/响应目的.
我正在尝试为仪表板中的Excel图表构建一些自定义主题.在记录宏以查看它们是如何实现时,宏记录了以下代码;
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 268
Run Code Online (Sandbox Code Playgroud)
我通过谷歌搜索高低,找到这些图表样式的列表,或任何有关如何自定义它们的文档.每次搜索都会返回图表类型常量的链接,即xlLine,xlPie等.不是Excel功能区中"图表工具 - 设计"选项卡上可用的主题图表.
如果有人能指出我正确的方向,我将不胜感激.
编辑:
这些图表样式常量的文档很少甚至没有,因此我创建了一个示例工作簿,其中所有图表样式类型都显示为饼图.它在这里可用.至少在选择类型之前,您将拥有图表的直观表示.
可以在这里查看工作簿,如果有人知道如何在帖子中添加可下载的版本请评论
您可以使用以下代码自行构建它,只需添加名为ChartStyles的工作表并创建名为GolfRoundsPlayed的数据表并使用此数据
月轮播放1月42日2月53日3月77 4月124 5月198 6月288 7月312 8月303 9月264 10月149 11月54 12月33日
Sub BuildChartStyleSheet()
Dim targetChart As Chart
Dim targetSheet As Worksheet
Dim top As Long
Dim x As Integer, chtTitle As String
top = 15
Dim dataRange As Range
Set dataRange = Range("GolfRoundsPlayed")
Set targetSheet = Sheets("ChartStyles")
Application.ScreenUpdating = False
For x = 1 To 353
If x > 1 Then top = top + 128
On …Run Code Online (Sandbox Code Playgroud) 我最初使用 Serilog 的一个日志文件,这是我通过这样做完成的
var slc = new SerilogSubLoggerConfiguration();
configuration.GetSection("Serilog:SubLogger").Bind(slc);
Run Code Online (Sandbox Code Playgroud)
然后在Program.cs的Main方法中配置SubLogger
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.WriteTo.Logger(logger => logger.Filter.
ByIncludingOnly(lvl => lvl.Level == slc.Level).WriteTo.RollingFile(slc..PathFormat))
.CreateLogger();
Run Code Online (Sandbox Code Playgroud)
我已转而使用现在在 appsettings 文件中定义的三个单独的日志。这将创建具有一个属性的类,即一系列 Serilog 配置
public class SerilogSubLoggerConfigurations
{
public List<SerilogSubLoggerConfiguration> SubLoggers { get; set; }
}
var slcs = configuration.GetSection("Serilog").Get<SerilogSubLoggerConfigurations>();
Run Code Online (Sandbox Code Playgroud)
现在我有了 SubLogger 配置列表,我需要创建记录器并添加所有这些子记录器。每个 SubLogger 都需要自己的
.WriteTo.Logger(logger => logger.Filter.
ByIncludingOnly(lvl => lvl.Level == slc.Level).WriteTo.RollingFile(slc..PathFormat))
Run Code Online (Sandbox Code Playgroud)
Log.Logger 调用中的行,因此我需要迭代 SubLoggers。我的目的是写一个方法来做到这一点。
public static LoggerConfiguration GetLoggerConfiguration(IConfiguration config, SerilogSubLoggerConfigurations slcs)
{
var lc = new LoggerConfiguration();
lc.ReadFrom.Configuration(config);
foreach (var cfg in slcs.SubLoggers) …Run Code Online (Sandbox Code Playgroud) 我的 GitHub 扩展无法像在 VS2017 中那样运行。我无法将我的新应用发布到 GitHub。事实上,当我通过扩展输入我的凭据登录 GitHub 时,它仍然显示离线。
我正在尝试卸载扩展程序,以便我可以重新安装它并查看它是否在我升级到 VS 2019 ver 16.3 后自行修复
卸载失败,日志文件很大,不知道从哪里开始。还有人遇到这个问题吗?
示例日志
9/25/2019 10:47:58 AM - Microsoft VSIX Installer
9/25/2019 10:47:58 AM - -------------------------------------------
9/25/2019 10:47:58 AM - vsixinstaller.exe version:
9/25/2019 10:47:58 AM - 16.3.2099
9/25/2019 10:47:58 AM - -------------------------------------------
9/25/2019 10:47:58 AM - Command line parameters:
9/25/2019 10:47:58 AM - C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\vsixinstaller.exe,/appidinstallpath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe,/skuName:Pro,/skuVersion:16.3.29318.209,/appidname:Microsoft Visual Studio Professional 2019,/culture:en-US,/noep,/u:c3d3dc68-c977-411f-b3e8-03b0dccf7dfc,/callingprocessid:27568,/installas:3432
9/25/2019 10:47:58 AM - -------------------------------------------
9/25/2019 10:47:58 AM - Microsoft VSIX Installer …Run Code Online (Sandbox Code Playgroud) 我对MVC开始从网络表单迁移有点新,所以请耐心等待.
我有一个性别定义为的单选按钮组;
<div class="form-group">
@Html.LabelFor(m => m.Gender, new { @class = "col-xs-3 control-label" })
<div class="col-xs-5">
<div class="radio">
<label>
@Html.RadioButtonFor(m => m.Gender, new { @class = "form-control", value= Gender.Male})<span>Male</span>
@*<input type="radio" name="gender" value="male"/> Male*@
</label>
</div>
<div class="radio">
<label>
@Html.RadioButtonFor(m => m.Gender, new { @class = "form-control", value = Gender.Female }) <span>Female</span >
@*<input type="radio" name="gender" value="female"/> Female*@
</label>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Gender是另一个项目中定义的枚举,但viewmodel类使用该枚举.
[Required]
[Display(Name = "Gender")]
public DomainClasses.Enums.Gender Gender { get; set; }
Run Code Online (Sandbox Code Playgroud)
无论我似乎试图做到这一点,我得到以下验证错误.
值'{class = form-control,value = Male}'对于Gender不起作用. …
c# ×5
logging ×2
serilog ×2
asp.net-core ×1
asp.net-mvc ×1
charts ×1
coreclr ×1
dictionary ×1
excel ×1
excel-vba ×1
github ×1
javascript ×1
jquery ×1
json ×1
linq ×1
radio-button ×1
regex ×1
vb.net ×1
vba ×1