Ejemplo n.º 1
0
        public List<SecureFieldInfo> LoadSecureFields()
        {
            var query = new QueryExpression("fieldpermission")
            {
                ColumnSet = new ColumnSet(true)
            };

            var fields = service.RetrieveMultiple(query).Entities.ToList();

            var fieldsInfos = new List<SecureFieldInfo>();

            foreach (var field in fields)
            {
                var fieldInfo =
                    fieldsInfos.FirstOrDefault(fi => fi.Entity == field.GetAttributeValue<string>("entityname")
                                                     && fi.Attribute ==
                                                     field.GetAttributeValue<string>("attributelogicalname"));

                if (fieldInfo == null)
                {
                    fieldInfo = new SecureFieldInfo
                    {
                        Attribute = field.GetAttributeValue<string>("attributelogicalname"),
                        Entity = field.GetAttributeValue<string>("entityname"),
                    };

                    fieldsInfos.Add(fieldInfo);
                }

                fieldInfo.Fields.Add(field);
            }

            return fieldsInfos;
        }
Ejemplo n.º 2
0
        public List <SecureFieldInfo> LoadSecureFields()
        {
            var query = new QueryExpression("fieldpermission")
            {
                ColumnSet = new ColumnSet(true)
            };

            var fields = service.RetrieveMultiple(query).Entities.ToList();

            var fieldsInfos = new List <SecureFieldInfo>();

            foreach (var field in fields)
            {
                var fieldInfo =
                    fieldsInfos.FirstOrDefault(fi => fi.Entity == field.GetAttributeValue <string>("entityname") &&
                                               fi.Attribute ==
                                               field.GetAttributeValue <string>("attributelogicalname"));

                if (fieldInfo == null)
                {
                    fieldInfo = new SecureFieldInfo
                    {
                        Attribute = field.GetAttributeValue <string>("attributelogicalname"),
                        Entity    = field.GetAttributeValue <string>("entityname"),
                    };

                    fieldsInfos.Add(fieldInfo);
                }

                fieldInfo.Fields.Add(field);
            }

            return(fieldsInfos);
        }