Пример #1
0
        static void CreatePersonalizedMailing(ICollection <WordStatementInfo> statements, Document sourceDoc, Document doc, IProgressReporter progress)
        {
            using (new ClipboardScope()) {
                var populator = new MailingPopulator();
                sourceDoc.Range().Copy();
                Range range = doc.Range();

                progress.Maximum = statements.Count;
                int i = 0;
                foreach (var person in statements.GroupBy(s => s.Person))
                {
                    if (progress.WasCanceled)
                    {
                        return;
                    }
                    progress.Progress = i;

                    range.Collapse(WdCollapseDirection.wdCollapseEnd);
                    range.Paste();

                    populator.Populate(range, person);
                    foreach (Shape shape in range.ShapeRange)
                    {
                        populator.Populate(shape.TextFrame.TextRange, person);
                    }

                    i++;
                }
            }
        }
        static void CreatePersonalizedMailing(ICollection<WordStatementInfo> statements, Document sourceDoc, Document doc, IProgressReporter progress)
        {
            using (new ClipboardScope()) {
                var populator = new MailingPopulator();
                sourceDoc.Range().Copy();
                Range range = doc.Range();

                progress.Maximum = statements.Count;
                int i = 0;
                foreach (var person in statements.GroupBy(s => s.Person)) {
                    if (progress.WasCanceled) return;
                    progress.Progress = i;

                    range.Collapse(WdCollapseDirection.wdCollapseEnd);
                    range.Paste();

                    populator.Populate(range, person);
                    foreach (Shape shape in range.ShapeRange)
                        populator.Populate(shape.TextFrame.TextRange, person);

                    i++;
                }
            }
        }