public string Processar(Stream file) { string resposta = "processado"; if (file != null && file.Length > 0) { var arquivo = new ConciliacaoArquivoManipular(new StreamReader(file)); String first_line = arquivo.LerLinha(true); try { if ((first_line.ToUpper().Contains("CIELO")) && (arquivo.ProcessarArquivoCielo(first_line))) //Opção de extrato - saldo em aberto { bool md5_encontrado = false; string lsArquivomd5 = ""; string is_linha_atual = ""; while ((is_linha_atual = arquivo.LerLinha()) != null) { lsArquivomd5 = lsArquivomd5 + is_linha_atual; } arquivo.Seek(0); string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; } else { // md5_encontrado = true; } var cielo = new ConciliacaoCieloDesmontar(arquivo, first_line); if (!md5_encontrado) { DAL.GravarList(cielo.GetCreditos()); DAL.GravarList(cielo.GetResumoEEVDOperacao()); DAL.GravarList(cielo.GetComprovanteEEVDVenda()); DAL.GravarList(cielo.GetResumoEEVCArquivo()); DAL.GravarList(cielo.GetComprovanteEEVCCVenda()); DAL.GravarList(cielo.GetParcelas()); DAL.GravarList(cielo.TotalizadorProdutoGet()); DAL.GravarList(cielo.TotalizadorBancoGet()); DAL.GravarList(cielo.TotalizadorEstabelecimentoGet()); if (md5.arquivo_md5.Equals("")) { DAL.Gravar(md5); } // DAL.GravarList(cielo.RedeGet()); } } else { resposta = "problemas"; } } catch (Exception ex) { resposta = "problemas"; } } else { resposta = "semregistro"; } return(resposta); }
public JsonResult ProcessarArquivo() { var model = new ArquivosEstabelecimentos(); if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { try { model.ds_arquivo = file.FileName; var arquivo = new ConciliacaoArquivoManipular(new StreamReader(file.InputStream)); String first_line = arquivo.LerLinha(true); bool md5_encontrado = false; string lsArquivomd5 = ""; string is_linha_atual = ""; var i = 0; while ((is_linha_atual = arquivo.LerLinha()) != null) { i++; if (i > 500) { break; } lsArquivomd5 = lsArquivomd5 + is_linha_atual; } arquivo.Seek(0); string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; } else { md5_encontrado = true; } var bancario = new ConciliacaoEstabelecimentoDesmontar(arquivo, first_line); model.ArquivoEstabelecimento = bancario.GetListTransacaoEstabelecimento(); if (!md5_encontrado) { DAL.GravarList(model.ArquivoEstabelecimento); EstabelecimentoDAL.ExcluirDuplicados(Convert.ToInt32(UsuarioLogado.IdConta)); DAL.Gravar(md5); } ViewBag.BotaoProcessar = "Gravar"; } catch (Exception ex) { this.AddNotification(ex.Message, NotificationType.Erro); } } } var result = Json(model, JsonRequestBehavior.AllowGet); result.MaxJsonLength = int.MaxValue; return(result); }
public ActionResult Processar(ArquivoDeCartoes model) { try { model.ArquivoResumo = new List <ArquivoResumo>(); model.ArquivoCompleto = new List <ArquivoCompleto>(); model.ArquivoDetalhado = new List <ArquivoDetalhado>(); model.ArquivoTransacao = new List <ArquivoTransacao>(); model.ArquivoAntecipado = new List <ArquivoAntecipado>(); int i = 0; if (Request.Files.Count > 0) { foreach (string fileName in Request.Files) { HttpPostedFileBase file = Request.Files[i]; i = i + 1; if (file != null && file.ContentLength > 0) { model.ds_arquivo = file.FileName; var arquivo = new ConciliacaoArquivoManipular(new StreamReader(file.InputStream)); String first_line = arquivo.LerLinha(true); if ((first_line.ToUpper().Contains("FINANCEIRA")) && (first_line.ToUpper().Contains("FD DO BRASIL PROCESSAMENTO DE DADOS LTDA."))) //&& (arquivo.ProcessarArquivobanese(first_line))) //Opção de extrato - saldo em aberto { bool md5_encontrado = false; string lsArquivomd5 = ""; string is_linha_atual = ""; while ((is_linha_atual = arquivo.LerLinha()) != null) { lsArquivomd5 = lsArquivomd5 + is_linha_atual; } arquivo.Seek(0); string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); var bin = new ConciliacaoBinDesmontar(arquivo, first_line); if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; } else { md5_encontrado = true; } model.ArquivoResumo = bin.ROGet(); model.ArquivoTransacao = bin.CVArrayGet(); model.ArquivoDetalhado = bin.DetalhadoGet(); model.ArquivoCompleto = bin.CompletoGet(); model.ArquivoAntecipado = bin.ARGet(); if (!md5_encontrado) { DAL.GravarList(bin.GetCreditos()); // DAL.GravarList(banese.GetResumoArquivo()); // DAL.GravarList(banese.GetAjustesAntecipacao()); // DAL.GravarList(banese.GetAjustesDesagendamento()); // DAL.GravarList(banese.GetDesagendamentoParcelas()); DAL.GravarList(bin.GetResumoEEVDOperacao()); DAL.GravarList(bin.GetComprovanteEEVDVenda()); DAL.GravarList(bin.GetResumoEEVCArquivo()); DAL.GravarList(bin.GetComprovanteEEVCCVenda()); DAL.GravarList(bin.GetParcelas()); DAL.GravarList(bin.TotalizadorProdutoGet()); DAL.GravarList(bin.TotalizadorBancoGet()); DAL.GravarList(bin.TotalizadorEstabelecimentoGet()); // DAL.GravarList(banese.RedeGet()); DAL.Gravar(md5); } ViewBag.BotaoProcessar = "Buscar"; } else if ((first_line.ToUpper().Contains("VENDAS")) && (first_line.ToUpper().Contains("FD DO BRASIL PROCESSAMENTO DE DADOS LTDA."))) { bool md5_encontrado = false; string lsArquivomd5 = ""; string is_linha_atual = ""; while ((is_linha_atual = arquivo.LerLinha()) != null) { lsArquivomd5 = lsArquivomd5 + is_linha_atual; } arquivo.Seek(0); string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); var bin = new ConciliacaoBinDesmontar(arquivo, first_line); if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; } else { md5_encontrado = true; } model.ArquivoResumo = bin.ROGet(); model.ArquivoTransacao = bin.CVArrayGet(); model.ArquivoDetalhado = bin.DetalhadoGet(); model.ArquivoCompleto = bin.CompletoGet(); model.ArquivoAntecipado = bin.ARGet(); if (!md5_encontrado) { DAL.GravarList(bin.GetCreditos()); // DAL.GravarList(banese.GetResumoArquivo()); // DAL.GravarList(banese.GetAjustesAntecipacao()); // DAL.GravarList(banese.GetAjustesDesagendamento()); // DAL.GravarList(banese.GetDesagendamentoParcelas()); DAL.GravarList(bin.GetResumoEEVDOperacao()); DAL.GravarList(bin.GetComprovanteEEVDVenda()); DAL.GravarList(bin.GetResumoEEVCArquivo()); DAL.GravarList(bin.GetComprovanteEEVCCVenda()); DAL.GravarList(bin.GetParcelas()); DAL.GravarList(bin.TotalizadorProdutoGet()); DAL.GravarList(bin.TotalizadorBancoGet()); DAL.GravarList(bin.TotalizadorEstabelecimentoGet()); // DAL.GravarList(banese.RedeGet()); DAL.Gravar(md5); } } } } } } catch (Exception e) { this.AddNotification(e.Message, "Alerta"); // ModelState.AddModelError(e.Message, e.Message); return(View(model)); } return(View(model)); }
public JsonResult ProcessarArquivo() { var model = new ArquivosBancarios(); if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { try { model.ds_arquivo = file.FileName; string lsArquivomd5 = file.FileName; string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); if (Path.GetExtension(file.FileName).ToLower().Equals(".ofx")) { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(file.InputStream); var list = ofxDocument.Transactions.Select(item => new TransacaoBancaria { conta = ofxDocument.Account.AccountID, ds_historico = item.Memo, nr_doc = item.TransactionID, vl_mvto = item.Amount, tp_mvto = item.TransType.ToString(), dt_mvto = item.Date } ).Where(c => (c.tp_mvto.Substring(0, 1) == "C") || // CREDITO (c.tp_mvto.Substring(0, 1) == "O" && // OU OTHER E CONTEM A PALAVRA CARTAO c.ds_historico.Contains("CARTAO")) ).ToList(); model.ArquivoBancario = list; model.datainicio = ofxDocument.StatementStart; model.datafinal = ofxDocument.StatementEnd; } else { var arquivo = new ConciliacaoArquivoManipular(new StreamReader(file.InputStream)); String first_line = arquivo.LerLinha(true); var bancario = new ConciliacaoBancariaDesmontar(arquivo, first_line); model.ArquivoBancario = bancario.GetListTransacaoBancaria(); } if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; DAL.GravarList(model.ArquivoBancario); DAL.Gravar(md5); } ViewBag.BotaoProcessar = "Gravar"; } catch (Exception ex) { this.AddNotification(ex.Message, NotificationType.Erro); } } } var result = Json(model, JsonRequestBehavior.AllowGet); result.MaxJsonLength = int.MaxValue; return(result); }
public JsonResult ProcessarArquivo() { var httpRequest = System.Web.HttpContext.Current.Request; HttpFileCollection uploadFiles = httpRequest.Files; var docfiles = new List <string>(); var model = new ArquivoDeCartoesUserRede(); if (httpRequest.Files.Count > 0) { foreach (string fileName in httpRequest.Files) { HttpPostedFileBase file = Request.Files[fileName]; if (file != null && file.ContentLength > 0) { try { model.ds_arquivo = file.FileName; var arquivo = new ConciliacaoArquivoManipular(new StreamReader(file.InputStream)); String first_line = arquivo.LerLinha(true); bool md5_encontrado = false; string lsArquivomd5 = ""; string is_linha_atual = ""; while ((is_linha_atual = arquivo.LerLinha()) != null) { lsArquivomd5 = lsArquivomd5 + is_linha_atual; } arquivo.Seek(0); string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; } else { md5_encontrado = true; } if (first_line.ToUpper().Contains("EEVD")) { var userrede = new ConciliacaoUseRedeEEVDDesmontar(arquivo, first_line); model.ArquivosDeCartoesEEVDUserRede = userrede.GetResumoOperacao(); if (!md5_encontrado) { DAL.GravarList(model.ArquivosDeCartoesEEVDUserRede); DAL.GravarList(userrede.GetComprovanteVenda()); DAL.GravarList(userrede.GetPontoVenda()); DAL.GravarList(userrede.GetTotalArquivo()); DAL.GravarList(userrede.GetTotalMatriz()); DAL.GravarList(userrede.TotalizadorBancoGet()); DAL.GravarList(userrede.TotalizadorProdutoGet()); DAL.GravarList(userrede.TotalizadorEstabelecimentoGet()); DAL.Gravar(md5); } } else if (first_line.ToUpper().Contains("EEVC")) { var userrede = new ConciliacaoUseRedeEEVCDesmontar(arquivo, first_line); model.ArquivosDeCartoesEEVCUserRede = userrede.GetResumoArquivo(); if (!md5_encontrado) { DAL.GravarList(userrede.TotalizadorBancoGet()); DAL.GravarList(userrede.TotalizadorProdutoGet()); DAL.GravarList(userrede.TotalizadorEstabelecimentoGet()); DAL.GravarList(userrede.GetComprovanteVenda()); DAL.GravarList(model.ArquivosDeCartoesEEVCUserRede); DAL.GravarList(userrede.GetParcelas()); DAL.Gravar(md5); } } else if (first_line.ToUpper().Contains("EEFI")) { var userrede = new ConciliacaoUseRedeEEFIDesmontar(arquivo, first_line); model.ArquivosDeCartoesEEFIUserRede = userrede.GetResumoArquivo(); if (!md5_encontrado) { DAL.GravarList(userrede.GetCreditos()); DAL.GravarList(userrede.GetAjustesAntecipacao()); DAL.GravarList(userrede.GetAjustesDesagendamento()); DAL.GravarList(userrede.GetDesagendamentoParcelas()); DAL.GravarList(userrede.GetTotalMatriz()); DAL.GravarList(userrede.GetTotalCredito()); DAL.Gravar(md5); } } // DAL.GravarList(model.ArquivosDeCartoesUserRede); ViewBag.BotaoProcessar = "Gravar"; } catch (Exception ex) { this.AddNotification(ex.Message + " " + ex.StackTrace, NotificationType.Erro); } } } } var result = Json(model, JsonRequestBehavior.AllowGet); result.MaxJsonLength = int.MaxValue; return(result); }
public ActionResult Processar(ArquivoDeCartoes model) { try { model.ArquivoResumo = new List <ArquivoResumo>(); model.ArquivoCompleto = new List <ArquivoCompleto>(); model.ArquivoDetalhado = new List <ArquivoDetalhado>(); model.ArquivoTransacao = new List <ArquivoTransacao>(); model.ArquivoAntecipado = new List <ArquivoAntecipado>(); int i = 0; if (Request.Files.Count > 0) { foreach (string fileName in Request.Files) { HttpPostedFileBase file = Request.Files[i]; i = i + 1; if (file != null && file.ContentLength > 0) { model.ds_arquivo = file.FileName; var arquivo = new ConciliacaoArquivoManipular(new StreamReader(file.InputStream)); String first_line = arquivo.LerLinha(true); if (first_line.ToUpper().Contains("GETNET")) //&& (arquivo.ProcessarArquivobanese(first_line))) //Opção de extrato - saldo em aberto { bool md5_encontrado = false; string lsArquivomd5 = ""; string is_linha_atual = ""; while ((is_linha_atual = arquivo.LerLinha()) != null) { lsArquivomd5 = lsArquivomd5 + is_linha_atual; } arquivo.Seek(0); string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); var getnet = new ConciliacaoGetNetDesmontar(arquivo, first_line); if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; } else { md5_encontrado = true; } model.ArquivoResumo = getnet.ROGet(); model.ArquivoTransacao = getnet.CVArrayGet(); model.ArquivoDetalhado = getnet.DetalhadoGet(); model.ArquivoCompleto = getnet.CompletoGet(); model.ArquivoAntecipado = getnet.ARGet(); if (!md5_encontrado) { DAL.GravarList(getnet.GetCreditos()); DAL.GravarList(getnet.GetResumoEEVDOperacao()); DAL.GravarList(getnet.GetComprovanteEEVDVenda()); DAL.GravarList(getnet.GetResumoEEVCArquivo()); DAL.GravarList(getnet.GetComprovanteEEVCCVenda()); DAL.GravarList(getnet.GetParcelas()); DAL.GravarList(getnet.TotalizadorProdutoGet()); DAL.GravarList(getnet.TotalizadorBancoGet()); DAL.GravarList(getnet.TotalizadorEstabelecimentoGet()); DAL.Gravar(md5); } ViewBag.BotaoProcessar = "Buscar"; } } } } } catch (Exception e) { throw e; } return(View(model)); }