Пример #1
0
        public UnidadeNegocio DefinirPropriedades(Intelbras.Message.Helper.MSG0002 xml)
        {
            var crm = new UnidadeNegocio(this.Organizacao, this.IsOffline);

            #region Propriedades Crm->Xml
            if (!String.IsNullOrEmpty(xml.Nome))
            {
                crm.Nome = xml.Nome;
            }

            if (!String.IsNullOrEmpty(xml.CodigoUnidadeNegocio))
            {
                crm.ChaveIntegracao = xml.CodigoUnidadeNegocio;
            }


            UnidadeNegocio unidadePai = new Intelbras.CRM2013.Domain.Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocioPorNome("Intelbras");

            if (unidadePai != null)
            {
                crm.NegocioPrimario = new Lookup((Guid)unidadePai.ID, "");
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Unidade pai não encontrada.";
            }

            #endregion
            return(crm);
        }
Пример #2
0
        public string Executar(string mensagem, string numeroMensagem, Domain.Model.Usuario usuario)
        {
            var objeto = this.DefinirPropriedades(this.CarregarMensagem <Pollux.MSG0002>(mensagem));

            if (!resultadoPersistencia.Sucesso)
            {
                retorno.Add("Resultado", resultadoPersistencia);
                return(CriarMensagemRetorno <Pollux.MSG0002R1>(numeroMensagem, retorno));
            }

            //Checa dentro da service se ele tentou mudar o proprietario,se positivo recusa e retorna erro
            bool mudancaProprietario = false;

            objeto = new Intelbras.CRM2013.Domain.Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).Persistir(objeto);
            if (objeto == null)
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Registro não encontrado!";
            }
            else
            {
                if (mudancaProprietario == true)
                {
                    resultadoPersistencia.Sucesso  = true;
                    resultadoPersistencia.Mensagem = "Integração ocorrida com sucesso, não houve alteração do proprietário.";
                }
                else
                {
                    resultadoPersistencia.Sucesso  = true;
                    resultadoPersistencia.Mensagem = "Integração ocorrida com sucesso";
                }
            }

            retorno.Add("Resultado", resultadoPersistencia);

            return(CriarMensagemRetorno <Pollux.MSG0002R1>(numeroMensagem, retorno));
        }
Пример #3
0
        public Segmento DefinirPropriedades(Intelbras.Message.Helper.MSG0026 xml)
        {
            var crm = new Segmento(this.Organizacao, this.IsOffline);

            Segmento TmpSegmento = new Intelbras.CRM2013.Domain.Servicos.RepositoryService(this.Organizacao, this.IsOffline).Segmento.ObterPor(xml.CodigoSegmento);

            if (TmpSegmento != null)
            {
                crm.DescontoVerdeHabilitado = TmpSegmento.DescontoVerdeHabilitado;
            }

            #region Propriedades Crm->Xml

            if (!String.IsNullOrEmpty(xml.Nome))
            {
                crm.Nome = xml.Nome;
            }

            if (!String.IsNullOrEmpty(xml.CodigoSegmento))
            {
                crm.CodigoSegmento = xml.CodigoSegmento;
            }

            if (xml.QuantidadeShowRoom.HasValue)
            {
                crm.QtdMaximaShowRoom = xml.QuantidadeShowRoom.Value;
            }
            else
            {
                crm.QtdMaximaShowRoom = 0;
            }

            if (!String.IsNullOrEmpty(xml.UnidadeNegocio))
            {
                Model.UnidadeNegocio unidadeNegocio = new UnidadeNegocio(this.Organizacao, this.IsOffline);
                unidadeNegocio = new Intelbras.CRM2013.Domain.Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocioPorChaveIntegracao(xml.UnidadeNegocio);
                if (unidadeNegocio != null)
                {
                    crm.UnidadeNegocios = new Lookup(unidadeNegocio.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "Unidade de Negocio não encontrada!";
                    return(crm);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Unidade de Negocio não enviado.";
                return(crm);
            }

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

            crm.Status = xml.Situacao;

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


            #endregion

            return(crm);
        }