我有一个如下数据列表
Item Vendor Compliance Status
I1 V1 C1 Y
I1 V1 C2 N
I1 V1 C3 Y
I1 V2 C1 Y
I1 V2 C2 Y
I2 V1 C3 Y
Run Code Online (Sandbox Code Playgroud)
如何查询以使其成为
Item Vendor C1 C2 C3
I1 V1 Y N Y
I1 V2 Y Y -
I2 V1 - - Y
Run Code Online (Sandbox Code Playgroud)
虽然合规可能有很多,但没有必要只有C1,C2,C3.
是否可以根据区域设置更改时间格式?
让我们看下面的场景
所以我的最终问题是,如何在asp.net core c#中根据区域设置设置时间?
我已经完成了带有日期的本地化,但我还必须完成时间。
上图显示了上午/下午。同样,我需要以 24 小时格式显示时间段,这是根据区域设置决定的。
我有一个现有的 API,它正在从请求正文中读取数据:
[HttpPost]
public async Task<IActionResult> Post([FromBody] CreateVm vm)
{
if (!ModelState.IsValid) return BadRequest();
var result = await _service.CreateAsync(vm);
return Ok(result);
}
Run Code Online (Sandbox Code Playgroud)
出现了一个新需求,要求客户端希望随视图模型一起提交图像。我的第一个想法是将 an 附加IFormFile到请求,在不同的服务中处理它,然后继续:
public async Task<IActionResult> Post([FromBody] CreateVm vm, IFormFile file) { /* ... */}
Run Code Online (Sandbox Code Playgroud)
这种方法的结果是,我收到状态代码 415“不支持的媒体类型”。
使用邮递员我尝试将 Content-Type 设置为multipart/form-data,但无济于事。
这种方法是否可行,或者我是否需要byte[]向视图模型添加一个属性并从那里解析图像?
我正在尝试使用默认的 Azure DevOps 模板将图像推送到 AKS:
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- upload: manifests
artifact: manifests
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
##[error]Path does not exist: /home/vsts/work/1/s/manifests
Run Code Online (Sandbox Code Playgroud)
我尝试过使用默认的发布任务
- task: PublishPipelineArtifact@1
inputs:
artifactName: 'manifests'
path: 'manifests'
Run Code Online (Sandbox Code Playgroud)
但这并没有改变任何事情。有人可以解释一下,这里发生了什么以及为什么 Msft 的默认模板不起作用?
当我使用 docker 时,我试图集中精力思考如何调试应用程序。我找到了这个文档,它没有产生预期的结果:https ://code.visualstudio.com/docs/containers/docker-compose
我所做的如下:
dotnet new mvcmetricdemo:
image: metricdemo
build:
context: .
dockerfile: Dockerfile
ports:
- 80
- 5000:443
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80;https://+:443
- ASPNETCORE_Kestrel__Certificates__Default__Password=password
- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.dotnet/https/aspnetcore-cert.pfx
volumes:
- C:\cert\:/root/.dotnet/https
- ~/.vsdbg:/remote_debugger:rw
Run Code Online (Sandbox Code Playgroud)
下一步是创建启动配置,以便附加调试器:
{
"name": "Docker .NET Core Attach (Preview)",
"type": "docker",
"request": "attach",
"platform": "netCore",
"netCore": {
"debuggerPath": "/remote_debugger/vsdbg"
},
"sourceFileMap": {
"/src": "${workspaceFolder}"
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了带和不带debuggerPath套件的两种组合。 …
我有个问题.当我从代码后面添加一个事件处理程序到一个按钮时,事件永远不会被触发.但是当我在创建按钮标签时添加它时,它完美地工作,我从后面的代码创建按钮,然后将其添加到表中.
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="show table" OnClick="Button1_OnClick" />
<table border="1">
<thead>
<tr>
</tr>
</thead>
<tbody id="tbody" runat="server">
</tbody>
</table>
</div>
</form>
protected void Button1_OnClick(object sender, EventArgs e)
{
var row = new TableRow();
var btnDownload = new Button { ID = "ID", Text = "Click Here" };
btnDownload.Click += ClickEvent;
var cell = new TableCell();
cell.Controls.Add(btnDownload);
row.Controls.Add(cell);
tbody.Controls.Add(row);
}
protected void ClickEvent(object sender, EventArgs e)
{
Debug.WriteLine(((Button)sender).Text);
}
Run Code Online (Sandbox Code Playgroud) string mystring="the are boys";
string[] tags = {"the"};
string[] replace ={"they"}
mystring.Replace(tags[0],replace[0]) // is not working
mystring.Replace("the","they") // is working
Run Code Online (Sandbox Code Playgroud)
我认为两者都是一样的,但第一个声明不起作用.第二个是.请帮我解决问题.
我有一个单身论坛,其中有一个电话号码字段
代码是:
try
{
cz.SignUp(nametxt.Value, passtxt.Value,
Convert.ToInt32(DropDownList1.SelectedValue),
Convert.ToInt32(DropDownList2.SelectedValue),
Convert.ToInt32(DropDownList3.SelectedValue),
mailtxt.Value,Convert.ToInt32(numbtxt.Value));
//GridView1.DataSource=ca.viewadmin();
Lbe6.Text = ("Signup Success");
}
catch
{
lbe5.Text = ("FAILED");
}
Run Code Online (Sandbox Code Playgroud)
但是,当我点击提交按钮时,它会显示错误.对于Int32,值太大或太小.
我也尝试过uint和int64,但它没有用
我想在我的代码中使用c#更改FontStyle和FontWeight.
我试过这个:
textblock.FontStyle =FontStyle.Normal
Run Code Online (Sandbox Code Playgroud)
和
textblock.FontWeight =FontWeight.Bold
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
获取以下有效的 json:
{
"universe": {
"solar system": "sun"
}
}
Run Code Online (Sandbox Code Playgroud)
这是简单的 C# 代码:
using Newtonsoft.Json;
JToken x = JToken.Parse("{\"universe\": {\"solar system\": \"sun\"}}");
string s = x.First.First.First.Path;
Run Code Online (Sandbox Code Playgroud)
在此刻s = "universe['solar system']"
然而我期待着"universe.['solar system']"(注意“宇宙”后面的“.”)。
如果 json 键没有空格(“solar_system”),我得到的"universe.solar_system"结果是正确的。
问题是:这是 json.net 中的错误还是我需要做其他事情来支持 json 键中的空格?
谢谢,
PT
c# ×6
asp.net-core ×3
asp.net ×2
docker ×2
azure-devops ×1
buttonclick ×1
code-behind ×1
events ×1
json ×1
json.net ×1
kubernetes ×1
linq ×1
replace ×1
xaml ×1
yaml ×1