public static byte[] CreateAgreementDoc(string WebPath, string AgreementNumber, string AgreementDate, string UserName, string SignerName, string TargetPosition, string TargetDepartment, string SignerShortName, string SignerPositionWithDepartment, string UserShortName)
 {
     FileInfo file = new FileInfo(Path.Combine(WebPath, @"StaffMovements\Dogovor.docx"));
     string newfilename = Path.Combine(WebPath,Guid.NewGuid().ToString()+".docx");
     var newfile = file.CopyTo(newfilename,true);
     using (var outputDocument = new TemplateProcessor(newfilename)
         .SetRemoveContentControls(true))
     {
         var documentenc = Encoding.GetEncoding(outputDocument.Document.Declaration.Encoding);
         var valuesToFill = new Content(
             new FieldContent("AgreementNumber", AgreementNumber),
             new FieldContent("AgreementDate", AgreementDate),
             new FieldContent("UserName", UserName),
             new FieldContent("Signer", SignerName),
             new FieldContent("TargetPosition", TargetPosition),
             new FieldContent("TargetDepartment", TargetDepartment),
             new FieldContent("SignerShortName", SignerShortName),
             new FieldContent("SignerPositionWithDepartment", SignerPositionWithDepartment),
             new FieldContent("UserShortName", UserShortName)
         );
         outputDocument.FillContent(valuesToFill);
         outputDocument.SaveChanges();
     }
     StreamReader reader = new StreamReader(newfilename);
     var result =  NoteCreator.ReadFull(reader.BaseStream);
     //newfile.Delete();
     return result;
 }
Esempio n. 2
1
        public static int Main2(string[] args)
        {
            File.Delete("out.docx");
            File.Copy("in.docx", "out.docx");

            var valuesToFill = new Content(new IContentItem[] {
                //new ChartContent("Chart"),

                // Add field.
                new FieldContent("Report date", DateTime.Now.ToShortDateString()),

                // Add field in header.
                new FieldContent("Company name", "Spiderwasp Communications"),

                // Add image in header.
                new ImageContent("Logo", File.ReadAllBytes("Logo.jpg")),

                // Add field in footer.
                new FieldContent("Copyright", "© All rights reserved"),

                // Add table.
                new TableContent("Team Members Table")
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer")
                }),
                // Add field inside table that not to propagate.
                new FieldContent("Count", "2"),
                // Add list.
                new ListContent("Team Members List")
                .AddItem(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager")
                })
                .AddItem(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer")
                }),

                // Add nested list.
                new ListContent("Team Members Nested List")
                .AddItem(new ListItemContent("Role", "Program Manager")
                         .AddNestedItem(new FieldContent("Name", "Eric"))
                         .AddNestedItem(new FieldContent("Name", "Ann")))
                .AddItem(new ListItemContent("Role", "Developer")
                         .AddNestedItem(new FieldContent("Name", "Bob"))
                         .AddNestedItem(new FieldContent("Name", "Richard"))),

                // Add list inside table.
                new TableContent("Projects Table")
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager"),
                    new ListContent("Projects")
                    .AddItem(new IContentItem[] { new FieldContent("Project", "Project one") })
                    .AddItem(new IContentItem[] { new FieldContent("Project", "Project two") })
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer"),
                    new ListContent("Projects")
                    .AddItem(new IContentItem[] { new FieldContent("Project", "Project one") })
                    .AddItem(new IContentItem[] { new FieldContent("Project", "Project three") })
                }),

                // Add table inside list.
                new ListContent("Projects List", new ListItemContent[] {})
                .AddItem(new ListItemContent("Project", "Project one", new ListItemContent[] {})
                         .AddTable(new TableContent("Team members", new TableRowContent[] {})
                                   .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager")
                })
                                   .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer")
                })))
                .AddItem(new ListItemContent("Project", "Project two", new ListItemContent[] {})
                         .AddTable(new TableContent("Team members", new TableRowContent[] {})
                                   .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager")
                })))
                .AddItem(new ListItemContent("Project", "Project three", new ListItemContent[] {})
                         .AddTable(new TableContent("Team members", new TableRowContent[] {})
                                   .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer")
                }))),


                // Add table with several blocks.
                new TableContent("Team Members Statistics")
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Richard"),
                    new FieldContent("Role", "Program Manager")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer")
                }),

                new TableContent("Team Members Statistics")
                .AddRow(new IContentItem[] {
                    new FieldContent("Statistics Role", "Program Manager"),
                    new FieldContent("Statistics Role Count", "2")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Statistics Role", "Developer"),
                    new FieldContent("Statistics Role Count", "1")
                }),

                // Add table with merged rows
                new TableContent("Team members info")
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager"),
                    new FieldContent("Age", "37"),
                    new FieldContent("Gender", "Male")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer"),
                    new FieldContent("Age", "33"),
                    new FieldContent("Gender", "Male")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Ann"),
                    new FieldContent("Role", "Developer"),
                    new FieldContent("Age", "34"),
                    new FieldContent("Gender", "Female")
                }),

                // Add table with merged columns
                new TableContent("Team members projects")
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Eric"),
                    new FieldContent("Role", "Program Manager"),
                    new FieldContent("Age", "37"),
                    new FieldContent("Projects", "Project one, Project two")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Bob"),
                    new FieldContent("Role", "Developer"),
                    new FieldContent("Age", "33"),
                    new FieldContent("Projects", "Project one")
                })
                .AddRow(new IContentItem[] {
                    new FieldContent("Name", "Ann"),
                    new FieldContent("Role", "Developer"),
                    new FieldContent("Age", "34"),
                    new FieldContent("Projects", "Project two")
                }),

                // Add image
                new ImageContent("photo", File.ReadAllBytes("Tesla.jpg")),

                // Add images inside a table
                new TableContent("Scientists Table")
                .AddRow(new IContentItem[] { new FieldContent("Name", "Nicola Tesla"),
                                             new FieldContent("Born", new DateTime(1856, 7, 10).ToShortDateString()),
                                             new ImageContent("Photo", File.ReadAllBytes("Tesla.jpg")),
                                             new FieldContent("Info",
                                                              "Serbian American inventor, electrical engineer, mechanical engineer, physicist, " +
                                                              "and futurist best known for his contributions to the design of the modern alternating current (AC) electricity supply system") })
                .AddRow(new IContentItem[] { new FieldContent("Name", "Thomas Edison"),
                                             new FieldContent("Born", new DateTime(1847, 2, 11).ToShortDateString()),
                                             new ImageContent("Photo", File.ReadAllBytes("Edison.jpg")),
                                             new FieldContent("Info",
                                                              "American inventor and businessman. He developed many devices that greatly influenced life around the world, " +
                                                              "including the phonograph, the motion picture camera, and the long-lasting, practical electric light bulb.") })
                .AddRow(new IContentItem[] { new FieldContent("Name", "Albert Einstein"),
                                             new FieldContent("Born", new DateTime(1879, 3, 14).ToShortDateString()),
                                             new ImageContent("Photo", File.ReadAllBytes("Einstein.jpg")),
                                             new FieldContent("Info",
                                                              "German-born theoretical physicist. He developed the general theory of relativity, " +
                                                              "one of the two pillars of modern physics (alongside quantum mechanics). Einstein's work is also known for its influence on the philosophy of science. " +
                                                              "Einstein is best known in popular culture for his mass–energy equivalence formula E = mc2 (which has been dubbed 'the world's most famous equation').") }),


                // Add images inside a list
                new ListContent("Scientists List")
                .AddItem(new IContentItem[] { new FieldContent("Name", "Nicola Tesla"),
                                              new FieldContent("Dates of life", new DateTime(1856, 7, 10).ToShortDateString()),
                                              new ImageContent("Photo", File.ReadAllBytes("Tesla.jpg")),
                                              new FieldContent("Info",
                                                               "Serbian American inventor, electrical engineer, mechanical engineer, physicist, " +
                                                               "and futurist best known for his contributions to the design of the modern alternating current (AC) electricity supply system") })
                .AddItem(new IContentItem[] { new FieldContent("Name", "Thomas Edison"),
                                              new FieldContent("Dates of life", new DateTime(1847, 2, 11).ToShortDateString()),
                                              new ImageContent("Photo", File.ReadAllBytes("Edison.jpg")),
                                              new FieldContent("Info",
                                                               "American inventor and businessman. He developed many devices that greatly influenced life around the world, " +
                                                               "including the phonograph, the motion picture camera, and the long-lasting, practical electric light bulb.") })
                .AddItem(new IContentItem[] { new FieldContent("Name", "Albert Einstein"),
                                              new FieldContent("Dates of life", new DateTime(1879, 3, 14).ToShortDateString()),
                                              new ImageContent("Photo", File.ReadAllBytes("Einstein.jpg")),
                                              new FieldContent("Info",
                                                               "German-born theoretical physicist. He developed the general theory of relativity, " +
                                                               "one of the two pillars of modern physics (alongside quantum mechanics). Einstein's work is also known for its influence on the philosophy of science. " +
                                                               "Einstein is best known in popular culture for his mass–energy equivalence formula E = mc2 (which has been dubbed 'the world's most famous equation').") }),

                new RepeatContent("Repeats")
                .AddItem(new IContentItem[] { new FieldContent("Name", "Nicola Tesla"),
                                              new FieldContent("Dates of life", new DateTime(1856, 7, 10).ToShortDateString()),
                                              new ImageContent("Photo", File.ReadAllBytes("Tesla.jpg")),
                                              new FieldContent("Info",
                                                               "Serbian American inventor, electrical engineer, mechanical engineer, physicist, " +
                                                               "and futurist best known for his contributions to the design of the modern alternating current (AC) electricity supply system") })
                .AddItem(new IContentItem[] { new FieldContent("Name", "Thomas Edison"),
                                              new FieldContent("Dates of life", new DateTime(1847, 2, 11).ToShortDateString()),
                                              new ImageContent("Photo", File.ReadAllBytes("Edison.jpg")),
                                              new FieldContent("Info",
                                                               "American inventor and businessman. He developed many devices that greatly influenced life around the world, " +
                                                               "including the phonograph, the motion picture camera, and the long-lasting, practical electric light bulb.") })
                .AddItem(new IContentItem[] { new FieldContent("Name", "Albert Einstein"),
                                              new FieldContent("Dates of life", new DateTime(1879, 3, 14).ToShortDateString()),
                                              new ImageContent("Photo", File.ReadAllBytes("Einstein.jpg")),
                                              new FieldContent("Info",
                                                               "German-born theoretical physicist. He developed the general theory of relativity, " +
                                                               "one of the two pillars of modern physics (alongside quantum mechanics). Einstein's work is also known for its influence on the philosophy of science. " +
                                                               "Einstein is best known in popular culture for his mass–energy equivalence formula E = mc2 (which has been dubbed 'the world's most famous equation').") }),

                new RepeatContent("Repeats with hide")
                .AddItem(new IContentItem[] { new FieldContent("Name", "Nicola Tesla"),
                                              new ImageContent("Photo", File.ReadAllBytes("Tesla.jpg")).Hide(),
                                              new FieldContent("Dates of life", string.Format("{0}-{1}",
                                                                                              1856, 1943)),
                                              new FieldContent("Info",
                                                               "Serbian American inventor, electrical engineer, mechanical engineer, physicist, and futurist best known for his contributions to the design of the modern alternating current (AC) electricity supply system") })
                .AddItem(new IContentItem[] { new FieldContent("Name", "Thomas Edison"),
                                              new ImageContent("Photo", File.ReadAllBytes("Edison.jpg")),
                                              new FieldContent("Dates of life", string.Format("{0}-{1}",
                                                                                              1847, 1931)).Hide(),
                                              new FieldContent("Info",
                                                               "American inventor and businessman. He developed many devices that greatly influenced life around the world, including the phonograph, the motion picture camera, and the long-lasting, practical electric light bulb.") })
                .AddItem(new IContentItem[] { new FieldContent("Name", "Albert Einstein"),
                                              new ImageContent("Photo", File.ReadAllBytes("Einstein.jpg")),
                                              new FieldContent("Dates of life", string.Format("{0}-{1}",
                                                                                              1879, 1955)),
                                              new FieldContent("Info",
                                                               "German-born theoretical physicist. He developed the general theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). " +
                                                               "Einstein's work is also known for its influence on the philosophy of science. Einstein is best known in popular culture for " +
                                                               "his mass–energy equivalence formula E = mc2 (which has been dubbed 'the world's most famous equation').").Hide() })
            });

            using (var outputDocument = new TemplateProcessor("out.docx")
                                        .SetRemoveContentControls(true))
            {
                outputDocument.FillContent(valuesToFill);
                outputDocument.SaveChanges();
            }
            return(0);
        }
Esempio n. 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="outFileName"></param>
 public static void addValuesPosv(string outFileName)
 {
     var ValuesToFill = new Content(
         new FieldContent("psvNomer", mvVars.psvNomer),
         new FieldContent("psvDataZv", mvVars.psvDataZv),
         new FieldContent("psvDataVik", mvVars.psvDataVik),
         new FieldContent("psvDataChn", mvVars.psvDataChn),
         new FieldContent("psvFio", mvVars.psvFio),
         new FieldContent("psvFioShort", mvVars.psvFioShort),
         new FieldContent("psvProfession", mvVars.psvProfession),
         new FieldContent("psvBirthDate", mvVars.psvBirthDate),
         new FieldContent("psvAddress", mvVars.psvAddress),
         new FieldContent("psvIpn", mvVars.psvIpn),
         new FieldContent("psvRr", mvVars.psvRr),
         new FieldContent("psvFioProfSklon", mvVars.psvFioProfSklon),
         new FieldContent("psvSumma", mvVars.psvSumma),
         new FieldContent("psvSummaStr", mvVars.psvSummaStr),
         new FieldContent("psvMonthZrp", mvVars.psvMonthZrp),
         new FieldContent("psvYearZrp", mvVars.psvYearZrp),
         new FieldContent("psvDataPosv", mvVars.psvDataPosv)//dgv[9, i].Value.ToString())
             );
     File.Copy(mvVars.dPath + "psv_templ.docx", outFileName);
     using (var outfile = new TemplateProcessor(outFileName).SetRemoveContentControls(true))
     {
         outfile.FillContent(ValuesToFill);
         outfile.SaveChanges();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="outFileName"></param>
 public static void addValuesZv(string outFileName)
 {
     var ValuesToFill = new Content(
         new FieldContent("zvFio", mvVars.zvFio),
         new FieldContent("zvProffesion", mvVars.zvProffesion),
         new FieldContent("zvAddress", mvVars.zvAddress),
         new FieldContent("zvMonth", mvVars.zvMonth),
         new FieldContent("zvDataZvernen", mvVars.zvDataZvernen),
         new FieldContent("zvDataZayviKTS", mvVars.zvDataZayviKTS),
         new FieldContent("zvDataZayviDVS", mvVars.zvDataZayviDVS),
         new FieldContent("zvYear", mvVars.zvYear)
             );
     File.Copy(mvVars.dPath + "zv_templ.docx", outFileName);
     using (var outfile = new TemplateProcessor(outFileName).SetRemoveContentControls(true))
     {
         outfile.FillContent(ValuesToFill);
         outfile.SaveChanges();
     }
 }
Esempio n. 5
0
        public static void generateRishenProtocol(string ItemsCount,string CurrentItem)
        {
            string[] files = Directory.GetFiles(mvVars.psvPath); // получить список файлов в папке
            ItemsCount = Directory.GetFiles(mvVars.psvPath).Length.ToString();
            int i = 0;
            if (mvDocsT.checkCondition(mvVars.prtPath))         //если выходня папка не пуста
            {
                foreach (string f in files)             //на основе каждого файла
                {
                    //txtErrCount.Text = mvDocsT.ErrCount.ToString();
                    string data = mvDocsT.getTextFromFile(f);

                    var ValuesToFill = new Content(
                        new FieldContent("Nomer", mvRegex.getNomerPosvid(data)),
                        new FieldContent("profession", mvRegex.getProfession(data)),
                        new FieldContent("month", mvRegex.getMonthZarplata(data)),
                        new FieldContent("Data", mvRegex.getDataRishen(data)),
                        new FieldContent("DataMin", mvVars.prtDataBefore),
                        new FieldContent("fioFull", mvRegex.getFio(data)),
                        new FieldContent("fioShort", mvVars.prtFioShort),
                        new FieldContent("zrp", mvRegex.getZarplata(data)),
                        new FieldContent("cmPeople", mvVars.prtCommission)
                            );

                    string outFileName = mvVars.prtPath + "Рішення та протокол №" + mvRegex.getNomerPosvid(data) + " " + mvVars.prtFioShort + ".docx";

                    File.Copy(mvVars.tmpPath + "rs_temp.docx", outFileName);
                    using (var outfile = new TemplateProcessor(outFileName).SetRemoveContentControls(true))
                    {
                        outfile.FillContent(ValuesToFill);
                        outfile.SaveChanges();
                    }

                    i++;
                    CurrentItem = i.ToString();
                }
                MessageBox.Show("Готово!", "Создание протоколов");
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Создание из шаблона файла розпорядження с подстановкой соответствующих полей
 /// </summary>
 /// <param name="outFileName">путь и имя выходного файла</param>
 //private void addValues(string outFileName)
 //{
 //    var ValuesToFill = new Content(
 //        new FieldContent("NomerRospor", nomerRospor),
 //        new FieldContent("NomerDataPosvid", nomerDataPosvid),
 //        new FieldContent("SummaDolga", SummaDolga),
 //        new FieldContent("SummaSbora", SummaSbora),
 //        new FieldContent("NomerRahunku", rr),
 //        new FieldContent("IdCode", ipn),
 //        new FieldContent("DataSboru", dataSboru),
 //        new FieldContent("FIO", shortFio),
 //        new FieldContent("FioFull", fioFull),
 //        //
 //        new FieldContent("NomerRospor2", nomerRospor2),
 //        new FieldContent("NomerDataPosvid2", nomerDataPosvid2),
 //        new FieldContent("SummaDolga2", SummaDolga2),
 //        new FieldContent("SummaSbora2", SummaSbora2),
 //        new FieldContent("NomerRahunku2", rr2),
 //        new FieldContent("IdCode2", ipn2),
 //        new FieldContent("DataSboru2", dataSboru2),
 //        new FieldContent("FIO2", shortFio2),
 //        new FieldContent("FioFull2", fioFull2),
 //        //
 //        new FieldContent("Date", date),
 //        new FieldContent("Month", monthFull),
 //        new FieldContent("Year", year),
 //        new FieldContent("MonthN", month),
 //        new FieldContent("org1", mvDocsT.orgTitle),
 //        new FieldContent("org2", mvDocsT.orgText)
 //        );
 //    File.Copy(mvVars.dPath + "r_temp2.docx", outFileName);
 //    using (var outfile = new TemplateProcessor(outFileName).SetRemoveContentControls(true))
 //    {
 //        outfile.FillContent(ValuesToFill);
 //        outfile.SaveChanges();
 //    }
 //}
 public static void generateRishenProtocol(string outFileName)
 {
     var ValuesToFill = new Content(
         new FieldContent("Nomer", mvVars.prtNomer),
         new FieldContent("profession", mvVars.prtProfession),
         new FieldContent("month", mvVars.prtMonth),
         new FieldContent("Data", mvVars.prtData),
         new FieldContent("DataMin", mvVars.prtDataBefore),
         new FieldContent("fioFull", mvVars.prtFioFull),
         new FieldContent("fioShort", mvVars.prtFioShort),
         new FieldContent("zrp", mvVars.prtZarp),
         new FieldContent("cmPeople", mvVars.prtCommission)
             );
     File.Copy(mvVars.tmpPath + "rs_temp.docx", outFileName);
     using (var outfile = new TemplateProcessor(outFileName).SetRemoveContentControls(true))
     {
         outfile.FillContent(ValuesToFill);
         outfile.SaveChanges();
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Создание из шаблона файла розпорядження с подстановкой соответствующих полей
 /// </summary>
 /// <param name="outFileName">путь и имя выходного файла</param>
 private void addValues(string outFileName)
 {
     var ValuesToFill = new Content(
         new FieldContent("NomerRospor", nomerRospor),
         new FieldContent("NomerDataPosvid", nomerDataPosvid),
         new FieldContent("SummaDolga", SummaDolga),
         new FieldContent("SummaSbora", SummaSbora),
         new FieldContent("NomerRahunku", rr),
         new FieldContent("IdCode", ipn),
         new FieldContent("DataSboru", dataSboru),
         new FieldContent("FIO", shortFio),
         new FieldContent("FioFull", fioFull),
         //
         new FieldContent("NomerRospor2", nomerRospor2),
         new FieldContent("NomerDataPosvid2", nomerDataPosvid2),
         new FieldContent("SummaDolga2", SummaDolga2),
         new FieldContent("SummaSbora2", SummaSbora2),
         new FieldContent("NomerRahunku2", rr2),
         new FieldContent("IdCode2", ipn2),
         new FieldContent("DataSboru2", dataSboru2),
         new FieldContent("FIO2", shortFio2),
         new FieldContent("FioFull2", fioFull2),
         //
         new FieldContent("Date", date),
         new FieldContent("Month", monthFull),
         new FieldContent("Year", year),
         new FieldContent("MonthN", month),
         new FieldContent("org1", mvDocsT.orgTitle),
         new FieldContent("org2", mvDocsT.orgText)
         );
     File.Copy(mvVars.dPath + "r_temp2.docx", outFileName);
     using (var outfile = new TemplateProcessor(outFileName).SetRemoveContentControls(true))
     {
         outfile.FillContent(ValuesToFill);
         outfile.SaveChanges();
     }
 }