Example #1
0
        protected string CreateFileToOpen(ProjectInfo projectInfo,
                                          bool linkToUserCss)
        {
            LexEntryRepository lexEntryRepository = projectInfo.ServiceProvider.GetService(typeof(LexEntryRepository)) as LexEntryRepository;
            var pliftPath = Path.Combine(projectInfo.PathToExportDirectory, projectInfo.Name + ".plift");


            var maker = new PLiftMaker();

            maker.MakePLiftTempFile(pliftPath, lexEntryRepository,
                                    projectInfo.ServiceProvider.GetService(typeof(ViewTemplate)) as
                                    ViewTemplate, LiftWriter.ByteOrderStyle.NoBOM);


            var pathToOutput = Path.Combine(projectInfo.PathToExportDirectory,
                                            projectInfo.Name + ".html");

            if (File.Exists(pathToOutput))
            {
                File.Delete(pathToOutput);
            }

            var htmWriter = new FLExCompatibleXhtmlWriter(linkToUserCss, ((WeSay.Project.WeSayWordsProject)projectInfo.Project).DefaultViewTemplate);

            SetupLetterGroups(projectInfo, htmWriter);

            using (var reader = new StreamReader(pliftPath))
            {
                using (var file = new StreamWriter(pathToOutput, false, new UTF8Encoding(false)))
                {
                    htmWriter.Write(reader, file);
                }
            }
            return(pathToOutput);
        }
Example #2
0
		protected string CreateFileToOpen(ProjectInfo projectInfo,
										  bool includeXmlDirective,
										  bool linkToUserCss)
		{
			//the problem we're addressing here is that when this is launched from the wesay configuration
			//that won't (and doesn't want to) have locked up the db4o db by making a record list manager,
			//which it normally has no need for.
			//So if we're in that situation, we temporarily try to make one and then release it,
			//so it isn't locked when the user says "open wesay"

			LexEntryRepository lexEntryRepository = projectInfo.ServiceProvider.GetService(typeof(LexEntryRepository)) as LexEntryRepository;
		  //  using(lexEntryRepository.GetRightToAccessLiftExternally())
			{
				string pliftPath;
				using (LameProgressDialog dlg = new LameProgressDialog("Exporting to PLift..."))
				{
					dlg.Show();
					PLiftMaker maker = new PLiftMaker();
					pliftPath = maker.MakePLiftTempFile(lexEntryRepository, projectInfo.ServiceProvider.GetService(typeof(ViewTemplate)) as ViewTemplate);
				}

				projectInfo.PathToLIFT = pliftPath;

				XsltArgumentList arguments = new XsltArgumentList();
				arguments.AddParam("writing-system-info-file",
								   string.Empty,
								   projectInfo.LocateFile("WritingSystemPrefs.xml"));
				arguments.AddParam("grammatical-info-optionslist-file",
								   string.Empty,
								   projectInfo.LocateFile("PartsOfSpeech.xml"));
				arguments.AddParam("link-to-usercss", string.Empty, linkToUserCss + "()");

				return TransformLift(projectInfo,
									 "plift2html.xsl",
									 ".htm",
									 arguments,
									 //word doesn't notice that is is html if the <xml> directive is in there
									 includeXmlDirective);
			}
		}