Beispiel #1
0
 public Annotation(Guid annotationCode, AnnotationType annType, AnnotationStatusEnum annStatus, int bookId, int bookCurrentVersion, string docId, string guideCardName, string noteText, string highlightText, string tocTitle, List <Guid> categoryTagIDs, AnnotationDataItem startLevel, AnnotationDataItem endLevel)
 {
     this.BookId             = bookId;
     this.BookCurrentVersion = bookCurrentVersion;
     this.UpdatedTime        = DateTime.UtcNow;
     this.DocId          = docId;
     this.Type           = annType;
     this.Status         = annStatus;
     this.AnnotationCode = annotationCode;
     this.GuideCardName  = guideCardName;
     this.NoteText       = noteText;
     this.HighlightText  = highlightText;
     this.CategoryTagIDs = categoryTagIDs;
     this.StartLevel     = startLevel;
     this.EndLevel       = endLevel;
     this.TOCTitle       = tocTitle;
 }
Beispiel #2
0
        private static async Task MergeAnnotation(AnnotationTaskContext context, string strFileName, int bookID)
        {
            XDocument xDocument = null;

            using (var stream = await GlobalAccess.DirectoryService.OpenFile(strFileName, BusinessModel.FileModeEnum.Open))
            {
                xDocument = XDocument.Load(stream);
            }

            if (xDocument != null)
            {
                var annotationCode   = Guid.Parse(xDocument.Root.Attribute(Constants.SId).Value);
                var localAnnotations = context.AnnotationAccess.getAnnotation(annotationCode);
                if (localAnnotations != null)
                {
                    var annotation     = AnnotationFactory.CreateAnnotation(localAnnotations.AnnotationContent);
                    var localDateTime  = annotation.UpdatedTime;
                    var serverDateTime = DateTime.Parse(xDocument.Root.Attribute(XName.Get(Constants.SUpdatedOn)).Value);

                    var dateDiff = DateTime.Compare(localDateTime, serverDateTime);
                    if (dateDiff > 0) //local version is newer than the server version
                    {
                        return;
                    }
                    localAnnotations.AnnotationContent = xDocument.Root.ToString();
                    localAnnotations.IsSynced          = true;
                    localAnnotations.AnnotationType    = int.Parse(xDocument.Root.Attribute(Constants.SType).Value);
                    localAnnotations.LastSyncDate      = DateTime.Now;
                    var statusString = xDocument.Root.Attribute(Constants.Status).Value;
                    AnnotationStatusEnum annoStatus = (AnnotationStatusEnum)Enum.Parse(typeof(AnnotationStatusEnum), statusString[0].ToString().ToUpper() + statusString.Substring(1));

                    localAnnotations.Status     = (int)annoStatus;
                    localAnnotations.DocumentID = xDocument.Root.Attribute(Constants.DocId).Value;

                    context.AnnotationAccess.UpdateAnnotation(localAnnotations);
                }
                else
                {
                    Annotations annotations = new Annotations
                    {
                        Email            = context.AnnotationSyncTask.Email,
                        ServiceCode      = context.AnnotationSyncTask.ServiceCode,
                        AnnotationCode   = annotationCode,
                        BookID           = bookID,
                        IsSynced         = true,
                        CreatedDate      = DateTime.Now,
                        LastModifiedDate = DateTime.Now,
                        LastSyncDate     = DateTime.Now
                    };
                    annotations.DocumentID     = xDocument.Root.Attribute(Constants.DocId).Value;
                    annotations.AnnotationType = int.Parse(xDocument.Root.Attribute(Constants.SType).Value);

                    var statusString = xDocument.Root.Attribute(Constants.Status).Value;
                    AnnotationStatusEnum annoStatus = (AnnotationStatusEnum)Enum.Parse(typeof(AnnotationStatusEnum), statusString[0].ToString().ToUpper() + statusString.Substring(1));

                    annotations.Status            = (int)annoStatus;
                    annotations.AnnotationContent = xDocument.Root.ToString();
                    context.AnnotationAccess.AddAnnotation(annotations);
                }
            }
        }
 public int DeleteAnnotation(AnnotationStatusEnum status, DateTime lastModifiedDate, bool isSynced, Guid annoCode)
 {
     return(base.Execute(base.MainDbPath, deleteAnnotationStatusSql, (int)status, lastModifiedDate, isSynced, annoCode));
 }
 public int UpdateAnnotation(string documentID, AnnotationType annotationType, AnnotationStatusEnum status, string content, DateTime lastModifiedDate, bool isSynced, Guid annoCode)
 {
     return(base.Execute(base.MainDbPath, updateAnnotationSql, documentID, (int)annotationType, (int)status, content, lastModifiedDate, isSynced, annoCode));
 }