예제 #1
0
        private Intelbras.Message.Helper.MSG0283 DefinirPropriedades(PagamentoServico crm)
        {
            Intelbras.Message.Helper.MSG0283 xml = new Pollux.MSG0283(Domain.Enum.Sistemas.RetornaSistema(Domain.Enum.Sistemas.Sistema.CRM), Helper.Truncate(crm.ID.ToString(), 40));

            xml.CodigoPagamento            = crm.ID.ToString();
            xml.CodigoTipoPagamentoServico = crm.TipoPagamentoId.Id.ToString();
            xml.CodigoOcorrencia           = crm.OcorrenciaId.Id.ToString();
            if (crm.Quantidade.HasValue)
            {
                xml.Quantidade = crm.Quantidade;
            }
            if (crm.Valor.HasValue)
            {
                xml.ValorTotal = crm.Valor;
            }
            if (!string.IsNullOrEmpty(crm.NumeroNotaFiscal))
            {
                xml.NumeroNotaFiscal = crm.NumeroNotaFiscal;
            }

            if (crm.DataPagamento.HasValue)
            {
                xml.DataPagamento = crm.DataPagamento;
            }

            if (!string.IsNullOrEmpty(crm.Observacao))
            {
                xml.Observacao = crm.Observacao;
            }

            return(xml);
        }
예제 #2
0
        public string Enviar(PagamentoServico objModel)
        {
            string resposta;

            Intelbras.Message.Helper.MSG0283 mensagem = DefinirPropriedades(objModel);

            Domain.Servicos.Integracao integracao = new Servicos.Integracao(this.Organizacao, this.IsOffline);
            if (integracao.EnviarMensagemBarramento(mensagem.GenerateMessage(true), "1", "1", out resposta))
            {
                Intelbras.Message.Helper.MSG0283R1 retorno = CarregarMensagem <Pollux.MSG0283R1>(resposta);
                if (!retorno.Resultado.Sucesso)
                {
                    throw new Exception(retorno.Resultado.Mensagem);
                }
            }
            else
            {
                Intelbras.Message.Helper.ERR0001 erro001 = CarregarMensagem <Pollux.ERR0001>(resposta);
                throw new Exception(erro001.GenerateMessage(false));
            }
            return(resposta);
        }
예제 #3
0
        public PagamentoServico DefinirPropriedades(Intelbras.Message.Helper.MSG0283 xml)
        {
            var crm = new Model.PagamentoServico(this.Organizacao, this.IsOffline);

            #region Propriedades Crm->Xml
            crm.IntegrarNoPlugin = true;
            if (!String.IsNullOrEmpty(xml.CodigoPagamento))
            {
                PagamentoServico pagamentoServico = new Servicos.PagamentoServicoService(this.Organizacao, this.IsOffline).BuscaPagamentoServico(new Guid(xml.CodigoPagamento));
                if (pagamentoServico != null)
                {
                    crm.Id = new Guid(xml.CodigoPagamento);
                    crm.ID = new Guid(xml.CodigoPagamento);
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoPagamento informado não existe para ser atualizado.";
                    return(crm);
                }
            }

            if (!string.IsNullOrEmpty(xml.CodigoOcorrencia))
            {
                Ocorrencia ocorrencia = new Intelbras.CRM2013.Domain.Servicos.OcorrenciaService(this.Organizacao, this.IsOffline).BuscaOcorrencia(new Guid(xml.CodigoOcorrencia));
                if (ocorrencia != null)
                {
                    crm.OcorrenciaId = new Lookup(ocorrencia.ID.Value, "incident");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoOcorrencia não encontrado no Crm.";
                    return(crm);
                }
            }

            if (!string.IsNullOrEmpty(xml.CodigoTipoPagamentoServico))
            {
                TipoPagamento tipoPagamento = new Intelbras.CRM2013.Domain.Servicos.TipoPagamentoService(this.Organizacao, this.IsOffline).ObterPor(new Guid(xml.CodigoTipoPagamentoServico));
                if (tipoPagamento != null)
                {
                    crm.TipoPagamentoId = new Lookup(tipoPagamento.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoTipoPagamentoServico não encontrado no Crm.";
                    return(crm);
                }
            }

            if (xml.Quantidade.HasValue)
            {
                crm.Quantidade = xml.Quantidade;
            }

            if (xml.ValorTotal.HasValue)
            {
                crm.Valor = xml.ValorTotal;
            }

            if (!string.IsNullOrEmpty(xml.NumeroNotaFiscal))
            {
                crm.NumeroNotaFiscal = xml.NumeroNotaFiscal;
            }

            if (xml.DataPagamento.HasValue)
            {
                crm.DataPagamento = xml.DataPagamento;
            }

            if (!string.IsNullOrEmpty(xml.Observacao))
            {
                crm.Observacao = xml.Observacao;
            }

            #endregion

            return(crm);
        }