public JsonResult AjaxCallCancelarLote() { try { _loteService.ApagarLote(LoteImagens.ID); LoteImagens = new Lote(); RegistrarLOGSimples(2, 8, LoteImagens.ID.ToString()); // LOG: Cancelou o lote na Captura } catch (ValidationException ex) { return Json(new RetornoViewModel(false, ex.Message, ex.Errors.Select(e => e.ErrorMessage).ToArray(), RetornoType.ValidationExceptions)); } catch (Exception ex) { return Json(new RetornoViewModel(false, ex.Message)); } return Json(new RetornoViewModel(true, null, LoteImagens)); }
public int ApagarLote(IDictionary<string, object> _queryParams) { try { Lote _lote = new Lote(); DbCommand _cmd; Database _db = DbConn.CreateDB(); _cmd = _db.GetStoredProcCommand(String.Format("proc_lote_del")); _db.AddInParameter(_cmd, "@IdLote", DbType.Int32, int.Parse(_queryParams["IdLote"].ToString())); int _ret = _db.ExecuteNonQuery(_cmd); return _ret; } catch (Exception ex) { throw; } }
public Lote(Lote _lote) { ID = _lote.ID; DataCriacao = _lote.DataCriacao; QtdeImagem = _lote.QtdeImagem; Duplex = _lote.Duplex; PathCaptura = _lote.PathCaptura; UsuarioCaptura = _lote.UsuarioCaptura; ServicoCaptura = _lote.ServicoCaptura; StatusLote = _lote.StatusLote; OrigemID = _lote.OrigemID; Itens = _lote.Itens; }
public JsonResult AjaxCallEncerrarLote() { try { int _ret = 0; bool UsaArquivoDados = _loteService.UsaArquivoDados(ServicoAtual.ID); if (UsaArquivoDados) { //logica com json if (LoteImagens.Log.Dados == null) { return Json(new RetornoViewModel(false, "O arquivo de importação do dados do lote é inválido. Favor verificar!", null, RetornoType.ValidationExceptions)); } if (LoteImagens.ID != 0 && ServicoAtual.ID == LoteImagens.ServicoCaptura.ID && LoteImagens.Itens.Count > 0) { if (LoteImagens.Log.NumeroPaginas == 0 || LoteImagens.QtdeImagem == LoteImagens.Log.NumeroPaginas) { _ret = _loteService.InserirItensLote(LoteImagens, ServicoAtual.ID); LoteImagens.StatusLote = 1010; _loteService.AtualizarLote(LoteImagens); } else { return Json(new RetornoViewModel(false, string.Format(@"A quantidade de imagens importadas ({0}) não corresponde com a quantidade de imagens informada no aquivo ({1}), certifique-se de que importou todos os documentos do lote, caso contrário digitalize novamente o lote.", LoteImagens.Itens.Count, LoteImagens.Log.NumeroPaginas), null, RetornoType.ValidationExceptions)); } int _retidlote = _loteService.VerificaLoteJaExiste(LoteImagens.ID, LoteImagens.Log.NomeLote); if (_retidlote != 0) { return Json(new RetornoViewModel(false, string.Format(@"Lote já importado!!!"), null, RetornoType.ValidationExceptions)); } if (!(ServicoAtual.ID == LoteImagens.ServicoCaptura.ID)) { return Json(new RetornoViewModel(false, string.Format(@"Lote não e deste Serviço !!!"), null, RetornoType.ValidationExceptions)); } string[] _dados = LoteImagens.Log.Dados; if (_dados.Count() > 0) { foreach (string _dado in _dados) { string[] _arr = _dado.Split('='); if (_arr[0].ToString().Trim() == "TipoDocumento") { if (!string.IsNullOrEmpty(_arr[1].ToString().Trim())) { _loteService.TipificarItemDescricao(UsuarioAtual.ID, ServicoAtual.ID, LoteImagens.ID, LoteImagens.ID, _arr[1].ToString().Trim()); } } } } //Se tiver codigo de barras, atualiza o dicumento atravez do lote e do nome original da imagem foreach (Arquivo _arq in LoteImagens.Log.Arquivos) { if (!string.IsNullOrEmpty(_arq.CB)) { string _img = string.Empty; _img = LoteImagens.Itens.Where(i => i.NomeOriginal.ToLowerInvariant() == _arq.Nome.ToLowerInvariant()).FirstOrDefault().NomeFinal; if (!string.IsNullOrEmpty(_img)) { _docService.AtualiarDocumentoCB(UsuarioAtual.ID, ServicoAtual.ID, LoteImagens.ID, _arq.Verso, _arq.CB, _img); } } } LoteImagens = new Lote(); } else { return Json(new RetornoViewModel(false, "Não foram importados arquivos de imagens para o lote gerado. Favor verificar!.", null)); } //-------------------- } else { //logica Sem json if (LoteImagens.Log.NumeroPaginas == 0 || LoteImagens.QtdeImagem == LoteImagens.Log.NumeroPaginas) { _ret = _loteService.InserirItensLote(LoteImagens, ServicoAtual.ID); LoteImagens.StatusLote = 1010; _loteService.AtualizarLote(LoteImagens); _loteService.TipificarItemDescricao(UsuarioAtual.ID, ServicoAtual.ID, LoteImagens.ID, LoteImagens.ID, ""); LoteImagens = new Lote(); } else { return Json(new RetornoViewModel(false, string.Format(@"A quantidade de imagens importadas ({0}) não corresponde com a quantidade de imagens informada no aquivo ({1}), certifique-se de que importou todos os documentos do lote, caso contrário digitalize novamente o lote.", LoteImagens.Itens.Count, LoteImagens.Log.NumeroPaginas), null, RetornoType.ValidationExceptions)); } //--------------------------------------------------------------------------------------- } RegistrarLOGSimples(2, 7, UsuarioAtual.NomeUsuario); // LOG: Encerra LOTE } catch (ValidationException ex) { return Json(new RetornoViewModel(false, ex.Message, ex.Errors.Select(e => e.ErrorMessage).ToArray(), RetornoType.ValidationExceptions)); } catch (Exception ex) { return Json(new RetornoViewModel(false, ex.Message)); } return Json(new RetornoViewModel(true, "Lote importado com sucesso!", null)); }
public UploadController() { _lote = new Lote(); this._loteService = DependencyResolver.Current.GetService<ILoteService>(); _docService = DependencyResolver.Current.GetService<IDocumentoService>(); }
public JsonResult AjaxCallGerarLote() { try { //if (LoteImagens.ID == 0 || ServicoAtual.ID != LoteImagens.ServicoCaptura.ID) //TODO: 08/03/2016 if (LoteImagens.ID == 0 || IdServico_Atual != LoteImagens.ServicoCaptura.ID) { LoteImagens = _loteService.CriarLote(UsuarioAtual.ID, 1, IdServico_Atual, RetornaDiretorioUpload()); RegistrarLOGSimples(2, 5, LoteImagens.ID.ToString()); // LOG: Criar Lote Vazio } } catch (ValidationException ex) { return Json(new RetornoViewModel(false, ex.Message, ex.Errors.Select(e => e.ErrorMessage).ToArray(), RetornoType.ValidationExceptions)); } catch (Exception ex) { return Json(new RetornoViewModel(false, ex.Message)); } return Json(new RetornoViewModel(true, null, LoteImagens)); }
//public void ExcluirLote(int idLote) //{ // try // { // this._queryParams.Clear(); // this._queryParams["idLote"] = idLote; // _repository.ListarLotes(_queryParams).Where(l => l.ID == idLote).FirstOrDefault(); // } // catch (Exception ex) { throw ex; } //} public Lote AtualizarLote(Lote lote) { try { this._queryParams.Clear(); _queryParams["IdLote"] = lote.ID; _queryParams["QtdeImagem"] = lote.QtdeImagem; _queryParams["Duplex"] = lote.Duplex; _queryParams["PathCaptura"] = lote.PathCaptura; _queryParams["IdUsuarioCaptura"] = lote.UsuarioCaptura.ID; _queryParams["IdServico"] = lote.ServicoCaptura.ID; _queryParams["IdStatus"] = lote.StatusLote; _queryParams["IdOrigem"] = lote.OrigemID; _queryParams["NomeLote"] = lote.Log.NomeLote ?? string.Empty; _queryParams["DataAbertura"] = lote.Log.DataAbertura ?? string.Empty; _queryParams["DataFim"] = lote.Log.DataFim ?? string.Empty; _queryParams["Login"] = lote.Log.Login ?? string.Empty; _queryParams["Versao"] = lote.Log.Versao ?? string.Empty; _queryParams["Estacao"] = lote.Log.Estacao ?? string.Empty; _queryParams["Scanner"] = lote.Log.Scanner ?? string.Empty; _queryParams["NumeroPaginas"] = lote.Log.NumeroPaginas; _queryParams["IDPerfil"] = lote.Log.IdPerfil; _queryParams["Arquivos"] = lote.Log.Arquivos; _queryParams["Dados"] = string.Empty; if (lote.Log.Dados != null) { foreach (string _dado in lote.Log.Dados) { string _dataConvertida = string.Empty; if (_dado.Contains("dtInicial")) { //_dataConvertida = _dado.Replace("dtInicial=", "").Replace("-", ""); if (_dado.Replace("dtInicial=", "").Replace("-", "").Length > 8) { _dataConvertida = _dado.Replace("dtInicial=", "").Replace("-", ""); _dataConvertida = "dtInicial=" + _dataConvertida.Replace("dtInicial=", "").Replace("-", "").Substring(0, 8); } } if (_dado.Contains("dtFinal")) { if (_dado.Replace("dtFinal=", "").Replace("-", "").Length > 8) { _dataConvertida = _dado.Replace("dtFinal=", "").Replace("-", ""); _dataConvertida = "dtFinal=" + _dataConvertida.Replace("dtFinal=", "").Replace("-", "").Substring(0, 8); } } if (string.IsNullOrEmpty(_dataConvertida)) { _queryParams["Dados"] += _dado + "; "; } else { _queryParams["Dados"] += _dataConvertida + "; "; } } _queryParams["Dados"] = _queryParams["Dados"].ToString().Trim().Substring(0, _queryParams["Dados"].ToString().Trim().Length - 1); _queryParams["Versao"] = lote.Log.Versao; _queryParams["IDPerfil"] = lote.Log.IdPerfil; _queryParams["Arquivos"] = string.Empty; /* foreach (string _arquivo in lote.Log.Arquivos) { _queryParams["Arquivos"] += _arquivo + "; "; } _queryParams["Arquivos"] = _queryParams["Arquivos"].ToString().Trim().Substring(0, _queryParams["Arquivos"].ToString().Trim().Length - 1); */ _queryParams["Arquivos"] = lote.Log.Arquivos; } else { } Lote _lote = this._repository.AtualizarLote(this._queryParams); return _lote; } catch (Exception ex) { throw ex; } }
public List<Lote> ListarLotesTipificar(int idUsuario, int idOrigem, int idServico) { try { Lote _lote = new Lote(); List<Lote> _lotes = new List<Lote>(); List<Lote> _lotes_temp = new List<Lote>(); LoteItem _item = new LoteItem(); List<LoteItem> _itens = new List<LoteItem>(); this._queryParams.Clear(); this._queryParams["Usuario_ID"] = idUsuario; this._queryParams["Origem_ID"] = idOrigem; this._queryParams["Servico_ID"] = idServico; _lotes = _repository.ListarLotes(this._queryParams).Where(l => l.StatusLote == 1010).ToList<Lote>(); foreach (Lote lote in _lotes) { lote.Itens.AddRange(ListarItensLote(lote.ID, idUsuario, idServico, true, 1000)); } /* int n=0; foreach (var tmp_lote in _lote.Itens) { if (tmp_lote.StatusImagem == 2000) { tmp_lote.Itens.RemoveRange(n, 1); } n++; } foreach (var _lt in _lotes[].Itens.){ _lt.Itens. _lotes_temp.AddRange(_lt.Itens.Where(x => x.StatusImagem == 1000).ToList<Lote>()); }*/ return _lotes; } catch (Exception ex) { throw ex; } }
public int InserirItensLote(Lote lote, int idServico) { try { int _qtdItens = 0; foreach (LoteItem item in lote.Itens.OrderBy(x=> x.DataCriacaoArqCap)) { int _id = 0; this._queryParams.Clear(); _queryParams["IdLote"] = lote.ID; _queryParams["IdOrigem"] = item.OrigemID; _queryParams["IdDocumentoModelo"] = item.DocumentoModelo.ID; _queryParams["IdUsuarioCaptura"] = item.UsuarioCaptura.ID; _queryParams["ImgNomeOriginal"] = item.NomeOriginal; _queryParams["ImgNomeFinal"] = item.NomeFinal; _queryParams["SequenciaCaptura"] = item.SequenciaCaptura; _queryParams["Verso"] = item.Verso; _queryParams["StatusImagem"] = item.StatusImagem; _queryParams["idservico"] = idServico; _id = _repository.InserirItemLote(_queryParams); if (_id != 0) _qtdItens++; } return lote.QtdeImagem - _qtdItens; } catch (Exception ex) { throw ex; } }
public Lote GetLote(int idLote, int idUsuario,int idServico, int numItens) { try { Lote _lote = new Lote(); this._queryParams.Clear(); this._queryParams["Lote_ID"] = idLote; this._queryParams["Usuario_ID"] = idUsuario; this._queryParams["Servico_ID"] = idServico; this._queryParams["Statusimagem"] = 1000; _lote = _repository.ListarLotes(_queryParams).Where(l => l.ID==idLote).FirstOrDefault(); if (numItens==0) { _lote.Itens.AddRange(_repository.ListarItensLote(_queryParams).ToList<LoteItem>()); } else { _lote.Itens.AddRange(_repository.ListarItensLote(_queryParams).Take(numItens).ToList<LoteItem>()); } return _lote; } catch (Exception ex) { throw ex; } }
public SupervisaoController() { _lote = new Lote(); _loteService = DependencyResolver.Current.GetService<ILoteService>(); _docService = DependencyResolver.Current.GetService<IDocumentoService>(); }
public Lote AtualizarLote(IDictionary<string, object> _queryParams) { try { Lote _lote = new Lote(); DbCommand _cmd; Database _db = DbConn.CreateDB(); _cmd = _db.GetStoredProcCommand(String.Format("proc_lote_alt")); _db.AddInParameter(_cmd, "@IdLote", DbType.Int32, int.Parse(_queryParams["IdLote"].ToString())); if (!string.IsNullOrEmpty(_queryParams["QtdeImagem"].ToString())) _db.AddInParameter(_cmd, "@QtdeImagem", DbType.Int32, int.Parse(_queryParams["QtdeImagem"].ToString())); if (!string.IsNullOrEmpty(_queryParams["PathCaptura"].ToString())) _db.AddInParameter(_cmd, "@PathCaptura", DbType.String, _queryParams["PathCaptura"].ToString()); if (!string.IsNullOrEmpty(_queryParams["IdUsuarioCaptura"].ToString())) _db.AddInParameter(_cmd, "@IdUsuarioCaptura", DbType.Int32, int.Parse(_queryParams["IdUsuarioCaptura"].ToString())); if (!string.IsNullOrEmpty(_queryParams["IdServico"].ToString())) _db.AddInParameter(_cmd, "@IdServico", DbType.Int32, int.Parse(_queryParams["IdServico"].ToString())); if (!string.IsNullOrEmpty(_queryParams["IdStatus"].ToString())) _db.AddInParameter(_cmd, "@IdStatus", DbType.Int32, int.Parse(_queryParams["IdStatus"].ToString())); if (!string.IsNullOrEmpty(_queryParams["IdOrigem"].ToString())) _db.AddInParameter(_cmd, "@IdOrigem", DbType.Int32, int.Parse(_queryParams["IdOrigem"].ToString())); if (!string.IsNullOrEmpty(_queryParams["NomeLote"].ToString())) _db.AddInParameter(_cmd, "@NomeLote", DbType.String, _queryParams["NomeLote"].ToString()); if (!string.IsNullOrEmpty(_queryParams["DataAbertura"].ToString())) _db.AddInParameter(_cmd, "@DataAbertura", DbType.DateTime, _queryParams["DataAbertura"].ToString()); if (!string.IsNullOrEmpty(_queryParams["DataFim"].ToString())) _db.AddInParameter(_cmd, "@DataFim", DbType.DateTime, _queryParams["DataFim"].ToString()); if (!string.IsNullOrEmpty(_queryParams["Login"].ToString())) _db.AddInParameter(_cmd, "@Login", DbType.String, _queryParams["Login"].ToString()); if (!string.IsNullOrEmpty(_queryParams["Scanner"].ToString())) _db.AddInParameter(_cmd, "@Scanner", DbType.String, _queryParams["Scanner"].ToString()); if (!string.IsNullOrEmpty(_queryParams["NumeroPaginas"].ToString()) || int.Parse(_queryParams["NumeroPaginas"].ToString()) > 0) _db.AddInParameter(_cmd, "@NumeroPaginas", DbType.Int32, int.Parse(_queryParams["NumeroPaginas"].ToString())); if (!string.IsNullOrEmpty(_queryParams["Dados"].ToString())) _db.AddInParameter(_cmd, "@Dados", DbType.String, _queryParams["Dados"].ToString()); if (!string.IsNullOrEmpty(_queryParams["Versao"].ToString())) _db.AddInParameter(_cmd, "@Versao", DbType.String, _queryParams["Versao"].ToString()); if (!string.IsNullOrEmpty(_queryParams["IDPerfil"].ToString()) || int.Parse(_queryParams["IDPerfil"].ToString()) > 0) _db.AddInParameter(_cmd, "@IDPerfil", DbType.Int32, int.Parse(_queryParams["IDPerfil"].ToString())); //if (_queryParams["Arquivos"] != null) // _db.AddInParameter(_cmd, "@Arquivos", DbType.String, _queryParams["Arquivos"].ToString()); using (IDataReader _dr = _db.ExecuteReader(_cmd)) { while (_dr.Read()) { _lote = (new Lote { ID = int.Parse(_dr["IdLote"].ToString()), QtdeImagem = int.Parse(_dr["QtdeImagem"].ToString()), PathCaptura = _dr["PathCaptura"].ToString(), UsuarioCaptura = (new Usuario { ID = int.Parse(_dr["IdUsuarioCaptura"].ToString()) }), ServicoCaptura = (new Servico { ID = int.Parse(_dr["IdServico"].ToString()) }), StatusLote = int.Parse(_dr["IdStatus"].ToString()), OrigemID = int.Parse(_dr["IdOrigem"].ToString()), }); } } return _lote; } catch (Exception ex) { throw; } }
private Lote ConverteBaseObjeto(IDataReader dt) { Lote _lote = new Lote(); _lote = (new Lote { ID = int.Parse(dt["IdLote"].ToString()), OrigemID = int.Parse(dt["IdOrigem"].ToString()), PathCaptura = dt["PathCaptura"].ToString(), QtdeImagem = int.Parse(dt["QtdeImagem"].ToString()), Duplex = Boolean.Parse(dt["Duplex"].ToString()), StatusLote = int.Parse(dt["IdStatus"].ToString()), DataCriacao = DateTime.Parse(dt["DataCriacao"].ToString()), UsuarioCaptura = (new Usuario { ID= int.Parse(dt["IdUsuarioCaptura"].ToString())}), Itens = new List<LoteItem>(), ServicoCaptura = (new Servico { ID = int.Parse(dt["IdServico"].ToString()) }) }); return _lote; }
//Walmir public int VerificaLoteJaExiste(IDictionary<string, object> _queryParams) { try { Lote _lote = new Lote(); DbCommand _cmd; Database _db = DbConn.CreateDB(); _cmd = _db.GetStoredProcCommand(String.Format("proc_lote_seleciona")); _db.AddInParameter(_cmd, "@idLote", DbType.Int32, (int.Parse(_queryParams["idLote"].ToString()))); _db.AddInParameter(_cmd, "@NomeLote", DbType.String, (_queryParams["NomeLote"].ToString())); int _ret=0; using (IDataReader _dr = _db.ExecuteReader(_cmd)) { while (_dr.Read()) { _ret = int.Parse(_dr[0].ToString()); } } //int _ret = _db.ExecuteNonQuery(_cmd); return _ret; } catch (Exception ex) { throw; } }
public List<Lote> ListarLotesStatus(IDictionary<string, object> _queryParams) { Lote _lote = new Lote(); List<Lote> _lotes = new List<Lote>(); try { DbCommand _cmd; Database _db = DbConn.CreateDB(); _cmd = _db.GetStoredProcCommand(String.Format("proc_lotes_servico_usuario_sel")); _db.AddInParameter(_cmd, "@IdUsuario", DbType.Int32, int.Parse(_queryParams["Usuario_ID"].ToString())); _db.AddInParameter(_cmd, "@IdServico", DbType.Int32, int.Parse(_queryParams["Servico_ID"].ToString())); //_db.AddInParameter(_cmd, "@IdStatus", DbType.Int32, int.Parse(_queryParams["Status_ID"].ToString())); using (IDataReader _dr = _db.ExecuteReader(_cmd)) { while (_dr.Read()) { _lotes.Add(ConverteBaseObjeto(_dr)); } } if (_lotes == null) { throw new Erro("Lote não localizado."); } return _lotes; } catch (Exception ex) { throw; } }
public Lote CriarLote(IDictionary<string, object> _queryParams) { try { Lote _lote = new Lote(); DbCommand _cmd; Database _db = DbConn.CreateDB(); _cmd = _db.GetStoredProcCommand(String.Format("proc_lote_ins")); _db.AddInParameter(_cmd, "@QtdeImagem", DbType.Int32, int.Parse(_queryParams["QtdeImagem"].ToString())); _db.AddInParameter(_cmd, "@Duplex", DbType.Boolean, Boolean.Parse(_queryParams["Duplex"].ToString())); _db.AddInParameter(_cmd, "@PathCaptura", DbType.String, _queryParams["PathCaptura"].ToString()); _db.AddInParameter(_cmd, "@IdUsuarioCaptura", DbType.Int32, int.Parse(_queryParams["IdUsuarioCaptura"].ToString())); _db.AddInParameter(_cmd, "@IdServico", DbType.Int32, int.Parse(_queryParams["IdServico"].ToString())); _db.AddInParameter(_cmd, "@IdStatus", DbType.Int32, int.Parse(_queryParams["IdStatus"].ToString())); _db.AddInParameter(_cmd, "@IdOrigem", DbType.Int32, int.Parse(_queryParams["IdOrigem"].ToString())); using (IDataReader _dr = _db.ExecuteReader(_cmd)) { while (_dr.Read()) { _lote = (new Lote { ID = int.Parse(_dr["IdLote"].ToString()), QtdeImagem = int.Parse(_dr["QtdeImagem"].ToString()), Duplex = Boolean.Parse(_queryParams["Duplex"].ToString()), PathCaptura = _dr["PathCaptura"].ToString(), UsuarioCaptura = (new Usuario { ID = int.Parse(_dr["IdUsuarioCaptura"].ToString()) }), ServicoCaptura = (new Servico { ID = int.Parse(_dr["IdServico"].ToString()) }), StatusLote = int.Parse(_dr["IdStatus"].ToString()), OrigemID = int.Parse(_dr["IdOrigem"].ToString()), }); } } return _lote; } catch (Exception ex) { throw; } }