Ok, so I did another thing.
People have been requesting to be able to pull down the files to develop BPMs locally, to
do development in more advanced IDEs.
This is the same way the client does it.
Please see these threads for previous discussions:
Anywho,
The initial dashboard is done in the Kinetic Web Client.
What this dashboard does is utilize the GetAssemblyBytes Function of the Service ICE → EcfTools.
If you provide that Business Object with an Assembly name, it will give you the Assembly in bytes.
The list of Assemblies available can be had by querying the Ice.BO.BpMethod.GetAvailableReferences
Business Object, and ask for “Assemblies”.
This is accomplished in a UBAQ directive on the GetList in a BAQ to drive the dashboard.
The code is as follows:
// UBAQ Directive:
// Post-Processing Directive on GetList
//ref: Ice.Contracts.BO.BpMethod
//using Ice.Assemblies;
using (Ice.Contracts.BpMethodSvcContract bpMethod = ServiceRenderer.GetService<Ice.Contracts.BpMethodSvcContract>(Db))
{
List<Ice.Contracts.BO.BpMethod.ReferenceInfo> referenceAssemblies = bpMethod.GetAvailableReferences("Assemblies");
int x = 0;
List<ResultsUbaqRow> resultsTemp = new List<ResultsUbaqRow>();
foreach(Ice.Contracts.BO.BpMethod.ReferenceInfo refAss in referenceAssemblies)
{
ResultsUbaqRow newRow = new ResultsUbaqRow();
newRow.Calculated_AssemblyName = refAss.Name;
newRow.Calculated_FileName = refAss.FileName;
newRow.Calculated_Version = refAss.Version;
string fileNameNoExt = System.IO.Path.GetFileNameWithoutExtension(refAss.FileName);
newRow.Calculated_ZipName = fileNameNoExt + ".zip";
newRow.RowIdent = x.ToString(); x++;
resultsTemp.Add(newRow);
}
result.Results.Clear();
result.Results.AddRange(resultsTemp);
};
The dashboard was created with the Classic Client Dashboard Designer, and is only the basics.
I published it as a Kinetic App, and modified from there.
Note: This can’t be server paged, find that in the grid and turn it off if you are trying
to recreate this from scratch.
I added a few textboxes and a button to download the files:
I added widget code to populate the event for download:
This code fills the CallContextBPMData with:
CallContextBPMData.ShortChar01 -> [GAB] (Trigger Phrase)
CallContextBPMData.ShortChar02 -> Assembly Name
CallContextBPMData.ShortChar03 -> File Name
Then we are going to do a little Tom-Foolery with the file-transfer-erp widget…
You can only download files with the file-transfer-erp widget from special folders, so no dice
there, however, it’s return type is byte, and one of it’s parameters is file name…
So what I have done, is pass some of my data I need in the CallContextBPMData
, and the
zip file name as a parameter for file-transfer-erp.
There is a pre-processing method directive on Ice.Lib.FileTransfer.DownloadFile
which checks for the trigger phrase.
If it finds it, we hijack the method, call EcfTools.GetAssemblyBytes
, and return that data
after we zip it.
I was returning just the dll file, but the browsers weren’t real happy, so now it’s zipped.
Code for Method Directive:
// Method Directive:
// Pre-Processing Directive on Ice.Lib.FileTransfer.DownloadFile
// Ice -> Simple Service -> FileTransfer
//ref: Ice.Contracts.Lib.EcfTools
//using Ice.Assemblies;
//using System.IO;
//using System.IO.Compression;
Func<string, byte[], byte[]> ZipByteArray = (fileName, fileBytes) =>
{
byte[] retBytes = null;
using (MemoryStream zipMS = new MemoryStream())
{
using (ZipArchive zipArchive = new ZipArchive(zipMS, ZipArchiveMode.Create, true))
{
var zipArchiveEntry = zipArchive.CreateEntry(fileName, CompressionLevel.Fastest);
using (var zipStream = zipArchiveEntry.Open())
{
zipStream.Write(fileBytes, 0, fileBytes.Length);
}
}
zipMS.Flush();
retBytes = zipMS.ToArray();
};
return retBytes;
};
//Processing begins here: -->
if(callContextBpmData.ShortChar01.ToLower() == "[gab]")
{
string assemblyToGet = callContextBpmData.ShortChar02;
string fileNameToGet = callContextBpmData.ShortChar03;
using (Ice.Contracts.EcfToolsSvcContract ecfTools = ServiceRenderer.GetService<Ice.Contracts.EcfToolsSvcContract>(Db))
{
byte[] resultBytes = ecfTools.GetAssemblyBytes(assemblyToGet);
result = ZipByteArray(fileNameToGet, resultBytes);
};
MarkCallCompleted();
}
Finally we clear the CallContextBPMData.
You choose your file, and click Download: