I'm having trouble parsing data sent from signalR hub to my client variables.
So heres how it goes,
I activate my signalR listener on my client, and i extract the message like so:
connection.on('StreamData', message => {
// catch message here.
console.log("Message recieved ", message)
});
and i get smth like this:
Message recieved Object {
"Alarms": Array [
Object {
"isActive": true,
"name": "Alarm1",
},
Object {
"isActive": true,
"name": "Alarm2",
},
Object {
"isActive": true,
"name": "Alarm3",
}]
},
"Temperature1": 13,
"Temperature2": 0,
"Temperature3": 0
}
so the thing is i want to pass these parameters and set variables on the clients side, like
clientTemerature1 = message.Temperature1;
Related
I can't order a message with timestamp , I tried many ways and it still doesn't work, please help
An arrangement with data like pictures
code
database
data:
{ chatRoom : {
"232": {
"-NKHmBkCihoyRiYABX5O": {
"createdAtDate": "2022-12-27",
"createdAtTime": "17:52:49",
"fromType": 4,
"message": "message2",
"readByAdmin": false,
"readByUser": true,
"timestamp": 1672131169.174558,
"user": "tuan do",
"userId": "232"
}
},
"242": {
"-NKHm6svnBJhWq321aNv": {
"createdAtDate": "2022-12-27",
"createdAtTime": "17:52:29",
"fromType": 3,
"message": "message1",
"readByAdmin": false,
"readByUser": true,
"timestamp": 1672131149.252743,
"user": "solashi 歯科衛生士",
"userId": "242"
}
}
}
}
code : const dbRefAdmin = firebase.database().ref('chatRoom').orderByChild('timestamp').limitToLast(10)
A simple answer :
Try to use "orderBy" instead of "orderByChild"
then "limit" instead of "limitToLast"
Give a feedback in comment and put your post in solved status if the code below solves your problem.
Official documentation : order and limit data with Cloud Firestore
var is_start_load = true;
const dbRefAdmin = firebase.database().ref('chatRoom').orderBy('timestamp').limit(10);
My NestJs server returns an indefinite list of stocks and their statuses:
"data": {
"AAPL": {
"status": 200,
"tradable": true,
"fractionable": true,
"symbol": "AAPL"
},
"MCFT": {
"status": 200,
"tradable": true,
"fractionable": true,
"symbol": "MCFT"
},
...
}
There are over 2 thousand stock tickers ("AAPL", "MCFT", etc). I understand that in OpenApi, you can define keys that are strings. Will I be able to define types like that in Nest? Is there a way to make the tickers key dynamic, so I do not have to keep updating the list of stocks?
How can we call MSCRM action using some HTTP Client request (c#)?
Can any one please assist on this.
The documentation is not covering this action, and I was able to pull this payload from couple of references. But I could not test this in my environment, please test it yourself.
The sample will look like this:
{
"SearchText": "",
"UseInflection": false,
"RemoveDuplicates": false,
"StateCode": 3,
"QueryExpression": {
"#odata.type": "Microsoft.Dynamics.CRM.QueryExpression",
"EntityName": "knowledgearticle",
"ColumnSet": {
"AllColumns": true
},
"Distinct": false,
"NoLock": false,
"PageInfo": {
"PageNumber": 1,
"Count": 10,
"ReturnTotalRecordCount": true,
"PagingCookie": ""
},
"LinkEntities": [],
"Criteria": {
"FilterOperator": "And",
"Conditions": [
{
"EntityName": "knowledgearticle",
"AttributeName": "languagelocaleid",
"Operator": "Equal",
"Values": [
"56940B3E-300F-4070-A559-5A6A4D11A8A3"
]
}
]
}
}
}
Reference.
Make a POST request to the the following URL.
[Your organization root URL]/api/data/v9.1/FullTextSearchKnowledgeArticle
Here is one sample payload that works. You can optionally add additional filters to filter the search result.
{
"SearchText":"test",
"UseInflection":true,
"RemoveDuplicates":true,
"StateCode":3,
"QueryExpression":{
"#odata.type":"Microsoft.Dynamics.CRM.QueryExpression",
"EntityName":"knowledgearticle",
"ColumnSet":{
"AllColumns":true
},
"PageInfo":{
"PageNumber":1,
"Count":10
},
"Orders":[
{
"AttributeName":"modifiedon",
"OrderType":"Descending"
}
]
}
}
Refer the link below for sample code for connecting to Dynamics.
CDSWebApiService class library (C#)
I'm using facebook Graph API to retrieve action values from campaigns. But the JSON returned is always different from any values from facebook screen.
My Request from JavaScript
var d = new FormData();
d.append("access_token", "MY_ADS_INSIGHTS_TOKEN");
d.append("fields", "actions");
d.append("date_preset", "lifetime"); // I want lifetime data
return await (await fetch("https://graph.facebook.com/v3.1/" + campaignid + "/insights", {
method: "post",
body: d
})).json();
and after I access the report insights using the URL:
https://graph.facebook.com/v3.1/REPORT_RUN_ID/insights?access_token=MY_ADS_INSIGHTS_TOKEN
JSON returned after access report task
{
"data": [
{
"actions": [
{
"action_type": "comment",
"value": "2"
},
{
"action_type": "like",
"value": "4"
},
{
"action_type": "photo_view",
"value": "30"
},
{
"action_type": "post",
"value": "1"
},
{
"action_type": "link_click",
"value": "7"
},
{
"action_type": "page_engagement",
"value": "249"
},
{
"action_type": "post_engagement",
"value": "245"
},
{
"action_type": "post_reaction",
"value": "205"
}
],
"date_start": "2018-07-09",
"date_stop": "2018-07-15",
"ad_id": null // removed
}
],
"paging": {
"cursors": {
"before": "MAZDZD",
"after": "MAZDZD"
}
},
"__fb_trace_id__": null // removed
}
Facebook Post Results
I want to know:
Why Facebook Graph API return the post_reaction as 205 since from facebook view it is 160 or 150? the value doesn't match anything, happens to action like too
Notes:
I'm not using any SDK, but this isn't the problem.
The Ad has only ONE ads group and the group has only ONE campaign
I make the requisition at the same time as I see the post. There are no major interactions in this post, it is old enough that the values do not change.
I known that Facebook cache anything, but this Ad is from 10, July.
Ad Campaign Insights reference: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group/insights/
I accept answers using SDKs or different programming languages like C#, php or Java as example, I want only know HOW make the right request or what is exactly happening.
I am using rails, and gathering some data to make pie charts. I am just using ruby objects (so no JSON), and using d3pie. First, I make a helper function. Then I make a javascript function using that helper, and pass it in the dom. Here's my code;
helper.rb
def options_data_to_d3(options_data)
d3_data = []
options_data.each do |key, value|
d3_data.push( { label: key.option.as_json, value: value.as_json } )
end
return JSON.pretty_generate(d3_data)
end
this takes the ruby hash, and makes it into json
js function
function dataPieChart(id, data) {
var config = {
"header": {
"title": {
"text": "Quiz Questions",
"fontSize": 18,
"font": "verdana"
},
"size": {
"canvasHeight": 400,
"canvasWidth": 500
},
"data": {
"content": data
},
"labels": {
"outer": {
"pieDistance": 32
}
}
}
}
var pie = new d3pie(id, config);
}
passing into the view
<div id="quizQuestionOptionPie<%= question.id %>"></div>
<script type="text/javascript">dataPieChart("quizQuestionOptionPie<%= question.id %>", <%= raw options_data_to_d3(data[:options]) %>);
</script>
when I call a console log in the javascript function to see what data is, I get the correct output that both d3pie and d3 are looking for, yet I am still getting the error
d3pie error: no data supplied.
does anyone see something wrong with my code, or something I am missing? any help is appreciated.
You config option is bracketed incorrectly (everything is a child of "header"). You really meant:
var config = {
"header": {
"title": {
"text": "Quiz Questions",
"fontSize": 18,
"font": "verdana"
},
},
"size": {
"canvasHeight": 400,
"canvasWidth": 500
},
"data": {
"content": data
},
"labels": {
"outer": {
"pieDistance": 32
}
}
};