我有一个 Asp.Net Core Api 3.1 和一个 Azure WebJob,两者都在 Azure 应用服务上运行。他们都需要发送通知,但都不会接收消息。分解它:
我在云中拥有每个应用程序都指向的 Azure SignalR 服务的单个实例。
我创建的 Hub 类位于 Api 和 WebJob 项目都引用的库中。
客户端只能通过 Api 连接到 Hub。
当 Api 向连接发送消息时一切正常,但 WebJob 却不然。
我真的不想将 WebJob 作为客户端运行,因为那样我就必须处理身份验证。我只是希望它作为同一集线器的另一个实例运行,该集线器将消息发送到与 API 相同的组。此外,此 WebJob 不适合作为 Azure 函数运行,因为它需要很长时间。
我在配置 WebJob 的方式中遗漏了一些内容,因为它似乎没有连接到 Azure SignalR。
当 WebJob 尝试发送消息时,我收到以下错误:(我尚未发布到 Azure,因此这一切都发生在我的本地计算机上)
Microsoft.Azure.SignalR.ServiceLifetimeManager[100] 无法发送消息(空)。Microsoft.Azure.SignalR.Common.AzureSignalRNotConnectedException:Azure SignalR 服务尚未连接,请稍后重试。在 Microsoft.Azure.SignalR.ServiceConnectionManager 1.WriteAsync(ServiceMessage serviceMessage) at Microsoft.Azure.SignalR.ServiceLifetimeManagerBase1.<>c__DisplayClass22_0 1.<WriteAsync>b__0(T m) at Microsoft.Azure.SignalR.ServiceLifetimeManagerBase1.WriteCoreAsync[T](T 消息,Func`2 任务)
网络工作主要:
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MyProject.Data; …Run Code Online (Sandbox Code Playgroud) azure azure-webjobs azure-webjobs-triggered asp.net-core-signalr azure-signalr
我是Fluent Validation的新手,刚刚从nu Get 获得了5.3版本.我正在尝试将现有验证器(PhoneValidator)应用于类(Employee)的集合属性(ICollection).Fluent Validator文档说要使用:
RuleFor(x => x.Orders).SetCollectionValidator(new OrderValidator()); // example usage
Run Code Online (Sandbox Code Playgroud)
但是,我的版本上没有SetCollectionValidator()方法.相反,只有SetValidator()被标记为[已弃用].我已经看到有关同样情况的其他帖子,并了解到SetCollectionValidator()是一个扩展方法,需要确保我已导入FluentValidation.我做.
我在这里错过了什么?
using FluentValidation;
using FluentValidation.Validators;
public class EmployeeValidator : AbstractValidator<Employee>
{
public EmployeeValidator()
{
// SetCollectionValidator doesn't show in intellisense and won't compile
RuleFor(e => e.PhoneNumbers).SetCollectionValidator(new PhoneValidator());
}
}
public class PhoneValidator : AbstractValidator<Phone>
{
public PhoneValidator()
{
RuleFor(e => e.Number).Length(10).Matches("^[0-9]$");
}
}
Run Code Online (Sandbox Code Playgroud) 我在尝试以递归方式遍历层次结构以查找可能具有多个顶级节点的组织结构中的所有后代节点的顶级节点时遇到问题.我试图使用SQL Server 2012 CTE这样做,但它不会递归到达每个分支的最顶级节点.我已经尝试过完全按照与此相关的其他帖子中显示我的查询,但仍然没有骰子.(至少我想我是.)我希望有人可以告诉我这里我做错了什么?这篇文章与我正在尝试做的事情密切相关,我已经按照接受的答案,但我仍然只是"得到它":在SQL中找到顶级父级

如上所示,我有OrgGroups引用直接父组,除非它是顶级然后它是NULL.例如,(4)财务(顶级) - >(5)人力资源 - >(11)福利
我想创建一个数据库视图,列出每个OrgGroup以及他们的TOP-MOST祖先的ID.(不是他们的直接父母)
因此,例如,DB View将拥有(11)Benefits OrgGroup的记录,以及(4)Finance的最顶层parentgroupId的相应列值.
;WITH OrgStructureIndex AS
(
SELECT O.OrgGroupId, O.Name, O.OrgStructureId, O.ParentGroupId, 1 AS Lvl
FROM OrgGroups O
UNION ALL
SELECT OG.OrgGroupId, OG.Name, OG.OrgStructureId, OG.ParentGroupId, Lvl+1 AS Lvl
FROM OrgGroups OG INNER JOIN OrgStructureIndex OI
ON OI.OrgGroupId = OG.ParentGroupId
)
SELECT * FROM OrgStructureIndex
Run Code Online (Sandbox Code Playgroud)
这导致福利组织组具有最高的ParentGroupId(5)HR.期望的结果将是(4)财务.它还会导致重复记录.

至少要删除重复项,我已将SQL更改为:
;WITH OrgStructureIndex AS
(
SELECT O.OrgGroupId, O.Name, O.OrgStructureId, O.ParentGroupId, 1 AS Lvl
FROM OrgGroups O
UNION ALL …Run Code Online (Sandbox Code Playgroud) sql-server recursive-query common-table-expression hierarchical-data