我正在开发一个Web API 2项目.对于身份验证,我使用的是承载令牌.在成功验证后,API返回JSON对象.
{"access_token":"Vn2kwVz...",
"token_type":"bearer",
"expires_in":1209599,
"userName":"username",
".issued":"Sat, 07 Jun 2014 10:43:05 GMT",
".expires":"Sat, 21 Jun 2014 10:43:05 GMT"}
Run Code Online (Sandbox Code Playgroud)
现在我想在这个JSON对象中返回用户角色.为了从JSON响应中获取用户角色,我需要做出哪些更改?
我正在关注此帖子以使用azure通知中心.我想要做的是创建web api,使用Azure通知中心注册设备.当我按照文章中所示发送注册设备的请求时,它会点击azure通知中心.
下面是我的天蓝色门户的屏幕截图.这表明有一个注册请求.
但是当我尝试使用以下代码获取已注册设备的详细信息时,它始终为0.
var registrationsCount = await hub.GetAllRegistrationsAsync(Int32.MaxValue);
return registrationsCount.Count().ToString();
Run Code Online (Sandbox Code Playgroud)
现在我几乎没有问题:
1)我如何探索注册设备的详细信息?
2)我如何从后端向ios设备发送测试通知.下面是我用来发送测试通知的代码.
var payload = string.Format(toastTemplate, message);
hub.SendAppleNativeNotificationAsync(payload, "worldnews");
Run Code Online (Sandbox Code Playgroud)
3)如果我使用web api作为后端,是否有必要在azure通知中心配置ios应用程序详细信息?即在天蓝色门户网站上传证书和其他详细信息?
我在我的应用程序中使用Windows azure通知集线器向用户提供通知.以下是在通知中心上注册设备的API代码.
var platform = registrationCall["platform"].ToString();
var installationId = registrationCall["instId"].ToString();
var channelUri = registrationCall["channelUri"] != null ?
registrationCall["channelUri"].ToString() : null;
var deviceToken = registrationCall["deviceToken"] != null ?
registrationCall["deviceToken"].ToString() : null;
string RegistrationID = registrationCall["RegistrationID"] != null ?
registrationCall["RegistrationID"].ToString() : null;
var userName = HttpContext.Current.User.Identity.Name;
RegistrationDescription registration = null;
AppleRegistrationDescription iosExistingRegistrationByDeviceToken = null;
string UserID = User.Identity.GetUserId().ToString();
var registrationFromHub = await hubClient.GetRegistrationsByChannelAsync(deviceToken, 100);
if (registrationFromHub.Count() >= 1)
{
iosExistingRegistrationByDeviceToken =
registrationFromHub.Where(x => x.RegistrationId == RegistrationID)
.SingleOrDefault() as AppleRegistrationDescription;
}
if (iosExistingRegistrationByDeviceToken …
Run Code Online (Sandbox Code Playgroud) 我按照图表设计了我的数据库。
Category
表是自引用父子关系Budget
将为每个类别定义所有类别和数量Expense
表将包含已花费金额的类别条目(考虑Total
此表中的列)。我想编写 select 语句来检索具有下面给出的列的数据集:
ID
CategoryID
CategoryName
TotalAmount (Sum of Amount Column of all children hierarchy From BudgetTable )
SumOfExpense (Sum of Total Column of Expense all children hierarchy from expense table)
Run Code Online (Sandbox Code Playgroud)
我尝试使用 CTE,但无法产生任何有用的东西。提前感谢您的帮助。:)
更新
我只是为了组合和简化数据,我用下面的查询创建了一个视图。
SELECT
dbo.Budget.Id, dbo.Budget.ProjectId, dbo.Budget.CategoryId,
dbo.Budget.Amount,
dbo.Category.ParentID, dbo.Category.Name,
ISNULL(dbo.Expense.Total, 0) AS CostToDate
FROM
dbo.Budget
INNER JOIN
dbo.Category ON dbo.Budget.CategoryId = dbo.Category.Id
LEFT OUTER JOIN
dbo.Expense ON dbo.Category.Id = dbo.Expense.CategoryId
Run Code Online (Sandbox Code Playgroud)
基本上应该会产生这样的结果。
这是我需要帮助的场景。
用户输入关键字并点击搜索
我将该关键字提供给多个 API,以便使用 httpclient 请求获取结果。
我收到基于来自不同 API 的搜索关键字的响应。
但问题是我正在对这些 api 进行一一搜索调用。我想做一些事情,一旦用户点击搜索,它就会立即调用所有 API,然后组合结果。
WalmartModel model=new WalmartModel();
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("**URL 1**");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//GET Method
HttpResponseMessage response = await client.GetAsync("");
if (response.IsSuccessStatusCode)
{
model = await response.Content.ReadAsAsync<WalmartModel>();
}
else
{
Console.WriteLine("Internal server Error");
}
}
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("**URL 2**");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//GET Method
HttpResponseMessage response = await client.GetAsync("");
if (response.IsSuccessStatusCode)
{
model = …
Run Code Online (Sandbox Code Playgroud) 我有一些这样的整数值:
2 4 6 4 2 4 8 4 2 3 7 4 2
我需要找到峰值 - 这是我的数组中值停止增加的点.在上面的例子中,有三个峰值 - 6, 8, 7
怎么做到呢?谢谢.
我正在尝试在我的asp.net gridview上实现datatables.net.我已经包含了必要的js和css文件.
我正在使用数据表
$(document).ready(function(){
$('#myGridview').dataTable();
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用.它在控制台中显示异常:
"无法读取未定义的属性'mData'
任何人都可以帮我解决这个问题吗?
谢谢
c# ×4
asp.net ×2
azure ×1
bearer-token ×1
duplicates ×1
filter ×1
gridview ×1
ios ×1
jquery ×1
math ×1
sql-server ×1