我使用 dotnet worker 服务(.net 5),我集成了 serilog 以及丰富器和接收器。但由于某种原因,我在文件日志中看不到任何输出。
这是我的 appsettings.json
{
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=eeee;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"WorkerOptions": {
"Batch": 5
},
"Serilog": {
"Using": [],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "E:\\Logs\\log_.txt",
"outputTemplate": "{Timestamp:o} {Message}{NewLine:1}{Exception:1}",
"rollingInterval": "Day",
"retainedFileCountLimit": 7
}
},
{
"Name": "File",
"Args": {
"path": "E:\\Logs\\log_.json",
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog",
"outputTemplate": "{Timestamp:o} {Message}{NewLine:1}{Exception:1}",
"rollingInterval": "Day", …Run Code Online (Sandbox Code Playgroud) c# backgroundworker serilog asp.net-core asp.net-core-webapi
我已经设法找到并编辑每个单词文件。有了这个代码:
$objWord = New-Object -comobject Word.Application
$objWord.Visible = $false
$objDoc = $objWord.Documents.Open("C:\users\stefan\test\New Microsoft Word Document.docx")
$objSelection = $objWord.Selection
$FindText = "that"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "this"
$wdFindContinue = 1
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith)
$objDoc.Save()
$objWord.Quit()
Run Code Online (Sandbox Code Playgroud)
但我想对整个文件夹执行此操作。我尝试插入这样的内容:
$objWord = New-Object -comobject Word.Application
$objWord.Visible = $false
$list = Get-ChildItem "c:\users\stefan\test\*.*" -Include *.doc*
foreach($item in $list){ …Run Code Online (Sandbox Code Playgroud) 我不知道这段代码哪里错了。
If Dir(FILE_PATH & personList(i, 1) & FILE_EXT) <> "" Then
.SaveAs2 FILE_PATH & "1" & personList(i, 1) & FILE_EXT
.Close
Else
.SaveAs2 FILE_PATH & personList(i, 1) & FILE_EXT
.Close
End If
Run Code Online (Sandbox Code Playgroud)
一切正常,但是当我在列中遇到相同的值(例如:John Doe、John Doe)时,程序会覆盖第一个 John Doe 文件。
在我的 Page1 后面的代码中,我有:
{
//do not select item
((ListView)sender).SelectedItem = null;
//go to stockDetailsPage
await Shell.Current.GoToAsync("postlogin/stockdetails?tickerSymbol=AAPL.NASDAQ");
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我对值进行了硬编码以对其进行测试。
早些时候它没有 param ,它可以工作,现在我需要传递 param tickerSymbol。在我的 ViewModel 的 stockDetailsPage 中,我添加了
[QueryProperty("TickerSymbol", "tickerSymbol")] 高于我的班级
在我的班级中,我声明了属性:
public string TickerSymbol
{
set { SetProperty(ref tickerSymbol, Uri.UnescapeDataString(value)); }
get { return tickerSymbol; }
}
Run Code Online (Sandbox Code Playgroud)
因此,在该 vm 的构造函数中,我现在想使用该参数的输入参数调用方法,但我null一直在获取。
你能告诉我我错在哪里吗?
我有 3 个属性(为了简单起见,有 3 个变量) 方法FillOrNotFill说明了 strings a, b,c可以为空,也可以不为空或 null。
我需要验证一种情况,即只有一个字符串必须不为空且不为 null,而其他字符串必须为空或 null 。
我可以用多个条件来做到这一点(比如在那些多个 if 中),但我正在寻找一些更优雅的解决方案。
string x = "someValue"
string a = FillOrNotFill(x);
string b = FillOrNotFill(x);
string c = FillOrNotFill(x);
//sample of multiple if's
if((!string.IsNullOrWhiteSpace(payload.a) && string.IsNullOrWhiteSpace(payload.b) && string.IsNullOrWhiteSpace(payload.c))
|| (!string.IsNullOrWhiteSpace(payload.b) && string.IsNullOrWhiteSpace(payload.a) && string.IsNullOrWhiteSpace(payload.c)
|| (!string.IsNullOrWhiteSpace(payload.c) && string.IsNullOrWhiteSpace(payload.b) && string.IsNullOrWhiteSpace(payload.a)
)))
{
//valid!
}
Run Code Online (Sandbox Code Playgroud) 如何在 Visual Studio 2022 中为构建程序添加 Docker 选项?
例如,当我创建一个新解决方案并检查 Docker 时,我可以选择:
但是在我之前没有使用 Docker 并创建了一些解决方案中dockerfile,我的解决方案没有选项 Docker?
我应该在.csproj文件中添加一些东西吗?
我也在看这篇文章,但在 VS 2022 的项目选项卡中找不到 Docker 支持
我想动态地将两个页面 (ShellContents) 添加到我的 LoginShell 中,但LoginShell.Current始终为空?
{
public LoginShell(string page = null)
{
InitializeComponent();
ShellItem si = new ShellItem();
LoginShell.Current.Items.FirstOrDefault().Items.Add(new ShellContent {ContentTemplate = new DataTemplate(typeof(SignUpPage))});
}
}
Run Code Online (Sandbox Code Playgroud)
LoginShell.Current 是只读属性。
更新
我为 StartUpShell 类实现了以下代码:
public partial class StartUpShell : Shell
{
public StartUpShell(string page)
{
InitializeComponent();
ShellContent content;
if(page == nameof(SignUpPage))
{
content = new SignUpPage();
}
else if(page == nameof(LoginPinPage))
{
content = new LoginPinPage();
}
else
{
content = new SignUpPage();
}
ShellSection shellSection = new ShellSection();
shellSection.Items.Add(new …Run Code Online (Sandbox Code Playgroud) 我有一个 json 文件的示例 https://pastebin.com/wL6LWbxk
{
"rates": [{
"code": "ATS",
"date": "2021-03-05",
"date_from": "2021-03-05",
"number": 40,
"parity": 1,
"exchange_middle": 8.5448
}
]
}
Run Code Online (Sandbox Code Playgroud)
我有以下代码:
...
var responseStream = await response.Content.ReadAsStreamAsync(); //Im getting bytes OK
var something = await JsonSerializer.DeserializeAsync<Curr>(responseStream); //object something is null
...
Run Code Online (Sandbox Code Playgroud)
我的模型看起来像:
public class Currency
{
[JsonProperty("code")]
public string Code { get; set; }
[JsonProperty("date")]
public DateTimeOffset Date { get; set; }
[JsonProperty("date_from")]
public DateTimeOffset DateFrom { get; set; }
[JsonProperty("number")]
public long Number { get; set; } …Run Code Online (Sandbox Code Playgroud)