예제 #1
0
        protected async Task ContinueSeq()  // continue sequencing - tracking new notes
        {
            // first check for responses
            NoteHeader x = Model.AllNotes.Where(p => p.NoteOrdinal == currentHeader.NoteOrdinal &&
                                                p.ResponseOrdinal > currentHeader.ResponseOrdinal &&
                                                p.LastEdited > trackers[seqIndx].LastTime)
                           .OrderBy(p => p.ResponseOrdinal).FirstOrDefault();

            if (x != null) // found a response
            {
                currentHeader = x;
                await SetNote();

                return;
            }
            // else goto next base
            seqBaseIndx++;
            if (seqBaseIndx >= SeqBases.Count)  // finished with this file
            {
                await OnClick.InvokeAsync("SeqFileDone");

                return;
            }
            currentHeader = SeqBases[seqBaseIndx];
            await SetNote();
        }
예제 #2
0
        public static async Task <string> DeleteLinked(ApplicationDbContext db, NoteHeader nh)
        {
            // Check for linked notefile(s)

            List <LinkedFile> links = await db.LinkedFile.Where(p => p.HomeFileId == nh.NoteFileId).ToListAsync();

            if (links == null || links.Count < 1)
            {
            }
            else
            {
                foreach (var link in links)
                {
                    if (link.SendTo)
                    {
                        LinkQueue q = new LinkQueue
                        {
                            Activity     = LinkAction.Delete,
                            LinkGuid     = nh.LinkGuid,
                            LinkedFileId = nh.NoteFileId,
                            BaseUri      = link.RemoteBaseUri
                        };

                        db.LinkQueue.Add(q);
                        await db.SaveChangesAsync();
                    }
                }
            }

            return("Ok");
        }
        private async Task SendNewNoteToSubscribers(NoteHeader myNote)
        {
            List <Subscription> subs = await _db.Subscription
                                       .Where(p => p.NoteFileId == myNote.NoteFileId)
                                       .ToListAsync();

            if (subs == null || subs.Count == 0)
            {
                return;
            }

            ForwardViewModel fv = new ForwardViewModel();

            fv.NoteID = myNote.Id;

            string myEmail = await LocalService.MakeNoteForEmail(fv, _db, Globals.PrimeAdminEmail, Globals.PrimeAdminName);

            EmailSender emailSender = new EmailSender();

            foreach (Subscription s in subs)
            {
                IdentityUser usr = await _userManager.FindByIdAsync(s.SubscriberId);

                await emailSender.SendEmailAsync(usr.UserName, myNote.NoteSubject, myEmail);
            }
        }
예제 #4
0
        /// <summary>
        /// Given the currentHeader, set up to display or print a note
        /// </summary>
        protected async Task SetNote()
        {
            // get NoteContent entity and list of tags
            DisplayModel dm = await Http.GetJsonAsync <DisplayModel>("api/NoteContent/" + currentHeader.Id);

            currentContent = dm.content;
            tags           = dm.tags;

            // store stuff to display re responses
            respX = "";
            if (currentHeader.ResponseOrdinal > 0)
            {
                NoteHeader bnh = Model.Notes.Find(p => p.Id == currentHeader.BaseNoteId);
                respX = " - Response " + currentHeader.ResponseOrdinal + " of " + bnh.ResponseCount;
            }
            else if (currentHeader.ResponseCount > 0)
            {
                respX = " - " + currentHeader.ResponseCount + " Responses ";
            }

            // set nav box info
            curN = "" + currentHeader.NoteOrdinal;
            if (currentHeader.ResponseOrdinal > 0)
            {
                curN += "." + currentHeader.ResponseOrdinal;
            }

            // stuff currentHeader into the Model for tracking
            Model.myHeader = currentHeader;
            this.StateHasChanged();     // tell blazor things have changed
        }
예제 #5
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);
            }
        }
예제 #6
0
        /// <summary>
        /// Given a NoteContent Object and Response number get the response NoteID
        /// </summary>
        /// <param name="db"></param>
        /// <param name="nc"></param>
        /// <param name="resp"></param>
        /// <returns></returns>
        public static async Task <long?> FindResponseId(ApplicationDbContext db, NoteHeader nc, int resp)
        {
            NoteHeader content = await db.NoteHeader
                                 .Where(p => p.NoteFileId == nc.NoteFileId && p.ArchiveId == nc.ArchiveId && p.NoteOrdinal == nc.NoteOrdinal && p.ResponseOrdinal == resp)
                                 .FirstOrDefaultAsync();

            return(content?.Id);
        }
        public async Task <NoteHeader> Get(string noteId)
        {
            long Id = long.Parse(noteId);

            NoteHeader header = await _db.NoteHeader.Where(p => p.Id == Id).FirstOrDefaultAsync();

            return(header);
        }
예제 #8
0
        private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            NoteHeader myHeader = (NoteHeader)dataGridView1.Rows[e.RowIndex].DataBoundItem;

            new DisplayNote(MyFile, myHeader.NoteOrdinal, this)
            {
                Visible = true
            };
        }
예제 #9
0
        public static async Task <NoteHeader> GetBaseNoteHeader(ApplicationDbContext db, long id)
        {
            NoteHeader nh = await db.NoteHeader
                            .Where(p => p.Id == id)
                            .FirstOrDefaultAsync();

            return(await db.NoteHeader
                   .Where(p => p.Id == nh.BaseNoteId)
                   .FirstOrDefaultAsync());
        }
        public async Task <NoteHeader> Create(Notes2021.Models.TextViewModel inputModel)
        {
            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(null);
            }
            string     userID = auths[1];
            NoteAccess myAcc  = await AccessManager.
                                GetAccess(_context, userID, inputModel.NoteFileID, 0);

            if (!myAcc.Write)
            {
                return(null);
            }

            await _signInManager.SignInAsync(me, false);

            DateTime now = DateTime.Now.ToUniversalTime();

            NoteHeader nheader = new NoteHeader()
            {
                LastEdited       = now,
                ThreadLastEdited = now,
                CreateDate       = now,
                NoteFileId       = inputModel.NoteFileID,
                AuthorName       = appMe.DisplayName,
                AuthorID         = _userManager.GetUserId(User),
                NoteSubject      = inputModel.MySubject,
                ResponseOrdinal  = 0,
                ResponseCount    = 0
            };

            if (inputModel.BaseNoteHeaderID == 0)
            {
                return(await NoteDataManager
                       .CreateNote(_context, _userManager, nheader,
                                   inputModel.MyNote.Replace("\n", "<br />"),
                                   inputModel.TagLine,
                                   inputModel.DirectorMessage, true, false));
            }
            NoteHeader bnh = await NoteDataManager.GetNoteHeader(_context, inputModel.BaseNoteHeaderID);

            nheader.BaseNoteId = bnh.Id;
            return(await NoteDataManager.CreateResponse(_context, _userManager,
                                                        nheader, inputModel.MyNote, inputModel.TagLine,
                                                        inputModel.DirectorMessage, true, false));
        }
예제 #11
0
 /// <summary>
 /// Delete a Note
 /// </summary>
 /// <param name="db">ApplicationDbContext</param>
 /// <param name="nc">NoteContent</param>
 /// <returns></returns>
 public static async Task <bool> DeleteNote(ApplicationDbContext db, NoteHeader nc)
 {
     if (nc.ResponseOrdinal == 0)     // base note
     {
         return(await DeleteBaseNote(db, nc));
     }
     else  // Response
     {
         return(await DeleteResponse(db, nc));
     }
 }
예제 #12
0
        protected async Task NextBaseNote()
        {
            NoteHeader newbase = Model.Notes.Find(p => p.NoteOrdinal == currentHeader.NoteOrdinal + 1 && p.ResponseOrdinal == 0);

            if (newbase == null)
            {
                return;
            }
            currentHeader = newbase;
            await SetNote();
        }
예제 #13
0
        public static async Task <string> MakeNoteForEmail(ForwardViewModel fv, NotesDbContext db, string email, string name)
        {
            NoteHeader nc = await NoteDataManager.GetNoteByIdWithFile(db, fv.NoteID);

            if (!fv.hasstring || !fv.wholestring)
            {
                return("Forwarded by Notes 2021 - User: "******" / " + name
                       + "<p>File: " + nc.NoteFile.NoteFileName + " - File Title: " + nc.NoteFile.NoteFileTitle + "</p><hr/>"
                       + "<p>Author: " + nc.AuthorName + "  - Director Message: " + nc.NoteContent.DirectorMessage + "</p><p>"
                       + "<p>Subject: " + nc.NoteSubject + "</p>"
                       + nc.LastEdited.ToShortDateString() + " " + nc.LastEdited.ToShortTimeString() + " UTC" + "</p>"
                       + nc.NoteContent.NoteBody
                       + "<hr/>" + "<a href=\"" + Globals.ProductionUrl + "?show=" + fv.NoteID + "\" >Link to note</a>");
            }
            else
            {
                List <NoteHeader> bnhl = await db.NoteHeader
                                         .Where(p => p.NoteFileId == nc.NoteFileId && p.NoteOrdinal == nc.NoteOrdinal && p.ResponseOrdinal == 0)
                                         .ToListAsync();

                NoteHeader bnh = bnhl[0];
                fv.NoteSubject = bnh.NoteSubject;
                List <NoteHeader> notes = await db.NoteHeader.Include("NoteContent")
                                          .Where(p => p.NoteFileId == nc.NoteFileId && p.NoteOrdinal == nc.NoteOrdinal)
                                          .ToListAsync();

                StringBuilder sb = new StringBuilder();
                sb.Append("Forwarded by Notes 2020 - User: "******" / " + name
                          + "<p>\nFile: " + nc.NoteFile.NoteFileName + " - File Title: " + nc.NoteFile.NoteFileTitle + "</p>"
                          + "<hr/>");

                for (int i = 0; i < notes.Count; i++)
                {
                    if (i == 0)
                    {
                        sb.Append("<p>Base Note - " + (notes.Count - 1) + " Response(s)</p>");
                    }
                    else
                    {
                        sb.Append("<hr/><p>Response - " + notes[i].ResponseOrdinal + " of " + (notes.Count - 1) + "</p>");
                    }
                    sb.Append("<p>Author: " + notes[i].AuthorName + "  - Director Message: " + notes[i].NoteContent.DirectorMessage + "</p>");
                    sb.Append("<p>Subject: " + notes[i].NoteSubject + "</p>");
                    sb.Append("<p>" + notes[i].LastEdited.ToShortDateString() + " " + notes[i].LastEdited.ToShortTimeString() + " UTC" + " </p>");
                    sb.Append(notes[i].NoteContent.NoteBody);
                    sb.Append("<hr/>");
                    sb.Append("<a href=\"");
                    sb.Append(Globals.ProductionUrl + "show=" + notes[i].Id + "\" >Link to note</a>");
                }

                return(sb.ToString());
            }
        }
예제 #14
0
        /// <summary>
        /// Get next available BaseNoteOrdinal
        /// </summary>
        /// <param name="db">ApplicationDbContext</param>
        /// <param name="noteFileId">NoteFileID</param>
        /// <returns></returns>
        public static async Task <int> NextBaseNoteOrdinal(ApplicationDbContext db, int noteFileId, int arcId)
        {
            IOrderedQueryable <NoteHeader> bnhq = GetBaseNoteHeaderByIdRev(db, noteFileId, arcId);

            if (bnhq == null || !bnhq.Any())
            {
                return(1);
            }

            NoteHeader bnh = await bnhq.FirstAsync();

            return(bnh.NoteOrdinal + 1);
        }
예제 #15
0
        public async Task Post(ForwardViewModel fv)
        {
            NoteHeader nh = await NoteDataManager.GetBaseNoteHeaderById(_db, fv.NoteID);

            IdentityUser usr = await _userManager.FindByNameAsync(User.Identity.Name);

            UserData ud = await _db.UserData.SingleOrDefaultAsync(p => p.UserId == usr.Id);

            string myEmail = await LocalService.MakeNoteForEmail(fv, _db, User.Identity.Name, ud.DisplayName);

            EmailSender emailSender = new EmailSender();

            await emailSender.SendEmailAsync(usr.UserName, fv.NoteSubject, myEmail);
        }
예제 #16
0
        public async Task <string> CreateLinkNote(LinkCreateModel inputModel)
        {
            NoteFile file = await _context.NoteFile
                            .SingleAsync(p => p.NoteFileName == inputModel.linkedfile);

            if (file == null)
            {
                return("Target file does not exist");
            }

            // check for acceptance

            if (!await AccessManager.TestLinkAccess(_context, file, ""))
            {
                return("Access Denied");
            }

            inputModel.header.NoteFileId      = file.Id;
            inputModel.header.ArchiveId       = 0;
            inputModel.header.BaseNoteId      = 0;
            inputModel.header.Id              = 0;
            inputModel.header.NoteContent     = null;
            inputModel.header.NoteFile        = null;
            inputModel.header.NoteOrdinal     = 0;
            inputModel.header.ResponseOrdinal = 0;
            inputModel.header.ResponseCount   = 0;

            var tags = Tags.ListToString(inputModel.tags);

            NoteHeader nh = await NoteDataManager.CreateNote(_context, null, inputModel.header,
                                                             inputModel.content.NoteBody, tags, inputModel.content.DirectorMessage, true, true);

            if (nh == null)
            {
                return("Remote note create failed");
            }

            LinkLog ll = new LinkLog()
            {
                Event     = "Ok",
                EventTime = DateTime.UtcNow,
                EventType = "RcvdCreateBaseNote"
            };

            _context.LinkLog.Add(ll);
            await _context.SaveChangesAsync();

            return("Ok");
        }
예제 #17
0
        private static async Task <string> MakeNoteForEmail(ForwardViewModel fv, ApplicationDbContext db, string email, string name, string ProductionUrl)
        {
            NoteHeader nc = await GetNoteByIdWithFile(db, fv.NoteID);

            if (!fv.hasstring || !fv.wholestring)
            {
                return("Forwarded by Notes 2021 - User: "******" / " + name
                       + "<p>File: " + nc.NoteFile.NoteFileName + " - File Title: " + nc.NoteFile.NoteFileTitle + "</p><hr/>"
                       + "<p>Author: " + nc.AuthorName + "  - Director Message: " + nc.NoteContent.DirectorMessage + "</p><p>"
                       + "<p>Subject: " + nc.NoteSubject + "</p>"
                       + nc.LastEdited.ToShortDateString() + " " + nc.LastEdited.ToShortTimeString() + " UTC" + "</p>"
                       + nc.NoteContent.NoteBody
                       + "<hr/>" + "<a href=\"" + ProductionUrl + "NoteDisplay/Display/" + fv.NoteID + "\" >Link to note</a>");
            }
            else
            {
                List <NoteHeader> bnhl = await GetBaseNoteHeadersForNote(db, nc.NoteFileId, nc.ArchiveId, nc.NoteOrdinal);

                NoteHeader bnh = bnhl[0];
                fv.NoteSubject = bnh.NoteSubject;
                List <NoteHeader> notes = await GetBaseNoteAndResponses(db, nc.NoteFileId, nc.ArchiveId, nc.NoteOrdinal);

                StringBuilder sb = new StringBuilder();
                sb.Append("Forwarded by Notes 2020 - User: "******" / " + name
                          + "<p>\nFile: " + nc.NoteFile.NoteFileName + " - File Title: " + nc.NoteFile.NoteFileTitle + "</p>"
                          + "<hr/>");

                for (int i = 0; i < notes.Count; i++)
                {
                    if (i == 0)
                    {
                        sb.Append("<p>Base Note - " + (notes.Count - 1) + " Response(s)</p>");
                    }
                    else
                    {
                        sb.Append("<hr/><p>Response - " + notes[i].ResponseOrdinal + " of " + (notes.Count - 1) + "</p>");
                    }
                    sb.Append("<p>Author: " + notes[i].AuthorName + "  - Director Message: " + notes[i].NoteContent.DirectorMessage + "</p>");
                    sb.Append("<p>Subject: " + notes[i].NoteSubject + "</p>");
                    sb.Append("<p>" + notes[i].LastEdited.ToShortDateString() + " " + notes[i].LastEdited.ToShortTimeString() + " UTC" + " </p>");
                    sb.Append(notes[i].NoteContent.NoteBody);
                    sb.Append("<hr/>");
                    sb.Append("<a href=\"");
                    sb.Append(ProductionUrl + "NoteDisplay/Display/" + notes[i].Id + "\" >Link to note</a>");
                }

                return(sb.ToString());
            }
        }
예제 #18
0
        protected void Copy(NoteHeader Note)
        {
            if (!Model.myAccess.ReadAccess)
            {
                return;
            }

            StopTimer();
            var parameters = new ModalParameters();

            parameters.Add("Note", Note);
            parameters.Add("UserData", Model.UserData);
            Modal.OnClose += HideDialog;
            Modal.Show <Copy>("", parameters);
        }
예제 #19
0
        public async Task <List <NoteHeader> > Get(string sid)
        {
            int fileid             = int.Parse(sid);
            List <NoteHeader> list = new List <NoteHeader>();

            NoteFile noteFile = _db.NoteFile.SingleOrDefault(p => p.Id == fileid);

            for (int i = 0; i <= noteFile.NumberArchives; i++)
            {
                NoteHeader header = _db.NoteHeader.Where(p => p.ArchiveId == i).OrderBy(p => p.CreateDate).FirstOrDefault();
                list.Add(header);
            }

            return(list);
        }
        public async Task Delete(string fileId)
        {
            long noteId = long.Parse(fileId);

            NoteHeader nh = _db.NoteHeader.SingleOrDefault(p => p.Id == noteId);

            if (nh == null)
            {
                return;
            }

            await NoteDataManager.DeleteNote(_db, nh);

            await ProcessLinkedNotes();
        }
예제 #21
0
        private string MakeHeader(NoteHeader header)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<div class=\"copiednote\">From: ");
            sb.Append(noteFile.NoteFileName);
            sb.Append(" - ");
            sb.Append(header.NoteSubject);
            sb.Append(" - ");
            sb.Append(header.AuthorName);
            sb.Append(" - ");
            sb.Append(header.CreateDate.ToShortDateString());
            sb.AppendLine("</div>");
            return(sb.ToString());
        }
예제 #22
0
        public async Task <string> EditLinkResponse(LinkCreateEModel inputModel)
        {
            NoteFile file = _context.NoteFile.SingleOrDefault(p => p.NoteFileName == inputModel.linkedfile);

            if (file == null)
            {
                return("Target file does not exist");
            }

            // check for acceptance

            if (!await AccessManager.TestLinkAccess(_context, file, inputModel.Secret))
            {
                return("Access Denied");
            }

            // find local base note for this and modify header

            NoteHeader extant = _context.NoteHeader.SingleOrDefault(p => p.LinkGuid == inputModel.myGuid);

            if (extant == null) // || extant.NoteFileId != file.Id)
            {
                return("Could not find note");
            }

            inputModel.header.NoteOrdinal = extant.NoteOrdinal;
            inputModel.header.ArchiveId   = extant.ArchiveId;

            inputModel.header.NoteFileId = file.Id;

            inputModel.header.BaseNoteId = extant.BaseNoteId;
            inputModel.header.Id         = extant.Id;
            //inputModel.header.NoteContent = null;
            //inputModel.header.NoteFile = null;
            inputModel.header.ResponseOrdinal = extant.ResponseOrdinal;
            inputModel.header.ResponseCount   = extant.ResponseCount;


            NoteHeader nh = await NoteDataManager.EditNote(_context, null, inputModel.header,
                                                           inputModel.content, inputModel.tags);

            if (nh == null)
            {
                return("Remote response edit failed");
            }

            return("Ok");
        }
예제 #23
0
        /// <summary>
        /// Delete a Response Note
        /// </summary>
        /// <param name="db">ApplicationDbContext</param>
        /// <param name="nc">NoteContent</param>
        /// <returns></returns>
        // Steps involved:
        // 1. Delete single NoteContent row where NoteFileID, NoteOrdinal, and ResponseOrdinal match input
        // 2. Decrement all NoteContent.ResponseOrdinal where NoteFileID, and NoteOrdinal match input and NoteContent.ResponseOrdinal > nc.ResponseOrdinal
        // 3. Decrement single row (Responses field)in BaseNoteHeader where NoteFileID, NoteOrdinal match input
        private static async Task <bool> DeleteResponse(ApplicationDbContext db, NoteHeader nc)
        {
            int fileId  = nc.NoteFileId;
            int arcId   = nc.ArchiveId;
            int noteOrd = nc.NoteOrdinal;
            int respOrd = nc.ResponseOrdinal;

            try
            {
                List <NoteHeader> deleteCont = await db.NoteHeader
                                               .Where(p => p.NoteFileId == fileId && p.ArchiveId == arcId && p.NoteOrdinal == noteOrd && p.ResponseOrdinal == nc.ResponseOrdinal)
                                               .ToListAsync();

                if (deleteCont.Count != 1)
                {
                    return(false);
                }

                await DeleteLinked(db, deleteCont.First());

                db.NoteHeader.Remove(deleteCont.First());

                List <NoteHeader> upCont = await db.NoteHeader
                                           .Where(p => p.NoteFileId == fileId && p.ArchiveId == arcId && p.NoteOrdinal == noteOrd && p.ResponseOrdinal > respOrd)
                                           .ToListAsync();

                foreach (var cont in upCont)
                {
                    cont.ResponseOrdinal--;
                    db.Entry(cont).State = EntityState.Modified;
                }

                NoteHeader bnh = await GetBaseNoteHeader(db, fileId, arcId, noteOrd);

                bnh.ResponseCount--;
                db.Entry(bnh).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(true);
            }
            catch
            {
                // ignored
            }

            return(false);
        }
예제 #24
0
        public async Task <string> CreateLinkResponse(LinkCreateRModel inputModel)
        {
            NoteFile file = _context.NoteFile.SingleOrDefault(p => p.NoteFileName == inputModel.linkedfile);

            if (file == null)
            {
                return("Target file does not exist");
            }

            // check for acceptance

            if (!await AccessManager.TestLinkAccess(_context, file, inputModel.Secret))
            {
                return("Access Denied");
            }

            // find local base note for this and modify header

            NoteHeader extant = _context.NoteHeader.SingleOrDefault(p => p.LinkGuid == inputModel.baseGuid);

            if (extant == null) // || extant.NoteFileId != file.Id)
            {
                return("Could not find base note");
            }

            inputModel.header.NoteOrdinal = extant.NoteOrdinal;

            inputModel.header.NoteFileId = file.Id;

            inputModel.header.BaseNoteId  = extant.BaseNoteId;
            inputModel.header.Id          = 0;
            inputModel.header.NoteContent = null;
            inputModel.header.NoteFile    = null;
            //inputModel.header.ResponseOrdinal = 0;
            //inputModel.header.ResponseCount = 0;

            var tags = Tags.ListToString(inputModel.tags);

            NoteHeader nh = await NoteDataManager.CreateResponse(_context, null, inputModel.header,
                                                                 inputModel.content.NoteBody, tags, inputModel.content.DirectorMessage, true, true);

            if (nh == null)
            {
                return("Remote response create failed");
            }

            return("Ok");
        }
        public void Header_SimpleInput()
        {
            var s      = @"[1,1/4,3]";
            var header = NoteHeader.FromString(s);

            var std = new NoteHeader {
                Measure     = 1,
                Nominator   = 1,
                Denominator = 4,
                Start       = 3,
                End         = 3,
                Speed       = 1
            };

            Assert.AreEqual(std, header);
        }
        public void Header_SpecifyStartEndSpeed()
        {
            var s      = @"[1,1/4,3,4,10]";
            var header = NoteHeader.FromString(s);

            var std = new NoteHeader {
                Measure     = 1,
                Nominator   = 1,
                Denominator = 4,
                Start       = 3,
                End         = 4,
                Speed       = 10
            };

            Assert.AreEqual(std, header);
        }
        public void Header_DotSpeed3()
        {
            var s      = @"[1,1/4,3,4,2.]";
            var header = NoteHeader.FromString(s);

            var std = new NoteHeader {
                Measure     = 1,
                Nominator   = 1,
                Denominator = 4,
                Start       = 3,
                End         = 4,
                Speed       = 2
            };

            Assert.AreEqual(std, header);
        }
예제 #28
0
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }
            var dataGridViewRow = ((DataGridView)(sender)).CurrentRow;

            if (dataGridViewRow != null)
            {
                NoteHeader myHeader = (NoteHeader)dataGridViewRow.DataBoundItem;
                new DisplayNote(MyFile, myHeader.NoteOrdinal, this)
                {
                    Visible = true
                };
            }
        }
예제 #29
0
        public static async Task <NoteHeader> CreateResponse(ApplicationDbContext db, UserManager <IdentityUser> userManager, NoteHeader nh, string body, string tags, string dMessage, bool send, bool linked)
        {
            NoteHeader mine = await GetBaseNoteHeader(db, nh.BaseNoteId);

            db.Entry(mine).State = EntityState.Unchanged;
            await db.SaveChangesAsync();

            mine.ThreadLastEdited = DateTime.Now.ToUniversalTime();
            mine.ResponseCount++;

            db.Entry(mine).State = EntityState.Modified;
            await db.SaveChangesAsync();

            nh.ResponseOrdinal = mine.ResponseCount;
            nh.NoteOrdinal     = mine.NoteOrdinal;
            return(await CreateNote(db, userManager, nh, body, tags, dMessage, send, linked));
        }
        public async Task <NoteHeader> Edit(Notes2021.Models.TextViewModel inputModel)
        {
            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(null);
            }
            string     userID = auths[1];
            NoteAccess myAcc  = await AccessManager.GetAccess(_context, userID, inputModel.NoteFileID, 0); //TODO

            if (!myAcc.Write)
            {
                return(null);
            }

            await _signInManager.SignInAsync(me, false);

            DateTime now = DateTime.Now.ToUniversalTime();

            NoteHeader oheader = await NoteDataManager
                                 .GetBaseNoteHeaderById(_context, inputModel.NoteID);

            if (oheader.AuthorID != userID) // must be a note this user wrote.
            {
                return(null);
            }

            oheader.LastEdited       = now;
            oheader.ThreadLastEdited = now;
            oheader.NoteSubject      = inputModel.MySubject;

            NoteContent oContent = await NoteDataManager
                                   .GetNoteContent(_context, oheader.NoteFileId, 0, oheader.NoteOrdinal, oheader.ResponseOrdinal); //TODO

            oContent.NoteBody        = inputModel.MyNote;
            oContent.DirectorMessage = inputModel.DirectorMessage;

            return(await NoteDataManager
                   .EditNote(_context, _userManager, oheader, oContent, inputModel.TagLine));
        }