🌟 ExportAllTheThings - Export Your Custom Objects

2 Likes

Done. Not in the library yet, but here ya go…

ExportAllTheThings.ExportAllKineticCustomLayers
/*
* ==========================================================================================
* AUTHOR:    Kevin Lincecum
* COPYRIGHT: Kevin Lincecum 2024
* LICENSE:   MIT
* ==========================================================================================
* Library:     ExportAllTheThings
* Function:    ExportAllKineticCustomLayers
* Description: This plugin downloads all custom Kinetic layers.
* ==========================================================================================
* 
* INPUTS: NONE
*
* OUTPUTS:
*   BOOL:   Success        -> Function Success / Failure
*   STRING: ListErrorsJson -> Json Serialized List<Exception>
*   STRING: ZipBase64      -> Base64 Encoded Byte Array
*
* CHANGELOG:
* 09/04/2024 | klincecum | Kevin Lincecum | Initial Implementation
*
* ==========================================================================================
*/
  //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.MetaFXSvcContract>(metaFX =>
     {
        //Create a request to list the apps       
        var request = new Epicor.MetaFX.Core.Models.Applications.ApplicationRequest()
        {
            Type = "view",
            SubType = "",
            SearchText = "",
            IncludeAllLayers = true
        };

        //Get a list of apps
        List<Epicor.MetaFX.Core.Models.Applications.Application> applications = metaFX.GetApplications(request);
        
        //Create an export request list 
        List<Epicor.MetaFX.Core.Models.Layers.EpMetaFxLayerForApplication> applicationList = new List<Epicor.MetaFX.Core.Models.Layers.EpMetaFxLayerForApplication>();

        //Loop through the list and add custom apps to the export list
        foreach(var item in applications.Where(x => x.SystemFlag == false))
        {
            applicationList.Add(new Epicor.MetaFX.Core.Models.Layers.EpMetaFxLayerForApplication() { Id = item.Id });
        }
        
        //Export the apps and return the zip file data as a Base64 encoded string.
        ZipBase64 = metaFX.ExportLayers(applicationList);
     }); 
     
     Success = true;
     
  //****   
  }
  catch (Exception ex)
  {
      Success = false;
      ListErrorJson = AddExceptionToList(ex, ListErrorJson);
  }
  finally
  {
      //Maybe later?
  }
ExportAllTheThings.ExportAllKineticSystemLayers
/*
* ==========================================================================================
* AUTHOR:    Kevin Lincecum
* COPYRIGHT: Kevin Lincecum 2024
* LICENSE:   MIT
* ==========================================================================================
* Library:     ExportAllTheThings
* Function:    ExportAllKineticSystemLayers
* Description: This plugin downloads all system Kinetic layers.
* ==========================================================================================
* 
* INPUTS: NONE
*
* OUTPUTS:
*   BOOL:   Success        -> Function Success / Failure
*   STRING: ListErrorsJson -> Json Serialized List<Exception>
*   STRING: ZipBase64      -> Base64 Encoded Byte Array
*
* CHANGELOG:
* 09/04/2024 | klincecum | Kevin Lincecum | Initial Implementation
*
* ==========================================================================================
*/
  //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.MetaFXSvcContract>(metaFX =>
     {
        //Create a request to list the apps       
        var request = new Epicor.MetaFX.Core.Models.Applications.ApplicationRequest()
        {
            Type = "view",
            SubType = "",
            SearchText = "",
            IncludeAllLayers = true
        };

        //Get a list of apps
        List<Epicor.MetaFX.Core.Models.Applications.Application> applications = metaFX.GetApplications(request);
        
        //Create an export request list 
        List<Epicor.MetaFX.Core.Models.Layers.EpMetaFxLayerForApplication> applicationList = new List<Epicor.MetaFX.Core.Models.Layers.EpMetaFxLayerForApplication>();

        //Loop through the list and add custom apps to the export list
        foreach(var item in applications.Where(x => x.SystemFlag == true))
        {
            applicationList.Add(new Epicor.MetaFX.Core.Models.Layers.EpMetaFxLayerForApplication() { Id = item.Id });
        }
        
        //Export the apps and return the zip file data as a Base64 encoded string.
        ZipBase64 = metaFX.ExportLayers(applicationList);
     }); 
     
     Success = true;
     
  //****   
  }
  catch (Exception ex)
  {
      Success = false;
      ListErrorJson = AddExceptionToList(ex, ListErrorJson);
  }
  finally
  {
      //Maybe later?
  }
1 Like

In the library at the top, and on github.

1 Like

I have been a big advocate of just splitting custom stuff from the std db. Just having a setting in either your database settings or server settings that allows you to define what custom dB everthing is pointing to is a sensible approach. I have seen this approach used successfully with other software

I hope Epicor continue down the path of the common dB.

Data related to ud tables may be of concern, not really sure how to explain what I mean there, but if we are only talking about just the definition of the fields should be OK…

Having everything custom in a separate dB then allows you to compare customs pretty easily Compare and Synchronize the Data of Two Databases - SQL Server Data Tools (SSDT) | Microsoft Learn

Which makes the upgrade process a lot easier not to mention development against the demo dB @Mark_Wonsil :grin:

Awesome work @klincecum

2 Likes

UD fields β†’ Done, not posted yet

Classic Form Customizations β†’ Done, not posted yet

Form customizations are currently exported as rows tablesets, because putting it the xml export format is hard. Will revisit. (maybe? :rofl: )

1 Like

It’s a real nice templating system that lets him do this so quickly.

1 Like