Rules for a plugin:
- Create a function (plugin) in the “ExportAllTheThings” Library.
- Start the function name with “Export”.
- Return the “Success”, “ListErrorJson”, and “ZipBase64” fields. (Helper included in Library)
Here is the BAQ one. Still needs some tlc, but it’s done.
//Helper Functions Section----------------------------------------------------------------------------------------------------------------------------------------->
Func<Exception, string, string> AddExceptionToList = (exception, exceptionListJson) =>
{
List<Exception> exceptionList = new List<Exception>(){exception};
if(!String.IsNullOrEmpty(exceptionListJson)) { try { exceptionList.AddRange( JsonConvert.DeserializeObject<List<Exception>>(exceptionListJson) ); } catch {} }
return JsonConvert.SerializeObject(exceptionList);
};
//<-----------------------------------------------------------------------------------------------------------------------------------------Helper Functions Section
try
{
//****
CallService<Ice.Contracts.BAQDesignerSvcContract>(baqD =>
{
Dictionary<string, string> mainZipFileDictionary = new Dictionary<string, string>();
bool more = false;
BAQDesignerListTableset baqListTS = baqD.GetList("SystemFlag=false", 0, 1, out more);
foreach(DynamicQueryDesignerListRow item in baqListTS.DynamicQueryDesignerList)
{
try
{
Dictionary<string, string> options = new Dictionary<string, string>();
byte[] itemBytes = baqD.ExportBaq(item.QueryID, ref options, out logResult);
string itemBase64 = Convert.ToBase64String(itemBytes);
mainZipFileDictionary.Add($"{item.QueryID}.baq", itemBase64);
}
catch (Exception iEx)
{
iEx.Data.Add("QueryID", item.QueryID);
ListErrorJson = AddExceptionToList(iEx, ListErrorJson);
}
}
string fileDictionaryJson = JsonConvert.SerializeObject(mainZipFileDictionary);
ZipBase64 = ThisLib.ZipFiles(fileDictionaryJson);
});
Success = true;
//****
}
catch (Exception ex)
{
Success = false;
ListErrorJson = AddExceptionToList(ex, ListErrorJson);
}
finally
{
//?
}