private string toJson(VSITVENC entidade) { string result = string.Empty; dynamic record = new ExpandoObject(); record.Code = entidade.RecId.ToString(); record.Name = entidade.RecId.ToString(); record.U_STATUS = (VSITVENC.VSITVENCIntegrationStatus.Created); record.U_LAST_UPDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); record.U_DATA_INCLUSAO = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); record.U_LOJ_ORG = entidade.loj_org; record.U_DIG_ORG = entidade.dig_org; record.U_NRO_NOTA = entidade.nro_nota; record.U_SERIE = entidade.serie; record.U_DTA_AGENDA = entidade.dta_agenda; record.U_OPER = entidade.oper; record.U_DTA_VENCTO = entidade.dta_vencto; record.U_VLR_PARCELA = entidade.vlr_parcela; record.U_VLR_DESCONTO = entidade.vlr_desconto; record.U_VLR_ACR_FIN = entidade.vlr_acr_fin; record.U_FORA_PGTO = entidade.fora_pgto; record.U_VLR_COMISSAO = entidade.vlr_comissao; result = JsonConvert.SerializeObject(record); return(result); }
private VSITVENC toRecord(dynamic record) { VSITVENC entidade = new VSITVENC(); entidade.RecId = Guid.Parse(record.Code); entidade.status = (VSITVENC.VSITVENCIntegrationStatus)record.U_STATUS; entidade.lastupdate = record.U_LAST_UPDATE; entidade.loj_org = record.U_LOJ_ORG; entidade.dig_org = record.U_DIG_ORG; entidade.nro_nota = record.U_NRO_NOTA; entidade.serie = record.U_SERIE; entidade.dta_agenda = record.U_DTA_AGENDA; entidade.oper = record.U_OPER; entidade.dta_vencto = record.U_DTA_VENCTO; entidade.vlr_parcela = record.U_VLR_PARCELA; entidade.vlr_desconto = record.U_VLR_DESCONTO; entidade.vlr_acr_fin = record.U_VLR_ACR_FIN; entidade.fora_pgto = record.U_FORA_PGTO; entidade.vlr_comissao = record.U_VLR_COMISSAO; return(entidade); }
async public Task Insert(VSITVENC entity) { IBatchProducer batch = _serviceLayerConnector.CreateBatch(); entity.status = Data.Model.Integration.VSITVENC.VSITVENCIntegrationStatus.Importing; string record = toJson(entity); batch.Post(HttpMethod.Post, "/U_VSITINVOICEVENC", record); ServiceLayerResponse response = await _serviceLayerConnector.Post(batch); // // Erro no protocolo http ou na estrutura do arquivo // if (!response.success) { string message = $"Erro ao enviar transação de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}"; Console.WriteLine(message); throw new ApplicationException(message); } }
async public Task <VSITVENC> Find(List <Criteria> criterias) { string recid = criterias[0].Value; string query = Global.BuildQuery($"U_VSITINVOICEVENC('{recid}')"); string data = await _serviceLayerConnector.getQueryResult(query); ExpandoObject record = Global.parseQueryToObject(data); VSITVENC entidade = toRecord(record); // Recupera as linhas da nota iscal string[] filter = new string[] { $"Code eq '{recid}'" }; query = Global.MakeODataQuery("U_VSITINVOICEVENC", null, filter); data = await _serviceLayerConnector.getQueryResult(query); return(entidade); }
public Task Delete(VSITVENC entity) { throw new NotImplementedException(); }