GetNoteContent(int id, int id2, int id3)
        {
            string authHeader = Request.Headers["authentication"];

            string[]     auths = authHeader.Split(',');
            IdentityUser me    = await _userManager
                                 .FindByIdAsync(auths[1]);

            UserData appMe = await _context.UserData.SingleAsync(p => p.UserId == me.Id);

            if (String.Compare(auths[2], appMe.MyGuid, StringComparison.Ordinal) != 0)
            {
                return(new NoteContent());
            }
            string     userID = auths[1];
            NoteAccess myAcc  = await AccessManager.GetAccess(_context, userID, id, 0);

            if (!myAcc.ReadAccess)
            {
                return(new NoteContent());
            }

            NoteContent result = await NoteDataManager
                                 .GetNoteContent(_context, id, 0, id2, id3);

            return(result);
        }
        public async Task Put(TextViewModel tvm)
        {
            if (tvm.MyNote == null)
            {
                return;
            }

            //UserData me = NoteDataManager.GetUserData(_userManager, User, _db);

            DateTime now = DateTime.Now.ToUniversalTime();

            tvm.NoteHeader.NoteSubject      = tvm.MySubject;
            tvm.NoteHeader.LastEdited       = now;
            tvm.NoteHeader.ThreadLastEdited = now;

            NoteContent nc = new NoteContent
            {
                NoteHeaderId    = tvm.NoteHeader.Id,
                NoteBody        = tvm.MyNote,
                DirectorMessage = tvm.DirectorMessage
            };

            await NoteDataManager.EditNote(_db, _userManager, tvm.NoteHeader, nc, tvm.TagLine);

            await ProcessLinkedNotes();

            return;
        }
Ejemplo n.º 3
0
        //todo:格式化URL

        //todo:得到内容
        public IActionResult GetNoteContent(string token, string noteId)
        {
            ApiRe falseRe = new ApiRe()
            {
                Ok  = false,
                Msg = "GetNoteContent_is_error"
            };
            Note        note        = NoteService.GetNote(MyConvert.HexToLong(noteId), getUserIdByToken(token));
            NoteContent noteContent = NoteContentService.GetNoteContent(MyConvert.HexToLong(noteId), getUserIdByToken(token), false);

            if (noteContent == null || note == null)
            {
                return(Json(falseRe, MyJsonConvert.GetOptions()));
            }
            if (noteContent != null && !string.IsNullOrEmpty(noteContent.Content))
            {
                noteContent.Content = NoteService.FixContent(noteContent.Content, note.IsMarkdown);
            }
            ApiNoteContent apiNote = new ApiNoteContent()
            {
                NoteId  = note.NoteId,
                UserId  = note.UserId,
                Content = noteContent.Content
            };

            return(Json(apiNote, MyJsonConvert.GetOptions()));
        }
        public static HtmlTag NoteTitleDiv(NoteContent dbEntry)
        {
            var titleContainer = new HtmlTag("div").AddClass("title-container");

            titleContainer.Children.Add(new HtmlTag("h1").AddClass("title-content").Text(dbEntry.Title));
            return(titleContainer);
        }
Ejemplo n.º 5
0
        public static async Task <(GenerationReturn generationReturn, NoteContent noteContent)> SaveAndGenerateHtml(
            NoteContent toSave, DateTime?generationVersion, IProgress <string> progress)
        {
            var validationReturn = await Validate(toSave);

            if (validationReturn.HasError)
            {
                return(validationReturn, null);
            }

            Db.DefaultPropertyCleanup(toSave);
            toSave.Tags = Db.TagListCleanup(toSave.Tags);

            await Db.SaveNoteContent(toSave);

            GenerateHtml(toSave, generationVersion, progress);
            await Export.WriteLocalDbJson(toSave, progress);

            DataNotifications.PublishDataNotification("Note Generator", DataNotificationContentType.Note,
                                                      DataNotificationUpdateType.LocalContent, new List <Guid> {
                toSave.ContentId
            });

            return(await GenerationReturn.Success($"Saved and Generated Content And Html for {toSave.Title}"), toSave);
        }
Ejemplo n.º 6
0
        public CreateNote(NoteFile myfile, long baseId, NoteHeader noteHeader, NoteContent noteContent, IEnumerable <Tags> noteTags, IRelistAble myParent)
        {
            InitializeComponent();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmReplace));
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

            currentFile = "";

            MyFile   = myfile;
            MybaseId = baseId;
            MyParent = myParent;

            MyHeader  = noteHeader;
            MyContent = noteContent;
            MyTags    = noteTags;

            if (MyHeader != null)
            {
                this.Text              = @"Edit Note";
                textBoxSubject.Text    = MyHeader.NoteSubject;
                textBoxDirMessage.Text = MyContent.DirectorMessage;
                // tags

                rtbDoc.Rtf = MarkupConverter.HtmlToRtfConverter.ConvertHtmlToRtf(MyContent.NoteBody);
            }
        }
Ejemplo n.º 7
0
 public void UpdateNoteContent(long?noteId, NoteContent noteContent)
 {
     dataContext.NoteContent.Where(b => b.NoteId == noteId && b.IsHistory == false).Update(x => new NoteContent()
     {
         IsHistory = true
     });
     AddNoteContent(noteContent);
 }
        public async Task <NoteContent> Get(string sid)
        {
            long id = long.Parse(sid);

            NoteContent c = _db.NoteContent.Single(p => p.NoteHeaderId == id);

            return(c);
        }
Ejemplo n.º 9
0
        public NoteContentEditorWindow(NoteContent toLoad)
        {
            InitializeComponent();
            StatusContext = new StatusControlContext();
            NoteContent   = new NoteContentEditorContext(StatusContext, toLoad);

            DataContext            = this;
            AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, NoteContent);
        }
Ejemplo n.º 10
0
        public static bool InsertNoteContent(NoteContent noteContent)
        {
            using (var db = new DataContext())
            {
                var result = db.NoteContent.Add(noteContent);

                return(db.SaveChanges() > 0);
            }
        }
Ejemplo n.º 11
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = NoteTime.GetHashCode();
         hashCode = (hashCode * 397) ^ (NoteContent != null ? NoteContent.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ChildCallNotes != null ? Utilities.GetHashCode(ChildCallNotes) : 0);
         return(hashCode);
     }
 }
Ejemplo n.º 12
0
 public static void CopyTo(this NoteContentEntity noteContentEntity, NoteContent targetNoteContent)
 {
     targetNoteContent.Id          = noteContentEntity.Id;
     targetNoteContent.NoteId      = noteContentEntity.NoteId;
     targetNoteContent.Type        = noteContentEntity.Type;
     targetNoteContent.Content     = noteContentEntity.Content;
     targetNoteContent.CreateTime  = noteContentEntity.CreateTime;
     targetNoteContent.IsDeleted   = noteContentEntity.IsDeleted;
     targetNoteContent.DeletedTime = noteContentEntity.DeletedTime;
 }
Ejemplo n.º 13
0
 // 添加笔记本内容
 // [ok]
 public static NoteContent AddNoteContent(NoteContent noteContent)
 {
     noteContent.CreatedTime   = Tools.FixUrlTime(noteContent.CreatedTime);
     noteContent.UpdatedTime   = Tools.FixUrlTime(noteContent.UpdatedTime);
     noteContent.UpdatedUserId = noteContent.UserId;
     InsertNoteContent(noteContent);
     // 更新笔记图片
     NoteImageService.UpdateNoteImages(noteContent.UserId, noteContent.NoteId, "", noteContent.Content);
     return(noteContent);
 }
Ejemplo n.º 14
0
        public SingleNoteDiv(NoteContent dbEntry)
        {
            DbEntry = dbEntry;

            var settings = UserSettingsSingleton.CurrentSettings();

            SiteUrl  = settings.SiteUrl;
            SiteName = settings.SiteName;
            PageUrl  = settings.NotePageUrl(DbEntry);
        }
Ejemplo n.º 15
0
        public void InsertNoteContentTest()
        {
            string      ContentJson = System.IO.File.ReadAllText(@"E:\Project\JSON\note\getNoteContent.json");
            NoteContent noteConteny = JsonSerializer.Deserialize <NoteContent>(ContentJson, MyJsonConvert.GetOptions());

            noteConteny.NoteId        = 201901;
            noteConteny.UpdatedUserId = SnowFlake_Net.GenerateSnowFlakeID();
            noteConteny.UserId        = SnowFlake_Net.GenerateSnowFlakeID();
            NoteContentService.InsertNoteContent(noteConteny);
        }
Ejemplo n.º 16
0
        public NoteContent AddNoteContent(NoteContent noteContent)
        {
            NoteContentEntity entity = noteContent.ToEntity();

            entity.CreateTime  = DateTime.Now;
            entity.DeletedTime = DateTime.Now;
            entity.IsDeleted   = false;
            this.dbContext.NoteContents.Add(entity);
            this.dbContext.SaveChanges();
            return(entity.ToModel());
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 获得笔记和内容
        /// </summary>
        /// <param name="noteId"></param>
        /// <param name="userId"></param>
        /// <param name="isTrach">是否垃圾</param>
        /// <param name="isDelete">是否删除</param>
        /// <param name="IsHistory">是否历史记录</param>
        /// <returns></returns>
        public static NoteAndContent GetNoteAndContent(long noteId, long userId, bool isTrach, bool isDelete, bool IsHistory)
        {
            Note        note        = GetNote(noteId, userId, isTrach, isDelete);
            NoteContent noteContent = NoteContentService.GetNoteContent(noteId, userId, IsHistory);

            return(new NoteAndContent()
            {
                note = note,
                noteContent = noteContent
            });
        }
Ejemplo n.º 18
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            NoteContent noteContent = Actions.GetNoteContent(Program.MyClient, MyFile.Id, baseOrdinal, currentResp);

            IEnumerable <Tags> myTags = Actions.GetTags(Program.MyClient, MyFile.Id, baseOrdinal, currentResp);

            new CreateNote(MyFile, Myheadlist[0].Id, Myheadlist[currentResp], noteContent, myTags, this)
            {
                Visible = true
            };
        }
Ejemplo n.º 19
0
        public async Task <DisplayModel> Get(string sid)
        {
            long id = long.Parse(sid);

            NoteContent c    = _db.NoteContent.Single(p => p.NoteHeaderId == id);
            List <Tags> tags = await _db.Tags.Where(p => p.NoteHeaderId == id).ToListAsync();

            return(new DisplayModel {
                content = c, tags = tags
            });
        }
Ejemplo n.º 20
0
 private void ResumeSession_Click(object sender, RoutedEventArgs e)
 {
     ResetSession();
     if (!_currentSession.ResumeSession())
     {
         return;
     }
     StateMove(Session.SessionStartingStage.Notes, true);
     _currentSession.UpdateNotes("Note", "Resuming Session...");
     NoteContent.Focus();
 }
Ejemplo n.º 21
0
        public static void GenerateHtml(NoteContent toGenerate, DateTime?generationVersion, IProgress <string> progress)
        {
            progress?.Report($"Note Content - Generate HTML for {toGenerate.Title}");

            var htmlContext = new SingleNotePage(toGenerate)
            {
                GenerationVersion = generationVersion
            };

            htmlContext.WriteLocalHtml();
        }
Ejemplo n.º 22
0
 private static string TypeToFilterTag(object content)
 {
     return(content switch
     {
         NoteContent _ => "post",
         PostContent _ => "post",
         ImageContent _ => "image",
         PhotoContent _ => "image",
         FileContent _ => "file",
         LinkStream _ => "link",
         _ => "other"
     });
Ejemplo n.º 23
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            NoteContent noteContent = Actions.GetNoteContent(Program.MyClient, MyFile.Id, baseOrdinal, currentResp);

            Actions.DeleteNote(Program.MyClient, noteContent.NoteHeaderId);

            Thread.Sleep(400);

            MyParentListNotes.Relist();

            Close();
        }
Ejemplo n.º 24
0
        public async Task <NoteContent> Get(string modelstring)
        {
            long noteid;

            noteid = long.Parse(modelstring);

            NoteContent nh = await _db.NoteContent
                             .Where(p => p.NoteHeaderId == noteid)
                             .FirstOrDefaultAsync();

            return(nh);
        }
Ejemplo n.º 25
0
        RTFNote rtf            = new RTFNote();     // The enhanced note window

        /** Starting Process **/
        /**********************/
        /// The application starts by asking for tester and charter information. Only then the session starts

        // Default constructor, everything is empty/default values
        public SMWidget()
        {
            Logger.record("[SMWidget]: App constructor. Initializing.", "SMWidget", "info");
            InitializeComponent();
            rtf.InitializeComponent();
            rtf.sm = this;
            NoteContent.Focus();

            parseCLI();
            handleCLI();
            Logger.record("[SMWidget]: App constructor initialized and CLI executed.", "SMWidget", "info");
        }
        public NoteContentEditorContext(StatusControlContext statusContext, NoteContent noteContent)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SaveAndCreateLocalCommand = new Command(() => StatusContext.RunBlockingTask(SaveAndCreateLocal));
            SaveUpdateDatabaseCommand = new Command(() => StatusContext.RunBlockingTask(SaveToDbWithValidation));
            ViewOnSiteCommand         = new Command(() => StatusContext.RunBlockingTask(ViewOnSite));
            ExtractNewLinksCommand    = new Command(() => StatusContext.RunBlockingTask(() =>
                                                                                        LinkExtraction.ExtractNewAndShowLinkStreamEditors(BodyContent.BodyContent,
                                                                                                                                          StatusContext.ProgressTracker())));

            StatusContext.RunFireAndForgetTaskWithUiToastErrorReturn(async() => await LoadData(noteContent));
        }
Ejemplo n.º 27
0
 public static NoteContentEntity ToEntity(this NoteContent model)
 {
     return(new NoteContentEntity()
     {
         Id = model.Id,
         NoteId = model.NoteId,
         Type = model.Type,
         Content = model.Content,
         CreateTime = model.CreateTime,
         IsDeleted = model.IsDeleted,
         DeletedTime = model.DeletedTime
     });
 }
        public static HtmlTag NoteTitleLinkDiv(NoteContent dbEntry)
        {
            var settings = UserSettingsSingleton.CurrentSettings();

            var titleContainer = new HtmlTag("div").AddClass("title-link-container");

            var header         = new HtmlTag("h2").AddClass("title-link-content");
            var linkToFullPost = new LinkTag(dbEntry.Title, settings.NotePageUrl(dbEntry));

            header.Children.Add(linkToFullPost);

            titleContainer.Children.Add(header);

            return(titleContainer);
        }
Ejemplo n.º 29
0
        internal string CreateTitle(string noteTiltle)
        {
            NoteTitle noteTitle = new NoteTitle();

            noteTitle.n_title     = noteTiltle;
            noteTitle.n_length    = 0;
            noteTitle.create_time = DateTime.Now.ToString();
            db.Insertable(noteTitle).ExecuteCommand();
            var         noteID      = db.Queryable <NoteTitle>().Max(nt => nt.id);
            NoteContent noteContent = new NoteContent();

            noteContent.n_title_id = noteID;
            db.Insertable(noteContent).ExecuteCommand();
            return(noteID.ToString());
        }
        public async Task <IActionResult> EditContent(NoteContent nc)
        {
            NoteContent edited = await _context.NoteContent.SingleAsync(p => p.NoteHeaderId == nc.NoteHeaderId);

            edited.NoteBody        = nc.NoteBody;
            edited.DirectorMessage = nc.DirectorMessage;

            await AccessManager.Audit(_context, "EditContent", User.Identity.Name,
                                      User.Identity.Name, "Edit Content NoteID " + edited.NoteHeaderId);

            _context.Entry(edited).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", new { id = await NoteDataManager.GetNoteById(_context, nc.NoteHeaderId) }));
        }