// GET: Acoes public ActionResult IndexAcao() { List <AcaoViewModel> listaAcoes = new List <AcaoViewModel>(); try { List <ApplicationUser> listaUsrSist = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(u => u.Ativo == true).OrderBy(u => u.UserName).ToList(); using (AppServiceAcoesUsuarios appServAcoesUsuarios = new AppServiceAcoesUsuarios(this.UfwCartNew, this.IdCtaAcessoSist)) { IEnumerable <Acao> listaTodasAcoes = appServAcoesUsuarios.UfwCartNew.Repositories.GenericRepository <Acao>().Get().OrderBy(a => a.DescricaoMedio).ToList(); AddListaAcao(appServAcoesUsuarios, listaUsrSist, listaTodasAcoes.Where(a => a.SeqAcesso == null).ToList(), listaAcoes); AddListaAcao(appServAcoesUsuarios, listaUsrSist, listaTodasAcoes.Where(a => a.SeqAcesso != null).ToList(), listaAcoes); //listAcessos = Mapper.Map<IEnumerable<DtoAcesso>, IEnumerable<ACESSOViewModel>>(null); } ViewBag.listaUsuarios = new SelectList(listaUsrSist, "Id", "Nome"); } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); } return(View(listaAcoes)); }
public ActionResult EditarAto(long?Id) { try { if (Id.HasValue) { Ato Ato = this.UfwCartNew.Repositories.GenericRepository <Ato>().GetById(Id); if (Ato == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } //else if (Ato.Bloqueado == true) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Não é possível editar um ato já bloqueado."); //} AtoViewModel atoViewModel = new AtoViewModel() { Id = Id, NumSequenciaAto = Ato.NumSequenciaAto }; return(View(atoViewModel)); } else { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); return(RedirectToAction("InternalServerError", "Adm", new { excecao = ex })); } }
public bool ExisteAto(string NumMatricula) { try { //string filePath = Server.MapPath($"~/App_Data/Arquivos/Atos/{NumMatricula}.docx"); //using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) //{ //} Response.StatusCode = 200; return(true); } catch (FileNotFoundException ex) { Response.StatusCode = 200; TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); return(false); } catch (Exception ex) { Response.StatusCode = 500; Console.Write(ex); return(false); } }
public FileResult DownloadFile([Bind(Include = "Id, Ip")] DadosPostModeloDocxDownload dadosPost) { string fileName = "modelo_" + dadosPost.Id.ToString() + ".docx"; string filePath = Server.MapPath($"~/App_Data/Arquivos/Modelos/modelo_{dadosPost.Id}.docx"); try { string ipAddress = dadosPost.Ip; if (string.IsNullOrEmpty(ipAddress)) { var host = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { ipAddress = ip.ToString(); } } } byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); //Cadastro de LOG CadastrarLogDownload(ipAddress, dadosPost.Id); return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)); } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); return(null); } }
public JsonResult GetListaModelosDocx(long?IdTipoAto) { bool resp = false; string mesage = string.Empty; List <DtoModeloDocxList> lista = new List <DtoModeloDocxList>(); try { using (var appService = new AppServiceModelosDoc(this.UfwCartNew, this.IdCtaAcessoSist)) { lista = appService.GetListaModelosDocx(IdTipoAto).ToList(); resp = true; mesage = "Dados retornados con sucesso"; } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); mesage = "Falha ao obter dados! " + "[" + ex.Message + "]"; } var resultado = new { resposta = resp, msg = mesage, ListaModelosDocx = lista }; return(Json(resultado)); }
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)); }
/// <summary> /// Pega o arquivo DOCX do ATO /// </summary> /// <param name="dadosPost">Dados do post</param> /// <returns>Download do arquivo DOCX</returns> public FileResult DownloadFileCompleto([Bind(Include = "Id")] long?Id) { string fileName = Id.ToString(); string filePath = Server.MapPath($"~/App_Data/Arquivos/Atos/{Id}.docx"); try { byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); Response.StatusCode = 200; return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)); } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); Response.StatusCode = 500; return(null); } }
public ActionResult BloquearAto(long?Id) { try { if (Id.HasValue) { Ato Ato = this.UfwCartNew.Repositories.GenericRepository <Ato>().GetById(Id); if (Ato == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } //else if (Ato.Bloqueado == true) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Não é possível bloquear um ato já bloqueado"); //} AtoListViewModel atoViewModel = new AtoListViewModel { Id = Ato.Id, Ativo = Ato.Ativo, //NumSequencia = Ato.NumSequencia, Codigo = "", DataAlteracao = Ato.DataAlteracao, DataCadastro = Ato.DataCadastro, //NomeArquivo = Ato.NomeArquivo, NumMatricula = Ato.NumMatricula, IdPrenotacao = Ato.IdPrenotacao }; return(View(atoViewModel)); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); return(RedirectToAction("InternalServerError", "Adm", new { excecao = ex })); } }
public ActionResult EditarModelo(ModeloDocxViewModel modeloDocxViewModel) { try { List <TipoAtoList> listaTipoAto = this.UfwCartNew.Repositories.RepositoryTipoAto.ListaTipoAtos(null).ToList(); ViewBag.listaTipoAto = listaTipoAto; // new SelectList(listaTipoAto, "Id", "Descricao"); if (ModelState.IsValid) { // Fazendo Upload do arquivo using (var appService = new AppServiceModelosDoc(this.UfwCartNew, this.IdCtaAcessoSist)) { appService.EditarModelo(new DtoModeloDoc() { Id = modeloDocxViewModel.Id, IdCtaAcessoSist = this.IdCtaAcessoSist, IdTipoAto = modeloDocxViewModel.IdTipoAto, CaminhoEArquivo = modeloDocxViewModel.CaminhoEArquivo, // Path.Combine(Server.MapPath("~/App_Data/Arquivos/Modelos/"), NovoId.ToString() + ".docx"), ArquivoDocxModelo = modeloDocxViewModel.ArquivoDocxModelo, DescricaoModelo = modeloDocxViewModel.DescricaoModelo, IpLocal = modeloDocxViewModel.IpLocal, UsuarioSistOperacional = System.Security.Principal.WindowsIdentity.GetCurrent().Name, Ativo = modeloDocxViewModel.Ativo }, UsuarioAtual.Id); } //UploadArquivo(arquivoModeloDocxViewModel); //ViewBag.resultado = "Arquivo salvo com sucesso!"; return(RedirectToActionPermanent(nameof(IndexModelo))); } return(View(modeloDocxViewModel)); } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
// GET: Modelo/Novo public ActionResult NovoModelo() { try { List <TipoAtoList> listaTipoAto = this.UfwCartNew.Repositories.RepositoryTipoAto.ListaTipoAtos(null).ToList(); ViewBag.listaTipoAto = listaTipoAto; // new SelectList(listaTipoAto, "Id", "Descricao"); ModeloDocxViewModel model = new ModeloDocxViewModel(); model.IdCtaAcessoSist = this.IdCtaAcessoSist; model.IdUsuarioCadastro = this.UsuarioAtual.Id; model.DescricaoTipoAto = ""; return(View(model)); } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
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)); }
public JsonResult RemoveUsrAcao(long IdAcao, string IdUsuario) { bool resposta = false; string msg = string.Empty; try { using (AppServiceAcoesUsuarios appServiceAcoesUsuarios = new AppServiceAcoesUsuarios(this.UfwCartNew, this.IdCtaAcessoSist)) { var usrAcao = appServiceAcoesUsuarios.UfwCartNew.Repositories.GenericRepository <UsuarioAcao>().GetWhere(u => (u.IdAcao == IdAcao) && (u.IdUsuario == IdUsuario)).FirstOrDefault(); if ((usrAcao != null) || (!string.IsNullOrEmpty(usrAcao.IdUsuario))) { //fazer remove var appResp = appServiceAcoesUsuarios.RemoveUsrAcao(IdAcao, IdUsuario); resposta = appResp.Execute; msg = appResp.Message; } else { msg = string.Format("Ação {0} não encontrado para o usuário!", IdAcao); } } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); msg = "Erro na solicitação: " + ex.Message; } var resultado = new { resposta = resposta, msg = msg }; 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); }
private void AddListaAcao(AppServiceAcoesUsuarios appServAcoesUsuarios, List <ApplicationUser> listaUsrSist, List <Acao> listaTodasAcoes, List <AcaoViewModel> listaAcoes) { bool addUser; try { foreach (var acao in listaTodasAcoes) { List <UsuarioAcaoViewModel> listaUsrAcao = new List <UsuarioAcaoViewModel>(); var listaUsers = appServAcoesUsuarios.UfwCartNew.Repositories.GenericRepository <UsuarioAcao>().GetWhere(u => u.IdAcao == acao.Id).ToList(); foreach (var usuario in listaUsers) { addUser = true; var usrtmp = listaUsrSist.Find(u => u.Id == usuario.IdUsuario); if (acoesAdmin.Contains(acao.Id ?? 0)) { addUser = usrtmp.Claims.Where(c => (c.ClaimType == ClaimTypes.Role) && (c.ClaimValue == "Admin")).Count() > 0; } if ((usrtmp != null) && addUser) { listaUsrAcao.Add(new UsuarioAcaoViewModel { IdUsuario = usuario.IdUsuario, UserName = usrtmp.UserName, Email = usrtmp.Email, Nome = usrtmp.Nome }); } } listaAcoes.Add(new AcaoViewModel { Id = acao.Id, IdCtaAcessoSist = acao.IdCtaAcessoSist, SeqAcesso = acao.SeqAcesso, Programa = acao.Programa, Obs = acao.Obs, DescricaoPequeno = acao.DescricaoPequeno, DescricaoMedio = acao.DescricaoMedio, DescricaoGrande = acao.DescricaoGrande, DescricaoTip = acao.DescricaoTip, DescricaoBalao = acao.DescricaoBalao, Orientacao = acao.Orientacao, Action = acao.Action, Controller = acao.Controller, Parametros = acao.Parametros, IconeWeb = acao.IconeWeb, IconeMobile = acao.IconeMobile, Ativo = acao.Ativo, EmManutencao = acao.EmManutencao, ListaUsersAcao = listaUsrAcao }); } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); } }
public JsonResult AddUsrAcao(long IdAcao, string IdUsuario) { bool resposta = false; string msg = string.Empty; string nome = string.Empty; string usrName = string.Empty; string email = string.Empty; try { using (AppServiceAcoesUsuarios appServAcoesUsuarios = new AppServiceAcoesUsuarios(this.UfwCartNew, this.IdCtaAcessoSist)) { Acao acao = appServAcoesUsuarios.UfwCartNew.Repositories.GenericRepository <Acao>().GetWhere(a => a.Id == IdAcao).FirstOrDefault(); if ((acao != null) || (!string.IsNullOrEmpty(acao.Programa))) { var usuario = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(u => u.Id == IdUsuario).FirstOrDefault(); if ((usuario == null) || (!usuario.Ativo)) { msg = "Usuário inexistente ou não ativo, não pode ser adicionado."; } else { if (acoesAdmin.Contains(acao.Id ?? 0)) { if (!(usuario.Claims.Where(c => (c.ClaimType == ClaimTypes.Role) && (c.ClaimValue == "Admin")).Count() > 0)) { msg = "Esta permissão só pode ser atribuída para usuários do grupo Admin!"; } } else { //fazer add var appResp = appServAcoesUsuarios.AddUsrAcao(IdAcao, IdUsuario); resposta = appResp.Execute; msg = appResp.Message; usrName = usuario.UserName; nome = usuario.Nome; email = usuario.Email; } } } else { msg = string.Format("Ação {0} não encontrado!", IdAcao); } } } catch (Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); msg = "Erro na solicitação: " + ex.Message; } var resultado = new { resposta = resposta, msg = msg, usuario = new { Id = IdUsuario, UserName = usrName, Nome = nome, Email = email } }; return(Json(resultado)); }
protected virtual void SaveLog(Exception ex) { TypeInfo t = this.GetType().GetTypeInfo(); IOFunctions.GerarLogErro(t, ex); }
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; } }