Пример #1
0
        public async Task Start()
        {
            var nomes = sheetReader.GetTagColumn("Nome");

            if (nomes == null)
            {
                throw new Exception("Não foi possível identificar o cabeçalho de Nome." +
                                    "\nÉ necessário o nome da pessoa indicado pela coluna");
            }
            var emails = sheetReader.GetTagColumn("Email");

            if (emails == null)
            {
                throw new Exception("Não foi possível identificar o cabeçalho de Email.");
            }

            var pdfList = generatorPDF.CreatePDFs();

            if (pdfList != null && pdfList.Count > 0)
            {
                var total = pdfList.Count;
                for (int i = 0; i < total; i++)
                {
                    await se.To(emails[i], nomes[i], pdfList[i]);
                }
            }
        }
Пример #2
0
        private string ReplaceTags(int row)
        {
            var result = html;

            Regex rCheck     = new Regex(@"\{\{(\w+)\}\}");
            var   tagsInside = Array.FindAll(sheetReader.Tags,
                                             x => html.Contains("{{" + x + "}}"));
            var matches = rCheck.Matches(html);

            foreach (Match m in matches)
            {
                var value  = m.Groups[1].Value;
                var exists = Array.Exists(sheetReader.Tags, x => x == value);
                if (!exists)
                {
                    throw new Exception(
                              string.Format("Não foi possível identificar o cabeçalho com a tag {{{{{0}}}}} posta no texto",
                                            value));
                }
            }

            foreach (var tag in tagsInside)
            {
                result = result.Replace("{{" + tag + "}}",
                                        sheetReader.GetTagColumn(tag)[row]);
            }

            return(result);
        }