public string Divergencia()
        {
            AcessoBD abd = new AcessoBD();

            return(abd.GetDadosDivergencia(idTarefa));
        }
Beispiel #2
0
        /// <summary>
        /// Importa os dados de xml de manifestos na pasta padrão
        /// </summary>
        public bool LerPreManifesto(string nomeArquivo)
        {
            try
            {
                XmlDocument manifesto = new XmlDocument();
                manifesto.Load(nomeArquivo);

                var      ValueResult = manifesto.GetElementsByTagName("Value");
                var      TextResult  = manifesto.GetElementsByTagName("TextValue");
                AcessoBD abd         = new AcessoBD();

                var ctesNoXml = new List <string>();
                for (int i = 5; i < ValueResult.Count - 4; i = i + 6)
                {
                    ctesNoXml.Add(ValueResult[i].InnerText);
                }
                var quantCtes = ctesNoXml.Distinct().Count();

                Manifestos lido = new Manifestos()
                {
                    numeroManifesto    = int.Parse(nomeArquivo.Replace(PastasXml.Default.PastaPreManifestos + "\\", "").Replace(".xml", "")),
                    VolumesManifesto   = (int)double.Parse(ValueResult[ValueResult.Count - 4].InnerText.Replace('.', ',')),
                    pesoManifesto      = double.Parse(ValueResult[ValueResult.Count - 2].InnerText.Replace('.', ',')),
                    quantCtesManifesto = quantCtes
                };

                abd.CadastrarManifesto(lido);

                int        cte;
                int        indexNF = 0;
                string     fornecedor;
                List <Cte> ctesNoPreManifesto = new List <Cte>();
                for (int i = 5; i < ValueResult.Count - 4; i = i + 6)
                {
                    cte = int.Parse(ValueResult[i].InnerText.Replace('/', ' '));

                    Cte cteDaVez = ctesNoPreManifesto.Where(x => x.numeroCte == cte).Select(x => x).FirstOrDefault();
                    if (cteDaVez == null)
                    {
                        ctesNoPreManifesto.Add(new Cte(cte, TextResult[indexNF].InnerText.TrimStart('0')));
                    }
                    else
                    {
                        cteDaVez.notasCte += "\\" + TextResult[indexNF].InnerText.TrimStart('0');
                    }

                    fornecedor = ValueResult[i - 5].InnerText;
                    indexNF++;
                }
                foreach (var item in ctesNoPreManifesto)
                {
                    abd.CadastrarCte(new Cte(item.numeroCte, item.notasCte));
                    AlterarNfs(item.notasCte, item.numeroCte, fornecedor);  //  alterado para novo cte
                    CriarCteManifesto(item.numeroCte, lido.numeroManifesto);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Importa os dados de xml de manifestos na pasta padrão
        /// </summary>
        public bool LerManifesto(string nomeArquivo)
        {
            try
            {
                XmlDocument manifesto = new XmlDocument();
                manifesto.Load(nomeArquivo);

                AcessoBD   abd    = new AcessoBD();
                var        result = manifesto.GetElementsByTagName("Value");
                Manifestos lido   = new Manifestos
                {
                    numeroManifesto    = int.Parse(nomeArquivo.Replace(PastasXml.Default.PastaManifestos + "\\", "").Replace(".xml", "")),
                    VolumesManifesto   = (int)double.Parse(result[result.Count - 2].InnerText.Replace('.', ',')),
                    pesoManifesto      = double.Parse(result[result.Count - 3].InnerText.Replace('.', ',')),
                    quantCtesManifesto = (int)double.Parse(result[result.Count - 4].InnerText.Replace('.', ','))
                };

                abd.CadastrarManifesto(lido);

                int          cte;
                NotasFiscais nfLida = new NotasFiscais();

                for (int i = 0; i < result.Count - 4; i = i + 10)
                {
                    cte = int.Parse(result[i].InnerText);

                    abd.CadastrarCte(new Cte(cte, result[i + 1].InnerText));

                    CriarCteManifesto(cte, lido.numeroManifesto);

                    nfLida.fornecedorNF = result[i + 2].InnerText;
                    nfLida.clienteNF    = result[i + 7].InnerText;
                    nfLida.CteNovoNF    = abd.GetNovoCtePorNum(int.Parse(result[i].InnerText)).Max(x => x.idCte);
                    nfLida.skuNF        = 0;

                    if (!result[i + 1].InnerText.Contains("\\"))
                    {
                        nfLida.numeroNF  = result[i + 1].InnerText;
                        nfLida.volumesNF = (int)double.Parse(result[i + 8].InnerText.Replace('.', ','));
                        InserirNotaFiscal(nfLida);
                    }
                    else
                    {
                        var nfs = result[i + 1].InnerText.Split('\\');
                        nfLida.volumesNF = (int)System.Math.Ceiling(double.Parse(result[i + 8].InnerText.Replace('.', ',')) / nfs.Count()); //volume total pode variar por causa desse truncamento

                        foreach (var item in nfs)
                        {
                            nfLida.numeroNF = item;
                            InserirNotaFiscal(nfLida);
                        }
                    }

                    // AlterarNfs(result[i + 1].InnerText, cte);
                }

                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Importa os dados de xml de manifestos na pasta padrão
        /// </summary>
        public bool LerPreManifesto(string nomeArquivo)
        {
            try
            {
                XmlDocument manifesto = new XmlDocument();
                manifesto.Load(nomeArquivo);

                var          ValueResult = manifesto.GetElementsByTagName("Value");
                var          TextResult  = manifesto.GetElementsByTagName("TextValue");
                AcessoBD     abd         = new AcessoBD();
                NotasFiscais nfLida      = new NotasFiscais();

                var ctesNoXml = new List <string>();

                //------------------------- CADASTRO PRE MANIFEST0 ------------------

                for (int i = 5; i < ValueResult.Count - 4; i += 6)
                {
                    ctesNoXml.Add(ValueResult[i].InnerText);
                }

                Manifestos lido = new Manifestos()
                {
                    numeroManifesto    = int.Parse(nomeArquivo.Replace(PastasXml.Default.PastaPreManifestos + "\\", "").Replace(".xml", "")),
                    VolumesManifesto   = (int)double.Parse(ValueResult[ValueResult.Count - 4].InnerText.Replace('.', ',')),
                    pesoManifesto      = double.Parse(ValueResult[ValueResult.Count - 2].InnerText.Replace('.', ',')),
                    quantCtesManifesto = ctesNoXml.Distinct().Count()
                };

                abd.CadastrarManifesto(lido);

                //------------------------- CADASTRO CTES ------------------

                int        cte;
                int        indexNF            = 0;
                string     fornecedor         = "";
                List <Cte> ctesNoPreManifesto = new List <Cte>();
                for (int i = 5; i < ValueResult.Count - 4; i += 6)
                {
                    cte = int.Parse(ValueResult[i].InnerText.Replace('/', ' '));

                    Cte cteDaVez = ctesNoPreManifesto.Where(x => x.numeroCte == cte).Select(x => x).FirstOrDefault();
                    if (cteDaVez == null)
                    {
                        ctesNoPreManifesto.Add(new Cte(cte, TextResult[indexNF].InnerText.TrimStart('0')));
                    }

                    else
                    {
                        cteDaVez.notasCte += "\\" + TextResult[indexNF].InnerText.TrimStart('0');
                    }

                    fornecedor = ValueResult[i - 5].InnerText;
                    indexNF++;
                }



                foreach (var item in ctesNoPreManifesto)
                {
                    abd.CadastrarCte(new Cte(item.numeroCte, item.notasCte));
                    CriarCteManifesto(item.numeroCte, lido.numeroManifesto);
                }


                //------------------------- CADASTRO/ALTERAÇÃO DE NF'S E EXPORTAÇÃO CROSS ------------------

                indexNF = 0;
                for (int i = 5; i < ValueResult.Count - 4; i += 6)
                {
                    nfLida.numeroNF     = TextResult[indexNF].InnerText.TrimStart('0');
                    nfLida.fornecedorNF = ValueResult[i - 5].InnerText;
                    nfLida.clienteNF    = ValueResult[i - 4].InnerText;
                    nfLida.CteNovoNF    = abd.GetNovoCtePorNum(int.Parse(ValueResult[i].InnerText.Replace('/', ' '))).Max(x => x.idCte);
                    nfLida.skuNF        = 0;
                    nfLida.volumesNF    = int.Parse(ValueResult[i - 3].InnerText.Replace(".00", "")); //volume corrigido
                    InserirNotaFiscal(nfLida);

                    indexNF++;

                    ExportarXmlCrossDocking(ValueResult[i].InnerText.Replace('/', ' '), nfLida.fornecedorNF);
                }
                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }