Esempio della procedura di esportazione
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Synchronization].[GetCustomData]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [Synchronization].[GetCustomData]
GO
CREATE FUNCTION [Synchronization].[GetCustomData]
(
@syncType int,
@documentId int
)
RETURNS XML
AS
BEGIN
declare @data XML;
set @data = (select [Implementations].[GetSpecificData](@syncType, @documentId)
for xml path('SpecificElements'), root('CustomData'), type)
return @data
END
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Implementations].[GetSpecificData]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [Implementations].[GetSpecificData]
GO
CREATE FUNCTION [Implementations].[GetSpecificData]
(
@syncType int,
@documentId int
)
RETURNS XML
AS
BEGIN
declare @specifics XML;
set @specifics = (select
el.OrdinalNumber as [@OrdinalNumber],
el.SpecificCode as [@SpecificCode],
SpecificTypeId as [@SpecificTypeId]
from ExtensionSchema.SpecificDataTable el
inner join Documents.TradeDocuments doc on el.DocumentId = doc.Id
where el.DocumentId = @documentId and @syncType = 45
for xml path('row'))
return @specifics
END
GO
Esportazione dei dati da POS
Esportazione dei dati da POS
È anche possibile aggiungere i propri dati agli oggetti creati in POS e sincronizzati verso il sistema ERP. Per farlo bisogna sovrascrivere nel database POS la funzione Synchronization.GetCustomData. La funzione restituisce XML e come argomenti assume il tipo dell’oggetto sincronizzato (int) e il suo identificatore (int). La funzione viene avviata separatamente pe rogni ogetto che va inviato al sistema ERP.
Importazione in DataService
L’importazione dei dati viene eseguita in codice C#. Ogni oggetto elaborato possiede la proprietà CustomData, del tipo XEelement. I dati vanno deserializzati e elaborati manualmente.
Le informazioni utili possono essere scaricate dalla classe statica WebServiceHelper. Per ciascuna chiamata del metodo del contratto di DataService è possibile ottenere le seguenti informazioni sull’istanza POS:
– codice POS
– GUID POS
– codice profilo
– versione
Esempio di importazione su DataService
[DataServiceBusinessModule]
public static class Module
{
[MethodInitializer]
public static void Initialize()
{
var customerService = IoC.Container.Resolve<IDataCustomerExtensionPointService>();
customerService.AfterSaveCustomerEvent += CustomerServiceEx_AfterSaveCustomerEvent;
}
private static void CustomerServiceEx_AfterSaveCustomerEvent(object sender, DTOResultEventArgs<Queue.DTO.CustomerDTO, string, int> e)
{
Console.WriteLine("{0}: {1}", e.Argument, e.EntityRow.CustomData.Name);
var xe = e.EntityRow.CustomData; // XElement
}
}