public HttpResponseMessage ExportVocabulary(VocabularySettingsModel model) { ImplementationGuide ig = this.tdb.ImplementationGuides.Single(y => y.Id == model.ImplementationGuideId); byte[] data = new byte[0]; string fileType = string.Empty; string contentType = string.Empty; VocabularyService service = new VocabularyService(this.tdb, ig.ImplementationGuideType.SchemaURI == "urn:hl7-org:v3"); switch (model.ExportFormat) { case VocabularySettingsModel.ExportFormatTypes.Standard: case VocabularySettingsModel.ExportFormatTypes.SVS: case VocabularySettingsModel.ExportFormatTypes.FHIR: fileType = "xml"; contentType = XML_MIME_TYPE; string vocXml = service.GetImplementationGuideVocabulary(model.ImplementationGuideId, model.MaximumMembers, (int)model.ExportFormat, model.Encoding); Encoding encoding = Encoding.GetEncoding(model.Encoding); data = encoding.GetBytes(vocXml); break; case VocabularySettingsModel.ExportFormatTypes.Excel: fileType = "xlsx"; contentType = XLSX_MIME_TYPE; data = service.GetImplementationGuideVocabularySpreadsheet(model.ImplementationGuideId, model.MaximumMembers); break; } string fileName = string.Format("{0}.{1}", ig.GetDisplayName(true), fileType); return(GetExportResponse(fileName, contentType, data)); }
public bool deleteUserById(int id) { vocabularyRepository = new VocabularyService(); vocabularyRepository.deleteAllVocabulariesByUserId(id); repository.deleteUserById(id); return(true); }
public void Init() { database = new Mock <IDocumentSession>(); database.Setup(x => x.Load <Vocabulary>("")).Returns <Vocabulary>(null); validator = new Mock <IVocabularyValidator>(); validator.Setup(x => x.Validate(It.IsAny <Vocabulary>())).Returns(new ValidationResult <Vocabulary>()); service = new VocabularyService(database.Object, validator.Object); }
public void TryingToLearnWord_WordShouldBeLearned() { //Arrange IUser user = new User(Guid.NewGuid(), "Bob", DateTimeOffset.Now); IVocabularyService vocabularyService = new VocabularyService(user); IWord word = new Word("Dog", "Собака"); user.vocabulary.UnlearnedWords.ToList().Add(word); //Act vocabularyService.TracingRightAnswer(word); //Assert Assert.IsTrue(user.vocabulary.LearnedWords.ToList().Count > 0); }
public string ExportImplementationGuide(int implementationGuideId, int maxMembers = 100, VocabularyOutputType format = VocabularyOutputType.Default, string encoding = "UTF-8") { VocabularyService service = new VocabularyService(this.tdb); return(service.GetImplementationGuideVocabulary(implementationGuideId, maxMembers, (int)format, encoding)); }
public string ExportValueSet(string valueSetOid, VocabularyOutputType format = VocabularyOutputType.Default, string encoding = "UTF-8") { VocabularyService service = new VocabularyService(this.tdb); return(service.GetValueSet(valueSetOid, (int)format, encoding)); }
private string GenerateExport() { string templateExport = TemplateExporter.GenerateXMLExport(this.tdb, this.templates, this.igSettings, true, this.categories); LantanaXmlResolver resolver = new LantanaXmlResolver(); string stylesheetContent = string.Empty; using (StreamReader stylesheetReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(StylesheetResource))) { stylesheetContent = stylesheetReader.ReadToEnd(); } var export = TransformFactory.Transform(templateExport, stylesheetContent, StylesheetUri, resolver); if (includeVocabulary) { // Export the vocabulary for the implementation guide in SVS format VocabularyService vocService = new VocabularyService(tdb, false); string vocXml = vocService.GetImplementationGuideVocabulary(igSettings.ImplementationGuideId, 1000, 4, "utf-8"); // Merge the two ATOM exports together XmlDocument exportDoc = new XmlDocument(); exportDoc.LoadXml(export); // Remove extra xmlns attributes from vocabulary xml System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Parse(vocXml); foreach (var descendant in doc.Root.Descendants()) { var namespaceDeclarations = descendant.Attributes().Where(y => y.IsNamespaceDeclaration && y.Name.LocalName == "atom"); foreach (var namespaceDeclaration in namespaceDeclarations) { namespaceDeclaration.Remove(); } } vocXml = doc.ToString(); XmlDocument vocDoc = new XmlDocument(); vocDoc.LoadXml(vocXml); XmlNamespaceManager vocNsManager = new XmlNamespaceManager(vocDoc.NameTable); vocNsManager.AddNamespace("atom", "http://www.w3.org/2005/Atom"); XmlNodeList vocEntryNodes = vocDoc.SelectNodes("/atom:feed/atom:entry", vocNsManager); foreach (XmlNode vocEntryNode in vocEntryNodes) { XmlNode clonedVocEntryNode = exportDoc.ImportNode(vocEntryNode, true); exportDoc.DocumentElement.AppendChild(clonedVocEntryNode); } // Format the XmlDocument and save it as a string using (StringWriter sw = new StringWriter()) { XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; exportDoc.WriteContentTo(xtw); export = sw.ToString(); } } return(export); }