Specific Data provider

  • 20 October 2020
  • 7 replies
  • 299 views

Userlevel 1

Can we develop a specific data provider type ?


7 replies

Userlevel 6
Badge +9

Hi @SadokHanini 

 

Yes, you can write your own data provider. Here’s some boilerplate code to help you get started; Acumatica will automatically detect your provider. This is from an existing provider that I wrote, I just removed everything that is specific and provided just a base template for you.

InternalImport/InternalExport are the functions you need to implement and where the actual work happens.

 

using PX.Api;
using PX.Data;
using PX.DataSync;
using PX.Objects.AP;
using PX.SM;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;

namespace Velixo.Sample
{
public class SampleProvider : PXSYBaseEncodedFileProvider, IPXSYProvider
{
protected const string MsgId = "MsgId";

public string DefaultFileExtension => ".xml";

public override string ProviderName => "My Provider";

public override string Extensiton => DefaultFileExtension;

public override PXFieldState[] GetSchemaFields(string objectName)
{
List<PXFieldState> ret = new List<PXFieldState>(base.GetSchemaFields(objectName));

//TODO: Add the fields your provider will be exposing
ret.Add(CreateFieldState(new SchemaFieldInfo(-1, MsgId)));

return ret.ToArray();
}

protected override List<PXStringState> FillParameters()
{
List<PXStringState> ret = base.FillParameters();

//TODO: Add the parameters your provider will be exposing

return ret;
}

protected override byte[] InternalExport(string objectName, PXSYTable table)
{
throw new NotImplementedException();
}

protected override void InternalImport(PXSYTable table)
{
throw new NotImplementedException();
}
}
}

 

Userlevel 4
Badge +1

What are you trying to create the provider for?  Some multi-table type import operations might not be ideal to use integration scenarios.

Userlevel 2
Badge

 

So this could work with any file extension or only the ones supported by acumatica (xml,  excel; csv..) ? 

public string DefaultFileExtension => ".xml";

Userlevel 1

What are you trying to create the provider for?  Some multi-table type import operations might not be ideal to use integration scenarios.

For a specific file with .TRA extension that doesn’t exist already in acumatica

Userlevel 1

Hi @SadokHanini 

 

Yes, you can write your own data provider. Here’s some boilerplate code to help you get started; Acumatica will automatically detect your provider. This is from an existing provider that I wrote, I just removed everything that is specific and provided just a base template for you.

InternalImport/InternalExport are the functions you need to implement and where the actual work happens.

 

using PX.Api;
using PX.Data;
using PX.DataSync;
using PX.Objects.AP;
using PX.SM;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;

namespace Velixo.Sample
{
public class SampleProvider : PXSYBaseEncodedFileProvider, IPXSYProvider
{
protected const string MsgId = "MsgId";

public string DefaultFileExtension => ".xml";

public override string ProviderName => "My Provider";

public override string Extensiton => DefaultFileExtension;

public override PXFieldState[] GetSchemaFields(string objectName)
{
List<PXFieldState> ret = new List<PXFieldState>(base.GetSchemaFields(objectName));

//TODO: Add the fields your provider will be exposing
ret.Add(CreateFieldState(new SchemaFieldInfo(-1, MsgId)));

return ret.ToArray();
}

protected override List<PXStringState> FillParameters()
{
List<PXStringState> ret = base.FillParameters();

//TODO: Add the parameters your provider will be exposing

return ret;
}

protected override byte[] InternalExport(string objectName, PXSYTable table)
{
throw new NotImplementedException();
}

protected override void InternalImport(PXSYTable table)
{
throw new NotImplementedException();
}
}
}

 

Thnk u :) 
where can i find this code to modify it ? thnx 

Userlevel 6
Badge +9

@SadokHanini this is it, it’s the full provider, without an actual implementation.. you just need to add this to your project, and implement InternalImport and/or InternatExport based on your requirements. Here’s another link you will find useful: https://asiablog.acumatica.com/2016/09/custom-integration-services-data.html

Userlevel 1

@SadokHanini this is it, it’s the full provider, without an actual implementation.. you just need to add this to your project, and implement InternalImport and/or InternatExport based on your requirements. Here’s another link you will find useful: https://asiablog.acumatica.com/2016/09/custom-integration-services-data.html

Thanks :) 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved