示例#1
0
        /// <summary>
        /// Handles entity Inserted event.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">The <see cref="T:Terrasoft.Core.Entities.EntityAfterEventArgs" /> instance containing the
        /// event data.</param>
        public override void OnInserted(object sender, EntityAfterEventArgs e)
        {
            base.OnInserted(sender, e);
            Entity adminUnit = (Entity)sender;

            if (adminUnit.GetTypedColumnValue <Guid>("ContactId") != Guid.Empty &&
                adminUnit.GetTypedColumnValue <bool>("ConnectionType"))
            {
                RightsHelper = RightsHelper ?? new RightsHelper(adminUnit.UserConnection);
                RightsHelper.SetRecordRight(adminUnit.GetTypedColumnValue <Guid>("Id"), "Contact",
                                            adminUnit.GetTypedColumnValue <string>("ContactId"), 0, 2);
                RightsHelper.SetRecordRight(adminUnit.GetTypedColumnValue <Guid>("Id"), "Contact",
                                            adminUnit.GetTypedColumnValue <string>("ContactId"), 1, 2);
            }
        }
        protected virtual void SetCopiedRecordsRights()
        {
            RightsHelper rightHelper = ClassFactory.Get <RightsHelper>(new ConstructorArgument("userConnection",
                                                                                               UserConnection.AppConnection.SystemUserConnection));

            foreach (var entity in InsertQueue)
            {
                var recordRecordId = entity.GetTypedColumnValue <string>("Id");
                rightHelper.SetRecordRight(UserConnection.CurrentUser.Id, "Project", recordRecordId,
                                           (int)EntitySchemaRecordRightOperation.Read, (int)EntitySchemaRecordRightLevel.AllowAndGrant);
                rightHelper.SetRecordRight(UserConnection.CurrentUser.Id, "Project", recordRecordId,
                                           (int)EntitySchemaRecordRightOperation.Edit, (int)EntitySchemaRecordRightLevel.AllowAndGrant);
                rightHelper.SetRecordRight(UserConnection.CurrentUser.Id, "Project", recordRecordId,
                                           (int)EntitySchemaRecordRightOperation.Delete, (int)EntitySchemaRecordRightLevel.AllowAndGrant);
            }
        }