C# 如何使用.net core 3.1 Signal用于存储过程
我想使用signer作为存储过程。我想运行实时存储过程 页面需要刷新。但是我不知道在哪里运行我的存储过程。C# 如何使用.net core 3.1 Signal用于存储过程,c#,stored-procedures,.net-core,signalr,C#,Stored Procedures,.net Core,Signalr,我想使用signer作为存储过程。我想运行实时存储过程 页面需要刷新。但是我不知道在哪里运行我的存储过程。 如果你能帮忙,我会很高兴的。这对我来说很重要。我的是使用EFCore的信号机。您只需在testsignal()函数中运行存储过程 Startup.cs 添加services.AddSignalR()和app.UseSignalR() YourPage.cshtml 是的,这对我有用。但我在转换数据时出错了。因为 模型未定义。JSON序列化它解决了我的问题 public async Task
如果你能帮忙,我会很高兴的。这对我来说很重要。我的是使用EFCore的信号机。您只需在testsignal()函数中运行存储过程 Startup.cs 添加services.AddSignalR()和app.UseSignalR() YourPage.cshtml
是的,这对我有用。但我在转换数据时出错了。因为 模型未定义。JSON序列化它解决了我的问题
public async Task UpdateCustomerList(){branch_id=Convert.ToInt32(_httpContextAccessor.HttpContext.User.FindFirstValue(“branch_id”);if(branch_id!=0){customerViewModelsList=_.customers.GetLiveCustomers(sube_id)}返回JsonConvert.serialized对象(customerViewModelsList)}
存储过程正在数据库服务器中运行。我不理解与Signal R的关系。过程代码是高度特定于供应商的-因此请添加一个标记,以指定您是否正在使用mysql
,postgresql
,sql server
,oracle
或db2
-或其他完全不同的东西。@DA他的意思是,当存储过程也在live上执行时,他希望网站在live上运行。
public void ConfigureServices(IServiceCollection services)
{
services.AddSignalR();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSignalR(routes =>
{
routes.MapHub<YourSignalHub>("/yoursignalhub");
});
}
public class YourSignalHub : Hub
{
public async Task SendWhatever()
{
await Clients.All.SendAsync("GetSomething");
}
}
<a id="btnSend">Send</a>
<span id="spanLiveMessage"></span>
<script>
var connection = new signalR.HubConnectionBuilder().withUrl("/yoursignalhub").build();
connection.on("GetSomething", function () {
$.post('@Url.Action("TestSignalR", "Home")', null, function (e) {
$("#spanLiveMessage").text("test");
// or your code
});
});
$("#btnSend").click(function () {
connection.invoke("SendWhatever").catch(function (err) {
return console.error(err.toString());
});
});
</script>
[HttpPost]
public IActionResult TestSignalR()
{
// your code to execute stored procedure here
}