private Intelbras.Message.Helper.MSG0088 DefinirPropriedades(Product crm) { Intelbras.Message.Helper.MSG0088 xml = new Pollux.MSG0088(Domain.Enum.Sistemas.RetornaSistema(Domain.Enum.Sistemas.Sistema.CRM), Helper.Truncate(crm.Nome, 40)); if (crm.Codigo != null) { xml.CodigoProduto = crm.Codigo; } if (crm.DataUltAlteracaoPVC.HasValue) { xml.DataAlteracaoPrecoVenda = crm.DataUltAlteracaoPVC.Value.ToLocalTime(); } if (crm.Showroom.HasValue) { xml.ShowRoom = crm.Showroom; } if (crm.Nome != null) { xml.Nome = crm.Nome; } if (crm.Descricao != null) { xml.Descricao = crm.Descricao; } if (crm.PesoEstoque != null) { xml.PesoEstoque = crm.PesoEstoque; } xml.Situacao = (crm.Status.HasValue ? crm.Status.Value : (int)Enum.Produto.StateCode.ativo); if (crm.TipoProdutoid.HasValue) { xml.TipoProduto = crm.TipoProdutoid.Value; } if (crm.GrupoEstoque != null) { GrupoEstoque grpEstoq = new Servicos.GrupoEstoqueService(this.Organizacao, this.IsOffline).ObterPor(crm.GrupoEstoque.Id); if (grpEstoq != null && grpEstoq.Codigo.HasValue) { xml.GrupoEstoque = grpEstoq.Codigo.Value; } } if (crm.UnidadeNegocio != null) { UnidadeNegocio unidadeNegocio = new Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocio(crm.UnidadeNegocio.Id); if (unidadeNegocio != null) { xml.UnidadeNegocio = unidadeNegocio.ChaveIntegracao; xml.NomeUnidadeNegocio = unidadeNegocio.Nome; } } if (crm.Segmento != null) { Model.Segmento segmento = new Servicos.SegmentoService(this.Organizacao, this.IsOffline).ObterPor(crm.Segmento.Id); if (segmento != null && !String.IsNullOrEmpty(segmento.CodigoSegmento)) { xml.Segmento = segmento.CodigoSegmento; xml.NomeSegmento = segmento.Nome; } } if (crm.FamiliaProduto != null) { Model.FamiliaProduto familiaProduto = new Servicos.FamiliaProdutoService(this.Organizacao, this.IsOffline).ObterPor(crm.FamiliaProduto.Id); if (familiaProduto != null && !String.IsNullOrEmpty(familiaProduto.Codigo)) { xml.Familia = familiaProduto.Codigo; } } if (crm.SubfamiliaProduto != null) { SubfamiliaProduto subFamiliaProduto = new Servicos.SubFamiliaProdutoService(this.Organizacao, this.IsOffline).ObterPor(crm.SubfamiliaProduto.Id); if (subFamiliaProduto != null && !String.IsNullOrEmpty(subFamiliaProduto.Codigo)) { xml.SubFamilia = subFamiliaProduto.Codigo; } } if (crm.Origem != null) { Origem Origem = new Servicos.OrigemService(this.Organizacao, this.IsOffline).ObterPor(crm.Origem.Id); if (Origem != null && !String.IsNullOrEmpty(Origem.Codigo)) { xml.Origem = Origem.Codigo; } } if (crm.UnidadePadrao != null) { Unidade unidade = new Servicos.UnidadeService(this.Organizacao, this.IsOffline).BuscaPor(crm.UnidadePadrao.Id); if (unidade != null && !String.IsNullOrEmpty(unidade.Nome)) { xml.UnidadeMedida = unidade.Nome; } } if (crm.GrupoUnidades != null) { GrupoUnidade grupoUnidade = new Servicos.GrupoUnidadeMedidaService(this.Organizacao, this.IsOffline).ObterPor(crm.GrupoUnidades.Id); if (grupoUnidade != null) { xml.GrupoUnidadeMedida = grupoUnidade.Nome; } } if (crm.FamiliaComercial != null) { FamiliaComercial familiaComercial = new Servicos.FamiliaComercialService(this.Organizacao, this.IsOffline).ObterPor(crm.FamiliaComercial.Id); if (familiaComercial != null && !String.IsNullOrEmpty(familiaComercial.Codigo)) { xml.FamiliaComercial = familiaComercial.Codigo; } } if (crm.QuantidadeMultiplaProduto.HasValue) { xml.QuantidadeMultipla = crm.QuantidadeMultiplaProduto.Value; } if (crm.NaturezaProduto != null) { xml.NaturezaProduto = crm.NaturezaProduto.Value; } if (crm.FamiliaMaterial != null) { FamiliaMaterial familiaMaterial = new Servicos.FamiliaMaterialService(this.Organizacao, this.IsOffline).ObterPor(crm.FamiliaMaterial.Id); if (familiaMaterial != null && !String.IsNullOrEmpty(familiaMaterial.Codigo)) { xml.FamiliaMaterial = familiaMaterial.Codigo; } } if (crm.FamiliaMaterial != null) { FamiliaMaterial familiaMaterial = new Servicos.FamiliaMaterialService(this.Organizacao, this.IsOffline).ObterPor(crm.FamiliaMaterial.Id); if (familiaMaterial != null && !String.IsNullOrEmpty(familiaMaterial.Codigo)) { xml.FamiliaMaterial = familiaMaterial.Codigo; } } if (crm.ListaPrecoPadrao != null) { xml.ListaPreco = crm.ListaPrecoPadrao.Name; } if (crm.Moeda != null) { xml.Moeda = crm.Moeda.Name; } if (crm.QuantidadeDecimal.HasValue) { xml.QuantidadeDecimal = crm.QuantidadeDecimal.Value; } if (crm.ExigeTreinamento.HasValue) { xml.ExigeTreinamento = crm.ExigeTreinamento.Value; } if (crm.RebatePosVendaAtivado.HasValue) { xml.RebateAtivado = crm.RebatePosVendaAtivado.Value; } if (crm.NomeFornecedor != null) { xml.Fabricante = crm.NomeFornecedor; } if (crm.NumeroPecaFabricante != null) { xml.NumeroPecaFabricante = crm.NumeroPecaFabricante; } if (crm.VolumeEstoque != null) { xml.VolumeEstoque = crm.VolumeEstoque; } if (crm.Complemento != null) { xml.ComplementoProduto = crm.Complemento; } if (crm.Url != null) { xml.URL = crm.Url; } if (crm.QuantidadeDisponivel.HasValue) { xml.QuantidadeDisponivel = crm.QuantidadeDisponivel.Value; } if (crm.Fornecedor != null) { xml.Fornecedor = crm.Fornecedor; } if (crm.ConsideraOrcamentoMeta.HasValue) { xml.ConsiderarOrcamentoMeta = crm.ConsideraOrcamentoMeta.Value; } if (crm.FaturamentoOutroProduto.HasValue) { xml.FaturamentoOutroProduto = crm.FaturamentoOutroProduto.Value; } xml.TemMensagem = crm.TemMensagem; if (crm.TemMensagem == true) { if (crm.Mensagem != null && crm.Mensagem != String.Empty) { xml.DescricaoMensagem = crm.Mensagem; } } else { xml.TemMensagem = false; } xml.AliquotaIPI = crm.PercentualIPI; xml.EAN = crm.EAN; xml.NCM = crm.NCM; xml.CustoPadrao = (crm.CustoAtual.HasValue) ? crm.CustoAtual.Value : 0; xml.CustoAtual = crm.CustoAtual; xml.BloquearComercializacao = crm.BloquearComercializacao; xml.ComercializadoForaKit = crm.ComercializadoForaKit; xml.PoliticaPosVendas = crm.PoliticaPosVenda; if (crm.PoliticaPosVenda != null) { xml.DescricaoPoliticaPosVendas = DescricaoPoliticaPosVenda(crm.PoliticaPosVenda.Value); } xml.TempoGarantia = crm.TempoGarantia; xml.EKit = crm.EKit; xml.PossuiSubstituto = crm.PossuiSubstituto; xml.PassivelSolicitacaoBeneficio = crm.PermitirEmSolBenef; xml.Backup = crm.BackupDistribuidor; xml.BackupRevendas = crm.BackupRevenda; xml.ShowRoomRevendas = crm.ShowroomRevenda; if (!String.IsNullOrEmpty(crm.DepositoPadrao)) { xml.DepositoPadrao = crm.DepositoPadrao; } if (crm.CodigoTipoDespesa.HasValue) { xml.CodigoTipoDespesa = crm.CodigoTipoDespesa; } if (crm.DestaqueNCM.HasValue) { xml.DestaqueNCM = crm.DestaqueNCM; } if (!String.IsNullOrEmpty(crm.NVE)) { xml.NVE = crm.NVE; } if (!String.IsNullOrEmpty(crm.CodigoUnidadeFamilia)) { xml.CodigoUnidadeFamilia = crm.CodigoUnidadeFamilia; } if (crm.ProdutoSubstituto != null) { var produtoSubstituto = RepositoryService.Produto.Retrieve(crm.ProdutoSubstituto.Id, "productnumber"); if (produtoSubstituto == null) { throw new ArgumentException("(CRM) Produto substituto não encontrado!"); } xml.CodigoProdutoSubstituto = produtoSubstituto.Codigo; } xml.TipoItem = crm.TipoItem; if (crm.LinhaProduto != null) { LinhaComercial linhaProduto = (new CRM2013.Domain.Servicos.RepositoryService()).LinhaComercial.Retrieve(crm.LinhaProduto.Id); if (linhaProduto != null) { xml.LinhaProduto = linhaProduto.Id.ToString(); xml.NomeLinhaProduto = linhaProduto.Nome; } } return(xml); }
public Pollux.MSG0143 DefinirPropriedades(PortfoliodoKeyAccountRepresentantes objModel) { #region Propriedades Crm->Xml Pollux.MSG0143 msg0143 = new Pollux.MSG0143(itb.RetornaSistema(itb.Sistema.CRM), Helper.Truncate(objModel.Nome, 40)); string nomeUnid = String.Empty; string nomeSegmento = String.Empty; msg0143.CodigoPortfolioRepresentante = objModel.ID.Value.ToString(); if (objModel.KeyAccountRepresentante != null) { Contato representante = new Servicos.ContatoService(this.Organizacao, this.IsOffline).BuscaContato(objModel.KeyAccountRepresentante.Id); if (representante != null && representante.CodigoRepresentante.Length > 0) { msg0143.CodigoRepresentante = Convert.ToInt32(representante.CodigoRepresentante); } else { throw new Exception("Representante não localizado/sem código representante."); } } if (objModel.UnidadedeNegocio != null) { UnidadeNegocio unidadeNegocio = new Servicos.UnidadeNegocioService(this.Organizacao, this.IsOffline).BuscaUnidadeNegocio(objModel.UnidadedeNegocio.Id); if (unidadeNegocio != null) { msg0143.CodigoUnidadeNegocio = unidadeNegocio.ChaveIntegracao; nomeUnid = unidadeNegocio.Nome; } else { throw new Exception("Unidade de negocio não localizada ou sem nome."); } } if (objModel.AssistentedeAdministracaodeVendas != null) { Usuario usuario = new Servicos.UsuarioService(this.Organizacao, this.IsOffline).ObterPor(objModel.AssistentedeAdministracaodeVendas.Id); if (usuario != null && usuario.CodigoAssistenteComercial != null) { msg0143.CodigoAssistente = usuario.CodigoAssistenteComercial.Value; msg0143.CodigoAssistenteCRM = usuario.ID.Value.ToString(); } else { throw new Exception("Usuario sem código de assistente comercial."); } } if (objModel.Segmento != null) { Segmento segmento = new Servicos.SegmentoService(this.Organizacao, this.IsOffline).ObterPor(objModel.Segmento.Id); if (segmento != null) { msg0143.CodigoSegmento = segmento.CodigoSegmento; nomeSegmento = segmento.Nome; } else { throw new Exception("Segmento não localizado."); } } else { msg0143.CodigoSegmento = "0000"; nomeSegmento = ""; } if (objModel.SupervisordeVendas != null) { Usuario supervisor = new Servicos.UsuarioService(this.Organizacao, this.IsOffline).ObterPor(objModel.SupervisordeVendas.Id); if (supervisor != null) { msg0143.CodigoSupervisor = supervisor.ID.Value.ToString(); if (!String.IsNullOrEmpty(supervisor.CodigoSupervisorEMS)) { msg0143.CodigoSupervisorEMS = supervisor.CodigoSupervisorEMS; } else { throw new Exception("Codigo Supervisor EMS não preenchido."); } } else { throw new Exception("Supervisor não localizado."); } } if (objModel.Status.HasValue) { if (objModel.Status.Value == 1) { msg0143.Situacao = 0; } else { msg0143.Situacao = 1; } } if (!String.IsNullOrEmpty(objModel.Nome)) { string nometmp = objModel.Nome + " - " + nomeUnid + " - " + nomeSegmento; if (nometmp.Length > 99) { msg0143.Nome = nometmp.Substring(0, 99); } else { msg0143.Nome = nometmp; } } else { throw new Exception("PortfolioRepresentante sem nome."); } #endregion return(msg0143); }