我是WPF应用程序的新手,我试着四处寻找能否找到适用于此的东西,但到目前为止我找不到任何工作(我想这是因为它的大部分已经过时).我想截取整个桌面(即所有显示器)的屏幕截图,并将其保存为.jpg特定文件夹,当我单击屏幕截图按钮时,时间和日期作为文件名.我能够在我的Windows窗体应用程序中实现这一点,但是我的WPF应用程序无法实现这一点.
这是我用于Windows窗体应用程序的代码.
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
using (Bitmap bmp = new Bitmap(screenWidth, screenHeight))
{
using (Graphics g = Graphics.FromImage(bmp))
{
String filename = "ScreenCapture-" + DateTime.Now.ToString("ddMMyyyy-hhmmss") + ".png";
Opacity = .0;
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size);
bmp.Save("C:\\ScreenShots\\" + filename);
Opacity = 1;
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
这是我的情况。
我正在使用 EPiServer 9 并且我已经配置了一个 SqlServerMembershipProvider 如下:
<add name="SqlServerMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
connectionStringName="EPiServerXYZ"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
applicationName="/"
passwordStrengthRegularExpression="^.*(?=.{8,})(?=.*\d)(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[^\w\d\s]).*$" />
Run Code Online (Sandbox Code Playgroud)
一切正常,验证和不同的场景。
我们的问题是会员提供者显示的错误消息是通过使用配置创建的,它最终给出了用户不友好的消息,例如:
我很想设置一个自定义错误消息,它真正向用户解释了我们在用于验证密码的正则表达式中的所有要求。
到目前为止,我可以考虑这样做的唯一方法是实现/扩展我们正在使用的当前提供程序,以便在验证出现问题时设置自定义错误消息,但我想可能有另一种更好/更简单的方法来做到这一点.
提前致谢!
我们有一个更新程序,可以自动将 WebDeploy 包发布到 IIS 服务器。该程序适用于 MVC 5 - 应用程序,但不适用于 .Net Core 应用程序。我们使用 Microsoft.Web.Deployment - API,我的发布方法如下所示:
private void UpdateIIS(DTOs.ApplicationConfiguration.ApplicationServer applicationServer, DTOs.Update.Update update) {
// SSL-Zertifikatsfehler ignorieren
System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(
(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => { return true; });
var sourceBaseOptions = new DeploymentBaseOptions();
var destBaseOptions = new DeploymentBaseOptions() {
ComputerName = string.Format("https://{0}:{1}/msdeploy.axd?site={2}", applicationServer.Adresse, applicationServer.MSDeployPort, applicationServer.SiteName),
UserName = applicationServer.User,
Password = applicationServer.Passwort,
AuthenticationType = "Basic"
};
string updatePackage = Directory.GetFiles(update.UpdateDirectory, "*.zip").FirstOrDefault();
if (!File.Exists(updatePackage)) {
throw new Exception("Update-Paketdatei …Run Code Online (Sandbox Code Playgroud) 我创建了免费的 Azure 订阅,并自今年(2020 年)四月左右以来一直在那里托管几个应用程序。我所有的资源;订阅、资源组、AppService 和应用程序是 F1 服务而不是 S1,以确保它们免费运行,并且我对当月的成本预测应始终为 0.0 美元。一开始这让我很困惑,我不得不联系微软来帮助我建立我的资源等级制度。在我的主 Web 应用程序中,我现在需要部署 SQL 数据库。我一直在我的 ASP.Net Core 3.1 应用程序中使用 LocalDB 进行开发。
现在免费 Azure 描述如下: https: //azure.microsoft.com/en-us/free/
提供了第一年免费订阅的 SQL Server 的这些规格:
250GB。现在我考虑的是 250GB 存储空间,而不是内存。但是当您开始选择数据库配置时,它们正在谈论内存。所以现在我对此感到困惑。通过免费的 Azure 订阅,您可以获得 250GB 的存储空间或内存吗?
另外,免费服务实际上只是说免费 SQL 数据库。不是免费的 SQL Server。所以我在这里也很困惑。您只获得一个数据库吗?我知道您必须设置 SQL Server 才能设置数据库。
接下来我找到了一个关于创建 SQL Server 数据库的快速教程: https: //learn.microsoft.com/en-us/azure/azure-sql/database/single-database-create-quickstart ?tabs=azure-portal
我想浏览本教程的三个版本: 使用:
这样我就可以感受环境并找到最适合我的方式。
我将首先浏览 Portal 教程。在步骤 9 中,默认值为通用、无服务器。这表示“最多 40 个 vCore,最多 120 GB 内存”。但免费订阅后你应该有 250GB 的空间。所以这不是它。我单击“配置”,现在它显示“最多 80 个 vCore,最多 408 GB 内存”。好吧,408GB 太多了;超过250GB。
所以我点击“寻找基本版、标准版还是高级版?” 然后从那里单击“标准”,因为我想我正在寻找 …
我正在尝试使用 nginx 创建一个简单的静态网络,并且希望拥有由 Dockerfile 创建的所有内容,问题是每当我尝试创建一个 index.html 文件时,它都会出现错误,我什至尝试测试它及其使用“index.htm”但格式不正确。
FROM centos:7
#update and install nginx section
RUN yum update -y
RUN yum install -y epel-release
RUN yum install -y nginx
#create path and add index.html
WORKDIR /usr/share/nginx/html
#this one working with no issue
RUN touch index.htm
#this one will get failed
RUN touch index.html
EXPOSE 80/tcp
CMD ["nginx", "-g", "daemon off;"]
Run Code Online (Sandbox Code Playgroud)
这是错误输出:
majid@DESKTOP-39CBKO0:~/nginx_simple_web$ docker build -t simple-web:v1 .
[+] Building 3.8s (11/11) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> …Run Code Online (Sandbox Code Playgroud) 我需要维护某些文档的历史记录,我最初的解决方案是将它们从.NET复制到共享文件夹,但这对我来说似乎不太安全。我可以使用 .NET 和 C# 将这些文件上传到 One Drive 吗?如果是这样,我想要有关它的文档,我已经进行了免费搜索,但没有找到任何可以满足我的需求的内容。如果问题太模糊,我深表歉意。谢谢。
Swagger UI 具有displayRequestDuration参数来显示请求需要多长时间。默认情况下它是禁用的。
使用Swashbuckle(非核心版本)时,如何在 SwaggerConfig.cs 配置中启用此功能?
我看到这在 Java 版本中是可能的。
我正在尝试通过 Azure DevOps 构建一个 dotnet 核心应用程序。我希望我的程序集使用内部版本号进行版本控制。
在 .csproj 文件中:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<Version>0.0.1</Version>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
yaml 构建管道包含:
trigger:
branches:
include:
- master
pool:
name: 'Hosted Windows 2019 with VS2019'
#vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
Version.Revision: $[counter(format('{0:yyyyMMdd}', pipeline.startTime), 0)]
VersionMajor: 0
VersionMinor: 1
name: '$(VersionMajor).$(VersionMinor).$(Date:yy)$(DayOfYear).$(Version.Revision)'
steps:
- task: DotNetCoreInstaller@0
inputs:
version: '2.2.300'
- script: dotnet build --configuration Release /p:Version=$(Build.BuildNumber)
displayName: 'dotnet build $(buildConfiguration) $(Build.BuildNumber)'
Run Code Online (Sandbox Code Playgroud)
在 Azure Devops 构建日志中,该命令似乎选择了正确的版本:
dotnet build --configuration Release /p:Version=0.1.19185.10
Run Code Online (Sandbox Code Playgroud)
但是当我下载工件并验证 dll 时,它们仍然包含版本号 0.0.1
在本地执行此命令会在 dll 中添加版本号。那么,为什么不通过 Azure DevOps …
当我在MS Teams(```)中输入markdown格式时,如何在字符串中创建换行符?当人类以降价格式输入内容时,按Enter键将换行。当我送一个字符串<br>,\n或\r\n在文字连接器,它不会创建一个换行符。我发现我可以对markdown进行转义,输入a <br>,然后再次输入markdown,但是它重新格式化每行以删除空格。
那么如何创建换行符并保持间距呢?
如果这很重要,我正在使用pymsteams连接器。
编辑:添加代码示例
import pymsteams
msg = pymsteams.connectorcard('...')
txt = '``` some text \n second line ```'
msg.text(txt)
msg.send()
Run Code Online (Sandbox Code Playgroud)
我也尝试过txt = '``` some text \r\n second line ```'和txt = '``` some text <br> second line ```',但是3个选项都没有在“某些文本”和“第二行”之间插入换行符。
我正在使用 .NET Core 5.0。我在 appsettings.json 文件中有以下部分。
"Policies": [
{
"name": "ApproverPolicy",
"description": "ApproverPolicy",
"rules": [
{
"name": "abc@gmail.com",
"description": "abc@gmail.com"
},
{
"name": "def@gmail.com",
"description": "def@gmail.com"
}
]
},
{
"name": "RegionPolicy",
"description": "RegionPolicy",
"rules": [
{
"name": "East US",
"description": "East US"
},
{
"name": "North Europe",
"description": "North Europe"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
我定义了以下 C# 类。
public class Policy : PolicyDefinition
{
public IList<Rule> Rules { get; set; }
}
public class PolicyDefinition
{
public string Name { …Run Code Online (Sandbox Code Playgroud) c# ×4
.net ×2
.net-core ×2
asp.net-core ×2
asp.net ×1
azure ×1
azure-devops ×1
centos7 ×1
docker ×1
dockerfile ×1
episerver ×1
html ×1
iis ×1
markdown ×1
msdeploy ×1
security ×1
swagger-ui ×1
swashbuckle ×1
versioning ×1
webdeploy ×1
wpf ×1