Esempio n. 1
0
        public ActionResult NovoAto(AtoViewModel modelo)
        {
            DtoExecProc  execProc   = new DtoExecProc();
            DtoAto       ato        = new DtoAto();
            List <Livro> listaLivro = this.UfwCartNew.Repositories.GenericRepository <Livro>().Get().ToList();

            ViewBag.listaLivro = new SelectList(listaLivro, "Id", "Descricao");

            //povoar tree view
            List <TipoAtoList> listaTipoAto = this.UfwCartNew.Repositories.RepositoryTipoAto.ListaTipoAtos(null).ToList();

            ViewBag.listaTipoAto = listaTipoAto;

            ViewBag.listaModelosDocx = new SelectList(
                new[] { new { IdModeloDoc = "0", NomeModelo = "Selecione um modelo" } },
                "IdModeloDoc",
                "NomeModelo"
                );

            if (ModelState.IsValid)
            {
                execProc = this.InsertOrUpdateAto(ato);
            }

            return(View(modelo));
        }
Esempio n. 2
0
        /// <summary>
        /// Função que escreve o ato no documento
        /// </summary>
        /// <param name="modelo">View model que contem o ato</param>
        /// <param name="doc">Documento ativo</param>
        /// <param name="numeroPagina">Numero da pagina inicial</param>
        /// <param name="posicaoCursor">Posição do cursor</param>
        public void EscreverAto(DtoAto modelo, int numeroPagina, int posicaoCursor, bool houveDesvio = false)
        {
            ValidarDoc();

            //if (string.IsNullOrEmpty(modelo.Ato))
            //{
            //    throw new ArgumentNullException("modelo", "O ato do modelo não pode ser nulo");
            //};

            //for (int i = 0; i < modelo.Ato.Length; i++)
            //{
            //    if (WordPageHelper.GetNumeroPagina(doc) > numeroPagina)
            //    {
            //        //Selecionando texto para salvar
            //        string textoParaSalvar = string.Empty;
            //        textoParaSalvar = SelecionaTextoParaSalvar(doc);

            //        //Escreve no documento o texto para salvar
            //        posicaoCursor = EscreverNoDocumento(modelo, doc, ref numeroPagina, textoParaSalvar);

            //        //Quando ocorre quebra de página ele acaba pulando uma letra
            //        i--;
            //    }
            //    else
            //    {
            //        WordParagraphHelper.InserirTextoEmRange(doc, posicaoCursor++, modelo.Ato[i].ToString());
            //    }
            //}
        }
Esempio n. 3
0
        /// <summary>
        /// Função que escreve no documento quando ocorre mudança de pagina
        /// </summary>
        /// <param name="modelo">View Model</param>
        /// <param name="doc">Documento Ativo</param>
        /// <param name="numeroPagina">Numero da pagina (Atualizada por ref) </param>
        /// <param name="textoParaSalvar">Texto para escrever</param>
        /// <returns>A posição do cursor para continuar a escrita do documento</returns>
        public int EscreverNoDocumento(DtoAto modelo, string textoParaSalvar)
        {
            //todo: MUDAR DtoCadastroDeAto para TodosCArt
            ValidarDoc();

            int numberOfSections      = _doc.Sections.Count;
            int numberOfParagraphs    = _doc.GetChildElements(true, ElementType.Paragraph).Count();
            int numberOfRunsAndFields = _doc.GetChildElements(true, ElementType.Run, ElementType.Field).Count();
            int numberOfInlines       = _doc.GetChildElements(true).OfType <Inline>().Count();


            StringBuilder sb = new StringBuilder();

            foreach (Paragraph paragraph in _doc.GetChildElements(true, ElementType.Paragraph))
            {
                foreach (Run run in paragraph.GetChildElements(true, ElementType.Run))
                {
                    bool   isBold = run.CharacterFormat.Bold;
                    string text   = run.Text;

                    sb.AppendFormat("{0}{1}{2}", isBold ? "<b>" : "", text, isBold ? "</b>" : "");
                }
                sb.AppendLine();
            }

            Console.WriteLine(sb.ToString());


            //Section sec = (Section)doc.GetChildElements(true, ElementType.Section).First();


            Paragraph paragraph1 = new Paragraph(_doc, Enumerable.Repeat("_", 80).ToString());
            Paragraph paragraph2 = new Paragraph(_doc, textoParaSalvar);

            _doc.Sections[0].Blocks.Add(paragraph1);
            _doc.Sections[0].Blocks.Add(paragraph2);



            //Insere o texto de rodapé
            //WordParagraphHelper.InserirRodape(doc);

            //Escrever o texto depois do rodapé
            //EscreverCabecalhoETexto(modelo, doc, out numeroPagina, out int posicaoCursor);

            //Reescreve o texto que foi perdido pelo rodapé e retorna a posição do cursor atualizada
            //posicaoCursor = WordParagraphHelper.ReescreverTextoDeFinalDePagina(doc, posicaoCursor, textoParaSalvar);
            return(0);
        }
Esempio n. 4
0
        public JsonResult InsertOrUpdateAtoAjax(AtoViewModel modelo)
        {
            DtoAto      ato                = new DtoAto();
            DtoExecProc execProc           = new DtoExecProc();
            List <DtoModeloDocxList> lista = new List <DtoModeloDocxList>();


            execProc = this.InsertOrUpdateAto(ato);

            var resultado = new
            {
                resposta = execProc.Resposta,
                msg      = execProc.Msg,
                execute  = execProc
            };

            return(Json(resultado));
        }
Esempio n. 5
0
        /// <summary>
        /// Escreve o cabeçalho de acordo com a pagina,ficha e verso. Além do texto modelo
        /// </summary>
        /// <param name="modelo">View Model</param>
        /// <param name="doc">Documento ativo</param>
        /// <param name="numeroPagina">Numero da pagina</param>
        /// <param name="posicaoCursor">Posição do cursor</param>
        public void EscreverCabecalhoETexto(DtoAto modelo, int numeroPagina, int posicaoCursor)
        {
            //if (doc == null) throw new ArgumentNullException("doc", "Documento não pode ser nulo");

            //if (!WordPageHelper.IsVerso(WordPageHelper.GetNumeroPagina(doc)))
            //{
            //    //Posiciona o cursor na ultima pagina e ajusta o paragrafo
            //    WordSelectionHelper.Goto(doc, WdGoToItem.wdGoToPage, WdGoToDirection.wdGoToNext, WordPageHelper.GetNumeroPagina(doc, 1));
            //    WordParagraphHelper.SpaceAfterParagraphs(doc, 0);
            //}
            ////Insere o cabeçalho
            //WordLayoutPageHelper.InserirCabecalho(modelo, doc);

            ////Se for continuação de alguma ficha
            //WordLayoutPageHelper.InserirContinuacaoFicha(doc);
            //doc.Paragraphs.Last.Range.Bold = 0;

            //posicaoCursor = WordPageHelper.GetContentEnd(doc, 1);
            //numeroPagina = WordPageHelper.GetNumeroPagina(doc);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public IEnumerable <DtoDocx> GerarFichas(DtoAto ato)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
        public List <DtoDocx> GerarDocx(DtoAto Ato, string filePathName)
        {
            List <DtoDocx> listaDocx = new List <DtoDocx>();
            DtoDocx        docxTmp   = new DtoDocx();
            bool           flagText  = true;
            string         strTmp    = string.Empty;
            int            j         = 0;
            int            paginaInicial;
            int            paginaAtual;

            /*
             * List<DtoDocxList> lista = _appServiceAtos.GetListDtoDocxAto(Ato.NumMatricula).ToList();
             * bool ExisteDocxAto = lista.Count > 0;
             *
             * if (ExisteDocxAto)
             * {
             *  long maxIdDocx = lista.Max(a => a.IdDocx);
             *
             *  DtoDocxList Ultimodoc = lista.Where(a => a.IdDocx == maxIdDocx).FirstOrDefault();
             *
             *  if (this.VerificarSeArquivoExiste(Ultimodoc.NomeArquivo))
             *  {
             *      this.LerDocumento(Ultimodoc.NomeArquivo);
             *  }
             *  else
             *  {
             *      throw new IOException(string.Format("Arquivo: {0} não existe no servidor!", filePathName));
             *  }
             * }
             * else
             * {
             *  this.LerDocumento(filePathName);
             * }
             *
             * paginaInicial = this.WordDocument.GetPaginator().Pages.Count;
             * paginaAtual = paginaInicial;
             *
             * Section sec = ObterSection();
             * Paragraph paragraph = this.NovoParagrafo(Ato.Texto, LoadOpitionsDocGemBox.Html);
             * sec.Blocks.Add(paragraph);
             *
             * //AtoWordHelper.IndexParagrafo = sec.Blocks.IndexOf(paragraph);
             * paginaAtual = paragraph.Document.GetPaginator().Pages.Count;
             *
             * if (paginaAtual > paginaInicial)
             * {
             *  if (paginaAtual > 2)
             *  {
             *      //AtoDocx.
             *  }
             *  else
             *  {
             *      string texto = paragraph.Content.ToString();
             *      string[] strWords = GetArryWords(texto);
             *      paragraph.Content.Delete();
             *
             *      while (flagText)
             *      {
             *          strTmp = string.Empty;
             *
             *          for (int i = j; i < strWords.Length; i++)
             *          {
             *              strTmp += Regex.Replace(strWords[i], @"\t|\n|\r", "") + " ";
             *              j = i + 1;
             *
             *              if ((j % 16) == 0)
             *              {
             *                  break;
             *              }
             *          }
             *
             *          Run run = new Run(WordDocument, strTmp);
             *          //run.CharacterFormat = new CharacterFormat()
             *          //{
             *
             *          //};
             *
             *          paragraph.Inlines.Add(run);
             *          paginaAtual = paragraph.Document.GetPaginator().Pages.Count;
             *
             *          if (paginaAtual > paginaInicial)
             *          {
             *              paragraph.Inlines.Remove(run);
             *              paragraph.Inlines.Add(new Run(WordDocument, "<<Quebrou>>"));
             *              paragraph.Inlines.Add(new SpecialCharacter(WordDocument, SpecialCharacterType.PageBreak));
             *              paragraph.Inlines.Add(run);
             *              paginaInicial = paginaAtual;
             *          }
             *
             *          flagText = (j < strWords.Length);
             *      }
             *  }
             * }
             */

            return(listaDocx);
        }