我试图在我们的ASP.NET MVC网站上制作类似facebook的通知系统
在一个场景中,通知系统的工作方式如下
NotificationItem到NotificationManagervia API请求.POST api/notifications/send
NotificationManager 然后处理此notificationItem,然后将其保存到Azure表存储Run Code Online (Sandbox Code Playgroud)class NotificationManager { void SaveNotification(NotificationItem item) { // save it to azure table storage } }
保存项目后,客户端(User2)然后通过NotificationHub(SignalR集线器)订阅notificationEvent
NotificationHub然后通知User2以及处理过的通知数据.
Run Code Online (Sandbox Code Playgroud)class NotificationHub: Hub { async Task NotifyUser(string recipientId) { // query data from storage and then process it var notificationData= await _repo.GetProcessedNotificationDataAsync(recipientId); Clients.Group(recipientId).notifyUser(notificationData); } }
我试图在这个图像上说明CURRENT过程和架构

现在,困扰我的是第5步中的这行代码
var notificationData= await _repo.GetProcessedNotificationDataAsync(recipientId);
Run Code Online (Sandbox Code Playgroud)
它背后的作用是查询notificationItem存储,将其处理为用户可读通知(例如"User1现在跟随你"),然后更新notificationItem后面的(IsSent,DateSent)状态.
不用说,它以某种方式执行"重"操作.而且它会实时每次有交付或广播给每个用户一个新的NotificationItem时间被触发.
显然,我在这里谈论性能和可伸缩性问题.所以我研究了一些可以解决这个问题的技术或方法.并且似乎使用Azure Service Bus背板方法是一个可行的选择
asp.net azure signalr azureservicebus azure-servicebus-queues
在javascript中,转换此字符串的最简单方法是什么
798205486e954fa880a0b366e6725f71
Run Code Online (Sandbox Code Playgroud)
像这样的GUID格式
79820548-6e95-4fa8-80a0-b366e6725f71
Run Code Online (Sandbox Code Playgroud)
这是我这样做的凌乱方式:)我正在寻找最干净的方式
var employeeId = shift.employee.id.substring(0, 8) + "-" + shift.employee.id.substring(8, 12)
+ "-" + shift.employee.id.substring(12, 16) + "-" + shift.employee.id.substring(16, 20) + "-" + shift.employee.id.substring(20, 32);
Run Code Online (Sandbox Code Playgroud) 我有一个dynamic有财产的实体
public partial class Meeting //partial class of POCO EF object
{
public dynamic UiPermissions { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我的web api中,我有一个实现OData查询的服务方法
[Queryable(MaxExpansionDepth = 5)]
[HttpGet("users/{id}/meetings")]
public IEnumerable<Meeting> GetUserMeetings(int id)
{
var meetings = _meetingRepository.GetUserMeetings(id);
// populate dynamic UiPermission
meetings.SetMeetingPermission(_permissionRepository, id);
return meetings;
}
Run Code Online (Sandbox Code Playgroud)
我使用ExpandoObject作为IDictionary填充动态属性
public static class PermissionExtensions
{
public static void SetMeetingPermission(this IEnumerable<Meeting> meetings, IPermissionRepository permissionRepository, int userId)
{
// get properties to be created from database table
var permissions = permissionRepository.GetAll();
// create a dynamic …Run Code Online (Sandbox Code Playgroud) 我在我的web api授权中使用OWIN/Katana中间件.
流动.
我发布acess_token和refresh_token请求的客户端.
将access_token有短暂的寿命,而refresh_token早已到期.
像往常一样,如果access_token到期,它将使用refresh_token请求另一个access_token.
现在,我的问题.由于我的refresh_token有很长的生命周期,看起来它失败了短命的access_token的目的.让我们说如果refresh_token被泄露,黑客仍然可以得到access_token,对吧?
我查看了谷歌和微软的OAuth实现,看起来他们还有这个额外的参数,你需要提供除了refresh_token.这就是client_id和client_secret.看起来它们是在API的开发者页面上登录时生成的.
现在,我如何在我的项目中实现它?我想要覆盖令牌创建并使令牌哈希基于ClientId和ClientSecret.
我正在使用最新的web api的基本OWIN/Katana身份验证,我不打算使用像Thinktecture这样的其他授权服务器.我只想使用ASP.NET Web API 2默认提供的基本功能
Startup.OAuth.cs
public partial class Startup
{
static Startup()
{
PublicClientId = "self";
UserManagerFactory = () => new UserManager<IdentityUser>(new AppUserStore());
var tokenExpiry = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ApiTokenExpiry"]);
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(tokenExpiry),
AllowInsecureHttp = true,
RefreshTokenProvider …Run Code Online (Sandbox Code Playgroud) 有问题的人使用angular-ui-select?
得到这个错误
GET http://localhost/select2/select.tpl.html 404 (Not Found) angular.js:8539
Error: [$compile:tpload] Failed to load template: select2/select.tpl.html
Run Code Online (Sandbox Code Playgroud)
从文档中 - 我只需要引用select.js和select.css
我有一个奇怪的例子,执行顺序混乱
我为所有步骤定义创建了一个基类
public abstract class BaseSteps
{
static BaseSteps()
{
Console.WriteLine("static Constructor");
}
protected BaseSteps()
{
Console.WriteLine("public Constructor");
}
[BeforeTestRun]
public static void BeforeTestRun()
{
Console.WriteLine("static void BeforeTestRun");
}
[AfterTestRun]
public static void AfterTestRun()
{
Console.WriteLine("static void AfterTestRun");
}
[Before]
public static void Before()
{
Console.WriteLine("Base Before Scenario");
}
}
[Binding]
public class SpecFlowFeature1Steps: BaseSteps
{
public SpecFlowFeature1Steps()
{
}
[BeforeScenario()]
public void Setup()
{
}
Run Code Online (Sandbox Code Playgroud)
但奇怪的是,我的调试模式下的执行顺序看起来像这样
我原以为它会像...
我有一个扩展方法,检查对象的类型,然后填充其成员属性
public static void LoadMeeting<T>(this T entity, IMeetingRepository meetingRepository)
where T: MyEntity
{
var agenda = entity as Agenda;
if (agenda != null)
{
agenda.Meeting = meetingRepository.GetMeetingById(agenda.MeetingId);
}
var participant = entity as Participant;
if (participant != null)
{
participant.Meeting = meetingRepository.GetMeetingById(participant.MeetingId);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以进一步重构这样的东西,使其更通用吗?
public static void LoadMeeting<T>(this T entity, IMeetingRepository meetingRepository) where T : MyEntity
{
var obj = entity as Agenda || entity as Participant;
if (obj != null)
{
obj.Meeting = meetingRepository.GetMeetingById(obj.MeetingId);
}
}
}
Run Code Online (Sandbox Code Playgroud)
PS:我不想把对象的属性 …
目标是在提交repo中的更改后立即在Windows Azure中进行两次自动部署.
这是我做的步骤
在Azure中配置持续部署后,Azure会自动在repo中部署最新内容并失败(请参阅下面的azure部署日志)

我在互联网上搜索了一段时间如何做到这一点.我不想使用Visual Studio,我只想使用VS Code.
是否有人可以一步一步地指导这样做?
TIA
更新 - 我实际上使用的是Angular-CLI样板,而不是angular-quickstart.这是package.json
{
"name": "my-webapp",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"postinstall": "typings install",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/forms": "0.1.1",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/router": "3.0.0-alpha.7",
"@angular2-material/button": "^2.0.0-alpha.5-2",
"@angular2-material/core": "^2.0.0-alpha.5-2",
"@angular2-material/toolbar": "^2.0.0-alpha.5-2",
"@angular2-material/icon": "^2.0.0-alpha.5-2",
"@angular2-material/sidenav": "^2.0.0-alpha.5-2",
"@angular2-material/list": "^2.0.0-alpha.5-2",
"@angular2-material/card": "^2.0.0-alpha.5-2", …Run Code Online (Sandbox Code Playgroud) 如何将此字典转换为列表
var dict = new Dictionary<string, List<string>>();
dict.Add("1", new List<string>() { "a", "b" });
dict.Add("2", new List<string>() { "a", "c" });
Run Code Online (Sandbox Code Playgroud)
我期待这个输出
List<dynamic> = new List<dynamic>()
{
new { id = "1", value = "a" }
new { id = "1", value = "a" }
new { id = "2", value = "a" }
new { id = "2", value = "a" }
}
Run Code Online (Sandbox Code Playgroud)
我试过这个但是无法获取嵌套集合的值:
dict.Select(c => new { id=c.Key, value= c.Value })
Run Code Online (Sandbox Code Playgroud)