我正在尝试获取唯一的用户名及其总时间,但不知道如何实现。我已经做过的是一组唯一的名称,但是不知道如何获取总和。我认为这应该通过使用像ex的字典这样的结构来实现。
Dictionary<string,int>但是这种结构似乎在打字稿中不存在。
let json = [{"User":"Tom Smith","Hours": 6},{"User":"Mark Zuckerberg","Hours": 8},{"User":"Elon Musk","Hours": 12},{"User":"Tom Smith","Hours": 1},{"User":"Tom Smith","Hours": 1}];
for(var i = 0; i < json.length; i++)
{
if(!userNames.find(a => a == json[i].User))
{
userNames.push(json[i].User);
}
}
Run Code Online (Sandbox Code Playgroud)
结果应为:
我将从机器人向 Microsoft Teams 发送一条主动消息,其中包含用户可以采取的 2 项建议操作。但在 Microsoft Teams 中,消息显示如下:
请注意,该消息未显示任何建议消息!在 Bot Framework Emulator 中,相同的消息如下所示:
Teams 或我的代码有什么问题?
下面是我验证、生成和发送消息的代码:
private async Task BotCallback(ITurnContext turnContext, CancellationToken cancellationToken)
{
string serviceUrl = turnContext.Activity.RelatesTo.ServiceUrl;
ConnectorClient Connector = new ConnectorClient(
new Uri(serviceUrl),
microsoftAppId: "[MicrosoftAppId]",
microsoftAppPassword: "[MicrosoftAppPassword]"
);
AppCredentials.TrustServiceUrl(serviceUrl);
ChannelAccount from = turnContext.Activity.From;
IMessageActivity activity = MessageFactory.SuggestedActions(
new string[] { "First action", "Second action" },
$"Hi {userName},\r\nYou've missed some lorem ipsum dolor sit amet:\r\n- **consectetur:** Ut porttitor\r\nChoose an action from below to add them."
);
await Connector.Conversations.SendToConversationAsync( …Run Code Online (Sandbox Code Playgroud) 我已经为 .NET Framework 项目创建了一个构建管道。当管道由拉取请求触发时,我在任务中遇到以下错误:“NuGet 恢复”
##[错误]nuget 命令失败,退出代码(1) 和错误(解析解决方案文件时出错
d:\a\1\s\***.sln:调用目标已引发异常。无法加载项目文件。无法加载文件或程序集Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a或其依赖项之一。系统找不到指定的文件。d:\a\1\s\***.sln)##[error]包恢复失败
当我尝试在与目标分支合并后在本地计算机上编译解决方案时,没有任何冲突或错误。
这是我的 YML 文件:
pool:
name: Hosted Windows 2019 with VS2019
demands:
- msbuild
- visualstudio
- vstest
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2 # --> This task fails.
displayName: 'NuGet restore'
inputs:
restoreSolution: '***.sln'
- task: VSBuild@1
displayName: 'Build solution'
inputs:
solution: '***.sln'
platform: 'any cpu'
configuration: 'release'
- task: PublishSymbols@2
displayName: 'Publish …Run Code Online (Sandbox Code Playgroud) 我正在使用 .NET Framework 开发 Azure webjob,但是当我在本地运行时,启动后出现此异常。
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException:函数的侦听器[Name of function]无法启动。内部异常:
ArgumentNullException: 值不能为空。
参数名称:connectionString
这是ProgramWeb 作业类中的代码。
static void Main()
{
HostBuilder builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddTimers();
});
using (IHost host = builder.Build())
{
host.Run(); // <-- error happens on this line
}
}
Run Code Online (Sandbox Code Playgroud)
在里面App.config我添加了接下来的两个连接字符串:
<add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=[Name];AccountKey=[Key]" />
<add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=https;AccountName=[Name];AccountKey=[Key]" />
Run Code Online (Sandbox Code Playgroud)
使用[Name]和[Key]作为来自实时环境的帐户名称 en 键。
此外,当我将连接字符串更改为 时UseDevelopmentStorage=true,我也遇到了相同的异常。
我怎么能解决这个问题?
单击按钮后,我会检查我的文本字段是否不为空。我的支票有效,但如果我显示我的消息,它会显示几秒钟。可能是我点击按钮的持续时间。这是我尝试过的一些代码。
<form>
<div id="errorblock">
<p id="errortext">Error.</p>
</div>
<!-- here are my input fields-->
<button>Send</button>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我在页面初始化后添加事件侦听器的地方:
document.getElementsByTagName("button")[0].addEventListener("click", function(){
sendEmail();
});
function sendEmail() {
//check if all fields are fill in. If not do this code;
document.getElementById("errortext").innerHTML = "Fill in all the fields please.";
var errorblock = document.getElementById("errorblock");
errorblock.style.visibility = "visible";
errorblock.style.height = "46px";
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我?谢谢
是否有可能在Visual Studio 2013中为Windows 10创建Windows通用应用程序?我应该安装某种SDK,之后一切都会好的,或者我必须使用VS2015?
如何将字节数组转换为DateTime? 我必须这样做,因为我为实体框架使用了一个带有属性的属性(命名CreationDataStamp)Timestamp。第二个属性(命名CreationDate),我使用的转换字节数组DateTime。
[System.ComponentModel.DataAnnotations.Timestamp]
public byte[] CreationDateStamp { get; set; }
[System.ComponentModel.DataAnnotations.Schema.NotMapped]
public DateTime CreationDate
{
get
{
return Convert.ToDateTime(CreationDateStamp);
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,我已经9于此异常日线:
无法将类型的对象强制转换
System.Byte[]为类型System.IConvertible。
更新:
我也从这个问题中尝试过:How to convert a byte[] into datetime in C#?
long longVar = BitConverter.ToInt64(CreationDateStamp, 0);
DateTime dateTimeVar = new DateTime(1980,1,1).AddMilliseconds(longVar);
Run Code Online (Sandbox Code Playgroud)
但我有这个例外:
要添加的值超出范围。
参数名称:值
你能帮助我吗?
我建立了一个网站,它必须与服务器进行实时通信。实时是指如果用户对某个主题进行投票,则所有连接的客户端都必须看到新的投票平均值。
我已经尝试了一些方法,但是遇到了一个问题:如何创建一个套接字服务器和一个HTTP服务器,以使用Node.JS侦听同一端口?我在下面运行代码,但有这个异常:
错误:听
EADDRINUSE
这是我的服务器代码:
let port = 8080;
const httpServer = require('http'),
app = require('express')(),
socketServer = http.Server(app),
io = require('socket.io')(httpServer);
httpServer.createServer(function (req, res) {
console.log('http server created on 8080');
}).listen(port);
socketServer.listen(port, function(){
console.log('listening on 8080');
});
Run Code Online (Sandbox Code Playgroud)
提前致谢
我有一个包含多个字段的 SharePoint 列表。我使用 JavaScript 通过执行以下操作来发布到列表:
$.ajax({
url: "https://my.domain.com/sites/mysite/_api/web/lists/getbytitle('listname')/items",
type: "POST",
contentType: "application/json;odata=verbose",
data: data,//Example WORKING JSON{ '__metadata': { 'type': 'SP.Data.TestListItem' }, 'title': 'Test' },
headers: {
"Accept": "application/json;odata=verbose",
"Authorization": "Bearer " + token
},
success: function (data) {
console.log("Success");
},
error: function (data) {
console.log("Failure");
}
});
Run Code Online (Sandbox Code Playgroud)
这效果非常好。问题是,当我使用 Postman 时,我的字段之一如下所示:
<d:Sst_Country_mc m:type="Collection(Edm.String)">
<d:element>Netherlands</d:element>
</d:Sst_Country_mc>
Run Code Online (Sandbox Code Playgroud)
所以我想我的 Json 会是这样的:
{
"__metadata": {
"type": "SP.Data.SST_x0020_Requests_x0020_StagingListItem"
},
"Title": "Andrew Test 4",
"Sst_Customer_Name_st": "Customer",
"Sst_Business_Category_sc": "Finance and Insurance",
"Sst_Country_mc": {
"element": "Spain"
},
"Sst_Actual_Request_mt": "", …Run Code Online (Sandbox Code Playgroud) 尝试使用 HTML 表单制作 Google 图像搜索克隆,在搜索字段中输入文本后,它将直接带您进入 Google 图像搜索结果页面。
这是我正在使用的代码:
<body>
<form action="https://google.com/search">
<input type="text" name="q">
<input type="submit" value="Google Search">
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
这将需要正常的谷歌搜索,如何将其更改为谷歌图片搜索结果页面?
c# ×3
javascript ×3
html ×2
.net ×1
angular ×1
azure ×1
botframework ×1
button ×1
buttonclick ×1
httpserver ×1
json ×1
node.js ×1
nuget ×1
sharepoint ×1
socket.io ×1
sockets ×1
sql-server ×1
typescript ×1
windows-10 ×1