当前位置: 首页>>代码示例>>C#>>正文


C# Note.MakePrivate方法代码示例

本文整理汇总了C#中Note.MakePrivate方法的典型用法代码示例。如果您正苦于以下问题:C# Note.MakePrivate方法的具体用法?C# Note.MakePrivate怎么用?C# Note.MakePrivate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Note的用法示例。


在下文中一共展示了Note.MakePrivate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnConfirm_Click


//.........这里部分代码省略.........
                {
                    string text = tbNote.Text;
                    bool isAlert = cbIsAlert.Checked;
                    bool isPrivate = cbIsPrivate.Checked;

                    var noteTypeService = new NoteTypeService( rockContext );
                    var noteType = noteTypeService.Get( Rock.SystemGuid.NoteType.PERSON_TIMELINE.AsGuid() );
                    if ( noteType != null )
                    {
                        var notes = new List<Note>();
                        var noteService = new NoteService( rockContext );

                        foreach ( int id in ids )
                        {
                            var note = new Note();
                            note.IsSystem = false;
                            note.EntityId = id;
                            note.Caption = isPrivate ? "You - Personal Note" : string.Empty;
                            note.Text = tbNote.Text;
                            note.IsAlert = cbIsAlert.Checked;
                            note.NoteType = noteType;
                            notes.Add( note );
                            noteService.Add( note );
                        }

                        rockContext.WrapTransaction( () =>
                        {
                            rockContext.SaveChanges();
                            foreach ( var note in notes )
                            {
                                note.AllowPerson( Authorization.EDIT, CurrentPerson, rockContext );
                                if ( isPrivate )
                                {
                                    note.MakePrivate( Authorization.VIEW, CurrentPerson, rockContext );
                                }
                            }
                        } );

                    }
                }

                #endregion

                #region Group

                int? groupId = gpGroup.SelectedValue.AsIntegerOrNull();
                if ( groupId.HasValue )
                {
                    var group = new GroupService( rockContext ).Get( groupId.Value );
                    if ( group != null )
                    {
                        var groupMemberService = new GroupMemberService( rockContext );

                        var existingMembers = groupMemberService.Queryable( "Group" )
                            .Where( m =>
                                m.GroupId == group.Id &&
                                ids.Contains( m.PersonId ) )
                            .ToList();

                        string action = ddlGroupAction.SelectedValue;
                        if ( action == "Remove" )
                        {
                            groupMemberService.DeleteRange( existingMembers );
                            rockContext.SaveChanges();
                        }
                        else
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:67,代码来源:BulkUpdate.ascx.cs

示例2: AddNote

        /// <summary>
        /// Add a note on the given person's record.
        /// </summary>
        /// <param name="personId"></param>
        /// <param name="noteTypeName"></param>
        /// <param name="noteText"></param>
        /// <param name="noteDate">(optional) The date the note was created</param>
        /// <param name="byPersonGuid">(optional) The guid of the person who created the note</param>
        /// <param name="rockContext"></param>
        private void AddNote( int personId, string noteTypeName, string noteText, string noteDate, string byPersonGuid, string isPrivate, RockContext rockContext )
        {
            var service = new NoteTypeService( rockContext );
            var noteType = service.Get( _personEntityTypeId, noteTypeName );

            // Find the person's alias
            int? createdByPersonAliasId = null;
            if ( byPersonGuid != null )
            {
                createdByPersonAliasId = _personCache[byPersonGuid.AsGuid()].PrimaryAliasId;
            }

            var noteService = new NoteService( rockContext );
            var note = new Note()
            {
                IsSystem = false,
                NoteTypeId = noteType.Id,
                EntityId = personId,
                Caption = string.Empty,
                CreatedByPersonAliasId = createdByPersonAliasId,
                Text = noteText,
                CreatedDateTime = string.IsNullOrWhiteSpace( noteDate ) ? RockDateTime.Now : DateTime.Parse( noteDate, new CultureInfo( "en-US" ) )
            };

            noteService.Add( note );

            if ( isPrivate.AsBoolean() )
            {
                rockContext.SaveChanges( disablePrePostProcessing: true );
                note.MakePrivate( Rock.Security.Authorization.VIEW, _personCache[byPersonGuid.AsGuid()], rockContext );
            }
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:41,代码来源:SampleData.ascx.cs

示例3: AddNote

        /// <summary>
        /// Add a note on the given person's record.
        /// </summary>
        /// <param name="personId"></param>
        /// <param name="noteTypeName"></param>
        /// <param name="noteText"></param>
        /// <param name="noteDate">(optional) The date the note was created</param>
        /// <param name="byPersonGuid">(optional) The guid of the person who created the note</param>
        /// <param name="rockContext"></param>
        private void AddNote( int personId, string noteTypeName, string noteText, string noteDate, string byPersonGuid, string isPrivate, RockContext rockContext )
        {
            var service = new NoteTypeService( rockContext );
            var noteType = service.Get( _personEntityTypeId, noteTypeName );
            // if the note type does not exist, create it
            if ( noteType == null )
            {
                noteType = new NoteType();
                noteType.IsSystem = false;
                noteType.EntityTypeId = _personEntityTypeId;
                noteType.EntityTypeQualifierColumn = string.Empty;
                noteType.EntityTypeQualifierValue = string.Empty;
                noteType.Name = noteTypeName;
                service.Add( noteType );
                rockContext.SaveChanges();
            }

            // Find the person's alias
            int? createdByPersonAliasId = null;
            if ( byPersonGuid != null )
            {
                createdByPersonAliasId = _personCache[byPersonGuid.AsGuid()].PrimaryAliasId;
            }

            var noteService = new NoteService( rockContext );
            var note = new Note()
            {
                IsSystem = false,
                NoteTypeId = noteType.Id,
                EntityId = personId,
                Caption = string.Empty,
                CreatedByPersonAliasId = createdByPersonAliasId,
                Text = noteText,
                CreatedDateTime = DateTime.Parse( noteDate ?? RockDateTime.Now.ToString() )
            };

            noteService.Add( note );

            if ( isPrivate.AsBoolean() )
            {
                rockContext.SaveChanges( disablePrePostProcessing: true );
                note.MakePrivate( Rock.Security.Authorization.VIEW, _personCache[byPersonGuid.AsGuid()] );
            }
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:53,代码来源:SampleData.ascx.cs

示例4: btnAddNote_Click

        /// <summary>
        /// Handles the Click event of the btnAddNote control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        void btnAddNote_Click( object sender, EventArgs e )
        {
            if ( !string.IsNullOrWhiteSpace( tbNewNote.Text ) )
            {
                var service = new NoteService();

                var note = new Note();
                note.IsSystem = false;
                note.NoteTypeId = noteType.Id;
                note.EntityId = contextEntity.Id;
                note.CreatedByPersonId = CurrentPersonId;
                note.CreationDateTime = DateTime.Now;
                note.Caption = cbPrivate.Checked ? "You - Personal Note" : string.Empty;
                note.IsAlert = cbAlert.Checked;
                note.Text = tbNewNote.Text;

                if ( noteType.Sources != null )
                {
                    var source = noteType.Sources.DefinedValues.FirstOrDefault();
                    if ( source != null )
                    {
                        note.SourceTypeValueId = source.Id;
                    }
                }

                service.Add( note, CurrentPersonId );
                service.Save( note, CurrentPersonId );

                note.AllowPerson("Edit", CurrentPerson, CurrentPersonId);

                if ( cbPrivate.Checked )
                {
                    note.MakePrivate( "View", CurrentPerson, CurrentPersonId );
                }
            }

            ShowNotes();
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:43,代码来源:Notes.ascx.cs

示例5: btnComplete_Click


//.........这里部分代码省略.........
                    {
                        foreach ( var person in people )
                        {
                            person.LoadAttributes();
                            foreach ( var attribute in attributes )
                            {
                                string originalValue = person.GetAttributeValue( attribute.Key );
                                string newValue = attributeValues[attribute.Id];
                                if ( ( originalValue ?? string.Empty ).Trim() != ( newValue ?? string.Empty ).Trim() )
                                {
                                    Rock.Attribute.Helper.SaveAttributeValue( person, attribute, newValue, rockContext );

                                    string formattedOriginalValue = string.Empty;
                                    if ( !string.IsNullOrWhiteSpace( originalValue ) )
                                    {
                                        formattedOriginalValue = attribute.FieldType.Field.FormatValue( null, originalValue, attribute.QualifierValues, false );
                                    }

                                    string formattedNewValue = string.Empty;
                                    if ( !string.IsNullOrWhiteSpace( newValue ) )
                                    {
                                        formattedNewValue = attribute.FieldType.Field.FormatValue( null, newValue, attribute.QualifierValues, false );
                                    }

                                    History.EvaluateChange( allChanges[person.Id], attribute.Name, formattedOriginalValue, formattedNewValue );
                                }
                            }
                        }
                    }

                    // Create the history records
                    foreach ( var changes in allChanges )
                    {
                        if ( changes.Value.Any() )
                        {
                            HistoryService.AddChanges( rockContext, typeof( Person ), Rock.SystemGuid.Category.HISTORY_PERSON_DEMOGRAPHIC_CHANGES.AsGuid(),
                                changes.Key, changes.Value );
                        }
                    }
                    rockContext.SaveChanges();

                    #endregion

                    #region Add Note

                    if ( !string.IsNullOrWhiteSpace( tbNote.Text ) && CurrentPerson != null )
                    {
                        string text = tbNote.Text;
                        bool isAlert = cbIsAlert.Checked;
                        bool isPrivate = cbIsPrivate.Checked;

                        var noteTypeService = new NoteTypeService( rockContext );
                        var noteService = new NoteService( rockContext );

                        string noteTypeName = GetAttributeValue( "NoteType" );
                        var noteType = noteTypeService.Get( personEntityTypeId, noteTypeName );

                        if ( noteType != null )
                        {
                            var notes = new List<Note>();

                            foreach ( int id in ids )
                            {
                                var note = new Note();
                                note.IsSystem = false;
                                note.EntityId = id;
                                note.Caption = isPrivate ? "You - Personal Note" : string.Empty;
                                note.Text = tbNote.Text;
                                note.IsAlert = cbIsAlert.Checked;
                                note.NoteType = noteType;

                                notes.Add( note );
                                noteService.Add( note );
                            }

                            rockContext.WrapTransaction( () =>
                            {
                                rockContext.SaveChanges();
                                foreach( var note in notes)
                                {
                                    note.AllowPerson( Authorization.EDIT, CurrentPerson, rockContext );
                                    if ( isPrivate)
                                    {
                                        note.MakePrivate( Authorization.VIEW, CurrentPerson, rockContext );
                                    }
                                }
                            } );

                        }
                    }

                    #endregion

                }

                string message = string.Format("{0} {1} succesfully updated!",
                    ids.Count().ToString("N0"), (ids.Count() > 1 ? "people were" : "person was") );
                ShowResult( message );
            }
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:101,代码来源:BulkUpdate.ascx.cs


注:本文中的Note.MakePrivate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。