I have a carousel, but it is not opening the URL when the CardAction button is clicked in Skype. It is working in Emulator though. Is there a reason for this?
foreach(var botAmazonItem in botAmazonItems)
{
List<CardImage> cardImages = new List<CardImage>();
cardImages.Add(new CardImage(url: $"{botAmazonItem.imageUrl}"));
List<CardAction> cardButtons = new List<CardAction>();
CardAction plButton = new CardAction()
{
Value = botAmazonItem.detailsPageUrl,
Type = ActionTypes.OpenUrl,
Title = botAmazonItem.title
};
cardButtons.Add(plButton);
HeroCard plCard = new HeroCard()
{
Title = $"{botAmazonItem.title}",
Subtitle = $"{botAmazonItem.formattedPrice}",
Images = cardImages,
Buttons = cardButtons
};
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);
}
Try changing your "value" links to https:// rather than http://. Skype requires all external links to be https://
The following code (based on yours) works:
var botAmazonItems = new List<AmazonBotItem>();
botAmazonItems.Add(new AmazonBotItem() { imageUrl = "http://placekitten.com/200/300", title = "Microsoft", formattedPrice = "$8.95", detailsPageUrl = "https://www.microsoft.com" });
botAmazonItems.Add(new AmazonBotItem() { imageUrl = "http://placekitten.com/300/300", title = "Bot Framework", formattedPrice = "$2.95", detailsPageUrl = "https://www.botframework.com" });
var reply = activity.CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
reply.Attachments = new List<Attachment>();
foreach (var botAmazonItem in botAmazonItems)
{
List<CardImage> cardImages = new List<CardImage>();
cardImages.Add(new CardImage(url: $"{botAmazonItem.imageUrl}"));
List<CardAction> cardButtons = new List<CardAction>();
CardAction plButton = new CardAction()
{
Value = botAmazonItem.detailsPageUrl,
Type = ActionTypes.OpenUrl,
Title = botAmazonItem.title
};
cardButtons.Add(plButton);
HeroCard plCard = new HeroCard()
{
Title = $"{botAmazonItem.title}",
Subtitle = $"{botAmazonItem.formattedPrice}",
Images = cardImages,
Buttons = cardButtons
};
Attachment plAttachment = plCard.ToAttachment();
reply.Attachments.Add(plAttachment);
}
Related
I have tried to adapt the code in https://learn.microsoft.com/en-us/office/open-xml/how-to-insert-a-picture-into-a-word-processing-document to insert an image to a table cell in my .Net Core MVC app. However, inserting the image just corrupts the word file.
I have noticed that when I extract the corrupt docx file, the "media" folder is outside the "word" folder. However, when I manually add an image to a docx file, the "media" folder is present inside the "word" folder.
...code here...
ImagePart imagePart = wordDoc.MainDocumentPart.AddImagePart(ImagePartType.Jpeg);
using (FileStream stream = new FileStream(#$"{_env.WebRootPath}\images\mono.jpg", FileMode.Open))
{
imagePart.FeedData(stream);
}
var element = new Drawing( new DW.Inline( new DW.Extent() { Cx = 990000L, Cy = 792000L },
new DW.EffectExtent(){ LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L },
new DW.DocProperties(){ Id = (UInt32Value)11U, Name = "Picture 1" },
new DW.NonVisualGraphicFrameDrawingProperties( new A.GraphicFrameLocks() { NoChangeAspect = true }),
new A.Graphic( new A.GraphicData( new PIC.Picture(
new PIC.NonVisualPictureProperties(
new PIC.NonVisualDrawingProperties(){ Id = (UInt32Value)10U, Name = "New Bitmap Image.jpg" },
new PIC.NonVisualPictureDrawingProperties()),
new PIC.BlipFill(
new A.Blip(new A.BlipExtensionList(new A.BlipExtension(){ Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" })) { Embed = wordDoc.MainDocumentPart.GetIdOfPart(imagePart), CompressionState = A.BlipCompressionValues.Print, },
new A.Stretch(new A.FillRectangle())),
new PIC.ShapeProperties( new A.Transform2D(
new A.Offset() { X = 0L, Y = 0L },
new A.Extents() { Cx = 990000L, Cy = 792000L }),
new A.PresetGeometry(new A.AdjustValueList()){ Preset = A.ShapeTypeValues.Rectangle }))){ Uri = "https://schemas.openxmlformats.org/drawingml/2006/picture" })) { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U, EditId = "50D07946" });
Table table0 = new Table();
TableProperties props0 = new TableProperties(...code here...);
table0.AppendChild<TableProperties>(props0);
var tr0 = new TableRow();
var tc0 = new TableCell();
var pp0 = new ParagraphProperties(new SpacingBetweenLines() { After = "0" }, new Justification() { Val = JustificationValues.Center });
var rn0 = new Run(element);
var pg0 = new Paragraph(pp0, rn0);
tc0.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Dxa, Width = "1792" })), new HorizontalMerge { Val = MergedCellValues.Restart });
tc0.Append(pg0);
tr0.Append(tc0);
table0.Append(tr0);
body.Append(table0);
doc.Append(body);
...code here...
I have figured it out. The MSDN docs are to blame.
This line in the MSDN docs:
) { Uri = "https://schemas.openxmlformats.org/drawingml/2006/picture" })
is invalid, because of the https that should be http.
Changing that makes the document open without issue.
I'm using a responsive datatables on which I'm trying to handle click on a row, so you get redirected to a new page if you click on the row. This works fine, but if the table is collapsed I cannot show the child row, since clicking on the expand icon activates the row click and I get redirected.
So I'm trying to see if I can check whether the icon is clicked or not, but I cannot figure out how to do it
I have tried to use
$("#jobListTable").hasClass('collapsed')
in order to see, if the table is collapsed or not, but I still miss how to check what cell i clicked
Simplyfied fiddle can be found here: http://jsfiddle.net/Anja_Reeft/agouq6ts/5/
But my actually code is
$('#jobListTable tbody').on('click', 'tr', function (e) {
var data = oTable.row( this ).data();
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
oTable.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
var selectedTaskID = data.taskID;
var selectedJobNumber = data.jobNumber;
var selectedReqno = data.reqno;
var selectedPriority = data.priority;
var selectedCreatedBy = data.createdBy;
var selectedEmployeeInitials = data.employeeInitials;
var selectedShortDescription = data.shortDescription;
var selectedLongDescription = data.longDescription;
var selectedSourceReference = data.sourceReference;
var selectedAktivitetstype = data.aktivitetstype;
var selectedDueDatetime = data.dueDatetime;
var selectedRecurrence = data.recurrence;
var selectedStatus = data.status;
var selectedStatusColor = encodeURIComponent(data.statusColor);
var teamID = "";
if (sessionStorage.getItem("teamID")) {
teamID = "&teamID="+sessionStorage.getItem("teamID");
}
document.location.href="jobinfo.php?taskID="+selectedTaskID+"&jobNumber="+selectedJobNumber+"&reqno="+selectedReqno+"&priority="+selectedPriority+"&createdBy="+selectedCreatedBy+"&employeeInitials="+selectedEmployeeInitials+"&shortDescription="+selectedShortDescription+"&longDescription="+selectedLongDescription+"&sourceReference="+selectedSourceReference+"&aktivitetstype="+selectedAktivitetstype+"&dueDatetime="+selectedDueDatetime+"&recurrence="+selectedRecurrence+"&status="+selectedStatus+"&statusColor="+selectedStatusColor+teamID;
} );
Please let me know if you need futher information.
In cases anyone has a simular problem:
I changed my code so I added a button to each row
"columns": [
{
data: null, // can be null or undefined
defaultContent: '<button type="button" id="jobInfoBtn" class="btn btn-sm"><i class="fa fa-info-circle" aria-hidden="true"></i></button>',
},
and then changed my on click function
$('#jobListTable tbody').on('click', 'tr', function (e) {
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
oTable.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
} );
$('#jobListTable tbody').on('click', 'button', function (e) {
var data = oTable.row( $(this).parents('tr') ).data();
var selectedTaskID = data.taskID;
var selectedJobNumber = data.jobNumber;
var selectedReqno = data.reqno;
var selectedPriority = data.priority;
var selectedCreatedBy = data.createdBy;
var selectedEmployeeInitials = data.employeeInitials;
var selectedShortDescription = data.shortDescription;
var selectedLongDescription = data.longDescription;
var selectedSourceReference = data.sourceReference;
var selectedAktivitetstype = data.aktivitetstype;
var selectedDueDatetime = data.dueDatetime;
var selectedRecurrence = data.recurrence;
var selectedStatus = data.status;
var selectedStatusColor = encodeURIComponent(data.statusColor);
var teamID = "";
if (sessionStorage.getItem("teamID")) {
teamID = "&teamID="+sessionStorage.getItem("teamID");
}
document.location.href="jobinfo.php?taskID="+selectedTaskID+"&jobNumber="+selectedJobNumber+"&reqno="+selectedReqno+"&priority="+selectedPriority+"&createdBy="+selectedCreatedBy+"&employeeInitials="+selectedEmployeeInitials+"&shortDescription="+selectedShortDescription+"&longDescription="+selectedLongDescription+"&sourceReference="+selectedSourceReference+"&aktivitetstype="+selectedAktivitetstype+"&dueDatetime="+selectedDueDatetime+"&recurrence="+selectedRecurrence+"&status="+selectedStatus+"&statusColor="+selectedStatusColor+teamID;
} );
We have several podcasts, each with multiple episodes. Which itemtype should we return for the podcasts and episodes and which type should the item be?
We currently use itemtype.collection for the list of podcasts and episodes and each episode has itemtype.stream and the item is then set to streamMetadata.
This does however not allow for scrubbing.
Podcast:
var mediaData = new mediaCollection()
{
id = string.Format({0}:{1}:{2}",Prefix, moodId, moodItem.Id),
title = moodItem.Id,
itemType = itemType.collection,
onDemand = true,
liveNow = false,
language = "Norwegian",
liveNowSpecified = false,
albumArtURI = new albumArtUrl() { Value = moodItem.ImageUri.ToString(), requiresAuthentication = false, requiresAuthenticationSpecified = false}
};
Episode:
return new mediaMetadata
{
id = string.Format("{0}:{1}:{2}:{3}", Prefix, moodId, podcast.Id, episode.Publishdate.Ticks.ToString()),
title = episode.Title,
itemType = itemType.stream,
mimeType = "audio/mpeg",
onDemand = true,
onDemandSpecified = true,
language = "Norwegian",
Item = new streamMetadata()
{
currentShow = episode.Title,
logo = new albumArtUrl { Value = podcast.ImageUri.ToString(), requiresAuthentication = false, requiresAuthenticationSpecified = true },
currentHost = "Someone",
}
};
Your getMetadataResponse for podcasts should be of itemType track and should include canResume true. Check out this page for specific information and examples.
#target photoshop
var doc = app.activeDocument;
if (doc == null) {
throw "No Valid document available for export.";
}
if (doc.width != doc.height) {
throw "Image is not square";
}
var startState = doc.activeHistoryState; // save for undo
var initialPrefs = app.preferences.rulerUnits; // will restore at end
app.preferences.rulerUnits = Units.PIXELS; // use pixels
// Folder selection dialog
var destFolder = Folder.selectDialog( "Select Output folder");
// Save icons in PNG using Save for Web.
var sfw = new ExportOptionsSaveForWeb();
sfw.format = SaveDocumentType.PNG;
sfw.PNG8 = false; // use PNG-24
sfw.transparency = true;
doc.info = null; // delete metadata
var icons = [
{"name": "ic_launcher", "folder_name":"drawable-ldpi","size":36},
{"name": "ic_launcher", "folder_name":"drawable-mdpi","size":48},
{"name": "ic_launcher", "folder_name":"drawable-hdpi","size":72},
{"name": "ic_launcher", "folder_name":"drawable-xdpi","size":96},
{"name": "ic_launcher120x120", "folder_name":"Others","size":120},
{"name": "ic_launcher144x144", "folder_name":"Others","size":144},
{"name": "ic_launcher512x512", "folder_name":"Others","size":512},
];
var icon;
for (i = 0; i < icons.length; i++) {
icon = icons[i];
//Resolution was 72 while creating the psd for the images.
doc.resizeImage(icon.size, icon.size, null, ResampleMethod.BICUBIC);
var destFileName = icon.name + ".png";
var folderPath = new Folder(destFolder + "/" + icon.folder_name);
if(!folderPath.exists)
folderPath.create();
doc.exportDocument(new File( folderPath + "/"
+ destFileName), ExportType.SAVEFORWEB, sfw);
doc.activeHistoryState = startState; // undo resize
}
alert("Android Icons created!");
if (doc != null) {
doc.close(SaveOptions.DONOTSAVECHANGES);
app.preferences.rulerUnits = initialPrefs; // restore prefs
}
I am trying to automate the behavior of "save for web" in Photoshop. I am successful in creating images but its producing low quality image.
I am a newbie here. Not sure what is going wrong.
If i do it the usual gui way, it generates the good quality.
I've had problems with save for web. It might be easier just to save it as png
var pngFile = new File(afilePath);
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.embedColorProfile = true;
pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
pngSaveOptions.matte = MatteType.NONE; pngSaveOptions.quality = 1;
activeDocument.saveAs(pngFile, pngSaveOptions, false, Extension.LOWERCASE);
Admittedly this is a bit old but below answer above is wrong, as it uses JPG settings for saving a PNG. See below for a commented correction.
var image = app.activeDocument;
// set Destination
var destination = new Folder("~/Desktop/Output");
if ( ! destination.exists ) {
destination.create()
}
// Get original filename
var sourceName = decodeURI(image.name).replace(/\.[^\.]+$/, '');
// Set destination path
var destination = File(destination + "/" + sourceName + ".png");
// PNG save options to use below, using defaults
var pngOpts = new PNGSaveOptions();
pngOpts.compression = 0;
pngOpts.interlaced = false;
// Save
image.saveAs(destination, pngOpts, true, Extension.LOWERCASE);
How can I parse the tumblr response in order to retrieve items such as the photo link, title etc. According to Tumblr API, it's in JSON format but I can't seem to understand how to code it. Here a snippet of the response:
{
"blog_name" = myBlogName;
"can_reply" = 0;
caption = "<p>pending again</p>";
date = "2014-01-19 15:54:22 GMT";
followed = 0;
format = html;
highlighted = ();
id = 73836876344;
"image_permalink" = "http://bantaybayan.tumblr.com/image/73836876344";
liked = 0;
"note_count" = 0;
photos = (
{
"alt_sizes" = (
{
height = 558;
url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_1280.jpg";
width = 740;
},
{
height = 377;
url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_500.jpg";
width = 500;
},
{
height = 302;
url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_400.jpg";
width = 400;
},
{
height = 189;
url = "http://25.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_250.jpg";
width = 250;
},
{
height = 75;
url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_100.jpg";
width = 100;
},
{
height = 75;
url = "http://31.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_75sq.jpg";
width = 75;
}
);
caption = "";
"original_size" = {
height = 558;
url = "http://24.media.tumblr.com/f3fc43d081e3a6366e794b4f94a82d37/tumblr_mzno6mMXgr1tnzku0o1_1280.jpg";
width = 740;
};
}
);
"post_url" = "http://bantaybayan.tumblr.com/post/73836876344/pending-again";
"reblog_key" = LUOtTeAe;
"short_url" = "http://tmblr.co/Z89Zxo14n1L8u";
slug = "pending-again";
state = published;
tags = (
);
timestamp = 1390146862;
type = photo;
}
Thanks in advance
First of all, this doesn't look like JSON. Check it with a validator like JSONLint
It's easier if you use an editor for JSON data. There a lots of free online services http://jsoneditoronline.org/
For Objective-C, this SO question might help you out: Parsing JSON using Objective-C