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)); }
// GET: Arquivos public ActionResult IndexModelo() { IEnumerable <ModeloDocxListViewModel> listaArquivoModeloDocxListViewModel = new List <ModeloDocxListViewModel>(); using (AppServiceModelosDoc appService = new AppServiceModelosDoc(this.UfwCartNew, this.IdCtaAcessoSist)) { IEnumerable <DtoModeloDocxList> listaDtoModelosDocx = appService.GetListaModelosDocx(null).Where(a => a.Ativo == true); listaArquivoModeloDocxListViewModel = Mapper.Map <IEnumerable <DtoModeloDocxList>, IEnumerable <ModeloDocxListViewModel> >(listaDtoModelosDocx); } return(View(listaArquivoModeloDocxListViewModel)); }
//[ValidateAntiForgeryToken] public void DesativarModelo([Bind(Include = "Id, Ip")] DadosPostModeloDocxDownload dadosPost) { bool respDesativar; using (AppServiceModelosDoc appService = new AppServiceModelosDoc(this.UfwCartNew, this.IdCtaAcessoSist)) { respDesativar = appService.Desativar(Convert.ToInt64(dadosPost.Id), this.UsuarioAtual.Id); } if (!respDesativar) { throw new Exception("Não foi possível desativar o modelo"); } }
public static void ListaPaizes() { Console.Clear(); //Console.WriteLine("----------------------------------------------------------------"); //Console.WriteLine("***************| RELATORIO |**************************"); //Console.WriteLine("----------------------------------------------------------------"); using (UnitOfWorkDataBaseCartNew unitOfWork2 = new UnitOfWorkDataBaseCartNew("contextOraCartNew")) { using (AppServiceModelosDoc appService = new AppServiceModelosDoc(unitOfWork2, 1)) { // } //unitOfWork2.SaveChanges(); } Console.ReadKey(); }
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)); } }
public ActionResult NovoModelo([Bind(Include = "Id,IdCtaAcessoSist,IdTipoAto,IdUsuarioCadastro,IdUsuarioAlteracao,DataCadastro,DataAlteracao,DescricaoModelo," + "DescricaoTipoAto,ArquivoDocxModelo,CaminhoEArquivo,Ativo,IpLocal")] ModeloDocxViewModel modeloDocxViewModel) { bool ControllerModelValid = ModelState.IsValid; bool success = false; string msg = ""; long? NovoId; try { List <TipoAtoList> listaTipoAto = this.UfwCartNew.Repositories.RepositoryTipoAto.ListaTipoAtos(null).ToList(); ViewBag.listaTipoAto = listaTipoAto; if (ControllerModelValid) { string filePath = string.Empty; modeloDocxViewModel.CaminhoEArquivo = Server.MapPath("~/App_Data/Arquivos/Modelos/"); using (AppServiceModelosDoc appService = new AppServiceModelosDoc(this.UfwCartNew, this.IdCtaAcessoSist)) { NovoId = appService.NovoModelo( new DtoModeloDoc() { 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, UsuarioSistOperacional = System.Security.Principal.WindowsIdentity.GetCurrent().Name, IpLocal = modeloDocxViewModel.IpLocal, Ativo = true }, this.UsuarioAtual.Id ); } if (modeloDocxViewModel.ArquivoDocxModelo != null && modeloDocxViewModel.ArquivoDocxModelo.ContentLength > 0) { //Pega os dados do arquivo HttpPostedFileBase arquivo = modeloDocxViewModel.ArquivoDocxModelo; //arquivo.FileName = "Mod_"+arquivoModel.DescricaoTipoAto+DateTime.Now.ToString("yyyyMMddTHHmmss") var nomeArquivo = Path.GetFileNameWithoutExtension(arquivo.FileName); // Salva o arquivo fisicamente filePath = Path.Combine(modeloDocxViewModel.CaminhoEArquivo, "modelo_" + NovoId.ToString() + ".docx"); arquivo.SaveAs(filePath); } //ModelState.AddModelError(Guid.NewGuid().ToString(), "Erro generico"); msg = "Modelo adicionado com sucesso!"; success = true; } } catch (Exception ex) { msg = "Não foi possível salvar! [" + ex.Message + "]"; ModelState.AddModelError(Guid.NewGuid().ToString(), msg); //System.Diagnostics.Debug.WriteLine("ArquivosController Exception: " + ex.Message); //return new HttpStatusCodeResult(HttpStatusCode.InternalServerError); //return RedirectToAction("InternalServerError", "Adm", new { excecao = ex }); } //var resultado = new //{ // success = success, // mensagem = msg //}; //return Json(resultado, JsonRequestBehavior.AllowGet); ViewBag.success = success ? "true" : "false"; ViewBag.ControllerModelValid = ControllerModelValid ? "true" : "false"; ViewBag.msg = msg; return(View(modeloDocxViewModel)); }