Exemple #1
0
 public static bool AddOrUpdateAnnotations(Repository.Annotation annotation)
 {
     lock (_AnnotationsSet)
     {
         try
         {
             using (var tran = _dbEngine.GetTransaction())
             {
                 tran.Insert <DateTime, DbCustomSerializer <Repository.Annotation> >(TableType.Annotation, annotation.DateTimeUTC, annotation);
                 tran.Commit();
             }
             if (_AnnotationsSet.ContainsKey(annotation.DateTimeUTC))
             {
                 _AnnotationsSet[annotation.DateTimeUTC] = annotation;
             }
             else
             {
                 _AnnotationsSet.Add(annotation.DateTimeUTC, annotation);
             }
         }
         catch (Exception ex)
         {
             return(false);
         }
         return(true);
     }
 }
Exemple #2
0
 public static bool DeleteAnnotation(Repository.Annotation annotation)
 {
     lock (_AnnotationsSet)
     {
         if (_AnnotationsSet.ContainsKey(annotation.DateTimeUTC) == false)
         {
             return(false);
         }
         try
         {
             using (var tran = _dbEngine.GetTransaction())
             {
                 tran.RemoveKey(TableType.Annotation, annotation.DateTimeUTC);
                 tran.Commit();
             }
             _AnnotationsSet.Remove(annotation.DateTimeUTC);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
     return(true);
 }