示例#1
0
 public int GetTotalNotesNum()
 {
     using (var dc = new MyDataContext())
     {
         return(!dc.DatabaseExists()
             ? 0
             : Enumerable.Sum(dc.NotebookTable, notebook => notebook.NotesNum));
     }
 }
示例#2
0
 public static void CreatetDatabaseIfNeeded()
 {
     using (var dc = new MyDataContext())
     {
         if (dc.DatabaseExists()) return;
         dc.CreateDatabase();
         Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库创建完成。");
     }
 }
示例#3
0
 public int GetTotalNotesNum()
 {
     using (var dc = new MyDataContext())
     {
         return !dc.DatabaseExists()
             ? 0
             : Enumerable.Sum(dc.NotebookTable, notebook => notebook.NotesNum);
     }
 }
示例#4
0
 public List <NotebookEntity> GetAllNotebook()
 {
     using (var dc = new MyDataContext())
     {
         return(!dc.DatabaseExists()
             ? new List <NotebookEntity>()
             : dc.NotebookTable.ToList());
     }
 }
示例#5
0
        public List<NotebookEntity> GetAllNotebook()
        {
            using (var dc = new MyDataContext())
            {
                return !dc.DatabaseExists()
                    ? new List<NotebookEntity>()
                    : dc.NotebookTable.ToList();

            }
        }
示例#6
0
 public static void DeleteDatabaseIfExists()
 {
     using (var dc = new MyDataContext())
     {
         if (dc.DatabaseExists())
         {
             dc.DeleteDatabase();
         }
         Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库已被删除。");
     }
 }
示例#7
0
 public static void DeleteDatabaseIfExists()
 {
     using (var dc = new MyDataContext())
     {
         if (dc.DatabaseExists())
         {
             dc.DeleteDatabase();
         }
         Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库已被删除。");
     }
 }
示例#8
0
 public static void CreatetDatabaseIfNeeded()
 {
     using (var dc = new MyDataContext())
     {
         if (dc.DatabaseExists())
         {
             return;
         }
         dc.CreateDatabase();
         Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库创建完成。");
     }
 }
示例#9
0
        /// <summary>
        /// 删除悬空图片(没有笔记引用的图片)。
        /// </summary>
        public static void DeleteNoRootImages()
        {
            using (var dc = new MyDataContext())
            {
                if (!dc.DatabaseExists()) return;

                foreach (var img in dc.ImageTable)
                {
                    if (NoteDao.Inst.NoteExist((img.BelongedNotePath))) continue;
                    DeleteIfExist(img.Id);
                    Debug.WriteLine("删除本地悬空图片:" + img.ImgLocalSavePath);
                }
            }
        }
示例#10
0
        /// <summary>
        /// 删除悬空图片(没有笔记引用的图片)。
        /// </summary>
        public static void DeleteNoRootImages()
        {
            using (var dc = new MyDataContext())
            {
                if (!dc.DatabaseExists())
                {
                    return;
                }

                foreach (var img in dc.ImageTable)
                {
                    if (NoteDao.Inst.NoteExist((img.BelongedNotePath)))
                    {
                        continue;
                    }
                    DeleteIfExist(img.Id);
                    Debug.WriteLine("删除本地悬空图片:" + img.ImgLocalSavePath);
                }
            }
        }