public RegiaoAtuacao DefinirPropriedades(Intelbras.Message.Helper.MSG0075 xml) { var crm = new RegiaoAtuacao(this.Organizacao, this.IsOffline); #region Propriedades Crm->Xml if (!String.IsNullOrEmpty(xml.CodigoConta)) { Model.Conta conta = new Model.Conta(this.Organizacao, this.IsOffline); conta = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoConta)); if (conta != null) { crm.Canal = conta.ID.Value; } } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "Canal não encontrado!"; return(crm); } #endregion return(crm); }
public void TesteDescredenciamentoAoPrograma() { var beneficioDoCanalService = new Intelbras.CRM2013.Domain.Servicos.BeneficioDoCanalService(this.OrganizationName, this.IsOffline); var canalService = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.OrganizationName, this.IsOffline); var canal = canalService.BuscaConta(new Guid("E333FE1D-A60E-E411-9408-00155D013D38")); beneficioDoCanalService.DescredenciamentoAoPrograma(canal); }
public RegiaoAtuacao DefinirPropriedades(Intelbras.Message.Helper.MSG0076 xml) { var crm = new RegiaoAtuacao(this.Organizacao, this.IsOffline); if (!String.IsNullOrEmpty(xml.CodigoConta)) { Model.Conta conta = new Model.Conta(this.Organizacao, this.IsOffline); conta = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoConta)); if (conta != null) { crm.Canal = conta.ID.Value; } } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "Canal não encontrado!"; return(crm); } //Municipio if (!String.IsNullOrEmpty(xml.ChaveIntegracaoCidade)) { Model.Municipio cidade = new Model.Municipio(this.Organizacao, this.IsOffline); cidade = new Intelbras.CRM2013.Domain.Servicos.EnderecoServices(this.Organizacao, this.IsOffline).BuscaMunicipio(xml.ChaveIntegracaoCidade); if (cidade != null && cidade.ID.HasValue) { crm.MunicipioId = cidade.ID.Value; } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "Cidade não encontrada!"; return(crm); } } return(crm); }
public string Executar(string mensagem, string numeroMensagem, Domain.Model.Usuario usuario) { //Trace.Add("Mensagem " + numeroMensagem + " XML: {0}", mensagem); var xml = this.CarregarMensagem <Pollux.MSG0078>(mensagem); Conta objetoConta = null; UnidadeNegocio objetoUnidade = null; Classificacao objetoclassificacao = null; Categoria objetocategoria = null; Estado objetoEstado = null; if (string.IsNullOrEmpty(xml.CodigoConta) && string.IsNullOrEmpty(xml.CodigoUnidadeNegocio) && string.IsNullOrEmpty(xml.ChaveIntegracaoEstado)) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "Paramêtros não enviados."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } if (!String.IsNullOrEmpty(xml.CodigoConta)) { objetoConta = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoConta)); if (objetoConta == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Conta] não encontrada."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } } if (!String.IsNullOrEmpty(xml.CodigoUnidadeNegocio)) { objetoUnidade = new Intelbras.CRM2013.Domain.Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocioPorChaveIntegracao(xml.CodigoUnidadeNegocio); if (objetoUnidade == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Unidade Negócio] não encontrada."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } } //new if (!String.IsNullOrEmpty(xml.Classificacao)) { objetoclassificacao = new Intelbras.CRM2013.Domain.Servicos.ClassificacaoService(this.Organizacao, this.IsOffline).BuscaClassificacao(new Guid(xml.Classificacao)); if (objetoclassificacao == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Classificao] não encontrada."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } } if (!String.IsNullOrEmpty(xml.Categoria)) { objetocategoria = new Intelbras.CRM2013.Domain.Servicos.CategoriaService(this.Organizacao, this.IsOffline).BuscaCategoria(new Guid(xml. Categoria)); if (objetocategoria == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Categoria] não encontrada."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } } // if (!String.IsNullOrEmpty(xml.ChaveIntegracaoEstado)) { objetoEstado = new Intelbras.CRM2013.Domain.Servicos.EnderecoServices(this.Organizacao, this.IsOffline).BuscaEstado(xml.ChaveIntegracaoEstado); if (objetoEstado == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Estado] não encontrado."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } } List <CategoriasCanal> lstObjetoCategoria = new List <CategoriasCanal>(); List <Guid> lstUnd = new List <Guid>(); if (objetoConta != null) { if (objetoUnidade != null) { lstObjetoCategoria = new Intelbras.CRM2013.Domain.Servicos.CategoriaCanalService(this.Organizacao, this.IsOffline).ListarPor((Guid)objetoConta.ID, (Guid)objetoUnidade.ID); } else { lstObjetoCategoria = new Intelbras.CRM2013.Domain.Servicos.CategoriaCanalService(this.Organizacao, this.IsOffline).ListarPor((Guid)objetoConta.ID, null); } foreach (CategoriasCanal item in lstObjetoCategoria ?? Enumerable.Empty <CategoriasCanal>()) { if (!lstUnd.Contains(item.UnidadeNegocios.Id)) { lstUnd.Add(item.UnidadeNegocios.Id); } } if (lstUnd != null && lstUnd.Count == 0) { resultadoConsulta.Sucesso = true; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } } else if (objetoUnidade != null) { lstUnd.Add(objetoUnidade.ID.Value); } var objetoMunicipio = new Intelbras.CRM2013.Domain.Servicos.MunicipioServices(this.Organizacao, this.IsOffline).ObterPor(objetoConta.Endereco1Municipioid.Id); List <LinhaCorteDistribuidor> objLinhaCorteItem = new Intelbras.CRM2013.Domain.Servicos.LinhaCorteService(this.Organizacao, this.IsOffline).ListarLinhadeCorteDistribuidor(lstUnd, objetoEstado, objetoMunicipio.CapitalOuInterior); foreach (var item in objLinhaCorteItem) { // service que pega o objLinhaCorte com base na unidade de negócio e o estadoId da conta List <LinhaCorteEstado> LinhaCorteEstado = new Intelbras.CRM2013.Domain.Servicos.LinhaCorteService(this.Organizacao, this.IsOffline).ObterLinhaDeCorteDistribuidorEstadoPorIdDistribuidor(item.ID.Value); retornoLinhaCorteItem.CodigoLinhaCorte = item.ID.ToString(); if (!String.IsNullOrEmpty(item.Nome)) { retornoLinhaCorteItem.Nome = item.Nome; } if (item.UnidadeNegocios != null) { retornoLinhaCorteItem.CodigoUnidadeNegocio = new Intelbras.CRM2013.Domain.Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocio(item.UnidadeNegocios.Id).ChaveIntegracao; retornoLinhaCorteItem.NomeUnidadeNegocio = item.UnidadeNegocios.Name; } retornoLinhaCorteItem.LinhaCorteSemestral = (decimal)item.LinhaCorteSemestral; retornoLinhaCorteItem.LinhaCorteTrimestral = (decimal)item.LinhaCorteTrimestral; if (item.Moeda != null) { retornoLinhaCorteItem.Moeda = item.Moeda.Name; } if (usuario != null) { retornoLinhaCorteItem.CodigoProprietario = usuario.ID.Value.ToString(); retornoLinhaCorteItem.NomeProprietario = usuario.Nome; } //if (LinhaCorteEstado.Count <= 0) //{ // retornoLinhaCorteItem.EstadosItens.Add(new Pollux.Entities.EstadoItem(){}); //} foreach (var estado in LinhaCorteEstado) { Estado objEstado = new Intelbras.CRM2013.Domain.Servicos.EnderecoServices(this.Organizacao, this.IsOffline).BuscaEstadoPorGuid(estado.Estado.Value); if (objEstado != null && item.ID == estado.LinhaCorteDistribuidor.Value) { if (!String.IsNullOrEmpty(objEstado.Nome)) { listaEstados.NomeEstado = objEstado.Nome; } if (!String.IsNullOrEmpty(objEstado.ChaveIntegracao)) { listaEstados.ChaveIntegracaoEstado = objEstado.ChaveIntegracao; } retornoLinhaCorteItem.EstadosItens.Add(listaEstados); listaEstados = new Pollux.Entities.EstadoItem { }; } } //Depois de pegar as infos adiciona o dictionary em uma lista de dictionaries response.Add(retornoLinhaCorteItem); retornoLinhaCorteItem = new Pollux.Entities.LinhaCorte { }; } retorno.Add("LinhasCorteItens", response); retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); }
public string Executar(string mensagem, string numeroMensagem, Domain.Model.Usuario usuario) { //Trace.Add("Mensagem " + numeroMensagem + " XML: {0}", mensagem); var xml = this.CarregarMensagem <Pollux.MSG0079>(mensagem); Conta objetoConta = null; UnidadeNegocio objetoUnidadeNeg = null; Categoria objetoCategoria = null; List <CategoriasCanal> lstCategCanal = null; if (String.IsNullOrEmpty(xml.CodigoConta) && String.IsNullOrEmpty(xml.CodigoUnidadeNegocio) && String.IsNullOrEmpty(xml.CodigoCategoria)) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "Pelo menos 1 parâmetro deve ser enviado."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0079R1>(numeroMensagem, retorno)); } if (!String.IsNullOrEmpty(xml.CodigoConta)) { objetoConta = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoConta)); if (objetoConta == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Conta] não encontrada."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0079R1>(numeroMensagem, retorno)); } } if (!String.IsNullOrEmpty(xml.CodigoUnidadeNegocio)) { objetoUnidadeNeg = new Intelbras.CRM2013.Domain.Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocioPorChaveIntegracao(xml.CodigoUnidadeNegocio); if (objetoUnidadeNeg == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Unidade Negócio] não encontrada."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0078R1>(numeroMensagem, retorno)); } } if (!String.IsNullOrEmpty(xml.CodigoCategoria)) { objetoCategoria = new Intelbras.CRM2013.Domain.Servicos.CategoriaService(this.Organizacao, this.IsOffline).ObterPor(new Guid(xml.CodigoCategoria)); if (objetoCategoria == null) { resultadoConsulta.Sucesso = false; resultadoConsulta.Mensagem = "[Categoria] não encontrada."; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0079R1>(numeroMensagem, retorno)); } } List <CategoriasCanal> lstObjetoCategoria = new List <CategoriasCanal>(); List <Guid> lstUnd = new List <Guid>(); if (objetoConta != null) { if (objetoUnidadeNeg != null) { lstObjetoCategoria = new Intelbras.CRM2013.Domain.Servicos.CategoriaCanalService(this.Organizacao, this.IsOffline).ListarPor((Guid)objetoConta.ID, (Guid)objetoUnidadeNeg.ID); } else { lstObjetoCategoria = new Intelbras.CRM2013.Domain.Servicos.CategoriaCanalService(this.Organizacao, this.IsOffline).ListarPor((Guid)objetoConta.ID, null); } foreach (CategoriasCanal item in lstObjetoCategoria ?? Enumerable.Empty <CategoriasCanal>()) { if (!lstUnd.Contains(item.UnidadeNegocios.Id)) { lstUnd.Add(item.UnidadeNegocios.Id); } } if (lstUnd.Count == 0) { resultadoConsulta.Sucesso = true; retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0079R1>(numeroMensagem, retorno)); } } else if (objetoUnidadeNeg != null) { lstUnd.Add(objetoUnidadeNeg.ID.Value); } else if (objetoCategoria != null) { lstUnd = null; } List <LinhaCorteRevenda> objLinhaCorteRevenda = new List <LinhaCorteRevenda>(); if (objetoCategoria != null) { objLinhaCorteRevenda = new Intelbras.CRM2013.Domain.Servicos.LinhaCorteService(this.Organizacao, this.IsOffline).ListarLinhadeCorteRevenda(lstUnd, objetoCategoria); } else if (lstObjetoCategoria.Count > 0) { //Passado Canal, mas nao categoria. As categorias foram obtidas atraves de CategoriasCanal foreach (var itemCateg in lstObjetoCategoria) { Categoria categ = new Servicos.CategoriaService(this.Organizacao, this.IsOffline).ObterPor(itemCateg.Categoria.Id); List <LinhaCorteRevenda> lstPorItem = new Intelbras.CRM2013.Domain.Servicos.LinhaCorteService(this.Organizacao, this.IsOffline).ListarLinhadeCorteRevenda(lstUnd, categ); if (lstPorItem.Count > 0) { foreach (var linhaCorte in lstPorItem) { objLinhaCorteRevenda.Add(linhaCorte); } } } } else { //Não foi passsado categoria, apenas CAnal, e nao foi encontrada CategoriasCanal objLinhaCorteRevenda = new Intelbras.CRM2013.Domain.Servicos.LinhaCorteService(this.Organizacao, this.IsOffline).ListarLinhadeCorteRevenda(lstUnd, null); } foreach (var item in objLinhaCorteRevenda) { if (!response.Exists(x => x.CodigoLinhaCorte == item.ID.Value.ToString())) { response.Add(this.DefinirPropriedades(item)); } } if (!resultadoConsulta.Sucesso) { retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0079R1>(numeroMensagem, retorno)); } resultadoConsulta.Sucesso = true; if (response != null && response.Count > 0) { resultadoConsulta.Mensagem = "Integração ocorrida com sucesso."; retorno.Add("LinhasCorteItens", response); } else { resultadoConsulta.Mensagem = "Linha de Corte Revenda não encontrado no Crm."; } retorno.Add("Resultado", resultadoConsulta); return(CriarMensagemRetorno <Pollux.MSG0079R1>(numeroMensagem, retorno)); }
public void TesteCrmWebService() { Guid? categoria = Guid.Empty; Guid? unidNeg = Guid.Empty; Guid? benefPrograma = Guid.Empty; Guid? classifCanal = Guid.Empty; string organizationName = ConfigurationManager.GetSettingValue("OrganizacaoIntelbras"); string resposta = string.Empty; Domain.Model.Conta canal = new Domain.Model.Conta(organizationName, false); JavaScriptSerializer jsonConverter = new JavaScriptSerializer(); Dictionary <string, object> dictResposta = new Dictionary <string, object>(); try { Intelbras.CRM2013.Domain.Model.BeneficioDoCanal benefCanal = new Intelbras.CRM2013.Domain.Servicos.BeneficioDoCanalService(organizationName, false).ObterPor(new Guid("88DD05CD-4D17-E411-9233-00155D013E44")); if (benefCanal == null || benefCanal.StatusBeneficio == null || (benefCanal.StatusBeneficio.Name != "Suspenso" && benefCanal.StatusBeneficio.Name != "Bloqueado")) { dictResposta.Add("Resultado", false); dictResposta.Add("Mensagem", "Não possui benefícios Suspensos ou Bloqueados"); resposta = jsonConverter.Serialize(dictResposta); } #region Se tiver algum atributo no beneficio do canal e canal vazio, seta a variavel como null se não,pega o Guid dela categoria = (benefCanal.Categoria == null) ? (Guid?)null : benefCanal.Categoria.Id; unidNeg = (benefCanal.UnidadeDeNegocio == null) ? (Guid?)null : benefCanal.UnidadeDeNegocio.Id; benefPrograma = (benefCanal.Beneficio == null) ? (Guid?)null : benefCanal.Beneficio.Id; if (benefCanal.Canal != null) { canal = new Intelbras.CRM2013.Domain.Servicos.ContaService(organizationName, false).BuscaConta(benefCanal.Canal.Id); if (canal != null && canal.Classificacao != null) { classifCanal = canal.Classificacao.Id; } else { classifCanal = null; } } #endregion #region Pega a lista de Beneficio x Compromisso com base no perfil(Unidade negocio,classificacao canal,categoria) Domain.Model.Perfil perfil = new Intelbras.CRM2013.Domain.Servicos.PerfilServices(organizationName, false).BuscarPerfil(unidNeg, classifCanal, categoria, null); List <Domain.Model.BeneficiosCompromissos> benefCompr = new Intelbras.CRM2013.Domain.Servicos.BeneficiosCompromissosService(organizationName, false).BuscaBeneficiosCompromissos(perfil.ID.Value, null, benefPrograma.Value); #endregion List <string> lstCompromissos = new List <string>(); foreach (Domain.Model.BeneficiosCompromissos item in benefCompr) { if (item.Compromisso != null) { Domain.Model.CompromissosDoCanal comproDoCanal = new Intelbras.CRM2013.Domain.Servicos.CompromissosDoCanalService(organizationName, false).BuscarCompromissoCanal(item.Compromisso.Id, unidNeg.Value, canal.ID.Value); if (comproDoCanal != null && comproDoCanal.StatusCompromisso != null && comproDoCanal.StatusCompromisso.Name == "Não Cumprido") { lstCompromissos.Add(comproDoCanal.Nome); } } } dictResposta.Add("Resultado", true); dictResposta.Add("Compromissos", lstCompromissos); resposta = jsonConverter.Serialize(dictResposta); } catch (Exception e) { dictResposta = new Dictionary <string, object>(); dictResposta.Add("Resultado", false); dictResposta.Add("Mensagem", e.Message); resposta = jsonConverter.Serialize(dictResposta); } }
public int CargaSellOutContas() { int pagina = 1; int contagem = 10; bool moreRecords = true; int registrosAtualizados = 0; string usuario = SDKore.Configuration.ConfigurationManager.GetSettingValue("SellOutCRMWSUser"); string senha = SDKore.Configuration.ConfigurationManager.GetSettingValue("SellOutCRMWSPasswd"); while (moreRecords) { List <Model.Conta> lstConta = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).ListarContas(ref pagina, contagem, out moreRecords); foreach (var item in lstConta) { string xml; XDocument xmlroot; bool resultado; string resposta; if (!string.IsNullOrEmpty(item.CodigoMatriz) && item.Status.HasValue && item.Status.HasValue && item.ID.HasValue && !String.IsNullOrEmpty(item.CpfCnpj)) { string cpfCnpj = item.CpfCnpj; switch (item.Classificacao.Name) { case Domain.Enum.Conta.Classificacao.Dist_BoxMover: case Domain.Enum.Conta.Classificacao.Dist_VAD: if (!Intelbras.CRM2013.Domain.Servicos.Helper.somenteNumeros(item.CpfCnpj)) { cpfCnpj = Intelbras.CRM2013.Domain.Servicos.Helper.FormatarCnpj(item.CpfCnpj); } xmlroot = new XDocument( new XDeclaration("1.0", "utf-8", "no"), new XElement("Distribuidor", new XElement("Iddistribuidorcrm", item.ID), new XElement("Iddistribuidorerp", item.CodigoMatriz), new XElement("Cnpj", cpfCnpj), new XElement("Statuscode", item.RazaoStatus), new XElement("Statecode", item.Status) )); xml = xmlroot.Declaration.ToString() + Environment.NewLine + xmlroot.ToString();; resultado = new Domain.Servicos.SellOutService(this.Organizacao, this.IsOffline).PersistirDistribuidor(usuario, senha, xml, out resposta); if (resultado == false) { throw new ArgumentException(resposta); } registrosAtualizados++; break; case Domain.Enum.Conta.Classificacao.Rev_Rel: case Domain.Enum.Conta.Classificacao.Rev_Trans: if (!Intelbras.CRM2013.Domain.Servicos.Helper.somenteNumeros(item.CpfCnpj)) { cpfCnpj = Intelbras.CRM2013.Domain.Servicos.Helper.FormatarCnpj(item.CpfCnpj); } xmlroot = new XDocument( new XDeclaration("1.0", "utf-8", "no"), new XElement("Revenda", new XElement("Idrevendacrm", item.ID), new XElement("Idrevendaerp", item.CodigoMatriz), new XElement("Cpfcnpj", cpfCnpj), new XElement("Statuscode", item.RazaoStatus), new XElement("Statecode", item.Status) )); xml = xmlroot.Declaration.ToString() + Environment.NewLine + xmlroot.ToString();; resultado = new Domain.Servicos.SellOutService(this.Organizacao, this.IsOffline).PersistirRevenda(usuario, senha, xml, out resposta); if (resultado == false) { throw new ArgumentException(resposta); } registrosAtualizados++; break; } } } } return(registrosAtualizados); }
public Ocorrencia DefinirPropriedades(Intelbras.Message.Helper.MSG0277 xml) { var crm = new Model.Ocorrencia(this.Organizacao, this.IsOffline); #region Propriedades Crm->Xml if (!String.IsNullOrEmpty(xml.CodigoOcorrencia)) { Ocorrencia ocorrencia = new Servicos.OcorrenciaService(this.Organizacao, this.IsOffline).BuscaOcorrencia(new Guid(xml.CodigoOcorrencia)); if (ocorrencia != null) { crm.Id = new Guid(xml.CodigoOcorrencia); } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "CodigoOcorrencia informado não existe para ser atualizado."; return(crm); } if (ocorrencia.RazaoStatus == (int)Domain.Enum.StatusDaOcorrencia.Cancelada) { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "Ocorrência " + ocorrencia.Numero + " está cancelada."; return(crm); } } if (xml.StatusOcorrencia.HasValue) { crm.RazaoStatus = xml.StatusOcorrencia; } if (xml.PrioridadeOcorrencia.HasValue) { crm.PrioridadeValue = xml.PrioridadeOcorrencia; } if (xml.TipoOcorrencia.HasValue) { crm.TipoDeOcorrencia = xml.TipoOcorrencia; } if (!string.IsNullOrEmpty(xml.DefeitoAlegado)) { crm.DefeitoAlegado = xml.DefeitoAlegado; } if (!string.IsNullOrEmpty(xml.AtividadeExecutada)) { crm.AtividadeExecutada = xml.AtividadeExecutada; } if (!string.IsNullOrEmpty(xml.Observacao)) { crm.Anexo = xml.Observacao; } if (xml.DataHoraPrevistaVisita.HasValue) { crm.DataPrevistaParaVisita = xml.DataHoraPrevistaVisita; } if (xml.DataHoraChegadaTecnico.HasValue) { crm.DataInicioTecnico = xml.DataHoraChegadaTecnico; } if (xml.DataHoraSaidaTecnico.HasValue) { crm.DataSaidaTecnico = xml.DataHoraSaidaTecnico; } if (xml.DataHoraConclusao.HasValue) { crm.DataDeConclusao = xml.DataHoraConclusao; } if (xml.DataHoraEscalacao.HasValue) { crm.DataEscalacao = xml.DataHoraEscalacao; } if (xml.TempoSLA.HasValue) { crm.DataSLA = xml.TempoSLA; } if (!string.IsNullOrEmpty(xml.OrdemServicoCliente)) { crm.OsCliente = xml.OrdemServicoCliente; } if (!string.IsNullOrEmpty(xml.CodigoContato)) { Contato contato = new Intelbras.CRM2013.Domain.Servicos.ContatoService(this.Organizacao, this.IsOffline).BuscaContato(new Guid(xml.CodigoContato)); if (contato != null) { crm.SolicitanteId = new Lookup(contato.ID.Value, "contact"); } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "CodigoContato não encontrado no Crm."; return(crm); } } if (!string.IsNullOrEmpty(xml.CodigoConta)) { Conta cliente = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoConta)); if (cliente != null) { crm.ClienteId = new Lookup(cliente.ID.Value, "account"); } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "CodigoConta não encontrado no Crm."; return(crm); } } if (!string.IsNullOrEmpty(xml.CodigoEmpresaExecutante)) { Conta empresaexecutante = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoEmpresaExecutante)); if (empresaexecutante != null) { crm.EmpresaExecutanteId = new Lookup(empresaexecutante.ID.Value, ""); } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "CodigoEmpresaExecutante não encontrado no Crm."; return(crm); } } if (!string.IsNullOrEmpty(xml.TecnicoResponsavel)) { Contato tecnicoresponsavel = new Intelbras.CRM2013.Domain.Servicos.ContatoService(this.Organizacao, this.IsOffline).BuscaContato(new Guid(xml.TecnicoResponsavel)); if (tecnicoresponsavel != null) { //crm.TecnicoResponsavelId = new Lookup(tecnicoresponsavel.ID.Value, ""); Trocado para Técnico da Visita, por solicitação da Silvana - Chamado 133127 crm.TecnicoDaVisitaId = new Lookup(tecnicoresponsavel.ID.Value, ""); } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "TecnicoResponsavel não encontrado no Crm."; return(crm); } } if (!string.IsNullOrEmpty(xml.Logradouro)) { crm.Rua = xml.Logradouro; } if (!string.IsNullOrEmpty(xml.Bairro)) { crm.Bairro = xml.Bairro; } if (!string.IsNullOrEmpty(xml.NomeCidade)) { crm.Cidade = xml.NomeCidade; } if (!string.IsNullOrEmpty(xml.UF)) { crm.Estado = xml.UF; } if (!string.IsNullOrEmpty(xml.DescricaoFCA)) { crm.DescricaoDaMensagemDeIntegracao = xml.DescricaoFCA; } if (!string.IsNullOrEmpty(xml.ResumoOcorrencia)) { crm.ResumoDaOcorrencia = xml.ResumoOcorrencia; } if (!string.IsNullOrEmpty(xml.CausaFinal)) { Causa causa = new Intelbras.CRM2013.Domain.Servicos.CausaService(this.Organizacao, this.IsOffline).ObterPor(new Guid(xml.CausaFinal)); if (causa != null) { crm.CausaFinal = new Lookup(causa.Id, ""); } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "CausaFinal não encontrada no Crm."; return(crm); } } if (!string.IsNullOrEmpty(xml.AcaoFinal)) { Acao acao = new Intelbras.CRM2013.Domain.Servicos.AcaoService(this.Organizacao, this.IsOffline).ObterPor(new Guid(xml.AcaoFinal)); if (acao != null) { crm.AcaoFinal = new Lookup(acao.Id, ""); } else { resultadoPersistencia.Sucesso = false; resultadoPersistencia.Mensagem = "AcaoFinal não encontrada no Crm."; return(crm); } } if (xml.StatusOcorrencia == 993520004) // Atendimento Rejeitado { Conta conta = new Intelbras.CRM2013.Domain.Servicos.ContaService(this.Organizacao, this.IsOffline).BuscaConta(new Guid(xml.CodigoEmpresaExecutante)); Ocorrencia ocorrencia = new Intelbras.CRM2013.Domain.Servicos.OcorrenciaService(this.Organizacao, this.IsOffline).BuscaOcorrencia(new Guid(xml.CodigoOcorrencia)); string justificativa = ""; if (ocorrencia.EmpresaAtendimentoRejeitado == null) { if (!string.IsNullOrEmpty(xml.Justificativa)) { justificativa = xml.Justificativa; } crm.EmpresaAtendimentoRejeitado = conta.RazaoSocial + " - " + justificativa + " - " + DateTime.Now; } else { if (!string.IsNullOrEmpty(xml.Justificativa)) { justificativa = xml.Justificativa; } crm.EmpresaAtendimentoRejeitado += "\r\n" + (conta.RazaoSocial + " - " + justificativa + " - " + DateTime.Now); } crm.AddNullProperty("EmpresaExecutanteId"); } #endregion return(crm); }