public void SplitLote(LoteDTO lote) { var arquivosPdfs = lote.ArquivosImportados.Where(a => a.ExtensaoArquivo == ".pdf").ToList(); foreach (var arquivoImportado in arquivosPdfs) { if (!File.Exists(arquivoImportado.CaminhoArquivo)) { continue; } if (lote.Individual) { SplitPdfIndividual(arquivoImportado, lote); } else { SplitPdf(arquivoImportado, lote); } } //lote.TipoSituacao = TipoSituacao.Processado; //_gir.GravarRotina(lote); }
private void MigrarArquivosUpload(LoteDTO lote) { var origem = String.Format(@"{0}\{1}", CaminhoDiretorio, PastaTempUpload); var destino = String.Format(@"{0}\{1}\{2}", CaminhoDiretorio, lote.AnoExercicio, Importados); var dir = new DirectoryInfo(origem); if (dir.Exists) { var fileTxt = dir.GetFiles("*.txt"); var filesPdf = dir.GetFiles("*.pdf"); var files = filesPdf.Concat(fileTxt).ToList(); foreach (var file in files) { if (!File.Exists(string.Format(@"{0}\{1}", destino, file.Name))) { File.Move(string.Format(@"{0}\{1}", file.DirectoryName, file.Name), string.Format(@"{0}\{1}", destino, file.Name)); } var arquivo = lote.ArquivosImportados.FirstOrDefault(a => a.NomeArquivo == file.Name); if (arquivo != null) { arquivo.CaminhoArquivo = String.Format(@"{0}\{1}", destino, arquivo.NomeArquivo); arquivo.CaminhoArquivoBanco = String.Format(@"\{0}\{1}", lote.AnoExercicio, Importados); } } dir.Delete(true); } }
public int GravarProcessamento(LoteDTO lote, IEnumerable <ContribuinteDTO> contribuintes) { var processamento = new Processamento(); processamento.Id = lote.Codigo; processamento.SituacaoProcessamento = (short)lote.TipoSituacao; processamento.AnoExercicio = lote.AnoExercicio; processamento.AnoCalendario = lote.AnoCalendario; processamento.Descricao = lote.Descricao; processamento.Individual = lote.Individual; processamento.DataRegistro = DateTime.Now; if (processamento.Id > 0) { _repositorioProcessamento.Atualizar(processamento); } else { _repositorioProcessamento.Adicionar(processamento); } _repositorioProcessamento.SalvarAlteracoes(); return(processamento.Id); }
public VNotificacionDetalle(DataGridViewRow row) { InitializeComponent(); FechaVencimientoLabel.Text = row.Cells[0].Value.ToString(); DescripcionLabel.Text = row.Cells[1].Value.ToString(); if (row.Cells[3].Value.ToString() != "0") //Lote { NumeroLoteOPresupuestoLabel.Text = row.Cells[3].Value.ToString(); LoteDTO lote = controladorFachada.BuscarLote(Convert.ToInt32(row.Cells[3].Value)); FechaCompraLabel.Text = lote.FechaCompra.ToString(); CantidadLabel.Text = lote.CantidadProductos.ToString(); ProductoLabel.Text = lote.NombreProducto; AdministrarPresupuesto.Visible = false; } else if (row.Cells[2].Value.ToString() != "0") //Presupuesto { NumeroLoteOPresupuestoLabel.Text = row.Cells[2].Value.ToString(); PresupuestoDTO pres = controladorFachada.BuscarPresupuestoDTO(Convert.ToInt32(row.Cells[2].Value)); FechaCompraLabel.Text = pres.FechaGeneracion.ToString(); NumeroLote.Text = "Numero Presupuesto"; FechaCompra.Text = "Fecha de Creación"; Producto.Visible = false; ProductoLabel.Visible = false; Cantidad.Visible = false; CantidadLabel.Visible = false; EliminarLote.Visible = false; } }
public void LimparOcorrencias(LoteDTO lote) { if (lote.Codigo > 0) { var ocorrencias = _contexto.Ocorrencias.Where(o => o.ProcessamentoId == lote.Codigo).ToList(); ocorrencias.ForEach(o => _repositorioOcorrencia.Excluir(o)); _repositorioOcorrencia.SalvarAlteracoes(); } }
public void GravarOcorrencias(IEnumerable <ContribuinteDTO> ocorrenciasDto, LoteDTO lote, int processamentoId) { var resultado = new List <Ocorrencia>(); foreach (var item in ocorrenciasDto) { resultado.Add(new Ocorrencia() { ProcessamentoId = processamentoId, SituacaoId = (short)item.Status, LoginUsuario = lote.LoginUsuario, DescricaoOcorrencia = String.Format("CPF/CNPJ {0} não foi possível separar arquivo.", item.CpfCnpj) }); } //Caso ocorra erro if (lote.TipoSituacao == TipoSituacao.Erro) { resultado.Add(new Ocorrencia() { ProcessamentoId = processamentoId, SituacaoId = (short)StatusContribuinte.FalhaArquivo, LoginUsuario = lote.LoginUsuario, DescricaoOcorrencia = String.Format("Erro no processamento: {0} {1}", lote.CodigoErro, lote.MensagemErro) }); } //Data hora processamento resultado.Add(new Ocorrencia() { ProcessamentoId = processamentoId, SituacaoId = (short)(lote.TipoSituacao == TipoSituacao.Erro ? StatusContribuinte.FalhaArquivo : StatusContribuinte.Sucesso), LoginUsuario = lote.LoginUsuario, DescricaoOcorrencia = String.Format("Data/Hora início do processamento: {0} - Data/Hora final do processamento: {1}", lote.InicioProcessamento.ToString("g"), DateTime.Now.ToString("g")) }); //Totais arquivos importados resultado.Add(new Ocorrencia() { ProcessamentoId = processamentoId, SituacaoId = (short)(lote.TipoSituacao == TipoSituacao.Erro ? StatusContribuinte.FalhaArquivo : StatusContribuinte.Sucesso), LoginUsuario = lote.LoginUsuario, DescricaoOcorrencia = String.Format("Quantidade de Arquivos PDF importados: {0}", lote.TotalArquivosImportados) }); //Totais arquivos gerados resultado.Add(new Ocorrencia() { ProcessamentoId = processamentoId, SituacaoId = (short)(lote.TipoSituacao == TipoSituacao.Erro ? StatusContribuinte.FalhaArquivo : StatusContribuinte.Sucesso), LoginUsuario = lote.LoginUsuario, DescricaoOcorrencia = String.Format("Arquivos gerados com sucesso: {0}", lote.TotalArquivosGerados) }); _repositorioOcorrencia.AdicionarRange(resultado); _repositorioOcorrencia.SalvarAlteracoes(); }
public int GuardarLote(LoteDTO pLoteDTO) { using (Repositorio repo = new Repositorio()) { Lote lote = new Lote(pLoteDTO.CantidadProductos, pLoteDTO.FechaVencimiento, repo.Productos.Find(pLoteDTO.IdProducto)); Lote loteo = repo.Lotes.Add(lote); repo.SaveChanges(); return(loteo.Id); } }
public void SplitPdfIndividual(ArquivoDTO arquivoImportado, LoteDTO lote) { var parametro = (lote.TipoContribuinte == TipoContribuinte.FuncionarioCassi ? Funcionarios : Prestadores); string caminho = string.Format(@"{0}\{1}\{2}\{3}", CaminhoDiretorio, lote.AnoExercicio, Processados, parametro); using (var reader = new PdfReader(arquivoImportado.CaminhoArquivo)) { int total = reader.NumberOfPages; for (int pagina = 1; pagina <= total; pagina++) { var textoPag = PdfTextExtractor.GetTextFromPage(reader, pagina, new SimpleTextExtractionStrategy()); var cpfsCnpjs = IdentificarCpfCnpjPdf(textoPag); if (cpfsCnpjs.Count() < 0) { continue; } lock (lote.ContribuinteIndividual) { foreach (var cpfCnpj in cpfsCnpjs) { if (string.IsNullOrEmpty(lote.ContribuinteIndividual.CpfCnpj)) { lote.ContribuinteIndividual.CpfCnpj = cpfCnpj; lote.ContribuinteIndividual.Arquivo.CaminhoArquivo = caminho; lote.ContribuinteIndividual.Arquivo.CaminhoArquivoBanco = String.Format(@"\{0}\{1}\{2}", lote.AnoExercicio, Processados, parametro); if (GerarArquivo(reader, lote.ContribuinteIndividual, pagina)) { lote.ContribuinteIndividual.Status = StatusContribuinte.Sucesso; lote.ContribuinteIndividual.TipoSituacao = TipoSituacao.Processado; } } else if (lote.ContribuinteIndividual.CpfCnpj == cpfCnpj) { if (GerarArquivo(reader, lote.ContribuinteIndividual, pagina)) { lote.ContribuinteIndividual.Status = StatusContribuinte.Sucesso; lote.ContribuinteIndividual.TipoSituacao = TipoSituacao.Processado; } } else { throw new NegocioException("Rotina indicada para geração individual deve possuir arquivo que contenha apenas um CPF/CNPJ."); } } } } } }
private static void RenomearArquivos(LoteDTO lote) { var parametro = (lote.TipoContribuinte == TipoContribuinte.FuncionarioCassi ? ArquivoServico.Funcionarios : ArquivoServico.Prestadores); string origem = string.Format(@"{0}\{1}\{2}\{3}", _arquivoServico.CaminhoDiretorio, Ano, ArquivoServico.Processados, parametro); var tarefas = new List <Task>(); Task tarefa; var contribuintes = (lote.Individual ? new List <ContribuinteDTO> { lote.ContribuinteIndividual } : lote.ContribuintesArquivoTxt.Where(p => p.Status == StatusContribuinte.Sucesso).ToList()); var dir = new DirectoryInfo(origem); if (dir.Exists) { /*Criacao de mais task para realizar a renomeacao e merge de arquivo. * Sera criado uma task para cada range de 250 contribuintes */ const int rangeParaCadaTask = 250; var total = contribuintes.Count; for (int i = 0; i < total; i = i + rangeParaCadaTask) { var listaContribuintes = contribuintes.Skip(i).Take(rangeParaCadaTask).ToList(); tarefa = new Task(() => { RotinaRenomearArquivos(dir, origem, listaContribuintes, lote); }); tarefas.Add(tarefa); tarefa.Start(); } var continuation = Task.Factory.ContinueWhenAll(tarefas.ToArray(), (antecedents) => { if (antecedents.Any(a => a.Exception != null)) { var exceptions = antecedents.Where(a => a.Exception != null).Select(a => a.Exception).ToList(); var excecoes = new List <Exception>(); foreach (var exception in exceptions) { excecoes.Add(new Exception(exception.InnerException.Message, exception.InnerException)); } AggregateException e = new AggregateException(excecoes); Console.WriteLine("Ocorreu falhas no processamento - Renomear arquivo e merge falhou!"); Debug.WriteLine("Ocorreu falhas no processamento - Renomear arquivo e merge falhou!"); throw e; } }); continuation.Wait(); } }
public List <ArtigoDTO> GetStockLote(LoteDTO dto) { var Product = new StockInfoDTO(); Product.LookupNumericField1 = dto.Codigo; Product.ArmazemID = int.Parse(dto.WareHouseName); Product.Filial = "-1"; Product.DesignacaoArtigo = ""; Product.Reference = ""; Product.BarCode = ""; return(daoProduct.ObterStock(Product)); }
public LoteDTO AddLote(LoteDTO model) { var evento = _IMapper.Map <Lote>(model); if (evento == null) { return(null); } _loteInterface.AddLote(evento); return(_IMapper.Map <LoteDTO>(evento)); }
public void GravarLog(LoteDTO lote, int processamentoId) { var log = new Log() { DataRegistroAcao = DateTime.Now, LoginUsuario = lote.LoginUsuario, DescricaoUsuario = String.Format("{0} - Rotina {1} {2}", lote.Operacao.GetDescription(), processamentoId, lote.TipoSituacao.GetDescription()) }; _repositorioLog.Adicionar(log); _repositorioLog.SalvarAlteracoes(); }
public void GravarRotina(LoteDTO lote) { using (var transaction = _contexto.Database.BeginTransaction()) { _contexto.Configuration.AutoDetectChangesEnabled = false; _contexto.Configuration.ValidateOnSaveEnabled = false; try { List <ContribuinteDTO> contribuintes; List <ContribuinteDTO> ocorrencias; if (lote.Individual) { contribuintes = (lote.ContribuinteIndividual.Status == StatusContribuinte.Sucesso ? new List <ContribuinteDTO> { lote.ContribuinteIndividual } : new List <ContribuinteDTO>()); ocorrencias = (lote.ContribuinteIndividual.Status != StatusContribuinte.Sucesso ? new List <ContribuinteDTO> { lote.ContribuinteIndividual } : new List <ContribuinteDTO>()); } else { contribuintes = lote.ContribuintesArquivoTxt.Where(p => p.Status == StatusContribuinte.Sucesso).ToList(); ocorrencias = lote.ContribuintesArquivoTxt.Where(p => p.Status != StatusContribuinte.Sucesso).ToList(); } lote.TotalArquivosGerados = contribuintes.Count; lote.TotalArquivosImportados = lote.ArquivosImportados.Count(); var processamentoId = GravarProcessamento(lote, contribuintes); GravarContribuintes(contribuintes, processamentoId); GravarArquivos(lote.ArquivosImportados, contribuintes, processamentoId); LimparOcorrencias(lote); GravarOcorrencias(ocorrencias, lote, processamentoId); GravarLog(lote, processamentoId); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.Message); } } }
public LoteDTO BuscarLote(int pIdLote) { Lote lote = controladorProducto.BuscarLote(pIdLote); LoteDTO loteDTO = new LoteDTO(); loteDTO.Id = lote.Id; loteDTO.FechaCompra = lote.FechaCompra; loteDTO.FechaVencimiento = lote.FechaVencimiento; loteDTO.CantidadProductos = lote.CantidadProductos; loteDTO.IdProducto = lote.Producto.Id; loteDTO.NombreProducto = lote.Producto.Nombre; loteDTO.Vencido = lote.Vencido; return(loteDTO); }
public List <LoteDTO> ObterPorFiltro(LoteDTO dto) { List <LoteDTO> lista = new List <LoteDTO>(); try { ComandText = "stp_GER_ARTIGO_LOTE_OBTERPORFILTRO"; AddParameter("@ARTIGO_ID", dto.ProductID); AddParameter("@REFERENCIA", dto.Referencia); AddParameter("@ARMAZEM_ID", dto.ArmazemID); MySqlDataReader dr = ExecuteReader(); while (dr.Read()) { dto = new LoteDTO(); dto.Codigo = int.Parse(dr[0].ToString()); dto.Referencia = dr[1].ToString(); dto.CodigoBarras = dr[2].ToString(); dto.ProductID = int.Parse(dr[3].ToString()); dto.DataFabrico = DateTime.Parse(dr[10].ToString()); dto.DataValidade = DateTime.Parse(dr[11].ToString()); dto.DataLimiteFaturacao = DateTime.Parse(dr[12].ToString()); /*dto.Armazem = dr[6].ToString(); * dto.ArmazemID = int.Parse(dr[7].ToString()); * dto.Quantidade = decimal.Parse(dr[8].ToString());*/ dto.IncomeUnit = int.Parse(dr[16].ToString() == "" ? "-1" : dr[16].ToString()); dto.OutComeUnit = int.Parse(dr[17].ToString() == "" ? "-1" : dr[17].ToString()); dto.ReferenceUnit = int.Parse(dr[18].ToString() == "" ? "-1" : dr[18].ToString()); dto.UnidadeVenda = dr[19].ToString() == "" ? "-1" : dr[19].ToString(); dto.UnidadeCompra = dr[20].ToString() == "" ? "-1" : dr[20].ToString(); lista.Add(dto); } } catch (Exception ex) { dto = new LoteDTO(); dto.MensagemErro = ex.Message.Replace("'", string.Empty); } finally { FecharConexao(); } return(lista); }
public void GerarProcessamento(LoteDTO lote) { try { using (Conexao = RedeUtil.RecuperarConexaoRede(CaminhoDiretorio, Usuario)) { CriarEstruturaDiretorios(lote.AnoExercicio); MigrarArquivosUpload(lote); if (!lote.Individual) { lote.ContribuintesArquivoTxt = LerDirfTxt(lote); } SplitLote(lote); } } catch (NegocioException e) { foreach (var arquivo in lote.ArquivosImportados) { File.Delete(arquivo.CaminhoArquivo); } Conexao.Dispose(); throw new NegocioException(e.Message, e.InnerException); } catch (Exception e) { Conexao.Dispose(); lote.TipoSituacao = TipoSituacao.Erro; lote.CodigoErro = Marshal.GetExceptionCode(); lote.MensagemErro = e.Message; if (Contribuinte != null) { Contribuinte.TipoSituacao = TipoSituacao.Erro; Contribuinte.Status = StatusContribuinte.FalhaArquivo; } _gir.GravarRotina(lote); throw new Exception(e.Message, e.InnerException); } }
public List <ContribuinteDTO> LerDirfTxt(LoteDTO lote) { List <ContribuinteDTO> contribuintes = new List <ContribuinteDTO>(); var txt = lote.ArquivosImportados.FirstOrDefault(c => c.ExtensaoArquivo == ".txt"); var file = new StreamReader(txt.CaminhoArquivo); string linha; while ((linha = file.ReadLine()) != null) { if (lote.TipoContribuinte == TipoContribuinte.FuncionarioCassi && linha.Contains(BPFDEC)) { var dados = linha.Split('|'); if (String.IsNullOrEmpty(dados[1])) { continue; } contribuintes.Add(new ContribuinteDTO() { CpfCnpj = (dados[1].Length > 11 ? FormatacaoUtil.FormatarCNPJ(dados[1]) : FormatacaoUtil.FormatarCPF(dados[1])), TipoContribuinte = lote.TipoContribuinte, Status = (dados[1].Length > 11 ? StatusContribuinte.FalhaCnpj : StatusContribuinte.FalhaCpf) }); } if (lote.TipoContribuinte == TipoContribuinte.PrestadorFornecedor && (linha.Contains(BPFDEC) || linha.Contains(BPJDEC))) { var dados = linha.Split('|'); if (String.IsNullOrEmpty(dados[1])) { continue; } contribuintes.Add(new ContribuinteDTO() { CpfCnpj = (dados[1].Length > 11 ? FormatacaoUtil.FormatarCNPJ(dados[1]) : FormatacaoUtil.FormatarCPF(dados[1])), TipoContribuinte = lote.TipoContribuinte, Status = (dados[1].Length > 11 ? StatusContribuinte.FalhaCnpj : StatusContribuinte.FalhaCpf) }); } } return(contribuintes.GroupBy(x => x.CpfCnpj).Select(y => y.FirstOrDefault()).ToList()); }
public static LoteDTO GerarLote() { var lote = new LoteDTO(); lote.Codigo = 0; lote.AnoExercicio = Ano; lote.AnoCalendario = Ano - 1; lote.Descricao = "Teste de perfomance"; lote.LoginUsuario = "capetinha@123"; lote.Operacao = OperacaoGIR.IncluirRotina; lote.TipoContribuinte = TipoContribuinte.PrestadorFornecedor; lote.TipoSituacao = TipoSituacao.Processado; lote.InicioProcessamento = DateTime.Now; lote.ArquivosImportados = BuscarArquivosImportados(Ano); return(lote); }
public void SplitPdf(ArquivoDTO arquivoImportado, LoteDTO lote) { var parametro = (lote.TipoContribuinte == TipoContribuinte.FuncionarioCassi ? Funcionarios : Prestadores); string caminho = string.Format(@"{0}\{1}\{2}\{3}", CaminhoDiretorio, lote.AnoExercicio, Processados, parametro); using (var reader = new PdfReader(arquivoImportado.CaminhoArquivo)) { int total = reader.NumberOfPages; for (int pagina = 1; pagina <= total; pagina++) { var textoPag = PdfTextExtractor.GetTextFromPage(reader, pagina, new SimpleTextExtractionStrategy()); var cpfsCnpjs = IdentificarCpfCnpjPdf(textoPag); if (cpfsCnpjs.Count() < 0) { continue; } ContribuinteDTO contribuinte = null; foreach (var cpfCnpj in cpfsCnpjs) { contribuinte = lote.ContribuintesArquivoTxt.FirstOrDefault(c => c.CpfCnpj == cpfCnpj); if (contribuinte != null) { break; } } if (contribuinte != null) { //Contribuinte encontrado no txt e pdf! contribuinte.Arquivo.CaminhoArquivo = caminho; contribuinte.Arquivo.CaminhoArquivoBanco = String.Format(@"\{0}\{1}\{2}", lote.AnoExercicio, Processados, parametro); if (GerarArquivo(reader, contribuinte, pagina)) { contribuinte.Status = StatusContribuinte.Sucesso; contribuinte.TipoSituacao = TipoSituacao.Processado; } } } } }
public ActionResult Delete([FromBody] LoteDTO model) { try { if (model == null) { return(NotFound(new { message = "Lote invalido!" })); } _servicoAplicacaoLote.Deletar(model); return(Ok("Lote deletado com sucesso!")); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Falha no banco: {e.Message}")); } }
public static LoteDTO Converter(LoteVM origem, string loginUsuario) { var destino = new LoteDTO() { InicioProcessamento = DateTime.Now, AnoCalendario = origem.AnoCalendario ?? 0, AnoExercicio = origem.AnoExercicio, ArquivosImportados = ArquivoVM.Converter(origem.ArquivosImportados), Codigo = origem.Codigo, Descricao = origem.Descricao, LoginUsuario = loginUsuario, Individual = origem.Individual, Operacao = origem.Operacao, TipoContribuinte = origem.TipoContribuinte, TipoSituacao = origem.TipoSituacao }; return(destino); }
public ActionResult Put([FromBody] LoteDTO model) { try { if (model == null) { return(NotFound(new { message = "Lote inválido!" })); } if (string.IsNullOrEmpty(model.Nome)) { return(NotFound(new { message = "Nome inválido!" })); } if (model.Preco < 2.00) { return(NotFound(new { message = "Preço inválido!" })); } if (model.Quantidade <= 0) { return(NotFound(new { message = "Quantidade inválida!" })); } if (model.DataInicio < DateTime.Today) { return(NotFound(new { message = "Data inicial inválida!" })); } if (model.DataFim < model.DataInicio) { return(NotFound(new { message = "Data final inválida!" })); } _servicoAplicacaoLote.Alterar(model); return(Ok("Lote alterado com sucesso!")); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Falha no banco: {e.Message}")); } }
public LoteDTO Excluir(LoteDTO dto) { try { ComandText = "stp_GER_ARTIGO_LOTE_EXCLUIR"; AddParameter("@ARTIGO", dto.Codigo); ExecuteNonQuery(); } catch (Exception ex) { dto.MensagemErro = ex.Message.Replace("'", string.Empty); } finally { FecharConexao(); } return(dto); }
public LoteDTO Adicionar(LoteDTO dto) { try { ComandText = "stp_GER_ARTIGO_LOTE_ADICIONAR"; AddParameter("@CODIGO", dto.Codigo); AddParameter("@REFERENCIA", dto.Referencia); AddParameter("@CODIGO_BARRAS", dto.CodigoBarras); AddParameter("@ARTIGO_ID", dto.ProductID); AddParameter("@STATUS_ID", dto.ProductStatus); /*AddParameter("@EXISTENCIA", dto.StockData.Actual); * AddParameter("@RECEPCAO", dto.StockData.ContagemFisica); * AddParameter("@ENTRADA", dto.StockData.Maxima); * AddParameter("@SAIDA", dto.StockData.Minima);*/ AddParameter("@FABRICO", dto.DataFabrico); AddParameter("@VALIDADE", dto.DataValidade); AddParameter("@LIMITE", dto.DataLimiteFaturacao); AddParameter("@SUPPLIER_ID", dto.Fornecedor == "-1" ? (object)DBNull.Value : dto.Fornecedor); AddParameter("@INCOME", dto.IncomeUnit == -1 ? (object)DBNull.Value : dto.IncomeUnit); AddParameter("@OUTCOME", dto.OutComeUnit == -1 ? (object)DBNull.Value : dto.OutComeUnit); AddParameter("@STOCK", dto.ReferenceUnit == -1 ? (object)DBNull.Value : dto.ReferenceUnit); AddParameter("@SALE", dto.UnidadeVenda == "-1" ? (object)DBNull.Value : dto.UnidadeVenda); AddParameter("@PURCHAGE", dto.UnidadeCompra == "-1" ? (object)DBNull.Value : dto.UnidadeCompra); AddParameter("@UTILIZADOR", dto.Utilizador); ExecuteNonQuery(); } catch (Exception ex) { dto.MensagemErro = ex.Message.Replace("'", string.Empty); } finally { FecharConexao(); } return(dto); }
public static void Rotina(ArquivoDTO arquivoImportado, LoteDTO lote) { if (File.Exists(arquivoImportado.CaminhoArquivo)) { try { if (lote.Individual) { _arquivoServico.SplitPdfIndividual(arquivoImportado, lote); } else { _arquivoServico.SplitPdf(arquivoImportado, lote); } Console.WriteLine("Sucesso na TASK SPLIT PDF ID:" + Task.CurrentId); Debug.WriteLine("Sucesso na TASK SPLIT PDF ID:" + Task.CurrentId); } catch (NegocioException e) { throw new NegocioException(e.Message, e.InnerException); } catch (Exception e) { Console.WriteLine("Houve falha na TASK SPLIT PDF ID:" + Task.CurrentId); Debug.WriteLine("Houve falha na TASK SPLIT PDF ID:" + Task.CurrentId); var msg = string.Format("Falha no processamento - TASK ID:{0} SPLIT PDF - {1}", Task.CurrentId, e.Message); throw new Exception(msg, e.InnerException); } } else { var msg = string.Format("Arquivo {0} NÃO EXISTI!", arquivoImportado.CaminhoArquivo); Console.WriteLine(msg); Debug.WriteLine(msg); } }
private void Listo_Click(object sender, EventArgs e) { int idLote = 0; List <ProductoDTO> ListaProductoDTO = new List <ProductoDTO>(); int i = 0; Boolean controlVence = true; //True si esta ok Boolean controlDatos = false; //True si esta ok Dictionary <LoteDTO, int> lotesAGuardar = new Dictionary <LoteDTO, int>(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (Convert.ToInt32(row.Cells[2].Value) == 0 | Convert.ToDouble(row.Cells[3].Value) == 0) //Chequeo que cantidad y precio de compra sean >0 { controlDatos = false; } else //Cantidad y Precio de compra ok { ProductoDTO unProducto = controladorFachada.BuscarProducto((Convert.ToInt32(row.Cells[0].Value))); unProducto.CantidadEnStock += Convert.ToInt32(row.Cells[2].Value); unProducto.IdCategoria = unProducto.CategoriaProductoDTO.Id; unProducto.PrecioDeCompra = Convert.ToDouble(row.Cells[3].Value); if (row.Cells[4].Value != "------") { if (string.IsNullOrEmpty((row.Cells[4].Value).ToString())) //Si no colocó fechaVencimiento { controlVence = false; } else { LoteDTO unLote = new LoteDTO(); unLote.CantidadProductos = Convert.ToInt32(row.Cells[2].Value); unLote.FechaCompra = DateTime.Now; // ARREGLAME unLote.FechaVencimiento = Convert.ToDateTime(row.Cells[4].Value); controlVence = true; //fechaVencimiento OK if (unLote.FechaCompra < unLote.FechaVencimiento) { unLote.Vencido = false; } else { unLote.Vencido = true; } unLote.IdProducto = unProducto.Id; lotesAGuardar.Add(unLote, i); //idLote = controladorFachada.GuardarLote(unLote); //dataGridView1.Rows[i].Cells[5].Value = idLote; } } i++; ListaProductoDTO.Add(unProducto); controlDatos = true; } controladorFachada.IngresoMercarderias(ListaProductoDTO); } Listo.Visible = false; Cancelar.Visible = false; Agregar.Visible = false; Boolean vencen = false; foreach (DataGridViewRow row in dataGridView1.Rows) { if (!vencen) { if (row.Cells[4].Value != "------") { vencen = true; } } } if (!controlDatos | !controlVence) //Si falta algun dato { if (!controlDatos) { MessageBox.Show("Debe completar la cantidad a ingresar y el Precio de Compra"); } if (!controlVence) { MessageBox.Show("Debe ingresar una fecha de vencimiento"); } Listo.Visible = true; Cancelar.Visible = true; Agregar.Visible = true; } else if (vencen) //Esta todo Ok y vencen { Console.WriteLine(dataGridView1.Rows.Count); // int j = 0; foreach (KeyValuePair <LoteDTO, int> lote in lotesAGuardar) { idLote = controladorFachada.GuardarLote(lote.Key); dataGridView1.Rows[lote.Value].Cells[5].Value = idLote; //Console.WriteLine(lotesAGuardar.Count()); } Confirmar.Visible = true; ConfirmarText.Visible = true; } else { this.Hide(); VControlProducto vControlProducto = new VControlProducto(); vControlProducto.ShowDialog(); this.Close(); } }
public void Update(int idEvento, int id, LoteDTO model) { var lote = _IMapper.Map <Lote>(model); _loteInterface.Update(idEvento, id, lote); }
public IActionResult PutLote(int idEvento, int id, [FromBody] LoteDTO model) { _dbLoteContext.Update(idEvento, id, model); return(Ok()); }
public IActionResult PostLote([FromBody] LoteDTO model) { var lote = _dbLoteContext.AddLote(model); return(Ok(lote)); }
public void MergeArquivo(string pathRaizLote, string pathArquivo, string pathArquivoParaMerge, string cpfCnpj, LoteDTO lote) { var pathArquivoTemp = String.Format(@"{0}\{1}_TEMP{2}", pathRaizLote, cpfCnpj, ".pdf"); //Arquivo formatado -> Ex..: 00081876000100.pdf //Arquivo para merger -> Ex..: 00081876000100_TASK1_1.pdf using (var readerArquivoFormatado = new PdfReader(pathArquivo)) using (var readerArquivoParaMerge = new PdfReader(pathArquivoParaMerge)) { int totalArqFormatado = readerArquivoFormatado.NumberOfPages; int totalArqMerge = readerArquivoParaMerge.NumberOfPages; var document = new Document(readerArquivoFormatado.GetPageSizeWithRotation(1)); var provider = new PdfCopy(document, new FileStream(pathArquivoTemp, FileMode.Create)); document.Open(); var conteudoPaginas = new List <string>(); string textoPag; //Adiciona paginas ao arquivo temporario. for (int pagina = 1; pagina <= totalArqFormatado; pagina++) { textoPag = PdfTextExtractor.GetTextFromPage(readerArquivoFormatado, pagina, new SimpleTextExtractionStrategy()); var imported = provider.GetImportedPage(readerArquivoFormatado, pagina); provider.AddPage(imported); conteudoPaginas.Add(textoPag); } //Adiciona paginas ao arquivo temporario se não houver duplicacao. for (int pagina = 1; pagina <= totalArqMerge; pagina++) { textoPag = PdfTextExtractor.GetTextFromPage(readerArquivoParaMerge, pagina, new SimpleTextExtractionStrategy()); if (!string.IsNullOrWhiteSpace(textoPag) && !conteudoPaginas.Contains(textoPag)) { var imported = provider.GetImportedPage(readerArquivoParaMerge, pagina); provider.AddPage(imported); } } document.Close(); provider.Close(); } File.Delete(pathArquivo); File.Delete(pathArquivoParaMerge); File.Move(pathArquivoTemp, pathArquivo); //throw new InvalidPdfException("Teste"); }