Exemplo n.º 1
0
        public DynamicEntity GetFirstMetadata(int id, bool isFolder)
        {
            var meta = GetFirstMetadataEntity(id, isFolder);

            if (meta == null)
            {
                var emptyMetadata = new Dictionary <string, object>();
                emptyMetadata.Add("Title", "");
                meta = new Eav.Data.Entity(Eav.Constants.TransientAppId, 0, "", emptyMetadata, "Title");
            }
            return(new DynamicEntity(meta, new[] { Thread.CurrentThread.CurrentCulture.Name }, Sexy));
        }
Exemplo n.º 2
0
        private IEnumerable <ToSic.Eav.Interfaces.IEntity> GetList()
        {
            EnsureConfigurationIsLoaded();

            var properties = Properties.Split(',').Select(p => p.Trim()).ToArray();
            var portalId   = PortalSettings.Current.PortalId;

            // read all user Profiles
            ArrayList users;

            if (UserIds == "disabled")
            {
                users = UserController.GetUsers(portalId);
            }
            // read user Profiles of specified UserIds
            else
            {
                var userIds = UserIds.Split(',').Select(n => Convert.ToInt32(n)).ToArray();
                users = new ArrayList();
                foreach (var user in userIds.Select(userId => UserController.GetUserById(portalId, userId)))
                {
                    users.Add(user);
                }
            }

            // convert Profiles to Entities
            var result = new List <ToSic.Eav.Interfaces.IEntity>();

            foreach (UserInfo user in users)
            {
                // add Profile-Properties
                var values = new Dictionary <string, object>();
                foreach (var property in properties)
                {
                    string value;
                    switch (property.ToLower())
                    {
                    case "displayname":
                        value = user.DisplayName;
                        break;

                    case "email":
                        value = user.Email;
                        break;

                    case "firstname":
                        value = user.FirstName;
                        break;

                    case "lastname":
                        value = user.LastName;
                        break;

                    case "username":
                        value = user.Username;
                        break;

                    default:
                        value = user.Profile.GetPropertyValue(property);
                        break;
                    }

                    values.Add(property, value);
                }

                // create Entity and add to result
                var entity = new Eav.Data.Entity(Eav.Constants.TransientAppId, user.UserID, ContentTypeBuilder.Fake(ContentType), values, TitleField);
                result.Add(entity);
            }

            return(result);
        }
Exemplo n.º 3
0
        public DynamicEntity GetFirstMetadata(int id, bool isFolder)
        {
            var meta = GetFirstMetadataEntity(id, isFolder);

            if (meta == null)
            {
                var emptyMetadata = new Dictionary<string, object>();
                emptyMetadata.Add("Title", "");
                meta = new Eav.Data.Entity(0, "", emptyMetadata, "Title");
            }
            return new DynamicEntity(meta, new[] {Thread.CurrentThread.CurrentCulture.Name}, Sexy);
        }
Exemplo n.º 4
0
        private IEnumerable<IEntity> GetList()
        {
            EnsureConfigurationIsLoaded();

            var properties = Properties.Split(',').Select(p => p.Trim()).ToArray();
            var portalId = PortalSettings.Current.PortalId;

            // read all user Profiles
            ArrayList users;
            if (UserIds == "disabled")
                users = UserController.GetUsers(portalId);
            // read user Profiles of specified UserIds
            else
            {
                var userIds = UserIds.Split(',').Select(n => Convert.ToInt32(n)).ToArray();
                users = new ArrayList();
                foreach (var user in userIds.Select(userId => UserController.GetUserById(portalId, userId)))
                    users.Add(user);
            }

            // convert Profiles to Entities
            var result = new List<IEntity>();
            foreach (UserInfo user in users)
            {
                // add Profile-Properties
                var values = new Dictionary<string, object>();
                foreach (var property in properties)
                {
                    string value;
                    switch (property.ToLower())
                    {
                        case "displayname":
                            value = user.DisplayName;
                            break;
                        case "email":
                            value = user.Email;
                            break;
                        case "firstname":
                            value = user.FirstName;
                            break;
                        case "lastname":
                            value = user.LastName;
                            break;
                        case "username":
                            value = user.Username;
                            break;
                        default:
                            value = user.Profile.GetPropertyValue(property);
                            break;
                    }

                    values.Add(property, value);
                }

                // create Entity and add to result
                var entity = new Eav.Data.Entity(user.UserID, ContentType, values, TitleField);
                result.Add(entity);
            }

            return result;
        }