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; }
//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); }
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); }
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); } }
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); }
public NoteContentEditorWindow(NoteContent toLoad) { InitializeComponent(); StatusContext = new StatusControlContext(); NoteContent = new NoteContentEditorContext(StatusContext, toLoad); DataContext = this; AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, NoteContent); }
public static bool InsertNoteContent(NoteContent noteContent) { using (var db = new DataContext()) { var result = db.NoteContent.Add(noteContent); return(db.SaveChanges() > 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); } }
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; }
// 添加笔记本内容 // [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); }
public SingleNoteDiv(NoteContent dbEntry) { DbEntry = dbEntry; var settings = UserSettingsSingleton.CurrentSettings(); SiteUrl = settings.SiteUrl; SiteName = settings.SiteName; PageUrl = settings.NotePageUrl(DbEntry); }
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); }
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()); }
/// <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 }); }
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 }; }
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 }); }
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(); }
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(); }
private static string TypeToFilterTag(object content) { return(content switch { NoteContent _ => "post", PostContent _ => "post", ImageContent _ => "image", PhotoContent _ => "image", FileContent _ => "file", LinkStream _ => "link", _ => "other" });
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(); }
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); }
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)); }
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); }
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) })); }