示例#1
0
        public void NormalizaArtigos()          //Normalizar para deixar somente números
        {
            List <string> NewListaArtigos = new List <string>();
            StringBuilder sb;

            for (int i = 0; i < this.ListaArtigos.Count; i++)
            {
                sb = new StringBuilder();

                if (!Util.PalavraContemDigito(this.ListaArtigos.ElementAt(i)))
                {
                    ListaArtigos.RemoveAt(i);
                }

                else
                {
                    foreach (char c in this.ListaArtigos.ElementAt(i))
                    {
                        if (char.IsDigit(c) || c.Equals('-'))
                        {
                            sb.Append(c);
                        }
                    }
                }

                NewListaArtigos.Add(sb.ToString());
            }

            this.ListaArtigos = NewListaArtigos;
        }
示例#2
0
        public void PreenchendoListaArtigos()
        {
            bool          SaoArtigos   = false;
            int           CountArtigos = 0;
            StringBuilder sb           = new StringBuilder();

            var PalavrasDaJuris = InteiroTeor.Split(' ');
            var PreviousWord    = PalavrasDaJuris.ElementAt(0);

            foreach (var CurrentWord in PalavrasDaJuris)
            {
                if (SaoArtigos)
                {
                    if (CurrentWord.EndsWith(".") || CurrentWord.Equals(".") ||
                        CurrentWord.EndsWith(")") || CurrentWord.Equals(")") ||
                        CurrentWord.EndsWith(":") || CurrentWord.Equals(":") ||
                        CurrentWord.EndsWith(@"\") || CurrentWord.Equals(@"\") ||
                        CurrentWord.EndsWith("\"") || CurrentWord.Equals("\"") ||
                        CurrentWord.EndsWith("\n") || CurrentWord.EndsWith("\r") ||
                        CountArtigos > 8)                                                       //Precisa de um maximo, de ler 8 palavras após achar um "ARTIGOS"
                    {
                        sb.Append(CurrentWord);
                        SaoArtigos   = false;
                        CountArtigos = 0;
                        sb.Clear();
                    }
                    else
                    {
                        sb.Append(CurrentWord);
                        CountArtigos++;
                    }
                }

                else
                {
                    if (PreviousWord.Contains("ARTIGOS") && Util.PalavraContemDigito(CurrentWord))  //Se a palavra anterior é "ARTIGOS" e a atual contem numeros
                    {
                        SaoArtigos = true;

                        sb.Append(CurrentWord);
                    }

                    else if (PreviousWord.Contains("ART.") || PreviousWord.Equals("ARTIGO") || (PreviousWord.Equals("ART")))
                    {
                        if (Util.PalavraContemDigito(CurrentWord))             //Só adicionará a lista de artigos caso a palavra posterior contenha um numero (Ex: Art. 23)
                        {
                            ListaArtigos.Add(CurrentWord);
                        }
                    }
                    else if (CurrentWord.StartsWith("ARTS.") || CurrentWord.StartsWith("ART.") || CurrentWord.StartsWith("art.") || CurrentWord.StartsWith("arts."))
                    {
                        if (Util.PalavraContemDigito(CurrentWord))             //Só adicionará a lista de artigos caso a palavra posterior contenha um numero (Ex: Art. 23)
                        {
                            ListaArtigos.Add(CurrentWord);
                        }
                    }
                }

                PreviousWord = CurrentWord.ToUpper();
            }

            NormalizaArtigos();
        }
        /// <summary>
        ///     Método que consulta a estrutura de artigos do banco de dados do Edgecam Manage.
        /// </summary>
        private void ConsultaEstruturaArtigos()
        {
            ListaArtigos lst = new ListaArtigos();

            MontaEstruturaArvore(lst);
        }
        /// <summary>
        ///     Método que monta a estrutura de pai e filho na grade de dados em forma de árvore.
        /// </summary>
        /// <param name="ListaArtigos">Lista de peças do banco de dados SQL</param>
        private void MontaEstruturaArvore(ListaArtigos ListaArtigos)
        {
            List <String> processados = new List <string>();

            if (ListaArtigos != null && ListaArtigos.Count > 0)
            {
                foreach (Artigo a in ListaArtigos)
                {
                    //Se já foi processado, ignora o item.
                    if (processados.Where(x => x.ToUpper() == a.id.ToString().ToUpper()).Count() > 0)
                    {
                        continue;
                    }

                    //Adiciona o item na lista de processados.
                    processados.Add(a.id.ToString());

                    //Recebe os nós do UltraTreeView para a partir dele, ir adicionados os próximos 'nodos' (filhos).
                    UltraTreeNode n = utv.Nodes.Add();

                    //Primeira adiciona o no pai
                    n.Cells[(int)e_SkaColunas.Selecionar].Value = false;

                    //Adiciona a imagem ao tipo de componente (peça ou conjunto)
                    EmbeddableImageRenderer embeddableImageRenderer = new EmbeddableImageRenderer();
                    embeddableImageRenderer.DrawBorderShadow = false;
                    n.Cells[(int)e_SkaColunas.Tipo].Editor   = embeddableImageRenderer;
                    n.Cells[(int)e_SkaColunas.Tipo].Value    = DefineImagemArtigo(a.IsPai);

                    n.Cells[(int)e_SkaColunas.NomeItem].Value = a.NomePeca;
                    n.Cells[(int)e_SkaColunas.Nivel].Value    = a.Nivel;
                    n.Cells[(int)e_SkaColunas.Ativo].Value    = a.Ativo;
                    n.Cells[(int)e_SkaColunas.Revisao].Value  = a.Revisao;

                    //Procuro os filhos
                    List <Artigo> lstFilhos = ListaArtigos.Where(x => x.NomePai.ToUpper() == a.NomePeca.ToUpper()).AsEnumerable().OrderBy(y => a.NomePeca).ToList();

                    //Possui filhos e os adiciono no grid.
                    if (lstFilhos.Count > 0)
                    {
                        foreach (Artigo filho in lstFilhos)
                        {
                            //Recebe os nós já adicionados no pai.
                            UltraTreeNode noFilho = n.Nodes.Add();

                            //Adiciona os elementos filhos à árvore
                            noFilho.Cells[(int)e_SkaColunas.Selecionar].Value = false;

                            //Adiciona a imagem ao tipo de componente (peça ou conjunto)
                            EmbeddableImageRenderer embeddableImageRenderer_f = new EmbeddableImageRenderer();
                            embeddableImageRenderer_f.DrawBorderShadow   = false;
                            noFilho.Cells[(int)e_SkaColunas.Tipo].Editor = embeddableImageRenderer_f;
                            noFilho.Cells[(int)e_SkaColunas.Tipo].Value  = DefineImagemArtigo(filho.IsPai);

                            noFilho.Cells[(int)e_SkaColunas.NomeItem].Value = filho.NomePeca;
                            noFilho.Cells[(int)e_SkaColunas.Nivel].Value    = filho.Nivel;
                            noFilho.Cells[(int)e_SkaColunas.Ativo].Value    = filho.Ativo;
                            noFilho.Cells[(int)e_SkaColunas.Revisao].Value  = filho.Revisao;

                            n.Nodes.Add(noFilho);

                            //Adiciona o item na lista de processados.
                            processados.Add(filho.id.ToString());
                        }
                    }
                    utv.Nodes.Add(n);
                }

                //  Após o 'foreach', expande a árvore.
                utv.ExpandAll();
            }
        }