Пример #1
0
        public string Executar(string mensagem, string numeroMensagem, Domain.Model.Usuario usuario)
        {
            List <Intelbras.Message.Helper.Entities.FormaPagamentoItem> lstFormaPagamentoItem = new List <Pollux.Entities.FormaPagamentoItem>();
            //FormaPagamentoItem

            List <FormaPagamento> lstFormaPagamentos = new Servicos.FormaPagamentoService(this.Organizacao, this.IsOffline).Listar();

            #region Lista

            if (lstFormaPagamentos != null && lstFormaPagamentos.Count > 0)
            {
                foreach (FormaPagamento crmItem in lstFormaPagamentos)
                {
                    Pollux.Entities.FormaPagamentoItem objPollux = new Pollux.Entities.FormaPagamentoItem();

                    if (String.IsNullOrEmpty(crmItem.Nome))
                    {
                        objPollux.NomeFormaPagamento = (String)this.PreencherAtributoVazio("string");
                    }
                    else
                    {
                        objPollux.NomeFormaPagamento = crmItem.Nome;
                    }

                    objPollux.CodigoFormaPagamento = crmItem.ID.ToString();

                    lstFormaPagamentoItem.Add(objPollux);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Não foram encontrados registros que satisfaçam os critérios de pesquisa.";
                retorno.Add("Resultado", resultadoPersistencia);
                return(CriarMensagemRetorno <Pollux.MSG0160R1>(numeroMensagem, retorno));
            }

            #endregion

            retorno.Add("FormaPagamentoItens", lstFormaPagamentoItem);
            retorno.Add("Resultado", resultadoPersistencia);
            return(CriarMensagemRetorno <Pollux.MSG0160R1>(numeroMensagem, retorno));
        }
Пример #2
0
        public SolicitacaoBeneficio DefinirPropriedades(Pollux.MSG0155 xml)
        {
            var crm = new SolicitacaoBeneficio(this.Organizacao, this.IsOffline);

            #region Propriedades Crm->Xml

            crm.IntegrarNoPlugin = true;
            crm.ValorAprovado    = xml.ValorAprovado;


            if (!string.IsNullOrEmpty(xml.CodigoSolicitacaoBeneficio))
            {
                if (xml.CodigoSolicitacaoBeneficio.Length == 36)
                {
                    crm.ID = new Guid(xml.CodigoSolicitacaoBeneficio);
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoSolicitacaoBeneficio fora do padrão (Guid)!";
                    return(crm);
                }
            }

            string NomeUnidadeNegocio = String.Empty;

            if (!string.IsNullOrEmpty(xml.CodigoUnidadeNegocio))
            {
                UnidadeNegocio unidadeNegocio = new Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocioPorChaveIntegracao(xml.CodigoUnidadeNegocio);
                if (unidadeNegocio == null)
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "UnidadeNegocio: " + xml.CodigoUnidadeNegocio + " não encontrado no Crm.";
                    return(crm);
                }
                else
                {
                    crm.UnidadedeNegocio = new Lookup(unidadeNegocio.ID.Value, "");
                    NomeUnidadeNegocio   = unidadeNegocio.Nome;
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "CodigoUnidadeNegocio não enviado!";
                return(crm);
            }


            crm.Nome = xml.NomeSolicitacaoBeneficio;
            crm.TipoPriceProtection = xml.TipoPriceProtection;

            if (!String.IsNullOrEmpty(xml.DescricaoSituacaoIrregular))
            {
                crm.SituacaoIrregular = xml.DescricaoSituacaoIrregular;
            }
            else
            {
                crm.AddNullProperty("SituacaoIrregular");
            }

            if (!String.IsNullOrEmpty(xml.CodigoBeneficioCanal) && xml.CodigoBeneficioCanal.Length == 36)
            {
                BeneficioDoCanal beneficioCanal = new Servicos.BeneficioDoCanalService(this.Organizacao, this.IsOffline).ObterPor(new Guid(xml.CodigoBeneficioCanal));
                if (beneficioCanal != null)
                {
                    crm.BeneficioCanal = new Lookup(beneficioCanal.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoBeneficioCanal : " + xml.CodigoBeneficioCanal + " - não cadastrado no Crm.";
                    return(crm);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "CodigoBeneficioCanal não Enviado ou fora do padrão(Guid).";
                return(crm);
            }

            crm.ValorSolicitado = xml.ValorSolicitado;

            if (!string.IsNullOrEmpty(xml.DescricaoSolicitacao))
            {
                crm.Descricao = xml.DescricaoSolicitacao;
            }
            else
            {
                crm.AddNullProperty("Descricao");
            }

            if (System.Enum.IsDefined(typeof(Enum.SolicitacaoBeneficio.StatusSolicitacaoBeneficio), xml.SituacaoSolicitacaoBeneficio))
            {
                crm.StatusSolicitacao = xml.SituacaoSolicitacaoBeneficio;
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "SituacaoSolicitacaoBeneficio não cadastrado no Crm(PickList).";
                return(crm);
            }
            if (xml.Situacao == 0 || xml.Situacao == 1)
            {
                crm.State = xml.Situacao;
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Situacao fora do padrão(0 ou 1).";
                return(crm);
            }


            if (crm.State.Value.Equals((int)Enum.SolicitacaoBeneficio.State.Ativo))
            {
                if (System.Enum.IsDefined(typeof(Enum.SolicitacaoBeneficio.RazaoStatusAtivo), xml.RazaoStatusSolicitacaoBeneficio))
                {
                    crm.Status = xml.RazaoStatusSolicitacaoBeneficio;
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "RazaoStatusSolicitacaoBeneficio não cadastrado para Situação Ativo.";
                    return(crm);
                }
            }
            else if (crm.State.Value.Equals((int)Enum.SolicitacaoBeneficio.State.Inativo))
            {
                if (System.Enum.IsDefined(typeof(Enum.SolicitacaoBeneficio.RazaoStatusInativo), xml.RazaoStatusSolicitacaoBeneficio))
                {
                    crm.Status = xml.RazaoStatusSolicitacaoBeneficio;
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "RazaoStatusSolicitacaoBeneficio não cadastrado para Situação Inativo.";
                    return(crm);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Situacao fora do padrão.";
                return(crm);
            }



            if (!String.IsNullOrEmpty(xml.CodigoFormaPagamento) && xml.CodigoFormaPagamento.Length == 36)
            {
                FormaPagamento formaPagamento = new Servicos.FormaPagamentoService(this.Organizacao, this.IsOffline).ObterPorGuid(new Guid(xml.CodigoFormaPagamento));
                if (formaPagamento != null)
                {
                    crm.FormaPagamento = new Lookup(formaPagamento.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoFormaPagamento : " + xml.CodigoFormaPagamento + " - não cadastrado no Crm.";
                    return(crm);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "CodigoFormaPagamento não Enviado ou fora do padrão(Guid).";
                return(crm);
            }

            if (!String.IsNullOrEmpty(xml.CodigoConta) && xml.CodigoConta.Length == 36)
            {
                Conta conta = new Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoConta));
                if (conta != null)
                {
                    crm.Canal = new Lookup(conta.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoConta : " + xml.CodigoConta + " - não cadastrado no Crm.";
                    return(crm);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "CodigoConta não Enviado ou fora do padrão(Guid).";
                return(crm);
            }



            if (!String.IsNullOrEmpty(xml.CodigoBeneficio) && xml.CodigoBeneficio.Length == 36)
            {
                Beneficio beneficio = new Servicos.BeneficioService(this.Organizacao, this.IsOffline).ObterPor(new Guid(xml.CodigoBeneficio));
                if (beneficio != null)
                {
                    crm.BeneficioPrograma = new Lookup(beneficio.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoBeneficio : " + xml.CodigoBeneficio + " - não cadastrado no Crm.";
                    return(crm);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "CodigoBeneficio não Enviado ou fora do padrão(Guid).";
                return(crm);
            }

            crm.AlteradaParaStockRotation = xml.AlteradaStockRotation;

            crm.SituacaoIrregularidades = xml.SolicitacaoIrregular;

            if (!String.IsNullOrEmpty(xml.CodigoTipoSolicitacao) && xml.CodigoTipoSolicitacao.Length == 36)
            {
                crm.TipoSolicitacao = new Lookup(new Guid(xml.CodigoTipoSolicitacao), "");
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "CodigoTipoSolicitacao não Enviado ou fora do padrão(Guid).";
                return(crm);
            }
            //Novos campos - 1409

            crm.AjusteSaldo = xml.SolicitacaoAjuste;

            crm.ValorAbater = xml.ValorAbater;

            Usuario objAssitente = new Servicos.UsuarioService(this.Organizacao, this.IsOffline).BuscaPorCodigoAssistente(xml.CodigoAssistente.Value);
            if (objAssitente != null)
            {
                crm.Assistente = new Lookup(objAssitente.ID.Value, "");
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Assistente não cadastrado no Crm.";
                return(crm);
            }

            Usuario supervisorEms = new Servicos.UsuarioService(this.Organizacao, this.IsOffline).BuscaPorCodigoSupervisorEMS(xml.CodigoSupervisorEMS);
            if (supervisorEms != null)
            {
                crm.Supervisor = new Lookup(supervisorEms.ID.Value, "");
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Supervisor não cadastrado no Crm.";
                return(crm);
            }

            if (!String.IsNullOrEmpty(xml.CodigoFilial))
            {
                crm.Filial = new Lookup(new Guid(xml.CodigoFilial), "");
            }
            else
            {
                crm.AddNullProperty("Filial");
            }

            if (xml.StatusPagamento.HasValue)
            {
                crm.StatusPagamento = xml.StatusPagamento;
            }
            else
            {
                crm.AddNullProperty("StatusPagamento");
            }

            if (xml.ValorPago.HasValue)
            {
                crm.ValorPago = xml.ValorPago.Value;
            }

            if (xml.ValorCancelado.HasValue)
            {
                crm.ValorCancelado = xml.ValorCancelado.Value;
            }

            if (xml.StatusCalculoPriceProtection.HasValue)
            {
                crm.StatusCalculoPriceProtection = xml.StatusCalculoPriceProtection.Value;
            }

            if (xml.DataValidade.HasValue)
            {
                crm.DataValidade = xml.DataValidade.Value;
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "DataValidade não informado favor verificar integração.";
                return(crm);
            }

            if (xml.CodigoCondicaoPagamento.HasValue)
            {
                CondicaoPagamento condicaoPagamento = new Servicos.CondicaoPagamentoService(this.Organizacao, this.IsOffline).BuscaCondicaoPagamentoPorCodigo(xml.CodigoCondicaoPagamento.Value);
                if (condicaoPagamento != null)
                {
                    crm.CondicaoPagamento = new Lookup(condicaoPagamento.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "CodigoCondicaoPagamento informado não registrado no CRM, favor verificar.";
                    return(crm);
                }
            }

            crm.DescartarVerba = xml.DescartarVerba;

            if (!string.IsNullOrEmpty(xml.TrimestreCompetencia))
            {
                crm.TrimestreCompetencia = xml.TrimestreCompetencia;
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "TrimestreCompetencia não informado favor verificar integração.";
                return(crm);
            }

            crm.FormaCancelamento = xml.FormaCancelamento;

            if (xml.CodigoSolicitacaoPrincipal != null)
            {
                crm.SolicitacaoBeneficioPrincipal = new Lookup(new Guid(xml.CodigoSolicitacaoPrincipal), "");
            }

            #endregion

            crm.IntegradoEm       = DateTime.Now;
            crm.IntegradoPor      = usuarioIntegracao.NomeCompleto;
            crm.UsuarioIntegracao = xml.LoginUsuario;

            return(crm);
        }