示例#1
0
        public RelacionamentoCanal DefinirPropriedades(Intelbras.Message.Helper.MSG0124 xml)
        {
            var crm = new RelacionamentoCanal(this.Organizacao, this.IsOffline);

            #region Propriedades Crm->Xml


            if (!String.IsNullOrEmpty(xml.Canal))
            {
                Conta conta = new Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.Canal));
                if (conta != null)
                {
                    crm.Canal = new Lookup(conta.ID.Value, "");
                }
                else
                {
                    resultadoPersistencia.Sucesso  = false;
                    resultadoPersistencia.Mensagem = "Canal não encontrado no CRM.";
                    return(crm);
                }
            }
            else
            {
                resultadoPersistencia.Sucesso  = false;
                resultadoPersistencia.Mensagem = "Identificador do canal não enviado.";
                return(crm);
            }
            #endregion

            return(crm);
        }
示例#2
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);
        }
        public RelacionamentoCanal Persistir(RelacionamentoCanal objRelCanal)
        {
            //if (relCanal.ID.HasValue)
            //{
            //    RepositoryService.RelacionamentoDoCanal.Update(relCanal);
            //    return relCanal;
            //}
            //else
            //{
            //    relCanal.ID = RepositoryService.RelacionamentoDoCanal.Create(relCanal);
            //    return relCanal;
            //}

            RelacionamentoCanal TmpRelCanal = null;

            if (objRelCanal.ID.HasValue)
            {
                TmpRelCanal = RepositoryService.RelacionamentoDoCanal.ObterPor(objRelCanal.ID.Value);
            }

            if (TmpRelCanal != null)
            {
                //Para poder atualizar state posteriormente
                int?stateUpdate = objRelCanal.Status;
                objRelCanal.Status = TmpRelCanal.Status;

                objRelCanal.ID = TmpRelCanal.ID;
                RepositoryService.RelacionamentoDoCanal.Update(objRelCanal);

                //Retorna o state e razao do update
                objRelCanal.Status = stateUpdate;

                //Se statusCode for diferente do atual altera
                if (!TmpRelCanal.Status.Equals(objRelCanal.Status))
                {
                    this.MudarStatus(objRelCanal.ID.Value, objRelCanal.Status.Value);
                }
                return(TmpRelCanal);
            }
            else
            {
                objRelCanal.ID = RepositoryService.RelacionamentoDoCanal.Create(objRelCanal);
            }
            return(objRelCanal);
        }
示例#4
0
        public string Enviar(RelacionamentoCanal objModel)
        {
            string resposta;

            Intelbras.Message.Helper.MSG0137 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.MSG0137R1 retorno = CarregarMensagem <Pollux.MSG0137R1>(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);
        }
示例#5
0
        public void CriarTarefaChecklist(RelacionamentoCanal relacionamentoCanal)
        {
            if (relacionamentoCanal.Canal == null)
            {
                throw new ApplicationException("Canal precisa estar preenchido para criação das atividades de checklist!");
            }

            if (relacionamentoCanal.Supervisor == null)
            {
                throw new ApplicationException("Supervisor precisa estar preenchido para criação das atividades de checklist!");
            }

            var conta = RepositoryService.Conta.Retrieve(relacionamentoCanal.Canal.Id, "itbc_classificacaoid", "name", "itbc_participa_do_programa");

            if (!conta.ParticipantePrograma.HasValue || conta.ParticipantePrograma.Value != (int)Domain.Enum.Conta.ParticipaDoPrograma.Sim)
            {
                return;
            }

            if (conta == null || conta.Classificacao == null)
            {
                throw new ApplicationException("Canal precisa estar classificado para criação das atividades de checklist!");
            }

            var parametroGlobalService = new Servicos.ParametroGlobalService(RepositoryService);
            var pAtividadeCheckList    = parametroGlobalService.ObterPor((int)Domain.Enum.TipoParametroGlobal.FrequenciaChecklist, null, conta.Classificacao.Id, null, null, null, null, (int)Domain.Enum.ParametroGlobal.Parametrizar.VisitaComercial);
            var pListaAtividades       = parametroGlobalService.ObterPor((int)Domain.Enum.TipoParametroGlobal.AtividadesChecklist, null, conta.Classificacao.Id, null, null, null, null, (int)Domain.Enum.ParametroGlobal.Parametrizar.VisitaComercial);

            if (pAtividadeCheckList == null || String.IsNullOrEmpty(pAtividadeCheckList.Valor))
            {
                throw new ApplicationException("Operação Cancelada. O parâmetro global de Frequência de Checklist (64) para Visita Comercial de canais com classificação : " + conta.Classificacao.Name + " não foi configurado. Para resolver o problema você deve criar esse parâmetro global.");
            }

            if (pListaAtividades == null || String.IsNullOrEmpty(pListaAtividades.Valor))
            {
                throw new ApplicationException("Operação Cancelada. O parâmetro global de Atividade  de Checklist (63) para Visita Comercial de canais com classificação :  " + conta.Classificacao.Name + " não foi configurado. Para resolver o problema você deve criar esse parâmetro global.");
            }

            var tarefaService = new Domain.Servicos.TarefaService(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline, RepositoryService.Provider);
            var tipoAtividade = tarefaService.BuscarTipoTarefa("Checklist");

            var novaTarefa = new Domain.Model.Tarefa(RepositoryService);

            novaTarefa.Assunto    = "Checklist - " + conta.RazaoSocial;
            novaTarefa.Conclusao  = DateTime.Now.AddDays(Convert.ToInt16(pAtividadeCheckList.Valor));
            novaTarefa.ReferenteA = new SDKore.DomainModel.Lookup(conta.ID.Value, "account");
            novaTarefa.Descricao  = pListaAtividades.Valor;

            if (tipoAtividade != null)
            {
                novaTarefa.TipoDeAtividade = new SDKore.DomainModel.Lookup(tipoAtividade.ID.Value, tipoAtividade.Nome, "");
            }

            novaTarefa.ID = tarefaService.Persistir(novaTarefa);
            if (novaTarefa.ID.HasValue)
            {
                Usuario proprietario = new Domain.Servicos.UsuarioService(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline, RepositoryService.Provider).BuscarProprietario("task", "activityid", relacionamentoCanal.Supervisor.Id);
                if (proprietario != null)
                {
                    new Domain.Servicos.UtilService(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline, RepositoryService.Provider).MudarProprietarioRegistro("systemuser", proprietario.ID.Value, "task", novaTarefa.ID.Value);
                }
            }
        }
示例#6
0
 public string Enviar(RelacionamentoCanal objModel)
 {
     throw new NotImplementedException();
 }
        public string IntegracaoBarramento(RelacionamentoCanal objConta)
        {
            Domain.Integracao.MSG0137 msgRelacionamentoCanal = new Domain.Integracao.MSG0137(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline);

            return(msgRelacionamentoCanal.Enviar(objConta));
        }
        public void VerificarRegistroDuplicado(RelacionamentoCanal objRelacionamentoCanal)
        {
            Guid     canal, supervisor, keyAccount, assistente;
            DateTime dtInicial, dtFinal;

            if (objRelacionamentoCanal.Canal != null)
            {
                canal = objRelacionamentoCanal.Canal.Id;
            }
            else
            {
                throw new ArgumentException("Campo Canal Obrigatório");
            }

            if (objRelacionamentoCanal.Supervisor != null)
            {
                supervisor = objRelacionamentoCanal.Supervisor.Id;
            }
            else
            {
                throw new ArgumentException("Campo Supervisor Obrigatório");
            }

            if (objRelacionamentoCanal.KeyAccount != null)
            {
                keyAccount = objRelacionamentoCanal.KeyAccount.Id;
            }
            else
            {
                throw new ArgumentException("Campo KeyAccount Obrigatório");
            }

            if (objRelacionamentoCanal.Assistente != null)
            {
                assistente = objRelacionamentoCanal.Assistente.Id;
            }
            else
            {
                throw new ArgumentException("Campo Assistente Obrigatório");
            }

            if (objRelacionamentoCanal.DataInicial != null)
            {
                dtInicial = objRelacionamentoCanal.DataInicial.Value;
            }
            else
            {
                throw new ArgumentException("Campo Data Inicial Obrigatório");
            }

            if (objRelacionamentoCanal.DataFinal != null)
            {
                dtFinal = objRelacionamentoCanal.DataFinal.Value;
            }
            else
            {
                throw new ArgumentException("Campo Data Final Obrigatório");
            }


            var retornoRelCanal = RepositoryService.RelacionamentoDoCanal.ListarPor(canal, supervisor, keyAccount, assistente, dtInicial, dtFinal);

            if (retornoRelCanal != null && retornoRelCanal.Count > 1)
            {
                throw new ArgumentException("Criação de registro de Relacionamento Do Canal duplicado,operação suspensa.");
            }
        }
示例#9
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);
        }