示例#1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static int Main()
        {
            try
            {
                string organizationName           = SDKore.Configuration.ConfigurationManager.GetSettingValue("OrganizacaoIntelbras");
                var    relacionamentoCanalService = new Intelbras.CRM2013.Domain.Servicos.RelacionamentoCanalService(organizationName, false);

                #region Recupera valor do parâmetro global.
                Intelbras.CRM2013.Domain.Servicos.RepositoryService RepositoryService = new Intelbras.CRM2013.Domain.Servicos.RepositoryService(organizationName, false);
                var parametroGlobal = RepositoryService.ParametroGlobal.ObterPorCodigoTipoParametroGlobal((int)Domain.Enum.TipoParametroGlobal.DataExecucaoValorPSD);
                if (parametroGlobal == null)
                {
                    throw new ArgumentException("(CRM) Não foi encontrado Parametro Global [" + (int)(int)Domain.Enum.TipoParametroGlobal.DataExecucaoValorPSD + "].");
                }
                var dataConsulta = Convert.ToDateTime(parametroGlobal.Valor);
                #endregion

                if (dataConsulta.Date == DateTime.Now.Date)
                {
                    ProdutoService ProdutoServices = new ProdutoService(organizationName, false);
                    ProdutoServices.EnviarValorPSD();

                    #region Atualiza data parâmetro global
                    parametroGlobal.Valor = Helper.ProximoMes().Day.ToString() + "/" + Helper.ProximoMes().Month.ToString() + "/" + Helper.ProximoMes().Year.ToString();
                    RepositoryService.ParametroGlobal.Update(parametroGlobal);
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erro : " + ex.Message);
            }
            return(0);
        }
示例#2
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);
        }