private void RestoreState()
 {
     GetAppbarBtns();
     if (State.ContainsKey("NoteEntity"))
     {
         NoteEntity = State["NoteEntity"] as NoteEntity;
     }
     if (State.ContainsKey("_appbarBtnSaveEnabled"))
     {
         _appbarBtnSave.IsEnabled = (bool)State["_appbarBtnSaveEnabled"];
     }
     if (State.ContainsKey("_appbarBtnCancelEnabled"))
     {
         _appbarBtnCancel.IsEnabled = (bool)State["_appbarBtnCancelEnabled"];
     }
     if (State.ContainsKey("tbTitleText"))
     {
         tbTitle.Text = (string)State["tbTitleText"];
     }
     if (State.ContainsKey("rtbContentText"))
     {
         rtbContent.SetHtml((string)State["rtbContentText"]);
     }
     if (State.ContainsKey("tbNotebookText"))
     {
         tbNotebook.Text = (string)State["tbNotebookText"];
     }
     if (State.ContainsKey("_photoChooserTask"))
     {
         _photoChooserTask = (PhotoChooserTask)State["_photoChooserTask"];
     }
 }
Beispiel #2
0
        public NoteDTO Replace(long id, NoteEntity newEntity)
        {
            var        transaction = _humanManagerContext.Database.BeginTransaction();
            NoteEntity oldEntity   = null;

            try
            {
                NoteEntity entity = _humanManagerContext.Notes.SingleOrDefault(item => item.Id == id);
                if (entity != null)
                {
                    entity.Id      = newEntity.Id;
                    entity.Content = newEntity.Content;
                    _humanManagerContext.SaveChanges();
                }

                transaction.Commit();

                NoteDTO dto = _mapper.Map <NoteDTO>(entity);

                return(dto);
            }
            catch
            {
                transaction.Rollback();
                return(null);
            }
        }
Beispiel #3
0
            private async Task SaveData(NoteEntity note, IDictionary <string, string?> newData, IEnumerable <DataEntity> oldData)
            {
                var entities = newData
                               .Where(d => !string.IsNullOrWhiteSpace(d.Value))
                               .Select(
                    entry => new DataEntity
                {
                    PartitionKey = note.PartitionKey,
                    RowKey       = $"{note.RowKey}-{entry.Key}",
                    Value        = entry.Value,
                })
                               .ToList();

                if (entities.Any() || oldData.Any())
                {
                    var batch = new TableBatchOperation();

                    entities.ForEach(d => batch.InsertOrReplace(d));

                    var dataNames = newData.Keys;
                    oldData
                    .Where(d => !dataNames.Contains(d.Name))
                    .ToList()
                    .ForEach(d => batch.Delete(d));

                    await _dataTable.ExecuteBatchAsync(batch);
                }
            }
Beispiel #4
0
        private static void noteCreated(NoteEntity newNoteEntity)
        {
            var belongNotebookPath = newNoteEntity.NotebookPath;

            lock (LockObj)
            {
                NoteCollection noteCollection;
                if (NoteCollectionDict.TryGetValue(belongNotebookPath, out noteCollection))
                {
                    var flag = false;
                    for (var i = 0; i < noteCollection.Count; i++)
                    {
                        if (noteCollection[i].ModifyTime >= newNoteEntity.ModifyTime)
                        {
                            continue;
                        }
                        noteCollection.Insert(i, newNoteEntity);
                        flag = true;
                        break;
                    }
                    if (!flag)
                    {
                        noteCollection.Add(newNoteEntity);
                    }
                }
                else
                {
                    noteCollection = new NoteCollection {
                        newNoteEntity
                    };
                    NoteCollectionDict.Add(belongNotebookPath, noteCollection);
                }
            }
        }
Beispiel #5
0
    /// <summary>
    /// 利用起始行获取注释信息
    /// </summary>
    /// <param name="startline">注释的起始行</param>
    /// <param name="cid">注释所属源码ID</param>
    /// <returns>返回注释</returns>
    public static List <NoteEntity> GetNotesBySartLine(int startline, int cid)
    {
        DataBase          db    = new DataBase();
        DataSet           rs    = db.RunProcReturn("select * from tb_note where startline=" + startline.ToString() + " and cid=" + cid.ToString(), "tb_note");
        List <NoteEntity> notes = new List <NoteEntity>();

        for (int i = 0; i < rs.Tables[0].Rows.Count; i++)
        {
            NoteEntity ne = new NoteEntity();
            ne.NoteName  = rs.Tables[0].Rows[i]["noteName"].ToString();
            ne.Uid       = int.Parse(rs.Tables[0].Rows[i]["uid"].ToString());
            ne.Cid       = int.Parse(rs.Tables[0].Rows[i]["cid"].ToString());
            ne.UpTime    = DateTime.Parse(rs.Tables[0].Rows[i]["upTime"].ToString());
            ne.Id        = int.Parse(rs.Tables[0].Rows[i]["id"].ToString());
            ne.StartLine = int.Parse(rs.Tables[0].Rows[i]["startLine"].ToString());
            ne.EndLine   = int.Parse(rs.Tables[0].Rows[i]["endLine"].ToString());
            ne.Agree     = int.Parse(rs.Tables[0].Rows[i]["agree"].ToString());
            ne.Disagree  = int.Parse(rs.Tables[0].Rows[i]["disagree"].ToString());
            ne.Context   = rs.Tables[0].Rows[i]["Context"].ToString();
            ne.User      = UserOperation.GetUser(ne.Uid);
            ne.Recommend = int.Parse(rs.Tables[0].Rows[i]["recommend"].ToString());
            notes.Add(ne);
        }
        return(notes);
    }
Beispiel #6
0
        private NoteEntity modifyNote(NoteSync noteSync, Note serverNote, NoteEntity findLocalNote, Dictionary <NoteBatchOperateEnum, List <NoteEntity> > dic = null)
        {
            findLocalNote.NotePath     = noteSync.NotePath;
            findLocalNote.Title        = serverNote.Title;
            findLocalNote.CreateTime   = serverNote.CreateTime;
            findLocalNote.ModifyTime   = serverNote.ModifyTime;
            findLocalNote.Size         = serverNote.Size;
            findLocalNote.Source       = serverNote.Source;
            findLocalNote.NotebookPath = noteSync.NotebookPath;
            findLocalNote.Content      = DownloadImageToLocalAsync(noteSync.NotePath, serverNote.Content).Result;
            findLocalNote.Author       = serverNote.Author;
            findLocalNote.NotebookName = noteSync.NotebookName;
            findLocalNote.NoteStatus   = NoteStatus.Normal;
            if (null == dic)
            {
                NoteDao.Inst.ModifyIfExist(findLocalNote);
            }
            else
            {
                if (null != findLocalNote)
                {
                    dic[NoteBatchOperateEnum.Modify].Add(findLocalNote);
                }
            }

            return(findLocalNote);
        }
Beispiel #7
0
    /// <summary>
    /// Page_Load
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uid"] == null)
        {
            Response.Write("请登录后再填写注释。");
            return;
        }
        DataBase   db = new DataBase();
        NoteEntity ne = new NoteEntity();

        ne.Agree     = 0;
        ne.Cid       = int.Parse(Request.QueryString["cid"].ToString());
        ne.Disagree  = 0;
        ne.EndLine   = int.Parse(Request.QueryString["endline"].ToString());
        ne.NoteName  = "";
        ne.StartLine = int.Parse(Request.QueryString["startline"].ToString());
        ne.Context   = Request.QueryString["context"].ToString();
        ne.Uid       = int.Parse(Session["uid"].ToString());
        ne.UpTime    = DateTime.Now;
        if (ne.Context == "")
        {
            Response.Write("请填写注释!");
            return;
        }
        if (NoteOperation.AddNote(ne))
        {
            Response.Write("注释添加成功。");
            return;
        }
        else
        {
            Response.Write("添加注释失败");
        }
    }
Beispiel #8
0
        public ActionResult <Api <NoteDTO> > Edit(long id, NoteEntity newEntity)
        {
            NoteDTO       dto    = _noteService.Replace(id, newEntity);
            Api <NoteDTO> result = new Api <NoteDTO>(200, dto, "Edit Success");

            return(Ok(result));
        }
Beispiel #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["uid"] == null)
     {
         Response.Write("请登录后再填写注释。");
         return;
     }
     DataBase db = new DataBase();
     NoteEntity ne = new NoteEntity();
     ne.Agree = 0;
     ne.Cid = int.Parse(Request.QueryString["cid"].ToString());
     ne.Disagree = 0;
     ne.EndLine = int.Parse(Request.QueryString["endline"].ToString());
     ne.NoteName = "";
     ne.StartLine = int.Parse(Request.QueryString["startline"].ToString());
     ne.Context = Request.QueryString["context"].ToString();
     ne.Uid = int.Parse(Session["uid"].ToString());
     ne.UpTime = DateTime.Now;
     if (NoteOperation.AddNote(ne))
     {
         Response.Write("注释添加成功。点击确定,关闭本窗口。");
         return;
     }
     else
     {
         Response.Write("添加注释失败");
     }
 }
Beispiel #10
0
    /// <summary>
    /// 修正链接
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void fixUrl(object sender, EventArgs e)
    {
        HyperLink  hl = (HyperLink)sender;
        NoteEntity ne = NoteOperation.GetNote(int.Parse(hl.NavigateUrl));

        hl.NavigateUrl = string.Format("../loadnotes.aspx?startline={0}&cid={1}&isDing=2", ne.StartLine, ne.Cid);
    }
 private void RestoreState()
 {
     if (State.ContainsKey("NoteEntity"))
     {
         NoteEntity = (NoteEntity)State["NoteEntity"];
     }
 }
 public static void AssertThatIssuerIsAuthorizedToDeleteNote(NoteEntity note, GroupEntity group, int userId)
 {
     if (note.CreatorId != userId && group.CreatorId != userId)
     {
         throw new SecurityException($"User with ID: {userId} does not have access to this operation.");
     }
 }
Beispiel #13
0
 void ViewNote(NoteEntity note)
 {
     Navigator.NavigateUntyped(note, new NavigateOptions()
     {
         Closed = (_, __) => Dispatcher.Invoke(() => ReloadNotes()),
     });
 }
Beispiel #14
0
            private async Task <bool> SaveNote(Request request, NoteEntity entity, string contentUri)
            {
                entity.Title   = request.Title;
                entity.Slug    = request.Slug;
                entity.BlobUri = contentUri;

                return(await _noteTable.ReplaceAsync(entity));
            }
Beispiel #15
0
 public static Note MapToModel(this NoteEntity entity)
 {
     return(new Note(entity.Id,
                     entity.UserId,
                     entity.Title,
                     entity.Subtitle,
                     entity.Description));
 }
 public NoteDomainModel(NoteEntity note)
 {
     WhenAdded = note.WhenCreated;
       UserId = note.UserId;
       Body = note.Content;
       CreatorFirstName = note.User.FirstName;
       CreatorLastName = note.User.LastName;
 }
 public NoteDomainModel(NoteEntity note)
 {
     WhenAdded        = note.WhenCreated;
     UserId           = note.UserId;
     Body             = note.Content;
     CreatorFirstName = note.User.FirstName;
     CreatorLastName  = note.User.LastName;
 }
Beispiel #18
0
        public NoteDTO FindOne(long id)
        {
            NoteDTO    dto    = new NoteDTO();
            NoteEntity entity = _humanManagerContext.Notes.Find(id);

            dto = _mapper.Map <NoteDTO>(entity);
            return(dto);
        }
Beispiel #19
0
        static string AddNote(AddNoteOption opt)
        {
            var    note = new NoteEntity((++noteNum).ToString(), opt.Desc);
            string output;

            output = $"Note: {note.NoteDescription} added";
            return(output);
        }
Beispiel #20
0
        public async Task <NoteEntity> UpdateNote(NoteEntity note)
        {
            NoteEntity noteToUpdate = await ReadNote((int)note.Id);

            noteToUpdate.UpdateFrom(note);
            _context.Update(noteToUpdate);
            return(await _context.SaveChangesAsync() > 0 ? noteToUpdate : null);
        }
Beispiel #21
0
 public ActionResult Add(NoteEntity node)
 {
     //
     node.UserId     = Account.UserId;
     node.CreateTime = DateTime.Now;
     node.UpdateTime = DateTime.Now;
     return(Json(new { result = (_service.Insert(node) > 0) }));
 }
Beispiel #22
0
        public List <Note> GetNoteByAuthorId(int id)
        {
            try
            {
                if (id <= 0)
                {
                    return(null);
                }

                DbParameter[] parameters = new DbParameter[]
                {
                    new SqlParameter()
                    {
                        ParameterName = SpParamsOfNote.Sp_Select_NoteByAuthorId_AuthorId,
                        Value         = id
                    }
                };

                using (DataSet dataSet = DbHelper.Instance.RunProcedureGetDataSet(SpNamesOfNote.Sp_Select_NoteByAuthorId, parameters))
                {
                    List <Note> notes = new List <Note>();

                    if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count != 0)
                    {
                        DataRowCollection    dataRows    = dataSet.Tables[0].Rows;
                        DataColumnCollection dataColumns = dataSet.Tables[0].Columns;

                        foreach (DataRow dataRow in dataRows)
                        {
                            NoteEntity entity = new NoteEntity()
                            {
                                Id              = (int)dataRow[dataColumns[0]],
                                AuthorId        = (int)dataRow[dataColumns[1]],
                                Title           = dataRow[dataColumns[2]].ToString(),
                                Remark          = dataRow[dataColumns[3]].ToString(),
                                CreateTime      = (DateTime)dataRow[dataColumns[4]],
                                LastBrowsedTime = (DateTime)dataRow[dataColumns[5]],
                                IsShared        = (bool)dataRow[dataColumns[6]],
                                IsDeleted       = (bool)dataRow[dataColumns[7]],
                                DeletedTime     = (DateTime)dataRow[dataColumns[8]]
                            };

                            Note model = entity.ToModel();
                            model.BrowsedTimes  = (int)dataRow[dataColumns[9]];
                            model.ApprovedTimes = (int)dataRow[dataColumns[10]];
                            model.CommentCount  = (int)dataRow[dataColumns[11]];
                            notes.Add(model);
                        }
                    }

                    return(notes);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #23
0
 public NoteResponse(NoteEntity noteEntity)
 {
     Id                 = noteEntity.NoteId;
     CreatorId          = noteEntity.CreatorId;
     GroupId            = noteEntity.Group.GroupId;
     Name               = noteEntity.Name;
     Description        = noteEntity.Description;
     AttachmentIdentity = noteEntity.AttachmentIdentity;
 }
Beispiel #24
0
        public async Task DeleteNoteAsync(NoteEntity entity, Action <SyncCompletedType, object> deleteCompleted)
        {
            if (null == entity)
            {
                throw new ArgumentNullException("entity");
            }

            await Task.Run(() => InternalDeleteNote(entity, deleteCompleted));
        }
Beispiel #25
0
 private Note Map(NoteEntity entity)
 {
     return(new Note(entity.Id)
     {
         Content = entity.Content,
         Type = (NoteType)entity.Type,
         Created = entity.Created
     });
 }
Beispiel #26
0
        public async Task <NoteResponse> CreateAsync(CreateNoteRequest request)
        {
            NoteEntity _CreatedEntity = await __NoteRepository.CreateAsync(request.ToEntity());

            return(_CreatedEntity.ToResponse() ?? new NoteResponse
            {
                Success = false,
                ErrorMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} create {ENTITY_NAME}."
            });
        }
 public Task Add(NoteEntity note)
 {
     return(Task.Run(() =>
     {
         lock (databaseLock)
         {
             DbConnection.Insert(note);
         }
     }));
 }
Beispiel #28
0
        public int Update(NoteEntity model)
        {
            string sql = @"UPDATE [SmallNote]
                                           SET  [Note] = @Note 
                                              ,[NState] = @NState
                                              ,[UpdateTime] = GETDATE()
                                         WHERE Id = @Id AND UserID = @UserId";

            return(Execute(OpenMsSqlConnection(), sql, model));
        }
Beispiel #29
0
        public int Update(NoteEntity model)
        {
            string sql = @"UPDATE [Note]
                                           SET [Title] = @Title  
                                              ,[Note] = @Note  
                                              ,[UpdateTime] = GETDATE()
                                         WHERE Id = @Id";

            return(Execute(OpenMsSqlConnection(), sql, model));
        }
 public Task Update(NoteEntity note)
 {
     return(Task.Run(() =>
     {
         lock (databaseLock)
         {
             DbConnection.Update(note);
         }
     }));
 }
Beispiel #31
0
        public async Task <NoteEntity> CreateNote(NoteEntity note)
        {
            note.Title     = note.Title ?? "New note";
            note.CreatedOn = note.CreatedOn ?? DateTime.Now;
            note.UpdatedOn = DateTime.Now;

            await _context.Notes.AddAsync(note);

            return(await _context.SaveChangesAsync() > 0 ? note : null);
        }
 public NoteViewModel(NoteEntity note)
 {
     Note        = note;
     Description = note.Description ?? "";
     this.ValidationRule(
         model => model.Description,
         s => !string.IsNullOrWhiteSpace(s),
         LocalizationContainer.Localization["Невалидное значение"]
         );
 }
Beispiel #33
0
        public async Task<CreateNoteResponse> CreateNote(CreateNoteRequest request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var validationContext = new ValidationContext();
            request.Validate(validationContext);

            if (validationContext.HasErrors)
            {
                throw new ValidationException(validationContext);
            }

            var editKey = Guid.NewGuid().ToString("n");
            var noteEntity = new NoteEntity
            {
                NoteId = GetShortId(),
                Title = request.Title,
                Content = request.Content,
                ExpirationTime = request.ExpiresOn,
                NoteType = request.NoteType,
                CreationTime = Clock.UtcNow,
                EditKeyHash = editKey.Sha256(),
            };

            bool duplicateKeyException = false;
            try
            {
                await this.noteStore.Insert(noteEntity, cancellationToken);
            }
            catch (DuplicateKeyException)
            {
                duplicateKeyException = true;
            }

            if (duplicateKeyException)
            {
                // try again with a GUID ID
                noteEntity.NoteId = Guid.NewGuid().ToString("n");
                await this.noteStore.Insert(noteEntity, cancellationToken);
            }

            return new CreateNoteResponse
            {
                StatusCode = HttpStatusCode.Created,
                NoteId = noteEntity.NoteId,
                EditKey = editKey,
            };
        }
Beispiel #34
0
 /// <summary>
 /// 添加注释
 /// </summary>
 /// <param name="ne">注释的实例</param>
 /// <returns>添加成功返回true 失败返回false</returns>
 public static bool AddNote(NoteEntity ne)
 {
     DataBase db = new DataBase();
     try
     {
         string sql = string.Format("INSERT INTO tb_note ( noteName, uid, upTime, startLine, endLine, cid, agree, disagree,context )VALUES  ( '{0}', '{1}','{2}', {3}, {4},{5},{6},{7},'{8}')", ne.NoteName, ne.Uid, ne.UpTime.ToString(), ne.StartLine, ne.EndLine, ne.Cid, ne.Agree, ne.Disagree, ne.Context.Trim().Replace(" ", ""));
         db.ExCommandNoBack(sql);
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #35
0
 public static NoteEntity GetNote(int noteId)
 {
     /*获取工程信息*/
     DataBase db = new DataBase();
     DataSet rs = db.RunProcReturn("select * from tb_note where id=" + noteId, "tb_note");
     if (rs.Tables[0].Rows.Count > 0)
     {
         NoteEntity ne = new NoteEntity();
         ne.NoteName = rs.Tables[0].Rows[0]["noteName"].ToString();
         ne.Uid = int.Parse(rs.Tables[0].Rows[0]["uid"].ToString());
         ne.Cid = int.Parse(rs.Tables[0].Rows[0]["cid"].ToString());
         ne.UpTime = DateTime.Parse(rs.Tables[0].Rows[0]["upTime"].ToString());
         ne.Id = int.Parse(rs.Tables[0].Rows[0]["id"].ToString());
         ne.StartLine = int.Parse(rs.Tables[0].Rows[0]["startLine"].ToString());
         ne.EndLine = int.Parse(rs.Tables[0].Rows[0]["endLine"].ToString());
         ne.Agree = int.Parse(rs.Tables[0].Rows[0]["agree"].ToString());
         ne.Disagree = int.Parse(rs.Tables[0].Rows[0]["disagree"].ToString());
         ne.Context = rs.Tables[0].Rows[0]["Context"].ToString();
         return ne;
     }
     return null;
 }
Beispiel #36
0
 /// <summary>
 /// 用源代码ID获取注释信息
 /// </summary>
 /// <param name="cid">源码ID</param>
 /// <returns>返回注释列表</returns>
 public static List<NoteEntity> GetAssNotes(int cid)
 {
     DataBase db = new DataBase();
     DataSet ds = db.ExCommand("select * from tb_note where cid =" + cid);
     List<NoteEntity> assNotes = new List<NoteEntity>();
     foreach (DataRow dr in ds.Tables[0].Rows)
     {
         NoteEntity ne = new NoteEntity();
         ne.Agree = int.Parse(dr["agree"].ToString());
         ne.Cid = int.Parse(dr["cid"].ToString());
         ne.Context = dr["context"].ToString();
         ne.Disagree = int.Parse(dr["disagree"].ToString());
         ne.EndLine = int.Parse(dr["endline"].ToString());
         ne.Id = int.Parse(dr["id"].ToString());
         ne.NoteName = dr["noteName"].ToString();
         ne.StartLine = int.Parse(dr["startline"].ToString());
         ne.Uid = int.Parse(dr["uid"].ToString());
         ne.UpTime = DateTime.Parse(dr["uptime"].ToString());
         assNotes.Add(ne);
     }
     return assNotes;
 }
Beispiel #37
0
 /// <summary>
 /// 利用起始行获取注释信息
 /// </summary>
 /// <param name="startline">注释的起始行</param>
 /// <param name="cid">注释所属源码ID</param>
 /// <returns>返回注释</returns>
 public static List<NoteEntity> GetNotesBySartLine(int startline, int cid)
 {
     DataBase db = new DataBase();
     DataSet rs = db.RunProcReturn("select * from tb_note where startline=" + startline.ToString() + " and cid=" + cid.ToString(), "tb_note");
     List<NoteEntity> notes = new List<NoteEntity>();
     for (int i = 0; i < rs.Tables[0].Rows.Count; i++)
     {
         NoteEntity ne = new NoteEntity();
         ne.NoteName = rs.Tables[0].Rows[i]["noteName"].ToString();
         ne.Uid = int.Parse(rs.Tables[0].Rows[i]["uid"].ToString());
         ne.Cid = int.Parse(rs.Tables[0].Rows[i]["cid"].ToString());
         ne.UpTime = DateTime.Parse(rs.Tables[0].Rows[i]["upTime"].ToString());
         ne.Id = int.Parse(rs.Tables[0].Rows[i]["id"].ToString());
         ne.StartLine = int.Parse(rs.Tables[0].Rows[i]["startLine"].ToString());
         ne.EndLine = int.Parse(rs.Tables[0].Rows[i]["endLine"].ToString());
         ne.Agree = int.Parse(rs.Tables[0].Rows[i]["agree"].ToString());
         ne.Disagree = int.Parse(rs.Tables[0].Rows[i]["disagree"].ToString());
         ne.Context = rs.Tables[0].Rows[i]["Context"].ToString();
         ne.User = UserOperation.GetUser(ne.Uid);
         ne.Recommend = int.Parse(rs.Tables[0].Rows[i]["recommend"].ToString());
         notes.Add(ne);
     }
     return notes;
 }