Discord .NET Value of type EmbedBuilder cannot be converted to Embed - vb.net

As the title says i get "Value of type EmbedBuilder cannot be converted to Embed" error.
This is the code i'm trying right now :
If msg.Equals("gDurum") Then
Dim eb As New EmbedBuilder With {
.Title = "Sunucu Bilgisi",
.Color = New Color(255, 0, 0),
.ImageUrl = "https://cache.gametracker.com/server_info/185.198.73.27:27015/b_560_95_1.png",
.Description = "Deneme"
}
eb.Build()
Await message.Channel.SendMessageAsync("", False, eb)

OK. I found the solution. I was trying to pass the EmbedBuilder instead of Embed.
Here's my new code :
If msg.Equals("gDurum") Then
Dim eb As New EmbedBuilder With {
.Title = "Sunucu Bilgisi",
.Color = New Color(255, 0, 0),
.ImageUrl = "https://cache.gametracker.com/server_info/185.198.73.27:27015/b_560_95_1.png",
.Description = "Deneme"
}
Await message.Channel.SendMessageAsync("", False, eb.Build())

For those who are looking at the official code example might encounter type mismatch while compiling.
Make sure to build Discord.Embed into a Rich Embed which is ready to be sent.
Corrected & working code example for this:
[Command("embed")]
public async Task SendRichEmbedAsync()
{
var embed = new EmbedBuilder
{
// Embed property can be set within object initializer
Title = "Hello world!"
Description = "I am a description set by initializer."
};
// Or with methods
embed.AddField("Field title",
"Field value. I also support [hyperlink markdown](https://example.com)!")
.WithAuthor(Context.Client.CurrentUser)
.WithFooter(footer => footer.Text = "I am a footer.")
.WithColor(Color.Blue)
.WithTitle("I overwrote \"Hello world!\"")
.WithDescription("I am a description.")
.WithUrl("https://example.com")
.WithCurrentTimestamp();
await ReplyAsync(embed: embed.Build());
}

Related

Swagger UI doesn't support uploading a file properly for RestEasy

I use a JAX-RS (RestEasy) along with a Swagger. One of my endpoint can upload a file. Defined way to upload the file (in RestEasy) is to provide a org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput as a parameter.
Here is my endpoint:
#PUT
#Path("/apis/{id}/file")
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Produces(MediaType.APPLICATION_JSON)
#ApiOperation(value = "Registers a file.", code = 201, nickname = "registerFile")
#ApiResponses(
value = {
#ApiResponse(code = 201, message = "File created.",
response = FileCreated.class),
#ApiResponse(code = 400, message = "Invalid parameters."),
#ApiResponse(code = 404, message = "API is not found.")})
Response registerFile(
#ApiParam(value = "API ID.", required = true) #PathParam("id") String apiId,
#ApiParam(value = "File to register.", required = true, type = "file", name = "apiFile")
MultipartFormDataInput apiFile) throws AppException;
What is the problem?
Unfortunately, swagger-ui generates a schema based on the inner properties of the MultipartFormDataInput instead of a button to upload the file.
I tried use a #FormParam annotation (to indicate that the providing parameter should be interpreted as file) along with the MultipartFormDataInput parameter, but then the app doesn't want to compile.
Question: Is there any solution/workaround to provide the button to upload the file in the swagger-ui?
The solution is removing #ApiParam from your apiFile argument and adding #ApiImplicitParam (which is not bound to Jax-RS and allows defining parameters manually) above the method :
#ApiImplicitParams({#ApiImplicitParam (value = "File to register.", required = true, dataType = "file", name = "apiFile", paramType="formData")})
The final solution
The final solution includes a selected answer, but instead of removing #ApiParam we should add #ApiParam(hidden = true). Why?
If we remove #ApiParam, there are two fields: apiId, body with the inner properties of the MultipartFormDataInput and the button to upload the file in the swagger-ui. This body field is a side effect. To fix this issue we should provide #ApiParam(hidden = true), then there are the field with apiId and the button to upload the file in the swagger-ui.
BTW: I tested below code for swagger-ui in 1.5.12 version.
#PUT
#Path("/apis/{id}/file")
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Produces(MediaType.APPLICATION_JSON)
#ApiOperation(value = "Registers a file.", code = 201, nickname = "registerFile")
#ApiResponses(
value = {
#ApiResponse(code = 201, message = "File created.",
response = FileCreated.class),
#ApiResponse(code = 400, message = "Invalid parameters."),
#ApiResponse(code = 404, message = "API is not found.")})
#ApiImplicitParams(
#ApiImplicitParam(value = "File to register.", required = true, dataType = "file",
name = "apiFile", paramType = "formData"))
Response registerFile(
#ApiParam(value = "API ID.", required = true) #PathParam("id") String apiId,
#ApiParam(hidden = true) MultipartFormDataInput apiFile) throws AppException;

Acumatica: How do I get an attachment file from SO Screen using Web API?

I'd folow the example From I200 pdf for a stock item, but I dont' know how to download the file from an Sales Order. Does anybody has a clue?
IN202500Content stockItemSchema = context.IN202500GetSchema();
var commands = new Command[]
{
new Value
{
Value = "AAMACHINE1",
LinkedCommand = stockItemSchema.StockItemSummary.InventoryID
},
new Value
{
FieldName = "T2MCRO.jpg",
LinkedCommand =
stockItemSchema.StockItemSummary.ServiceCommands.Attachment
}
};
var stockItemAttachment =
context.IN202500Export(commands, null, 1, false, true);
You were almost there, in the "stockItemAttachment" variable you should have the content of the file "T2MCRO.jpg" in byte format.
The only thing you have left to do is to write it to your file system.
You can use the following command :
File.WriteAllBytes(Path, Convert.FromBase64String(stockItemAttachment[0][0]));

Google UI Apps Script: Blank PDF when converting spreadsheet to PDF

I have a piece of code I am testing, in an attempt to learn how to convert a spreadsheet into a pdf using Google UI Apps Script. The code creates and writes to the spreadsheet but the pdf attachment is blank. Would appreciate any help to get this to work. Thanks.
var newSpreadsheet = SpreadsheetApp.create("My Test Sheet");
var columnNames = ["First Name", "Last Name", "Department"];
newSpreadsheet.getSheetByName('Sheet1').activate();
var headersRange = newSpreadsheet.getActiveSheet().getRange(1, 1, 1, columnNames.length);
headersRange.setValues([columnNames]);
var pdf = DocsList.getFileById(newSpreadsheet.getId()).getAs('application/pdf').getBytes();
var attach = {fileName:'My Test PDF.pdf',content:pdf, mimeType:'application/pdf'};
// Send email
MailApp.sendEmail("myemail#email.com", "subject", "message", {attachments:[attach]});
You should not use DocList anymore. Use DriveApp instead. Below a solution with little modifications of your code:
function toPdf(id){
SpreadsheetApp.flush();
// var ssDoc = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId());
var ssDoc = DriveApp.getFileById(id);
var pdf = DriveApp.createFile(ssDoc.getAs(MimeType.PDF));
return pdf.getBlob().getBytes();
}
function user2943227(){
var newSpreadsheet = SpreadsheetApp.create("My Test Sheet");
var columnNames = ["First Name", "Last Name", "Department"];
// newSpreadsheet.getSheetByName('Sheet1').activate();
var headersRange = newSpreadsheet.getActiveSheet().getRange(1, 1, 1, columnNames.length);
headersRange.setValues([columnNames]);
// var pdf = DocsList.getFileById(newSpreadsheet.getId()).getAs('application/pdf').getBytes();
var pdf = toPdf(newSpreadsheet.getId());
var attach = {fileName:'My Test PDF.pdf',content:pdf, mimeType:'application/pdf'};
// Send email
MailApp.sendEmail("myemail#email.com", "subject", "message", {attachments:[attach]});
}

convert HTML into word in .net application

Can anyone suggest how to show value stored in SQL in HTML form to word file. I am using open xml tool to generate my word from my asp.net MVC application and it works fine but now I am stuck in one point where there is a bullet points entry stored in my DB field and I have to show it in my table cell text property?
actual value stored in DB field: "<ul><li>tapan</li><li>gupta</li></ul><p> </p>"
Run run362 = new Run();
RunProperties runProperties358 = new RunProperties();
RunFonts runFonts851 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "Helvetica", HighAnsi = "Helvetica", ComplexScript = "Arial" };
FontSize fontSize833 = new FontSize() { Val = "20" };
Languages languages772 = new Languages() { EastAsia = "zh-HK" };
runProperties358.Append(runFonts851);
runProperties358.Append(fontSize833);
runProperties358.Append(languages772);
Text text299 = new Text() { Space = SpaceProcessingModeValues.Preserve };
text299.Text = **my field value**
run362.Append(runProperties358);
run362.Append(text299);
Try Html to Open XML.
Refer Here : http://html2openxml.codeplex.com/
Hope this helps!

Adobe Echo Sign Sending PDF file

I am working on Adobe Echo sign,I have downloaded the sample code from their website, I am using this sample code for sendingdocument, it has some code missing in sendDocument method so I have changed it. It's giving SoapHeader Exception,with nothing in InnerException,
{"apiActionId=XHZI4WF4BV693YS"}
below is my code of sending document
public static void sendDocument(string apiKey, string fileName, string recipient)
{
ES = new EchoSignDocumentService16();
FileStream file = File.OpenRead(fileName);
secure.echosign.com.FileInfo[] fileInfos = new secure.echosign.com.FileInfo[1];
fileInfos[0] = new secure.echosign.com.FileInfo(fileName, null, file);
SenderInfo senderInfo = null;
string[] recipients = new string[1];
recipients[0] = recipient;
DocumentCreationInfo documentInfo = new DocumentCreationInfo(
recipients,
"Test from SOAP: " + fileName,
"This is neat.",
fileInfos,
SignatureType.ESIGN,
SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
);
DocumentKey[] documentKeys;
senderInfo = new SenderInfo(recipient, "password", "APIKEY");
documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
Console.WriteLine("Document key is: " + documentKeys[0].documentKey);
}
its giving exception on this line
documentKeys = ES.sendDocument(apiKey, senderInfo, documentInfo);
Can anyone suggest some sample code of Adobe Echo Sign?
On the account page of your login there is an API log you can check. If you check the log entry for your request you may find more information there.
I can't see anything immediately wrong with your code however the EchoSign API guide says that the 'tos' field is deprecated and that the recipients field should be used instead. Helpfully this means you can't use the paramaterised constructor. Try creating your document creation info as such (this is C# but if you need Java it should be straightforward to figure out):
RecipientInfo[] recipientInfo = new RecipientInfo[1];
recipientInfo[0] = new RecipientInfo
{
email = "recipient",
role = RecipientRole.SIGNER,
roleSpecified = true
};
DocumentCreationInfo documentCreationInfo = new DocumentCreationInfo
{
recipients = recipientInfo,
name = "Test from SOAP: " + fileName,
message = "This is neat.",
fileInfos = fileInfos,
signatureType = SignatureType.ESIGN,
signatureFlow = SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED
};
Note that when using the recipientInfo array it seems that the roleSpecified field must be set to true. This little field tripped me up for ages and I was receiving errors similar to yours.