Пример #1
0
        public DocumentBuilder(CategoryServiceHelper categoryServiceHelper, DocumentBuilderSettings settings)
        {
            CategoryServiceHelper = categoryServiceHelper;

            Settings = settings;

            OffersTempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
            FinalTempFilePath  = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

            CategoriesForSave = new HashSet <DocumentBuilderVirtualCategory>();
        }
Пример #2
0
        public void WithGlossaryDocuments(string testId, string baseline, string src1, string src2, string src3, string src4, string src5, string src6)
        {
            var rawSources = new[] { src1, src2, src3, src4, src5, src6, };
            var sourcesStr = rawSources.Where(s => s != null).ToArray();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load the source documents
            var sources = sourcesStr.Select(s =>
            {
                var spl = s.Split(',');
                if (spl.Length == 1)
                {
                    var sourceFi  = new FileInfo(Path.Combine(_sourceDir.FullName, s));
                    var wmlSource = new WmlDocument(sourceFi.FullName);
                    return(new Source(wmlSource));
                }
                else if (spl.Length == 2)
                {
                    var start    = int.Parse(spl[1]);
                    var sourceFi = new FileInfo(Path.Combine(_sourceDir.FullName, spl[0]));
                    return(new Source(sourceFi.FullName, start, true));
                }
                else
                {
                    var start    = int.Parse(spl[1]);
                    var count    = int.Parse(spl[2]);
                    var sourceFi = new FileInfo(Path.Combine(_sourceDir.FullName, spl[0]));
                    return(new Source(sourceFi.FullName, start, count, true));
                }
            })
                          .Cast <ISource>()
                          .ToList();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Create the dir for the test
            var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));

            if (thisTestTempDir.Exists)
            {
                Assert.True(false, "Duplicate test id: " + testId);
            }
            else
            {
                thisTestTempDir.Create();
            }
            var tempDirFullName = thisTestTempDir.FullName;

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Copy sources to temp directory, for ease of review

            foreach (var item in sources)
            {
                var fi = new FileInfo(item.WmlDocument.FileName);
                var sourceCopiedToDestFi = new FileInfo(Path.Combine(tempDirFullName, fi.Name));
                if (!sourceCopiedToDestFi.Exists)
                {
                    File.Copy(item.WmlDocument.FileName, sourceCopiedToDestFi.FullName);
                }
            }

            if (baseline != null)
            {
                var baselineFi = new FileInfo(Path.Combine(_sourceDir.FullName, baseline));
                var baselineCopiedToDestFileName = new FileInfo(Path.Combine(tempDirFullName, baselineFi.Name));
                File.Copy(baselineFi.FullName, baselineCopiedToDestFileName.FullName);
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Use DocumentBuilder to build the destination document

            var outFi    = new FileInfo(Path.Combine(tempDirFullName, "Output.docx"));
            var settings = new DocumentBuilderSettings();

            DocumentBuilder.BuildDocument(sources, outFi.FullName, settings);
            Validate(outFi);
        }
Пример #3
0
 public YandexDocumentBuilder(CategoryServiceHelper categoryServiceHelper, DocumentBuilderSettings settings)
     : base(categoryServiceHelper, settings)
 {
 }