Related
{
"EventType": "Order:Update",
"Environment": {
"UserName": "Federico",
"MachineName": "HP",
"DomainName": "HP",
"CallingMethodName": "Audit.UnitTest.AuditTests.TestUpdate()",
"Exception": null,
"Culture": "en-GB"
},
"Target": {
"Type": "Order",
"Old": {
"OrderId": "39dc0d86-d5fc-4d2e-b918-fb1a97710c99",
"Status": 2,
},
"New": {
"OrderId": "39dc0d86-d5fc-4d2e-b918-fb1a97710c99",
"Status": -1,
}
},
"ReferenceId": "39dc0d86-d5fc-4d2e-b918-fb1a97710c99", // <-- Custom Field
"Comments": ["Status Updated to Cancelled"], // <-- Comments
"StartDate": "2016-08-23T11:34:44.656101-05:00",
"EndDate": "2016-08-23T11:34:55.1810821-05:00",
"Duration": 8531
}
You can't change the type of the AuditEvent properties, but you can add custom fields to the audit event with custom actions.
For example:
Audit.Core.Configuration.AddCustomAction(ActionType.OnScopeCreated, scope =>
{
scope.SetCustomField("StartDateTimeZone", GetCurrentDate());
});
Audit.Core.Configuration.AddCustomAction(ActionType.OnEventSaving, scope =>
{
scope.SetCustomField("EndDateTimeZone", GetCurrentDate());
});
I am trying to parse the JSON data below into the structs that are shown. I am having a helluva time trying to figure out how to get at the "nested" elements, such as elements "title:", "content:", and "excerpt:". Whenever the code runs, it barfs while parsing the nested elements.
I've looked at the Apple Developer stuff and reviewed the Playground here: https://developer.apple.com/documentation/foundation/archives_and_serialization/using_json_with_custom_types
I also tried using quicktype.io to create the data models from the sample JSON, however, in the header of the exported file from quicktype it has the line: "let blogItem = try? newJSONDecoder().decode(BlogItem.self, from: jsonData)", however, I get a compile error that jsonData is not recognized and I'm not able to find any reference to it.
struct BlogSection: Codable, Identifiable {
var id: Int
var slug: String
var link: String
var title: [BlogTitle]
var content: [ContentData]
}
struct BlogTitle: Codable, Equatable, Identifiable {
var id: UUID
var rendered: String
}
struct ContentData: Codable, Identifiable{
var id: UUID
var rendered: String
}
/**************** JSON Data ***************/
[
{
"id": 10960,
"date": "2019-10-02T01:00:07",
"date_gmt": "2019-10-02T05:00:07",
"guid": {
"rendered": "example.com/blog-template-copy-copy/"
},
"modified": "2019-09-20T07:08:41",
"modified_gmt": "2019-09-20T11:08:41",
"slug": "relationships-matter",
"status": "publish",
"type": "post",
"link": "example.com/relationships-matter/",
"title": {
"rendered": "Relationships Matter"
},
"content": {
"rendered": "<h1>Page content</h1>",
"protected": false
},
"excerpt": {
"rendered": "<p>By: Joe Schmoe<br />\nFirst Author",
"protected": false
},
"author": 57,
"featured_media": 10958,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
613
],
"tags": [],
"_links": {
"self": [
{
"href": "example.com/wp-json/wp/v2/posts/10960"
}
],
"collection": [
{
"href": "example.com/wp-json/wp/v2/posts"
}
],
"about": [
{
"href": "example.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "example.com/wp-json/wp/v2/users/57"
}
],
"replies": [
{
"embeddable": true,
"href": "example.com/wp-json/wp/v2/comments?post=10960"
}
],
"version-history": [
{
"count": 5,
"href": "example.com/wp-json/wp/v2/posts/10960/revisions"
}
],
"predecessor-version": [
{
"id": 10971,
"href": "example.com/wp-json/wp/v2/posts/10960/revisions/10971"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "example.com/wp-json/wp/v2/media/10958"
}
],
"wp:attachment": [
{
"href": "example.com/wp-json/wp/v2/media?parent=10960"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "example.com/wp-json/wp/v2/categories?post=10960"
},
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "example.com/wp-json/wp/v2/tags?post=10960"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
]
'
In the JSON you do not have arrays for title and content, so just remove the brackets
struct BlogSection: Codable, Identifiable {
var id: Int
var slug: String
var link: String
var title: BlogTitle
var content: ContentData
}
struct BlogTitle: Codable, Equatable, Identifiable {
var id: UUID
var rendered: String
}
struct ContentData: Codable, Identifiable{
var id: UUID
var rendered: String
}
Title and Content are not Arrays in the json provided so should be declared as entities. Your BlogTitle and ContentData are declared as Identifiable and have a variable for id, but both do not have an id in the json provided, so you will get a decoding error because of that as well.
The error you are getting points to a completely different problem though. How is your jsonData declared?
I'm setting up an action which uses push notifications. Yet, on firebase I can't get "UPDATES_USER_ID" of user to save. It returns "undefined".
I followed the guide on this link and here is my code to get UPDATES_USER_ID.
app.intent('Setup', (conv, params) => {
conv.ask(new UpdatePermission({
intent: "notificationResponseIntent"
}));
});
app.intent("FinishNotificationSetup", (conv, params) => {
if (conv.arguments.get('PERMISSION')) {
conv.data.GoogleUserID = conv.arguments.get("UPDATES_USER_ID");
console.log(conv.data.GoogleUserID);
conv.ask("some response....");
}
});
And here is my webhook request when FinishNotificationSetup intent is invoked.
{
"responseId": "2f425fe5-db42-47dc-90a1-c9bc85f725d2",
"queryResult": {
"queryText": "actions_intent_PERMISSION",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "projects/projectname/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_screen_output"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_intent_permission",
"parameters": {
"PERMISSION": true,
"text": ""
}
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/_actions_on_google",
"lifespanCount": 98,
"parameters": {
"data": "{\"***":\"***",\"***":\"***"}"
}
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_account_linking"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_audio_output"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/google_assistant_input_type_keyboard"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_web_browser"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_media_response_audio"
}
],
"intent": {
"name": "projects/projectname-10c22/agent/intents/a12b6d3f-0f24-45e9-a1b2-5649083831b0",
"displayName": "FinishNotificationSetup"
},
"intentDetectionConfidence": 1,
"languageCode": "tr"
},
"originalDetectIntentRequest": {
"source": "google",
"version": "2",
"payload": {
"isInSandbox": true,
"surface": {
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.ACCOUNT_LINKING"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
},
"requestType": "SIMULATOR",
"inputs": [
{
"rawInputs": [
{
"inputType": "KEYBOARD"
}
],
"arguments": [
{
"textValue": "true",
"name": "PERMISSION",
"boolValue": true
},
{
"name": "text"
}
],
"intent": "actions.intent.PERMISSION"
}
],
"user": {
"lastSeen": "2019-04-30T07:23:23Z",
"permissions": [
"UPDATE"
],
"locale": "tr-TR",
"userId": "ABwppHHCEdtf23ZaNg0DaCv3fvshSUXUvYGXHe6kR7jbKacwIS6vDBBL7YXbN70jYa8KaXWZqbsyhFFSdsYLiw"
},
"conversation": {
"conversationId": "ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA",
"type": "ACTIVE",
"conversationToken": "[\"_actions_on_google\"]"
},
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
}
]
}
},
"session": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA"
}
To send notification, I've been using userID instead of UPDATES_USER_ID and it is working. Yet, it will be deprecated soon. So, I need to find a solution to get this ID and couldn't make it working. What do I need to do to get this ID?
I've found solution for this problem. While getting UPDATES_USER_ID conv.arguments.get() only works for first attempt. So, while building your action you must save it. If you didn't store or save, you can reset your profile and try again, you will be able to get.
app.intent("FinishNotificationSetup", (conv, params) => {
if (conv.arguments.get('PERMISSION')) {
if(!conv.user.storage.GoogleUserID)
{
conv.user.storage.GoogleUserID = conv.arguments.get("UPDATES_USER_ID");
//For best case
//store ID in your db.
}
console.log(conv.user.storage.GoogleUserID);
conv.ask("some response....");
}
});
For best case, try saving this to your database because conv.user.storage does not work sometimes.
I'm currently building a query builder for Odata.
I took inspiration from this project :
http://mfauveau.github.io/angular-query-builder/.
I do have now a json interpretation of the query.
But the framework Im using to work with odata has a different format.
My problem is that the query could be infinitly nested.
I need this kind of output :
{ or: [
age: { ">": 40 },
and: [
{ lastName: { startsWith: 'A'}},
{ hireDate: { '<': new Date(2010, 0, 1) }}
]
]
}
And I have this input :
{
"rules": [
{
"condition": "=",
"field": "ID",
"data": "1",
"$$hashKey": "object:244"
},
{
"condition": "=",
"field": "ID",
"data": "1",
"$$hashKey": "object:310"
},
{
"group": {
"operator": "AND",
"rules": [
{
"condition": "=",
"field": "ID",
"data": "1",
"$$hashKey": "object:392"
},
{
"condition": "=",
"field": "ID",
"data": "1",
"$$hashKey": "object:456"
}
]
},
"$$hashKey": "object:363"
}
],
"operator": "OR"
}
I 'd need some advice to solve this problem.
So if you have a link or some ideas that could help me.
I would be grateful.
function convertQueryBuilderToBreeze(filtre) {
var jsonObject = {};
if (filtre.rules && filtre.operator) {
jsonObject[filtre.operator] = filtre.rules.map(function (rule) {
if (rule.condition) {
var condition = {};
var obj = {};
obj[rule.condition] = rule.data;
condition[rule.field] = obj;
return condition;
} else if (rule.group) {
return convertQueryBuilderToBreeze(rule.group);
}
});
}
return jsonObject;
}
I tried to reproduce example from here, I copied the code for you :
require(devtools)
install_github('ramnathv/rCharts#dev')
install_github('ramnathv/rMaps')
library(rMaps)
crosslet(
x = "country",
y = c("web_index", "universal_access", "impact_empowerment", "freedom_openness"),
data = web_index
)
The execution doesn't generate any error but the page in the navigator remains blank (either in Firefox and Chrome). I examined the element in the console and got the following error :
ReferenceError: head is not defined index.html:26:4
In Chrome the error is different, I have a Failed to load ressource for each link for the js library. This is strange because the link seem valid and I don't have the same problems with the plot fonctions in rCharts (another R library from the same author).
Here is the index.html code. I can see that there is a problem with the head element. (in the copy I removed some countries for sake of space)
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='C:\Users\S Combes\Documents\R\R-3.2.0\library\rMaps\libraries\crosslet/styles.css'>
<link rel='stylesheet' href='C:\Users\S Combes\Documents\R\R-3.2.0\library\rMaps\libraries\crosslet/http://fonts.googleapis.com/css?family=Open+Sans'>
<script src='C:\Users\S Combes\Documents\R\R-3.2.0\library\rMaps\libraries\crosslet/head.load.min.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
</style>
</head>
<body >
<div id="content" class="container"><div id="map"></div></div>
<script type="text/javascript">
var params = {"dom":"chart12fc45e47bf5","width":800,"height":400,"scope":"world","data":[{"country":"Argentina","web_index":55.2,"universal_access":47.1,"education_awareness":45.9,"access_affordability":67.9,"comm_infrastructure":47.2,"relevant_content":71.5,"web_use":82.8,"content_creation":56.1,"freedom_openness":52.2,"web_freedom":52.2,"impact_empowerment":39.8,"political_impact":49.7,"social_environmental":47.2,"economic_impact":33.4},{"country":"Australia","web_index":86.4,"universal_access":82.4,"education_awareness":75.8,"access_affordability":94.5,"comm_infrastructure":74.6,"relevant_content":92.6,"web_use":91.4,"content_creation":86.5,"freedom_openness":67.7,"web_freedom":67.7,"impact_empowerment":74.3,"political_impact":88,"social_environmental":71.1,"economic_impact":68.2},{"country":"Austria","web_index":84.8,"universal_access":85.9,"education_awareness":93.5,"access_affordability":89.4,"comm_infrastructure":72.8,"relevant_content":82.2,"web_use":81.3,"content_creation":77.7,"freedom_openness":78.6,"web_freedom":78.6,"impact_empowerment":66.4,"political_impact":89.3,"social_environmental":47.1,"economic_impact":69.8},{"country":"Bahrain","web_index":38.4,"universal_access":53.1,"education_awareness":57.2,"access_affordability":71.8,"comm_infrastructure":46.7,"relevant_content":59.3,"web_use":71.9,"content_creation":44.8,"freedom_openness":13.6,"web_freedom":13.6,"impact_empowerment":28.9,"political_impact":48.3,"social_environmental":15.2,"economic_impact":37.1},{"country":"Zimbabwe","web_index":10.1,"universal_access":17.7,"education_awareness":44.4,"access_affordability":29.1,"comm_infrastructure":22.4,"relevant_content":5.4,"web_use":10.5,"content_creation":9.4,"freedom_openness":22.8,"web_freedom":22.8,"impact_empowerment":11.2,"political_impact":25,"social_environmental":11.9,"economic_impact":13.8}],"id_field":"country","defaults":{"order":["web_index","universal_access","impact_empowerment","freedom_openness"],"active":"web_index"},"id":"chart12fc45e47bf5"}
head.ready(function(){
var myColorScale = d3.scale.linear()
.domain([1, 10, 20.1])
.range(["red", "yellow", "green"])
.interpolate(d3.cie.interpolateLab)
var config = {
map: getMap(params.scope),
data: {version: "1.0", id_field: params.id_field},
dimensions : {
"web_index": {
"title": "web_index",
"data": {
"dataSet": params.data ,
"field": "web_index"
}
},
"universal_access": {
"title": "universal_access",
"data": {
"dataSet": params.data ,
"field": "universal_access"
}
},
"education_awareness": {
"title": "education_awareness",
"data": {
"dataSet": params.data ,
"field": "education_awareness"
}
},
"access_affordability": {
"title": "access_affordability",
"data": {
"dataSet": params.data ,
"field": "access_affordability"
}
},
"comm_infrastructure": {
"title": "comm_infrastructure",
"data": {
"dataSet": params.data ,
"field": "comm_infrastructure"
}
},
"relevant_content": {
"title": "relevant_content",
"data": {
"dataSet": params.data ,
"field": "relevant_content"
}
},
"web_use": {
"title": "web_use",
"data": {
"dataSet": params.data ,
"field": "web_use"
}
},
"content_creation": {
"title": "content_creation",
"data": {
"dataSet": params.data ,
"field": "content_creation"
}
},
"freedom_openness": {
"title": "freedom_openness",
"data": {
"dataSet": params.data ,
"field": "freedom_openness"
}
},
"web_freedom": {
"title": "web_freedom",
"data": {
"dataSet": params.data ,
"field": "web_freedom"
}
},
"impact_empowerment": {
"title": "impact_empowerment",
"data": {
"dataSet": params.data ,
"field": "impact_empowerment"
}
},
"political_impact": {
"title": "political_impact",
"data": {
"dataSet": params.data ,
"field": "political_impact"
}
},
"social_environmental": {
"title": "social_environmental",
"data": {
"dataSet": params.data ,
"field": "social_environmental"
}
},
"economic_impact": {
"title": "economic_impact",
"data": {
"dataSet": params.data ,
"field": "economic_impact"
}
}
},
defaults: params.defaults,
};
new crosslet.MapView($("#map"),config)
})
function getMap(scope){
var map = []
map.world = {
leaflet: {
key: "af67a5248c104d27bff9e8d363b6db4a",
styleId: 96931, /* 81531, */
attribution: 'Map data © OpenStreetMap'
},
view: {
center: [35.505, -1.09],
zoom: 2
},
geo: {
url: "http://rawgithub.com/markmarkoh/datamaps/master/src/js/data/world.topo.json",
name_field: "name",
id_field: "name",
topo_object: "world"
}
}
map.us = {
leaflet: {
key: "fe623ce312234f8f9333bbee72d4a176",
styleId: 96931, /* 64657, */
attribution: 'Map data © OpenStreetMap'
},
view: {
center: [40.42, -98.73],
zoom:5
},
geo: {
url: "http://rawgithub.com/sztanko/crosslet/gh-pages/examples/us/data/us_counties.topo.json",
name_field: "NAME",
id_field: "GEOID",
topo_object: "us_counties"
}
}
return map[scope]
}
</script>
<script>
head.load(
"http://cdn.leafletjs.com/leaflet-0.4/leaflet.css",
"http://sztanko.github.io/crosslet/css/crosslet-min.css",
"//cdn.leafletjs.com/leaflet-0.4.4/leaflet.js",
"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js",
"//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js",
"//cdnjs.cloudflare.com/ajax/libs/d3/3.0.1/d3.v3.min.js",
"//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js",
"//sztanko.github.io/crosslet/js/crosslet.js"
)
</script>
<script></script>
</body>
</html>