Пример #1
0
        /// <summary>
        /// Percorre a tabela de Excel e retorna um tipo de objeto
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="path"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public void LePlanilhaExcelEInsereDados(string path, int idEntidade, string nomePlanilha = "Sheet1")
        {
            string nomeArquivo = Path.GetFileName(path);

            ENLog.MapaArquivos mapArq = new ENLog.MapaArquivos(nomeArquivo, ENLog.TipoArquivo.ACSOIDTSC, path, 0);

            Log.AtualizaArquivo <ENLog.MapaArquivos>(mapArq, ENLog.StatusProcessamentoArquivo.NaoProcessado, String.Empty, "Inicia processamento de arquivo");
            int idArquivo = mapArq.IdArquivo;

            int qtdCartoes     = 0;
            int qtdCartoesErro = 0;

            using (OleDbConnection conexao = new OleDbConnection(String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1';", path)))
            {
                Log.AtualizaArquivo <ENLog.MapaArquivos>(mapArq, ENLog.StatusProcessamentoArquivo.EmProcessamento, mapArq.Arquivo, "Em processamento de arquivo");
                string descErro = String.Empty;

                conexao.Open();

                ENLog.TipoLog tpLog = ENLog.TipoLog.Informação;
                using (OleDbDataAdapter adapter = new OleDbDataAdapter(String.Format("SELECT * FROM [{0}]", String.Format("{0}$", nomePlanilha)), conexao))
                {
                    try
                    {
                        DataSet ds     = new DataSet();
                        int     linhas = adapter.Fill(ds);

                        InsereCartoes(ds, idArquivo, tpLog, mapArq, qtdCartoes, qtdCartoesErro);
                    }
                    catch (Exception e)
                    {
                        tpLog    = ENLog.TipoLog.Erro;
                        descErro = "Erro ao processar arquivo Identificação Simplificada de Cartões";
                        this.InsereLog(mapArq, qtdCartoes, tpLog, descErro, string.Empty);
                        throw;
                    }
                    finally
                    {
                        conexao.Close();
                    }



                    PortadorBD.InsereNovoServico(idArquivo);
                }
            }
        }
Пример #2
0
        private bool ValidaExistenciaPanProxy(Portador ptr)
        {
            bool vExist = false;

            try
            {
                vExist = PortadorBD.ConsultaCartoes(ptr);
            }

            catch (Exception e)
            {
                if (upSight.Consulta.Base.BD.Geral.TS.TraceError)
                {
                    Trace.TraceError("{0}: {1}", new object[] { "u.CrtCorp.ACSOIDTS.PtrCN", e });
                }
                throw;
            }

            return(vExist);
        }
Пример #3
0
        /// <summary>
        /// Gera o arquivo de identificação simplificada de cartões
        /// </summary>
        /// <param name="path"></param>
        public void GeraArquivoIdentificacaoSimpCrt(string path)
        {
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string pathCompleto     = Path.Combine(path, FormataNomeArquivo());
                int    numLinha         = 0;
                int    qtdIdentificados = 0;
                using (StreamWriter sw = new StreamWriter(pathCompleto, false, Encoding.UTF8))
                {
                    numLinha++;

                    //Gera Cabeçalho
                    sw.WriteLine(CompoeLinhaCabecalho(numLinha));

                    //Gera detalhes
                    foreach (var det in PortadorBD.ConsultaDadosDetalhe())
                    {
                        numLinha++;
                        qtdIdentificados++;
                        sw.WriteLine(String.Concat(det, numLinha.ToString("000000")));
                    }

                    numLinha++;
                    //Gera Rodapé
                    sw.WriteLine(CompeLinhaRodape(qtdIdentificados, numLinha));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #4
0
        /// <summary>
        /// Dado o arquivo ele é realizado o parser e seus dados são salvos nas tabelas correspondentes
        /// </summary>
        /// <param name="path"></param>
        public void ProcessaArquivoIdentificacaoSimpCrt(string path, int idEntidade)
        {
            string nomeArquivo = Path.GetFileName(path);

            ENLog.MapaArquivos mapArq = new ENLog.MapaArquivos(nomeArquivo, ENLog.TipoArquivo.ACSOIDTSC, path, 0);

            Log.AtualizaArquivo <ENLog.MapaArquivos>(mapArq, ENLog.StatusProcessamentoArquivo.NaoProcessado, String.Empty, "Inicia processamento de arquivo");
            int idArquivo = mapArq.IdArquivo;

            int linhaAtual     = 0;
            int qtdCartoes     = 0;
            int qtdCartoesErro = 0;

            using (StreamReader sr = new StreamReader(path))
            {
                Log.AtualizaArquivo <ENLog.MapaArquivos>(mapArq, ENLog.StatusProcessamentoArquivo.EmProcessamento, mapArq.Arquivo, "Em processamento de arquivo");
                string descErro    = String.Empty;
                string codConvenio = string.Empty;

                ENLog.TipoLog tpLog = ENLog.TipoLog.Informação;
                DataSet       ds    = new DataSet();
                DataTable     dt    = new DataTable();


                while (!sr.EndOfStream)
                {
                    try
                    {
                        linhaAtual++;
                        string linha = sr.ReadLine();

                        switch (linha.Substring(0, 1))
                        {
                        case "0":
                            codConvenio = linha.Substring(95, 10).TrimEnd(null);
                            crtACSOIDTSCCabecalhoEN.Mapeia(linha, idArquivo).Insere();
                            break;

                        case "1":
                            dt.Rows.Add(crtACSOIDTSCDetalheEN.MapeiaTXTDet(linha, idArquivo, codConvenio, idEntidade, dt));
                            qtdCartoes++;
                            break;

                        case "9":
                            crtACSOIDTSCRodapeEN.Mapeia(linha, idArquivo).Insere();
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        tpLog    = ENLog.TipoLog.Erro;
                        descErro = "Erro ao processar arquivo Identificação Simplificada de Cartões";
                        this.InsereLog(mapArq, qtdCartoes, tpLog, descErro, string.Empty);
                        throw;
                    }
                }

                ds.Tables.Add(dt);
                InsereCartoes(ds, idArquivo, tpLog, mapArq, qtdCartoes, qtdCartoesErro);

                //switch (tpLog)
                //{
                //    case upSight.Global.Log.EN.TipoLog.Erro:
                //        Log.AtualizaArquivo<ENLog.MapaArquivos>(mapArq, ENLog.StatusProcessamentoArquivo.NaoProcessado, mapArq.Arquivo, "Finaliza processamento de arquivo");
                //        break;
                //    default:
                //        Log.AtualizaArquivo<ENLog.MapaArquivos>(mapArq, ENLog.StatusProcessamentoArquivo.ProcessadoOk, mapArq.Arquivo, "Finaliza processamento de arquivo");
                //        break;
                //}

                //if (qtdCartoesErro > 0)
                //{
                //    qtdCartoes = qtdCartoes - qtdCartoesErro;
                //    descErro = String.Format("Total de cartões com erro: {0}", qtdCartoesErro);
                //    this.InsereLog(mapArq, qtdCartoes, ENLog.TipoLog.Informação, descErro, string.Empty);
                //}

                //descErro = String.Format("Total de cartões identificados: {0}", qtdCartoes);
                //this.InsereLog(mapArq, qtdCartoes, ENLog.TipoLog.Informação, descErro, string.Empty);

                PortadorBD.InsereNovoServico(idArquivo);
            }
        }