Example #1
0
        private void ReplaceKeysWithValuesInIterations(DocX document,
                                                       IEnumerable <IterationKeyValuePairHolder> iterationKeyValuePairHolders)
        {
            foreach (var iterationKeyValuePairHolder in iterationKeyValuePairHolders)
            {
                var startTagIndex = GetFirstParagraphIndex(document, $"<{iterationKeyValuePairHolder.IterationBlockName}>");
                var endTagIndex   = GetFirstParagraphIndex(document, $"</{iterationKeyValuePairHolder.IterationBlockName}>");

                if (startTagIndex == -1 || endTagIndex == -1 || endTagIndex <= startTagIndex)
                {
                    return;
                }

                var paragraphs = new List <Paragraph>();
                for (int i = 1; i < endTagIndex - startTagIndex; i++)
                {
                    paragraphs.Add(document.Paragraphs[startTagIndex + i]);
                }

                //  Remove the iteration template
                for (int i = 0; i < (endTagIndex - startTagIndex) + 1; i++)
                {
                    document.RemoveParagraphAt(startTagIndex);
                }

                int offset = startTagIndex;
                var keyValuePairIterations =
                    (List <List <KeyValuePair> >)iterationKeyValuePairHolder.KeyValuePairIterations;
                for (int x = 0; x < keyValuePairIterations.Count; x++)
                {
                    var keyValuePairs = keyValuePairIterations[x];

                    offset = startTagIndex + x * paragraphs.Count;

                    InsertParagraphsAt(document, offset, paragraphs);

                    ReplaceKeysWithValues(document, keyValuePairs);
                }
            }
        }
Example #2
0
        private void InsertParagraphsAt(DocX document, int index, IEnumerable <Paragraph> paragraphs)
        {
            var followingParagraphs = new List <Paragraph>();

            for (int i = index; i < document.Paragraphs.Count; i++)
            {
                followingParagraphs.Add(document.Paragraphs[i]);
            }
            for (int i = document.Paragraphs.Count - 1; i >= index; i--)
            {
                document.RemoveParagraphAt(i);
            }

            foreach (var paragraph in paragraphs)
            {
                document.InsertParagraph(paragraph);
            }

            foreach (var paragraph in followingParagraphs)
            {
                document.InsertParagraph(paragraph);
            }
        }
Example #3
0
        public static void CreateWordDocument(string file_location, string output_location, List <string> list_nguon, List <string> list_dich, List <int> empty_para_index)
        {
            // Load the document.
            DocX document = null;

            try
            {
                document = DocX.Load(file_location);
                if (list_nguon.Count == list_dich.Count)
                {
                    for (int i = 0; i < list_nguon.Count; i++)
                    {
                        // Replace text in this document.
                        document.ReplaceText(list_nguon[i], list_dich[i]);
                    }
                }
                //Remove empty paragraph
                for (int j = 0; j < empty_para_index.Count; j++)
                {
                    document.RemoveParagraphAt(empty_para_index[j]);
                }

                try
                {
                    document.SaveAs(output_location);
                }
                catch
                {
                    MessageBox.Show("Không thể tạo file!", "Thông báo", MessageBoxButtons.OK);
                }
            }
            catch
            {
                MessageBox.Show("File đang được sử dụng!", "Thông báo", MessageBoxButtons.OK);
            }
        }
Example #4
0
        public static DocX CreateDocA(DocX template, SRViewModel model)
        {
            //Create Date for Header
            // string Fdate = model.date.ToString();
            //string[] d = Fdate.Split(' ');
            //Fdate = d[0];
            //Fdate = formatdate(Fdate, model);
            //Create Distrbution for Header

            string Fdist = distrb(model.Cat);

            string Folang = "English";

            //Session Numer
            string Fsnum = "[NUMBER]";

            if (!String.IsNullOrEmpty(model.sNum))
            {
                Fsnum = Sessionnum(model);
            }

            //sYMBOLE
            string symb = getSym(model.Cat);

            string[] sym = symb.Split(new string[] { "#" }, StringSplitOptions.None);
            string   x   = sym[1];

            x = model.Prep.ToString() + x;
            string Fsym1 = x;

            string Fmnum = GetOrdinalSuffix(Convert.ToInt32(model.Prep.ToString()));
            //second page meeting date
            string Fsodate = "";

            if (model.time.ToString() == "at 10 a.m.")
            {
                Fsodate = "The meeting was called to order at 10 a.m.";
            }
            if (model.time.ToString() == "at 3 p.m.")
            {
                Fsodate = "The meeting was called to order at 3 p.m.";
            }



            //QR code and Bar code

            string lang = getlanguageQR(model.lang_ID);

            string Fsym = getSym(model.Cat);

            //Fsym = Fsym.Remove(Fsym.Length-1);
            // Fsym = Fsym + Fsym1;

            Fsym = Fsym.Replace("#", model.Prep.ToString());

            string url = "http://undocs.org/m2/QRCode.ashx?DS=" + Fsym + "&Size=2&Lang=" + lang;

            using (var client = new WebClient())
            {
                //var content = client.DownloadData("https://api.qrserver.com/v1/create-qr-code/?size=66x66&data=http://undocs.org/fr/A/HRC/70");
                //var content = client.DownloadData("http://undocs.org/m2/QRCode.ashx?DS=A/HRC/70&Size=2&Lang=F");
                var content = client.DownloadData(url);

                using (var str1 = new MemoryStream(content))
                {
                    Image   image = template.AddImage(str1);
                    Picture p     = image.CreatePicture();
                    Footer  f     = template.Footers.first;
                    Table   t     = f.Tables[0];
                    //t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(pR);
                    t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(p);
                }
            }
            string Floc = model.loca.ToString() + ", " + model.locb.ToString();
            //string Fvirs = "";

            //if (model.ver != null)
            //{
            //    Fvirs = getVerisons(model);
            //}

            //create barcode & gdoc
            string Fbar   = " ";
            string gdoc   = " ";
            string Fgdocf = " ";

            if (!String.IsNullOrEmpty(model.Gdoc))
            {
                gdoc   = model.Gdoc.ToString();
                Fbar   = "*" + gdoc + "*";
                Fgdocf = gdoc;
                gdoc   = gdoc.Insert(2, "-");
            }
            string Fdname = "";

            if (!String.IsNullOrEmpty(model.Cname))
            {
                Fdname = model.Ctitle.ToString() + model.Cname.ToString();
            }
            if (String.IsNullOrEmpty(model.Cname))
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("Chair:"))
                    {
                        deleteStart = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("dname"))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart;
                    for (int i = deleteStart; i <= deleteEnd; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
            }

            string Flname1 = "";
            string Flname2 = "";

            if (!String.IsNullOrEmpty(model.L1name))
            {
                Flname1 = model.L1title.ToString() + model.L1name.ToString();
            }
            if (!String.IsNullOrEmpty(model.L2name))
            {
                Flname2 = model.L2title.ToString() + model.L2name.ToString();
            }
            if (String.IsNullOrEmpty(model.L1name))
            {
                int deleteStart  = 0;
                int deleteEnd    = 0;
                int deleteStart1 = 0;
                int deleteEnd1   = 0;
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("later") && template.Paragraphs[i].Text.Contains("lname2"))
                    {
                        deleteStart1 = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("lname2"))
                    {
                        deleteEnd1 = i;
                    }
                }
                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("later") && template.Paragraphs[i].Text.Contains("lname1"))
                    {
                        deleteStart = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("lname1"))
                    {
                        deleteEnd = i;
                    }
                }
                if (deleteStart1 > 0 && deleteEnd1 > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart1;
                    for (int i = deleteStart1; i <= deleteEnd1; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart;
                    for (int i = deleteStart; i <= deleteEnd; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
                //Get the array of the paragraphs containing the start and end catches
            }



            if (String.IsNullOrEmpty(model.L2name) && !String.IsNullOrEmpty(model.L1name))
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("later") && template.Paragraphs[i].Text.Contains("lname2"))
                    {
                        deleteStart = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("lname2"))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart;
                    for (int i = deleteStart; i <= deleteEnd; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
            }
            string[] info1  = info(model);
            string   Fldate = formatdate1(model);
            string   xxx    = DateTime.Now.ToString();

            template.AddCustomProperty(new CustomProperty("gdoc", gdoc));
            template.AddCustomProperty(new CustomProperty("gdocf", Fgdocf));
            template.AddCustomProperty(new CustomProperty("bar", Fbar));

            template.AddCustomProperty(new CustomProperty("osdate", Fsodate));
            template.AddCustomProperty(new CustomProperty("sym1", Fsym1));
            //template.
            //    template.ReplaceText(Fsym, Fsym, false, RegexOptions.IgnoreCase);

            template.AddCustomProperty(new CustomProperty("symh", Fsym));
            // template.ReplaceText(sym, sym, false, RegexOptions.IgnoreCase);

            template.AddCustomProperty(new CustomProperty("olang", Folang));

            template.AddCustomProperty(new CustomProperty("dist", Fdist));
            //    template.ReplaceText("dist", Fdist, false, RegexOptions.IgnoreCase);

            template.AddCustomProperty(new CustomProperty("date", " "));
            template.AddCustomProperty(new CustomProperty("ldate", Fldate));
            //   template.ReplaceText("date", Fdate, false, RegexOptions.IgnoreCase);
            template.AddCustomProperty(new CustomProperty("dname", Fdname));
            //   template.ReplaceText("date", Fdate, false, RegexOptions.IgnoreCase);
            template.AddCustomProperty(new CustomProperty("lname1", Flname1));
            template.AddCustomProperty(new CustomProperty("lname2", Flname2));

            template.AddCustomProperty(new CustomProperty("loca", Floc));
            //   template.ReplaceText("date", Fdate, false, RegexOptions.IgnoreCase);
            //template.AddCustomProperty(new CustomProperty("virs", Fvirs));
            //      template.ReplaceText("virs", "", false, RegexOptions.IgnoreCase);

            template.AddCustomProperty(new CustomProperty("snum", Fsnum));
            //    template.ReplaceText("snum", Fsnum, false, RegexOptions.IgnoreCase);



            template.AddCustomProperty(new CustomProperty("mnum", Fmnum));
            //  template.ReplaceText("prep", Fprep, false, RegexOptions.IgnoreCase);


            template.AddCustomProperty(new CustomProperty("Date-Generated", xxx));

            template.AddCustomProperty(new CustomProperty("Org", "SR"));
            template.AddCustomProperty(new CustomProperty("Entity", info1[0]));
            template.AddCustomProperty(new CustomProperty("doctype", info1[1]));
            template.AddCustomProperty(new CustomProperty("category", info1[2]));



            return(template);
        }
Example #5
0
        public static DocX CreateDocA(DocX template, ECEViewModel model, string source, bool cprvalue)
        {
            bool   addcor  = false;
            string Fadcorr = "";
            bool   special = false;
            string Fsnum   = "[NUMBER]";
            string sym     = getSym(model);

            if (!String.IsNullOrEmpty(model.Prep))
            {
                sym = sym.Replace("#", model.Prep.ToString());
            }
            if (cprvalue == true)
            {
                sym = sym + "/CRP." + model.cprnum.ToString();
            }
            if (!String.IsNullOrEmpty(model.Add) && model.cAdd == true && model.cCor == false)
            {
                sym     = sym + "/Add." + model.Add.ToString();
                Fadcorr = "Addendum";
                addcor  = true;
            }
            if (!String.IsNullOrEmpty(model.Cor) && model.cCor == true && model.cAdd == false)
            {
                sym     = sym + "/Corr." + model.Cor.ToString();
                Fadcorr = "Corrigendum";
                addcor  = true;
            }
            if (!String.IsNullOrEmpty(model.Cor) && !String.IsNullOrEmpty(model.Add) && model.cCor == true && model.cAdd == true)
            {
                sym     = sym + "/Add." + model.Add.ToString() + "/Corr." + model.Cor.ToString();
                Fadcorr = "Addendum Corrigendum";
                addcor  = true;
            }
            if (String.IsNullOrEmpty(model.Cor) && String.IsNullOrEmpty(model.Add))
            {
                addcor = false;
            }
            if (String.IsNullOrEmpty(model.CaseYear))
            {
                sym = sym.Replace("&", DateTime.Now.Year.ToString());
            }
            if (!String.IsNullOrEmpty(model.CaseYear))
            {
                sym = sym.Replace("&", model.CaseYear.ToString());
            }
            model.tsym = sym;
            string[] SymStr = sym.Split('/');
            string[] sym1   = SymStr.Skip(1).ToArray();
            string   Fsym   = String.Join("/", sym1);

            if (Fsym.Contains("/S/"))
            {
                special = true;
                Fsnum   = "special";
            }
            //Create Date for Header
            string Fdate = model.date.ToString();

            string[] d = Fdate.Split(' ');
            Fdate = d[0];
            Fdate = formatdate(Fdate, model);


            //Create Distribution for Header
            string Fdist = getDist(model);

            //Create Virsions for Header
            string Fvirs = "";

            //if (model.version1 != null)
            //{
            //    int deleteStart = 0;
            //    int deleteEnd = 0;

            //    //Get the array of the paragraphs containing the start and end catches
            //    for (int i = 0; i < template.Paragraphs.Count; i++)
            //    {
            //        if (template.Paragraphs[i].Text.Contains("Original"))
            //            deleteStart = i;
            //        if (template.Paragraphs[i].Text.Contains("olang"))
            //            deleteEnd = i;
            //    }

            //    if (deleteStart > 0 && deleteEnd > 0)
            //    {
            //        //delete from the paraIndex as the arrays will shift when a paragraph is deleted
            //        int paraIndex = deleteStart;
            //        for (int i = deleteStart; i <= deleteEnd; i++)
            //        {
            //            template.RemoveParagraphAt(paraIndex);
            //        }
            //    }
            //}

            //Fvirs = getVerisons(model);

            string Folang = "";

            Folang = Olanguage(model.lang_ID);

            string Fatitle = "[Title]";

            if (!String.IsNullOrEmpty(model.AgendaItem))
            {
                Fatitle = model.AgendaItem.ToString();
            }
            string Fsdate = "[Start-End Dates ]";

            if (model.Sdate != null & model.Edate != null)
            {
                string   sdate = model.Sdate.ToString();
                string[] sd    = sdate.Split(' ');
                sdate = sd[0];
                sdate = formatdate(sdate, model);

                string   edate = model.Edate.ToString();
                string[] ed    = edate.Split(' ');
                edate = ed[0];
                edate = formatdate(edate, model);


                Fsdate = SessionDate(sdate, edate, model);
            }
            string Fldate = "[Start Date]";

            if (model.Sdate != null & model.Edate != null)
            {
                string   ldate = model.Sdate.ToString();
                string[] ld    = ldate.Split(' ');
                ldate = ld[0];
                string dldate = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.GetDayName(DateTime.Parse(ldate).DayOfWeek);
                ldate = formatdate(ldate, model);
                //Regex rx = new Regex(@"^\d+\p{Zs}", RegexOptions.Compiled);
                //ldate = rx.Replace(ldate, dldate+" ");
                ldate  = dldate + " " + ldate;
                Fldate = ldate;
            }

            string Fanum = "[NUMBER]";

            if (!String.IsNullOrEmpty(model.AgendaNum))
            {
                Fanum = model.AgendaNum.ToString();
            }

            if (special == false)
            {
                if (!String.IsNullOrEmpty(model.SNum))
                {
                    Fsnum = Sessionnum(model);
                }
            }



            if (model.qrcode == true)
            {
                string lang = language(model.lang_ID);
                lang = lang.Substring(0, 1);


                string url = "http://undocs.org/m2/QRCode.ashx?DS=" + Fsym + "&Size=2&Lang=" + lang;
                using (var client = new WebClient())
                {
                    //var content = client.DownloadData("https://api.qrserver.com/v1/create-qr-code/?size=66x66&data=http://undocs.org/fr/A/HRC/70");
                    //var content = client.DownloadData("http://undocs.org/m2/QRCode.ashx?DS=A/HRC/70&Size=2&Lang=F");
                    var content = client.DownloadData(url);

                    using (var str = new MemoryStream(content))
                    {
                        if (lang == "A")
                        {
                            Image     image = template.AddImage(str);
                            NVPicture p     = image.CreatePicture();
                            NVFooter  f     = template.Footers.first;
                            NVTable   t     = f.Tables[0];
                            //t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(pR);
                            t.Rows[0].Cells[0].Paragraphs.First().AppendPicture(p);
                        }
                        else
                        {
                            NVImage   image = template.AddImage(str);
                            NVPicture p     = image.CreatePicture();
                            NVFooter  f     = template.Footers.first;
                            NVTable   t     = f.Tables[0];
                            //t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(pR);
                            t.Rows[0].Cells[1].Paragraphs.First().AppendPicture(p);
                        }
                    }
                }
            }
            string Fcategory = "";

            Fcategory = getCat(model.Cat);
            string FSubcategory = "";

            if (model.SCat != "Not Applicable" || model.SCat != "Special Session")
            {
                FSubcategory = model.SCat.ToString();
            }
            if (model.SCat == "Not Applicable" || model.SCat == "Special Session")
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("subcategory"))
                    {
                        deleteStart = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("subcategory"))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart;
                    for (int i = deleteStart; i <= deleteEnd; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
            }
            if (addcor == false)
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("adcorr"))
                    {
                        deleteStart = i;
                    }
                    if (template.Paragraphs[i].Text.Contains("adcorr"))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteStart;
                    for (int i = deleteStart; i <= deleteEnd; i++)
                    {
                        template.RemoveParagraphAt(paraIndex);
                    }
                }
            }
            string Fsplace = "[Session City]";

            if (!String.IsNullOrEmpty(model.splace))
            {
                Fsplace = model.splace.ToString();
            }
            string Floca = "[Session Location]";

            if (!String.IsNullOrEmpty(model.loca))
            {
                Floca = model.loca.ToString() + ", " + Fsplace;
            }

            DateTime x = DateTime.Now;

            string[] info1 = info(model);

            template.AddCustomProperty(new CustomProperty("sym1", Fsym));
            template.AddCustomProperty(new CustomProperty("symh", sym));
            template.AddCustomProperty(new CustomProperty("dist", Fdist));
            template.AddCustomProperty(new CustomProperty("date", Fdate));
            template.AddCustomProperty(new CustomProperty("sdate", Fsdate));
            template.AddCustomProperty(new CustomProperty("virs", Fvirs));
            template.AddCustomProperty(new CustomProperty("snum", Fsnum));
            template.AddCustomProperty(new CustomProperty("anum", Fanum));
            template.AddCustomProperty(new CustomProperty("adcorr", Fadcorr));
            template.AddCustomProperty(new CustomProperty("gdoc", ""));
            template.AddCustomProperty(new CustomProperty("gdocf", ""));
            template.AddCustomProperty(new CustomProperty("tlang", ""));
            template.AddCustomProperty(new CustomProperty("atitle", Fatitle));
            template.AddCustomProperty(new CustomProperty("ldate", Fldate));
            template.AddCustomProperty(new CustomProperty("loca", Floca));
            template.AddCustomProperty(new CustomProperty("categ", Fcategory));
            template.AddCustomProperty(new CustomProperty("subcategory", FSubcategory));
            template.AddCustomProperty(new CustomProperty("splace", Fsplace));
            template.AddCustomProperty(new CustomProperty("olang", Folang));
            template.AddCustomProperty(new CustomProperty("Date-Generated", x));
            template.AddCustomProperty(new CustomProperty("Org", "ECE"));
            template.AddCustomProperty(new CustomProperty("Entity", info1[0]));
            template.AddCustomProperty(new CustomProperty("doctype", info1[1]));
            template.AddCustomProperty(new CustomProperty("category", info1[2]));
            template.AddCustomProperty(new CustomProperty("bar", ""));

            for (int i = 0; i < template.Paragraphs.Count; i++)
            {
                if (template.Paragraphs[i].Text.Contains(Fsnum))
                {
                    string Fsnum1 = char.ToUpper(Fsnum[0]) + Fsnum.Substring(1);
                    template.Paragraphs[i].ReplaceText(Fsnum, Fsnum1);
                    break;
                }
            }
            if (addcor == true && cprvalue == false)
            {
                int deleteStart = 0;
                int deleteEnd   = 0;

                //Get the array of the paragraphs containing the start and end catches
                for (int i = 0; i < template.Paragraphs.Count; i++)
                {
                    if (template.Paragraphs[i].Text.Contains("*"))
                    {
                        deleteStart = i;
                    }

                    if (template.Paragraphs[i].Text.Contains(Fadcorr))
                    {
                        deleteEnd = i;
                    }
                }

                if (deleteStart > 0 && deleteEnd > 0)
                {
                    //delete from the paraIndex as the arrays will shift when a paragraph is deleted
                    int paraIndex = deleteEnd - deleteStart;
                    paraIndex = deleteStart + paraIndex - 1;

                    template.RemoveParagraphAt(paraIndex);
                }
                //List <string> replace = template.FindUniqueByPattern("*", RegexOptions.None);
                //foreach (string s in replace)
                //{
                //    if (!s.Equals("")) template.ReplaceText((s, "");
                //}

                template.ReplaceText("*", "");

                List <string> repl = template.FindUniqueByPattern(",\\s", RegexOptions.None);
                foreach (string rep in repl)
                {
                    if (!String.IsNullOrEmpty(rep))
                    {
                        template.ReplaceText(rep, "");
                    }
                }



                //bool flag = false;
                //List<List<string>> list1 = new List<List<string>>();
                //List<string> list2 = new List<string>();
                //foreach (Novacode.Paragraph item in template.Paragraphs)
                //{
                //    //use this if you need whole text of a paragraph
                //    string paraText = item.Text;
                //    var result = paraText.Split(' ');
                //    int count = 0;
                //    list2 = new List<string>();
                //    //use this if you need word by word
                //    foreach (var data in result)
                //    {
                //        string word = data.ToString();

                //        if (word.Contains(Fsnum)) flag = true;
                //        if (word.Contains("session"))
                //        {
                //            flag = false;
                //            // list2.Add(word);
                //        }
                //        if (flag)
                //            list2.Add(word);
                //        count++;
                //    }
                //    //    list2.RemoveAt(0);

                //    list1.Add(list2);

                //}
                ////   list1[0].Replace(list1[0], "*");
                //for (int i = 0; i < list1.Count(); i++)
                //{

                //    string temp = "";
                //    for (int y = 0; y < list1[i].Count(); y++)
                //    {
                //        if (y == 0)
                //        {
                //            temp = list1[i][y];
                //            continue;
                //        }
                //        temp += " " + list1[i][y];
                //        //   temp = temp.Remove(temp.IndexOf(',')-1, temp.Length);
                //    }
                //    int ind = temp.IndexOf("*");

                //    // temp = temp.Substring(ind, temp.Length - ind);
                //    if (!temp.Equals("")) template.ReplaceText("Done", "");
                //}
            }
            //using (WordprocessingDocument

            // document = WordprocessingDocument.Open(source, true))

            //{
            //    var bookMarks = FindBookmarks(document.MainDocumentPart.Document);
            //}
            // Return the template now that it has been modified to hold all of our custom data.
            return(template);
        }