public ActionResult DeleteResourceStructureAttribute(long id)
        {
            using (var rsaManager = new ResourceStructureAttributeManager())
                using (var permissionManager = new EntityPermissionManager())
                    using (var entityTypeManager = new EntityManager())
                    {
                        ResourceStructureAttribute rsa = rsaManager.GetResourceStructureAttributesById(id);
                        if (rsa != null)
                        {
                            bool deleted = rsaManager.DeleteResourceStructureAttribute(rsa);

                            if (deleted)
                            {
                                Type entityType = entityTypeManager.FindByName("Notification").EntityType;
                                //delete security
                                permissionManager.Delete(entityType, id);
                            }
                        }
                        else
                        {
                            //rsa not exsits, need implemention here
                        }
                    }
            return(View("ResourceStructureAttributeManager"));
        }
        public void RemoveRightFromEntityPermission(long subjectId, long entityId, long instanceId, int rightType)
        {
            var entityPermissionManager = new EntityPermissionManager();

            try
            {
                var entityPermission = entityPermissionManager.Find(subjectId, entityId, instanceId);

                if (entityPermission == null)
                {
                    return;
                }

                if (entityPermission.Rights == rightType)
                {
                    entityPermissionManager.Delete(entityPermission);
                }
                else
                {
                    if ((entityPermission.Rights & rightType) == 0)
                    {
                        return;
                    }
                    entityPermission.Rights -= rightType;
                    entityPermissionManager.Update(entityPermission);
                }
            }
            finally
            {
                entityPermissionManager.Dispose();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Purges a dataset, which means the dataset and all its versions will be physically removed from the database.
        /// </summary>
        /// <param name="id">the identifier of the dataset to be purged.</param>
        /// <remarks>This operation is not revocerable.</remarks>
        /// <returns></returns>
        public ActionResult Purge(long id)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Purge", Session.GetTenant());

            DatasetManager dm = new DatasetManager();
            var            entityPermissionManager = new EntityPermissionManager();

            try
            {
                if (dm.PurgeDataset(id))
                {
                    entityPermissionManager.Delete(typeof(Dataset), id);

                    if (this.IsAccessibale("DDM", "SearchIndex", "ReIndexUpdateSingle"))
                    {
                        var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary()
                        {
                            { "id", id }, { "actionType", "DELETE" }
                        });
                    }
                }
            }
            catch (Exception e)
            {
                ViewData.ModelState.AddModelError("", string.Format("Dataset {0} could not be purged.", id));
            }
            return(View());
        }
        public void RemoveInstanceFromPublic(long entityId, long instanceId)
        {
            var entityPermissionManager = new EntityPermissionManager();

            try
            {
                var entityPermission = entityPermissionManager.Find(null, entityId, instanceId);

                if (entityPermission == null)
                {
                    return;
                }
                entityPermissionManager.Delete(entityPermission);

                if (this.IsAccessible("DDM", "SearchIndex", "ReIndexSingle"))
                {
                    var x = this.Run("DDM", "SearchIndex", "ReIndexSingle", new RouteValueDictionary()
                    {
                        { "id", instanceId }
                    });
                }
            }
            finally
            {
                entityPermissionManager.Dispose();
            }
        }
        public ActionResult Delete(long id)
        {
            using (var rsManager = new ResourceStructureManager())
                using (var permissionManager = new EntityPermissionManager())
                    using (var entityTypeManager = new EntityManager())
                    {
                        ResourceStructure resourceStructure = rsManager.GetResourceStructureById(id);
                        bool deleted = rsManager.Delete(resourceStructure);

                        if (deleted)
                        {
                            Type entityType = entityTypeManager.FindByName("ResourceStructure").EntityType;
                            //delete security
                            permissionManager.Delete(entityType, id);
                        }
                    }

            return(RedirectToAction("ResourceStructure", "ResourceStructure"));
        }
        public void RemoveInstanceFromPublic(long entityId, long instanceId)
        {
            var entityPermissionManager = new EntityPermissionManager();

            try
            {
                var entityPermission = entityPermissionManager.Find(null, entityId, instanceId);

                if (entityPermission == null)
                {
                    return;
                }
                entityPermissionManager.Delete(entityPermission);
            }
            finally
            {
                entityPermissionManager.Dispose();
            }
        }
Esempio n. 7
0
        public ActionResult Delete(long id)
        {
            using (var nManager = new NotificationManager())
                using (var permissionManager = new EntityPermissionManager())
                    using (var entityTypeManager = new EntityManager())
                    {
                        Notification notification = nManager.GetNotificationById(id);

                        bool deleted = nManager.DeleteNotification(notification);

                        if (deleted)
                        {
                            Type entityType = entityTypeManager.FindByName("Notification").EntityType;
                            //delete security
                            permissionManager.Delete(entityType, id);
                        }
                    }

            return(RedirectToAction("Notification"));
        }
Esempio n. 8
0
        public ActionResult Purge(long id)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Purge", Session.GetTenant());

            using (DatasetManager dm = new DatasetManager())
                using (var entityPermissionManager = new EntityPermissionManager())
                    using (var datasetManager = new DatasetManager())
                        using (var entityManager = new EntityManager())
                            using (var userManager = new UserManager())
                            {
                                try
                                {
                                    var userName = GetUsernameOrDefault();
                                    var user     = userManager.Users.Where(u => u.Name.Equals(userName)).FirstOrDefault();

                                    // check if a user is logged in
                                    if (user != null)
                                    {
                                        // is the user allowed to delete this dataset
                                        if (entityPermissionManager.HasEffectiveRight(user.UserName, typeof(Dataset), id, Security.Entities.Authorization.RightType.Delete))
                                        {
                                            if (dm.PurgeDataset(id))
                                            {
                                                entityPermissionManager.Delete(typeof(Dataset), id);

                                                var es = new EmailService();
                                                es.Send(MessageHelper.GetPurgeDatasetHeader(id),
                                                        MessageHelper.GetPurgeDatasetMessage(id, user.Name),
                                                        ConfigurationManager.AppSettings["SystemEmail"]
                                                        );


                                                if (this.IsAccessible("DDM", "SearchIndex", "ReIndexUpdateSingle"))
                                                {
                                                    var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary()
                                                    {
                                                        { "id", id }, { "actionType", "DELETE" }
                                                    });
                                                }
                                            }
                                        }
                                        else // user is not allowed
                                        {
                                            ViewData.ModelState.AddModelError("", $@"You do not have the permission to purge the record.");

                                            var es = new EmailService();
                                            es.Send(MessageHelper.GetTryToPurgeDatasetHeader(id),
                                                    MessageHelper.GetTryToPurgeDatasetMessage(id, user.Name),
                                                    ConfigurationManager.AppSettings["SystemEmail"]
                                                    );
                                        }
                                    }
                                    else // no user exist
                                    {
                                        ViewData.ModelState.AddModelError("", $@"This function can only be executed with a logged-in user.");
                                        var es = new EmailService();
                                        es.Send(MessageHelper.GetTryToPurgeDatasetHeader(id),
                                                MessageHelper.GetTryToPurgeDatasetMessage(id, userName),
                                                ConfigurationManager.AppSettings["SystemEmail"]
                                                );
                                    }
                                }
                                catch (Exception e)
                                {
                                    ViewData.ModelState.AddModelError("", string.Format("Dataset {0} could not be purged.", id));
                                }
                            }
            return(View());
        }