Exemplo n.º 1
0
        public JsonResult GetNotebooks()
        {
            long?userid = GetUserIdBySession();

            Notebook[] noteBoooks = notebookService.GetNoteBookTree(userid);
            return(Json(noteBoooks, MyJsonConvert.GetLeanoteOptions()));
        }
Exemplo n.º 2
0
        public void GetNoteBookTreeTest()
        {
            Notebook[] notebooks = NotebookService.GetNoteBookTree(1208692382644703232);
            string     json      = JsonSerializer.Serialize(notebooks, MyJsonConvert.GetOptions());

            Console.WriteLine(json);
            // Assert.Fail();
        }
Exemplo n.º 3
0
        public IActionResult GetNotebooks()
        {
            long userid = 1208692382644703232;

            Notebook[] noteBoooks = NotebookService.GetNoteBookTree(userid);
            string     json       = JsonSerializer.Serialize(noteBoooks, MyJsonConvert.GetOptions());

            return(Content(json));
        }
Exemplo n.º 4
0
        public IActionResult Note()
        {
            ViewBag.msg = LanguageResource.GetMsg();
            Dictionary <string, string> js = new Dictionary <string, string>();
            long userid = 1208692382644703232;

            Notebook[] noteBoooks = NotebookService.GetNoteBookTree(userid);
            string     json       = JsonSerializer.Serialize(noteBoooks, MyJsonConvert.GetOptions());

            //json  = System.IO.File.ReadAllText(@"E:\Project\JSON\notebook\GetNotebooks.json");
            js.Add("notebooks", json);
            ViewBag.js = js;
            return(View());
        }
Exemplo n.º 5
0
        public IActionResult Editor(string noteIdHex)
        {
            this.SetLocale();                        //设置区域化信息
            //todo:存在一个问题,可能导出用户敏感信息
            var userInfo = this.GetUserAndBlogUrl(); //得到用户信息+博客主页
            //判断用户ID是否已经登录
            var user   = this.GetUserBySession();
            var userId = user.UserId;

            Notebook[] noteBoooks = notebookService.GetNoteBookTree(user.UserId);

            //是否已经开放注册功能
            ViewBag.openRegister = configFileService.WebConfig.SecurityConfig.OpenRegister;
            // 已登录了, 那么得到所有信息
            var notebooks = notebookService.GetNotebooks(userId);

            //获得共享的笔记

            // 还需要按时间排序(DESC)得到notes
            List <Note> notes       = new List <Note>();
            NoteContent noteContent = new NoteContent();

            if (!notebooks.IsNullOrNothing())
            {
                // noteId是否存在
                // 是否传入了正确的noteId
                var hasRightNoteId = false;

                long?noteId = noteIdHex.ToLongByHex();
                if (noteId != null)
                {
                    //说明ID本身是有效的
                    var note = noteService.GetNoteById(noteId);
                    if (note != null)
                    {
                        var noteOwner = note.UserId;
                        noteContent = noteContentService.GetNoteContent(noteId, noteOwner, false);

                        hasRightNoteId        = true;
                        ViewBag.curNoteId     = noteId.ToHex24();
                        ViewBag.curNotebookId = note.NotebookId.ToHex24();

                        // 打开的是共享的笔记, 那么判断是否是共享给我的默认笔记

                        if (noteOwner != GetUserIdBySession())
                        {
                            if (shareService.HasReadPerm(noteOwner, GetUserIdBySession(), noteId))
                            {
                                ViewBag.curSharedNoteNotebookId = note.NotebookId.ToHex24();
                                ViewBag.curSharedUserId         = noteOwner;
                            }
                            else
                            {
                                hasRightNoteId = false;
                            }
                        }
                        else
                        {
                            notes = noteService.ListNotes(this.GetUserIdBySession(), note.NotebookId, false, GetPage(), 50, defaultSortField, false, null);
                            // 如果指定了某笔记, 则该笔记放在首位
                        }
                    }
                    //获得最近的笔记
                    int count2      = 0;
                    var latestNotes = noteService.ListNotes(userId, false, GetPage(), 50, defaultSortField, false, null);
                    ViewBag.latestNotes = latestNotes;
                }
                // 没有传入笔记
                // 那么得到最新笔记
                if (!hasRightNoteId)
                {
                    notes = noteService.ListNotes(userId, false, GetPage(), 50, defaultSortField, false, null);
                    if (notes.Any())
                    {
                        noteContent       = noteContentService.GetValidNoteContent(notes[0].NoteId, userId);
                        ViewBag.curNoteId = notes[0].NoteId;
                    }
                }
            }

            ViewBag.isAdmin       = user.Username.Equals(config.SecurityConfig.AdminUsername);
            ViewBag.IsDevelopment = config.APPConfig.Dev;

            ViewBag.userInfo  = userInfo;
            ViewBag.notebooks = notebooks;
            //ViewBag.shareNotebooks= shareNotebooks;

            ViewBag.notes           = notes;
            ViewBag.noteContentJson = noteContent;
            ViewBag.noteContent     = noteContent == null ? null : noteContent.Content;

            ViewBag.tags   = tagService.GetTags(userId);
            ViewBag.config = config;

            Dictionary <string, string> js = new Dictionary <string, string>();

            SetLocale();
            ViewBag.js = js;

            //页面的值
            ViewBag.isAdmin = configFileService.WebConfig.SecurityConfig.AdminUsername.Equals(user.Username);

            ViewBag.userInfo = userInfo;

            ViewBag.OpenRegister = config.SecurityConfig.OpenRegister;
            //编辑器偏好
            ViewBag.MarkdownEditorOption = userInfo.MarkdownEditorOption;
            ViewBag.RichTextEditorOption = userInfo.RichTextEditorOption;
            return(View());
        }