Ejemplo n.º 1
0
        private Intelbras.Message.Helper.MSG0137 DefinirPropriedades(RelacionamentoCanal crm)
        {
            Intelbras.Message.Helper.MSG0137 xml = new Pollux.MSG0137(Domain.Enum.Sistemas.RetornaSistema(Domain.Enum.Sistemas.Sistema.CRM), Helper.Truncate(crm.Nome, 40));

            Contato contato = new Servicos.ContatoService(this.Organizacao, this.IsOffline).BuscaContato(crm.KeyAccount.Id);

            if (contato != null)
            {
                xml.CodigoRepresentante = Convert.ToInt32(contato.CodigoRepresentante);
            }

            Usuario objUsuarioAssistente = new Intelbras.CRM2013.Domain.Servicos.UsuarioService(this.Organizacao, this.IsOffline).ObterPor(crm.Assistente.Id);

            if (objUsuarioAssistente != null)
            {
                if (objUsuarioAssistente.CodigoAssistenteComercial != null)
                {
                    xml.CodigoAssistente    = (int)objUsuarioAssistente.CodigoAssistenteComercial.Value;
                    xml.CodigoAssistenteCRM = objUsuarioAssistente.ID.Value.ToString();
                }
            }

            Usuario objUsuarioSuper = new Intelbras.CRM2013.Domain.Servicos.UsuarioService(this.Organizacao, this.IsOffline).ObterPor(crm.Supervisor.Id);

            if (objUsuarioSuper != null)
            {
                xml.CodigoSupervisor = objUsuarioSuper.ID.Value.ToString();
                if (!String.IsNullOrEmpty(objUsuarioSuper.CodigoSupervisorEMS))
                {
                    xml.CodigoSupervisorEMS = objUsuarioSuper.CodigoSupervisorEMS;
                }
                else
                {
                    throw new Exception("Codigo Supervisor EMS não preenchido.");
                }
            }
            if (crm.Canal != null)
            {
                xml.CodigoConta = crm.Canal.Id.ToString();
            }
            xml.CodigoRelacionamentoCanal = crm.ID.Value.ToString();
            if (crm.Supervisor != null)
            {
                xml.CodigoSupervisor = crm.Supervisor.Id.ToString();
            }
            xml.DataFinal   = crm.DataFinal.Value;
            xml.DataInicial = crm.DataInicial.Value;
            xml.Nome        = crm.Nome;
            xml.Situacao    = (crm.Status.HasValue ? crm.Status.Value : 0);

            return(xml);
        }
Ejemplo n.º 2
0
        public RelacionamentoCanal DefinirPropriedades(Intelbras.Message.Helper.MSG0137 xml)
        {
            var crm = new RelacionamentoCanal(this.Organizacao, this.IsOffline);

            #region Propriedades Crm->Xml

            crm.IntegrarNoPlugin = true;

            if (!String.IsNullOrEmpty(xml.CodigoRelacionamentoCanal))
            {
                crm.ID = new Guid(xml.CodigoRelacionamentoCanal);
            }

            if (!String.IsNullOrEmpty(xml.Nome))
            {
                crm.Nome = xml.Nome;
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Nome não enviado.";
                return(crm);
            }
            if (!String.IsNullOrEmpty(xml.CodigoConta) && xml.CodigoConta.Length == 36)
            {
                crm.Canal = new Lookup(new Guid(xml.CodigoConta), "");
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "CodigoConta não enviado ou fora do padrão (Guid).";
                return(crm);
            }
            Contato keyAccount = new Intelbras.CRM2013.Domain.Servicos.ContatoService(this.Organizacao, this.IsOffline).BuscaContatoPorCodigoRepresentante(xml.CodigoRepresentante.ToString());
            if (keyAccount != null)
            {
                crm.KeyAccount = new Lookup(keyAccount.ID.Value, "");
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "keyAccount não encontrado no Crm.";
                return(crm);
            }

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

            if (!String.IsNullOrEmpty(xml.CodigoSupervisor) && xml.CodigoSupervisor.Length == 36)
            {
                crm.Supervisor = new Lookup(new Guid(xml.CodigoSupervisor), "");
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Supervisor não encontrado no Crm.";
                return(crm);
            }
            if (crm.DataInicial.HasValue)
            {
                xml.DataInicial = crm.DataInicial.Value.ToLocalTime();
            }

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

            crm.Status = xml.Situacao;

            #endregion

            return(crm);
        }