public static Annotation CreateAnnotation(string xmlString, List <AnnotationTag> tags = null, List <DlBook> dlBooks = null) { Annotation resultAnnotation = null; var xDocument = XDocument.Parse(xmlString); XElement annotation = xDocument.Descendants(Constants.Annotation).First(); if (annotation != null) { var startLevel = annotation.Element(Constants.SAnnotationData).Elements().FirstOrDefault(o => o.Name == Constants.SmallStartLevel); var endLevel = annotation.Element(Constants.SAnnotationData).Elements().FirstOrDefault(o => o.Name == Constants.SmallEndLevel); AnnotationDataItem annotDataStart = GetAnnotationDataItem(startLevel, true); AnnotationDataItem annotDataEnd = GetAnnotationDataItem(endLevel, false); var BookId = int.Parse(annotation.Attribute(Constants.SyncSDlid).Value); var currentVersion = int.Parse(annotation.Attribute(Constants.SDlversionid).Value); var updatedOn = annotation.Attribute(Constants.SUpdatedOn).Value; var type = (AnnotationType)int.Parse(annotation.Attribute(Constants.SType).Value); var annotationCode = Guid.Parse(annotation.Attribute(Constants.SId).Value); var isUpdated = annotation.Element(Constants.SIsupdated).Value; var guideCardName = annotation.Element(Constants.SGuideCardName).Value; var noteText = annotation.Element(Constants.SNote).Value; var tocTitle = annotation.Element(Constants.SdlBookTitle).Value; var highlightText = annotation.Element(Constants.SHighlight).Value; var statusString = annotation.Attribute(Constants.Status).Value; AnnotationStatusEnum annoStatus; annoStatus = (AnnotationStatusEnum)Enum.Parse(typeof(AnnotationStatusEnum), statusString[0].ToString().ToUpper() + statusString.Substring(1)); XElement tagIDs = annotation.Element(Constants.CategoryTagIDs); var categoryTagIDs = new List <Guid>(); if (tagIDs != null && !string.IsNullOrEmpty(tagIDs.Value)) { categoryTagIDs = tagIDs.Value.Split(',').Select(id => Guid.Parse(id)).ToList(); } resultAnnotation = new Annotation(annotationCode, type, annoStatus, BookId, currentVersion, annotDataStart.DocId, guideCardName, noteText, highlightText, tocTitle, categoryTagIDs, annotDataStart, annotDataEnd); resultAnnotation.UpdatedTime = DateTime.Parse(updatedOn); if (dlBooks != null) { //var dlBook = dlBooks.FirstOrDefault(o => o.BookId == BookId); //resultAnnotation.BookTitle = dlBook != null ? dlBook.Name : string.Empty; } resultAnnotation.CategoryTags = new List <AnnotationTag>(); if (tags != null) { foreach (var tagId in categoryTagIDs) { var tag = tags.FirstOrDefault(o => o.TagId == tagId); if (tag != null) { resultAnnotation.CategoryTags.Add(tag); } } } } return(resultAnnotation); }
private Annotation InitAnnotationWithNoTag() { AnnotationDataItem startLevel = new AnnotationDataItem(1, "latup10001000.xml", "CE_LATUP.SGM_CE.LATUP.S177", "/div/div[3]/div[3]/section[1]/ul[1]/li/span[3]/span", "CE_LATUP.SGM_CE.LATUP.C1"); AnnotationDataItem endLevel = new AnnotationDataItem(2, "latup10001000.xml", "CE_LATUP.SGM_CE.LATUP.S177", "/div/div[3]/div[3]/section[1]/ul[1]/li/span[4]", "CE_LATUP.SGM_CE.LATUP.C1"); List <Guid> TagIds = new List <Guid>(); Annotation annotation = new Annotation(Guid.NewGuid(), AnnotationType.Highlight, AnnotationStatusEnum.Created, bookid, 19, startLevel.DocId, "Introduction to the 2001 National Corporations Legislation", "fdffffffffffffffffffffffffffff", "highlight Text", "Historical background: Introduction to the 2001 National Corporations Legislation", TagIds, startLevel, endLevel); return(annotation); }
private void AddAnnotation() { int offset = 0; string fileName = string.Empty; string levelId = string.Empty; string xpath = string.Empty; string spanId = string.Empty; AnnotationDataItem item = new AnnotationDataItem(offset, fileName, levelId, xpath, spanId); }
private static AnnotationDataItem GetAnnotationDataItem(XElement xelement, bool isStartLevel = true) { var xpath = xelement.Attribute(Constants.SmallXPath).Value; var levelId = xelement.Attribute(Constants.SmallLevelId).Value; var offset = String.IsNullOrEmpty(xelement.Attribute(Constants.SOffset).Value.Trim()) ? -1 : Convert.ToInt32(xelement.Attribute(Constants.SOffset).Value, CultureInfo.CurrentCulture); var docId = xelement.Attribute(isStartLevel ? Constants.StartDocId : Constants.EndDocId).Value; var filename = xelement.Attribute(Constants.SId) != null?xelement.Attribute(Constants.SId).Value : null; AnnotationDataItem anotDataStart = new AnnotationDataItem(offset, filename, levelId, xpath, docId); return(anotDataStart); }
private Annotation InitAnnotation() { AnnotationDataItem startLevel = new AnnotationDataItem(1, "latup10001000.xml", "CE_LATUP.SGM_CE.LATUP.S177", "/div/div[3]/div[3]/section[1]/ul[1]/li/span[3]/span", "CE_LATUP.SGM_CE.LATUP.C1"); AnnotationDataItem endLevel = new AnnotationDataItem(2, "latup10001000.xml", "CE_LATUP.SGM_CE.LATUP.S177", "/div/div[3]/div[3]/section[1]/ul[1]/li/span[4]", "CE_LATUP.SGM_CE.LATUP.C1"); List <Guid> TagIds = new List <Guid>(); TagIds.Add(Guid.Parse("c731fa5f-1db3-4142-9541-45dbbd6cccba")); Annotation annotation = new Annotation(Guid.NewGuid(), AnnotationType.Highlight, AnnotationStatusEnum.Created, bookid, 19, startLevel.DocId, "Introduction to the 2001 National Corporations Legislation", null, null, "Historical background: Introduction to the 2001 National Corporations Legislation", TagIds, startLevel, endLevel); return(annotation); }
private async void doneButttonCLick(object o, EventArgs e) { string textViewStr = AppDisplayUtil.Instance.newAnnotationVC.TextView.Text; var bookId = AppDataUtil.Instance.GetCurrentPublication().BookId; var bookVersionId = AppDataUtil.Instance.GetCurrentPublication().CurrentVersion; var tocTitle = AppDataUtil.Instance.GetHighlightedTOCNode().Title; var guidCardName = AppDataUtil.Instance.GetHighlightedTOCNode().GuideCardTitle; // string highlightStr = EvaluateJavascript("window.getSelection().toString();"); AnnotationDataItem startDataItem = new AnnotationDataItem(130, "fileNmae", "levelId", "xPath", "docId"); AnnotationDataItem endDataItem = new AnnotationDataItem(130, "fileNmae", "levelId", "xPath", "docId"); await AnnotationUtil.Instance.AddAnnotation(new Annotation(Guid.NewGuid(), AnnotationType.StickyNote, AnnotationStatusEnum.Created, bookId, bookVersionId, "docId", guidCardName, textViewStr, "hightTextLabel selectedTextContent test textViewText Hi,Work", tocTitle, getGuidList, startDataItem, endDataItem)); AppDisplayUtil.Instance.DismissPopoverView(); }