JADE Environment Development Ideas

What's new in the upcoming JADE release?

IMPROVED DEVELOPER EFFICIENCY. ENHANCED SECURITY. SMOOTHER INTEGRATION

The JADE 2022 release meets tomorrow’s business demands.


Start your update to JADE's latest release

Add support for Drag and Drop Email - setDragAndDropFiles()

.Net Control built to allow drag and drop, the files + directory is now natively supported in Jade 2018 but the drag and drop email is not. See - // drag and drop from embedded attachment in email

// this event fires when the drop has occurred

private void DropTarget_DragDrop(object sender, DragEventArgs e)

{

// drag and drop from file system

if (e.Data.GetDataPresent(DataFormats.FileDrop))

{

// support multiple drag and drop from file system

string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

foreach (string file in files)

{

// call our internal OnDropEvent -> this will test if we have a Jade event handler assigned

OnDropEvent(file);

}

}

// drag and drop from embedded attachment in email

else if (e.Data.GetDataPresent("FileGroupDescriptor"))

{

Stream stream = (Stream)e.Data.GetData("FileGroupDescriptor");

// no nice api here that I could find.. very crude

// let's find the fileName

byte[] fileGroupDescriptor = new byte[512];

stream.Read(fileGroupDescriptor, 0, 512);

StringBuilder fileName = new StringBuilder("");

for (int i = 76; fileGroupDescriptor[i] != 0; i++)

{ fileName.Append(Convert.ToChar(fileGroupDescriptor[i])); }

string theFile = fileName.ToString();

// delete the file if it exists in your %temp% folder

FileInfo tempFile = new FileInfo(Path.Combine(Path.GetTempPath(), theFile));

if (File.Exists(tempFile.FullName))

{

tempFile.Delete();

}

// read the file contents into a memory stream and save it to disk

// e.g C:\Users\DurajM\AppData\Local\Temp\<fileName>

MemoryStream memoryStream = (MemoryStream)e.Data.GetData("FileContents", true);

Byte[] binary = new Byte[memoryStream.Length];

memoryStream.Position = 0;

memoryStream.Read(binary, 0, (int)memoryStream.Length);

FileStream fileStream = new FileStream(tempFile.FullName, FileMode.CreateNew);

fileStream.Write(binary, 0, (int)memoryStream.Length);

fileStream.Close();

// always good to make sure we actually created the file

if (File.Exists(tempFile.FullName))

{

// call our internal OnDropEvent -> this will test if we have a Jade event handler assigned

OnDropEvent(tempFile.FullName);

// delete the file from your %temp% folder

tempFile.Delete();

}

}

}

  • Michael Duraj
  • Aug 18 2020
  • Needs review
  • Attach files