CheckoutManager DownloadFilesAsync - How to use for downloading large amounts of files?

Hi Community,

does anyone of you have sample code for "downloadFilesAsync" C# function?

Aras Innovator provides the CheckoutManager to download Files from the Filevault to the server. There are a couple of examples that show how to use "DownloadFiles", but I have found none that shows how to use "DownloadFilesAsync".

This piece of code does nothing:

// Create a checkout manager to download all of the files to the server
Aras.IOME.CheckoutManager cm = new Aras.IOME.CheckoutManager(files);
//cm.DownloadFiles(filePath, 4);
cm.DownloadFilesAsync(filePath, 4);

When comparing Aras version of "DownloadFileAsync" to regular WebClient DownloadFilesAsync code, I think Async downloads need some additional event handlers. 

So I tried something like this:

// Create a checkout manager to download all of the files to the server
using(Aras.IOME.CheckoutManager cm = new Aras.IOME.CheckoutManager(files))
{
    //cm.DownloadFiles(filePath, 4);
    cm.DownloadFilesAsync(filePath, 4);
    cm.DownloadFileCompleted += DownloadFileCompletedEventHandler;
}


return this;
}
// Handle the DownloadFileCompleted event
private static void DownloadFileCompletedEventHandler(object sender, EventArgs e)
{

"DownloadFileCompleted" is not listed in the official Aras Innovator 12.0 .NET API Reference. But when using this function I didn´t get an error message in the Method editor, so the Innovator API definitely supports it.

But the 2nd sample of course still does nothing. 

Does anyone know more?

Best regards!

Angela

  • No one knows more?

    Basically I want to built a mass download tool where I can abort long running download tasks. 

  • 0 オフライン in reply to AngelaIp

    In addition to DownloadFileCompleted, CheckoutManager also has the DownloadFilesCompleted event. May be you need to use second one for async download?

    And there is DownloadFilesProgressChanged event with ProgressPercentage integer property in it's EventArgs.

  • Hi Alaxala,

    thanks for the input! I made some progress and I can confirm we need the event handlers. 

    I discovered that async code in server Method is something we cannot achieve in the standard Method editor.

    Good old Chris even gave an explanation years ago:

    https://community.aras.com/f/development/6522/how-to-call-async-methods-of-c-custom-library-from-aras-server-methods

    --> C# code basically gets plugged into another method before it gets compiled. This other method that your code gets inserted into does not use the async keyword, so you will not be able to take advantage of asynchronous code for your server Method items.

    So we have to build something outside the Method editor with Visual Studio. I was able to build a standalone EXE that can do the connection and downloads something. But I want something that blends into our Innovator.

    Does anyone has experience with building ASP.NET Webapplications with VC? My idea is to build something that I than can integrate as TOC View. This should be possible if I link the app IIS and then make a link to the target page in my TOC View.  That´s the theory.

    @ Community:  Which VC project template would you use for building a custom app that can be integrated into the existing Aras Client? 
    Especially when we have to consider that Aras changed to ASP.NET Core in the new releases (do aspx pages still work?!?!)?


    Would be happy if someone can share some experience!

    Angela

  • 0 オフライン in reply to AngelaIp

    Yes, the Aras Innovator inserts the body of our C# methods into the method of a special class created for each user server method. So there is code running before and after our. But AFAIK, this code defined in the method-config.xml on the server. I haven't tried it myself, but may be if you add your own template to this file and specify it as template for your method you can use async calls.

    Are you use Aras Innovator Method Plugin for Visual Studio? I haven't used the Aras method editor for a long time. It is much more convenient to write code in the Visual Studio with syntax highlight, intellisense and so on, and then just copy it to Aras. And when you open method from Aras using this plugin, it downloads entire code, including hidden from method editor.