public JsonResult GetTextoWordDocModelo(long IdModeloDoc) { bool resp = false; StringBuilder texto = new StringBuilder(); string message = string.Empty; try { string serverPath = Server.MapPath("~"); using (AppServiceAtos appServ = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { texto = appServ.GetTextoWordDocModelo(IdModeloDoc, serverPath); } resp = true; } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); message = "Falha GetTextoWordDocModelo[" + ex.Message + "]"; } var resultado = new { resposta = resp, msg = message, TextoHtml = texto.ToString() }; return(Json(resultado)); }
public JsonResult GetTextoAto(InfAtoViewModel dadosAtoViewModel) { bool resp = false; string message = string.Empty; string texto = string.Empty; try { if (dadosAtoViewModel.IdModeloDoc == 0) { throw new NullReferenceException("Modelo de documento não definido!"); } string serverPath = Server.MapPath("~"); using (AppServiceAtos appServiceAtos = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { DtoInfAto dtoInfAto = new DtoInfAto { IdAto = dadosAtoViewModel.IdAto, IdCtaAcessoSist = this.IdCtaAcessoSist, IdTipoAto = dadosAtoViewModel.IdTipoAto, IdLivro = dadosAtoViewModel.IdLivro, IdPrenotacao = dadosAtoViewModel.IdPrenotacao, IdModeloDoc = dadosAtoViewModel.IdModeloDoc, NumMatricula = dadosAtoViewModel.NumMatricula, ServerPath = serverPath, ListIdsPessoas = dadosAtoViewModel.ListIdsPessoas }; texto = appServiceAtos.GetTextoAto(dtoInfAto).ToString(); } resp = true; } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); resp = false; message = "Falha, GetTextoAto [" + ex.Message + "]"; } var resultado = new { resposta = resp, msg = message, TextoHtml = texto }; return(Json(resultado)); }
public JsonResult GetDadosPorPrenotacao(long IdPrenotacao) { bool resp = false; string message = string.Empty; DateTime?dataReg = null; List <DtoDadosImovel> listaDtoDadosImovel = new List <DtoDadosImovel>(); try { using (AppServiceAtos appServAtos = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { dataReg = appServAtos.DataRegPrenotacao(IdPrenotacao); listaDtoDadosImovel = appServAtos.GetListImoveisPrenotacao(IdPrenotacao).ToList(); if (listaDtoDadosImovel != null) { if (listaDtoDadosImovel.Count() > 0) { message = ":) Dados retornados con sucesso."; resp = true; } else { message = "Número de Prenotação e/ou matrículas não encontradas na base de dados!"; } } else { message = "Número de Prenotação Inválido!"; } } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); message = "Falha ao obter dados! " + "[" + ex.Message + "]"; } var resultado = new { resposta = resp, msg = message, DataRegPrenotacao = dataReg.HasValue? dataReg.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) :"", listaDtoDadosImovel }; return(Json(resultado)); }
// GET: Ato public ActionResult IndexAto(DateTime?DataIni = null, DateTime?DataFim = null) { bool FlagErro = false; IEnumerable <AtoListViewModel> listaAtoListViewModel = new List <AtoListViewModel>(); if ((DataIni != null) && (DataFim != null)) { if (DataIni > DataFim) { ModelState.AddModelError(Guid.NewGuid().ToString(), "Data inicial deve ser menor o igual à data final!!"); FlagErro = true; } } else { if (DataIni == null) { DataIni = DateTime.Today; DataFim = DateTime.Today; } else { if (DataFim == null) { DataFim = DataIni; } } } if (!FlagErro) { using (AppServiceAtos appService = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { IEnumerable <DtoAtoList> listaDto = null; // appService.GetListaAtos((DateTime)DataIni, (DateTime)DataFim).Where(a => a.Ativo == true); if (listaDto != null) { listaAtoListViewModel = Mapper.Map <IEnumerable <DtoAtoList>, IEnumerable <AtoListViewModel> >(listaDto); } } } ViewBag.DataIni = DataIni; ViewBag.DataFim = DataFim; return(View(listaAtoListViewModel)); }
public void BloquearAto(string NumMatricula, long IdAto) { using (var appService = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { var resultado = false; // appService.FinalizarAto(IdAto); if (resultado) { this.UfwCartNew.SaveChanges(); //todo: ronaldo fazer //WordHelper.EscreverAtoPrincipal(Server.MapPath($"~/App_Data/Arquivos/AtosPendentes/{NumMatricula}_pendente.docx"), Server.MapPath($"~/App_Data/Arquivos/Atos/{NumMatricula}.docx")); Response.StatusCode = 200; Response.Status = "Ato Bloqueado com sucesso!"; } else { Response.StatusCode = 500; Response.Status = "Erro ao atualizar o ato!"; } } }
public JsonResult GetListPessoasPrenotacao(long IdPrenotacao) { bool resp = false; string message = string.Empty; IEnumerable <DtoPessoaPesxPre> listaPes = new List <DtoPessoaPesxPre>(); string nomeMetodo = string.Format("{0}.{1}", MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name); try { using (AppServiceAtos appServiceAtos = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { listaPes = appServiceAtos.GetListPessoasPrenotacao(IdPrenotacao); resp = true; message = "Lista de pessoas da prenotação obtida com sucesso!"; } } catch (Exception ex) { resp = false; TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); message = "Falha em " + nomeMetodo + " [" + ex.Message + "]"; // Console.WriteLine(ex); // Response.StatusCode = 500; // Response.Status = "Erro ao buscar os dados das pessoas"; } //JsonConvert.SerializeObject() var resultado = new { resposta = resp, msg = message, listaPessoas = listaPes }; return(Json(resultado)); }
public JsonResult ProcReservarMatImovel(TipoReservaMatImovel TipoReserva, long IdPrenotacao, string NumMatricula) { bool resp = false; string message = string.Empty; DtoReservaImovel reservaImovel = new DtoReservaImovel(); List <ApplicationUser> listaUsrSist = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.OrderBy(u => u.UserName).ToList(); try { using (AppServiceAtos appServiceAtos = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { appServiceAtos.ListaUsuariosSistema = listaUsrSist; reservaImovel = appServiceAtos.ProcReservarMatImovel(TipoReserva, IdPrenotacao, NumMatricula, this.UsuarioAtual.Id); } resp = reservaImovel.Resposta; message = reservaImovel.Msg; } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); resp = false; message = "Falha, ProcReservarMatImovel [" + ex.Message + "]"; } var resultado = new { resposta = resp, operacao = reservaImovel.Operacao, tipoMsg = reservaImovel.TipoMsg, msg = message, Reserva = reservaImovel }; return(Json(resultado)); }
private DtoExecProc InsertOrUpdateAto(DtoAto ato) { DtoExecProc execProc = new DtoExecProc(); try { using (var appService = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { //se id == null faz insert if (ato.Id == null) { execProc.Operacao = DataBaseOperacoes.insert; //appService.Add(ato); execProc.Msg = "Dados incluidos com sucesso con sucesso"; } else { execProc.Operacao = DataBaseOperacoes.update; //appService.AtualizarAto(ato); execProc.Msg = "Dados Atualizados com sucesso con sucesso"; } execProc.TipoMsg = TipoMsgResposta.ok; execProc.Resposta = true; } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); execProc.TipoMsg = TipoMsgResposta.error; execProc.Msg = "Falha na requisição! " + "[" + ex.Message + "]"; } return(null); }
public ActionResult EditarAto(AtoViewModel modelo) { string filePath = Server.MapPath($"~/App_Data/Arquivos/AtosPendentes/{modelo.NumMatricula}_pendente.docx"); bool respEscreverWord = false; try { if (modelo.Id == null) { ViewBag.erro = "O Ato é obrigatório"; return(View(nameof(EditarAto), modelo)); } //todo: ronaldo arrumar ato editar //Ajusta a string de ato //modelo.Id = RemoveUltimaMarcacao(modelo.Id); if (ModelState.IsValid) { //Representa o documento e o numero de pagina //DtoCadastroDeAto modeloDto = Mapper.Map<AtoViewModel, DtoCadastroDeAto>(modelo); long?numSequenciaAto = null; if (modelo.NumSequenciaAto == 0 && modelo.IdTipoAto != (int)TipoAtoEnum.AtoInicial) { numSequenciaAto = this.UfwCartNew.Repositories.RepositoryAto.GetNumSequenciaAto(modelo.NumMatricula); numSequenciaAto = numSequenciaAto != null ? numSequenciaAto : 1; } else { numSequenciaAto = modelo.NumSequenciaAto; } //using (var appService = new AppServiceCadastroDeAto(this.UnitOfWorkDataBaseCartorio, this.UnitOfWorkDataBaseCartNew)) //{ // respEscreverWord = appService.EscreverAtoNoWord(modeloDto, filePath, Convert.ToInt64(numSequenciaAto)); //} if (respEscreverWord) { // Gravar no banco o array de bytes var arrayBytesNovo = System.IO.File.ReadAllBytes(filePath); // Gravar o ato e buscar o selo e gravar o selo using (var appService = new AppServiceAtos(this.UfwCartNew, this.IdCtaAcessoSist)) { //var dtoEditar = Mapper.Map<AtoViewModel, DtoCadastroDeAto>(modelo); //var resultado = appService.EditarAto(dtoEditar, this.UsuarioAtual.Id); //if (resultado) //{ // this.UnitOfWorkDataBaseCartNew.SaveChanges(); //} //else //{ // return new HttpStatusCodeResult(HttpStatusCode.InternalServerError); //} } } else { //Teve algum erro ao escrever o documento no WORD return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } //ViewBag.sucesso = "Ato cadastrado com sucesso!"; return(RedirectToActionPermanent(nameof(BloquearAto), new { modelo.Id })); } ViewBag.erro = "Erro ao cadastrar o ato!"; return(View(nameof(EditarAto), modelo)); } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); throw; } }