Пример #1
0
        /// <summary>
        /// Creates the lists of columns descriptors <see cref="PRColumn" />.
        /// </summary>
        /// <param name="sPFieldCollection">The s p field collection.</param>
        /// <param name="selected">The selected.</param>
        /// <param name="listsDictionary">The lists dictionary.</param>
        internal static List <PRColumn> CreatePRColumns(IEnumerable <SPField> sPFieldCollection, Func <string, SPFieldType, bool> selected, Dictionary <Guid, PRList> listsDictionary)
        {
            List <PRColumn> _ret = new List <PRColumn>();

            foreach (SPField _SPFieldX in sPFieldCollection)
            {
                PRColumn _PRColumn = CreatePRColumn(_SPFieldX, listsDictionary, selected);
                if (_PRColumn == null)
                {
                    continue;
                }
                _ret.Add(_PRColumn);
            }
            _ret.Sort((x, y) => { return(x.Name.CompareTo(y.Name)); });
            return(_ret);
        }
Пример #2
0
        //http://msdn.microsoft.com/en-us/library/office/ee535721(v=office.15).aspx
        private static PRColumn CreatePRColumn(SPField sPField, Dictionary <Guid, PRList> listsDictionary, Func <string, SPFieldType, bool> selected)
        {
            SPFieldLookup _spFieldLookup = sPField as SPFieldLookup;
            PRList        _lookupList    = null;

            if (_spFieldLookup != null)
            {
                if (_spFieldLookup.IsDependentLookup)
                {
                    return(null);
                }
                Guid _lookupListid = _spFieldLookup.LookupList.GuidTryParse();
                if (_lookupListid.Equals(Guid.Empty))
                {
                    return(null);
                }
                if (listsDictionary.ContainsKey(_lookupListid))
                {
                    _lookupList = listsDictionary[_lookupListid];
                }
                else
                {
                    _lookupList = PRList.Create(_lookupListid, listsDictionary);
                }
                Debug.Assert(_lookupList != null);
            }
            else
            {
                Debug.Assert(sPField.Type != SPFieldType.Lookup);
            }
            PRColumn _PRColumn = new PRColumn()
            {
                Checked       = selected(sPField.InternalName, sPField.Type),
                Member        = sPField.InternalName.SQLName(),
                Name          = sPField.InternalName,
                Type          = PRType.Enum, //http://msdn.microsoft.com/en-us/library/office/ee536245(v=office.15).aspx
                TypeSpecified = false,
                FieldType     = sPField.Type,
                ListLookup    = _lookupList,
                SQLDataType   = sPField.Type.SQLDataType(),
                SQLNullable   = !sPField.Required,
                SQLPrecision  = -1,
            };

            return(_PRColumn);
        }
Пример #3
0
        private static PRContentType CreatePRContentType(SPContentType contentType, Dictionary <Guid, PRList> listsDictionary, Func <string, bool, bool> selected)
        {
            List <PRColumn> _columns         = PRColumn.CreatePRColumns(contentType.Fields.Cast <SPField>(), (name, type) => type.IsSPFieldTypeSupported(), listsDictionary);
            PRContentType   _baseContentType = null;

            if (contentType.Id != SPBuiltInContentTypeId.System)
            {
                _baseContentType = PRContentType.CreatePRContentType(contentType.Parent, listsDictionary, (x, y) => false);
            }
            PRContentType _ret = new PRContentType()
            {
                Class                = contentType.Name,
                Checked              = selected(contentType.Group, contentType.Hidden),
                Column               = _columns.ToArray <PRColumn>(),
                SPContentTypeId      = contentType.Id,
                ExcludeColumn        = null,
                ExcludeOtherColumns  = null,
                IncludeHiddenColumns = null,
                Name            = contentType.Name,
                BaseContentType = _baseContentType
            };

            return(_ret);
        }