当前位置: 首页>>代码示例>>C#>>正文


C# FieldCollection.GetByInternalNameOrTitle方法代码示例

本文整理汇总了C#中FieldCollection.GetByInternalNameOrTitle方法的典型用法代码示例。如果您正苦于以下问题:C# FieldCollection.GetByInternalNameOrTitle方法的具体用法?C# FieldCollection.GetByInternalNameOrTitle怎么用?C# FieldCollection.GetByInternalNameOrTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FieldCollection的用法示例。


在下文中一共展示了FieldCollection.GetByInternalNameOrTitle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetWSSId

        /// <summary>
        /// Function to get the WssID for the Practice group, Area of law and Sub area of law terms
        /// </summary>
        /// <param name="clientContext">SP client context</param>
        /// <param name="matterMetadata">Object containing meta data for Matter</param>
        /// <param name="fields">Field Collection object</param>
        /// <returns>An Object containing meta data for Matter</returns>
        internal static MatterMetadata GetWSSId(ClientContext clientContext, MatterMetadata matterMetadata, FieldCollection fields)
        {
            ClientResult<TaxonomyFieldValue> practiceGroupResult = clientContext.CastTo<TaxonomyField>
                (fields.GetByInternalNameOrTitle(ServiceConstantStrings.ContentTypeColumnPracticeGroup))
                .GetFieldValueAsTaxonomyFieldValue(matterMetadata.PracticeGroupTerm.Id);
            ClientResult<TaxonomyFieldValue> areaOfLawResult = clientContext.CastTo<TaxonomyField>
                (fields.GetByInternalNameOrTitle(ServiceConstantStrings.ContentTypeColumnAreaOfLaw))
                .GetFieldValueAsTaxonomyFieldValue(matterMetadata.AreaTerm.Id);
            ClientResult<TaxonomyFieldValue> subareaOfLawResult = clientContext.CastTo<TaxonomyField>
                (fields.GetByInternalNameOrTitle(ServiceConstantStrings.ContentTypeColumnSubareaOfLaw))
                .GetFieldValueAsTaxonomyFieldValue(matterMetadata.SubareaTerm.Id);
            clientContext.ExecuteQuery();

            matterMetadata.PracticeGroupTerm.WssId = practiceGroupResult.Value.WssId;
            matterMetadata.AreaTerm.WssId = areaOfLawResult.Value.WssId;
            matterMetadata.SubareaTerm.WssId = subareaOfLawResult.Value.WssId;
            return matterMetadata;
        }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:25,代码来源:ProvisionHelperFunctionsUtility.cs

示例2: FindField

        private Field FindField(FieldCollection fields, ContentTypeFieldLinkDefinition listFieldLinkModel)
        {
            var context = fields.Context;

            var scope = new ExceptionHandlingScope(context);

            Field field = null;

            if (listFieldLinkModel.FieldId.HasGuidValue())
            {
                var id = listFieldLinkModel.FieldId.Value;

                using (scope.StartScope())
                {
                    using (scope.StartTry())
                    {
                        fields.GetById(id);
                    }

                    using (scope.StartCatch())
                    {

                    }
                }
            }
            else if (!string.IsNullOrEmpty(listFieldLinkModel.FieldInternalName))
            {
                var fieldInternalName = listFieldLinkModel.FieldInternalName;

                using (scope.StartScope())
                {
                    using (scope.StartTry())
                    {
                        fields.GetByInternalNameOrTitle(fieldInternalName);
                    }

                    using (scope.StartCatch())
                    {

                    }
                }
            }

            context.ExecuteQueryWithTrace();

            if (!scope.HasException)
            {
                if (listFieldLinkModel.FieldId.HasGuidValue())
                {
                    field = fields.GetById(listFieldLinkModel.FieldId.Value);
                }
                else if (!string.IsNullOrEmpty(listFieldLinkModel.FieldInternalName))
                {
                    field = fields.GetByInternalNameOrTitle(listFieldLinkModel.FieldInternalName);
                }

                context.Load(field);
                context.Load(field, f => f.SchemaXml);

                context.ExecuteQueryWithTrace();
            }

            return field;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:64,代码来源:ContentTypeFieldLinkModelHandler.cs

示例3: SetFieldValues

        /// <summary>
        /// Assign field values for specified content types to the specified matter (document library)
        /// </summary>
        /// <param name="matterMetadata">Object containing metadata for Matter</param>
        /// <param name="fields">Field Collection object</param>
        internal static void SetFieldValues(MatterMetadata matterMetadata, FieldCollection fields)
        {
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientId"]).DefaultValue = matterMetadata.Client.ClientId;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientId"]).ReadOnlyField = true;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientId"]).SetShowInDisplayForm(true);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientId"]).Update();
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientName"]).ReadOnlyField = true;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientName"]).SetShowInDisplayForm(true);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientName"]).DefaultValue = matterMetadata.Client.ClientName;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnClientName"]).Update();

            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterId"]).DefaultValue = matterMetadata.Matter.MatterId;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterId"]).ReadOnlyField = true;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterId"]).SetShowInDisplayForm(true);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterId"]).Update();
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterName"]).DefaultValue = matterMetadata.Matter.MatterName;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterName"]).ReadOnlyField = true;
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterName"]).SetShowInDisplayForm(true);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnMatterName"]).Update();
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnPracticeGroup"]).DefaultValue = string.Format(CultureInfo.InvariantCulture, Constants.MetadataDefaultValue, matterMetadata.PracticeGroupTerm.WssId, matterMetadata.PracticeGroupTerm.TermName, matterMetadata.PracticeGroupTerm.Id);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnPracticeGroup"]).SetShowInDisplayForm(true);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnPracticeGroup"]).Update();
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnAreaOfLaw"]).DefaultValue = string.Format(CultureInfo.InvariantCulture, Constants.MetadataDefaultValue, matterMetadata.AreaTerm.WssId, matterMetadata.AreaTerm.TermName, matterMetadata.AreaTerm.Id);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnAreaOfLaw"]).SetShowInDisplayForm(true);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnAreaOfLaw"]).Update();
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnSubareaOfLaw"]).DefaultValue = string.Format(CultureInfo.InvariantCulture, Constants.MetadataDefaultValue, matterMetadata.SubareaTerm.WssId, matterMetadata.SubareaTerm.TermName, matterMetadata.SubareaTerm.Id);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnSubareaOfLaw"]).SetShowInDisplayForm(true);
            fields.GetByInternalNameOrTitle(ConfigurationManager.AppSettings["ContentTypeColumnSubareaOfLaw"]).Update();
        }
开发者ID:Microsoft,项目名称:mattercenter,代码行数:34,代码来源:MatterProvisionHelper.cs

示例4: GetWSSId

 /// <summary>
 /// Function to get the WssID for all the managed columns that user has configured
 /// </summary>
 /// <param name="clientContext">SP client context</param>
 /// <param name="matterMetadata">Object containing meta data for Matter</param>
 /// <param name="fields">Field Collection object</param>
 /// <returns>An Object containing meta data for Matter</returns>
 private MatterMetadata GetWSSId(ClientContext clientContext, MatterMetadata matterMetadata, FieldCollection fields)
 {
     try
     {
         int levels = taxonomySettings.Levels;
         //For the number of levels that are configured, get the configured column name for each level and get the wssid and 
         //update the ManagedColumnTerms object with wssid
         for (int i = 1; i <= levels; i++)
         {
             string columnName = configuration.GetSection("ContentTypes").GetSection("ManagedColumns")["ColumnName" + i];
             ClientResult<TaxonomyFieldValue> managedColumnWSSId = clientContext.CastTo<TaxonomyField>
             (fields.GetByInternalNameOrTitle(columnName))
             .GetFieldValueAsTaxonomyFieldValue(matterMetadata.ManagedColumnTerms[columnName].Id);
             clientContext.ExecuteQuery();
             matterMetadata.ManagedColumnTerms[columnName].WssId = managedColumnWSSId.Value.WssId;
         }
         return matterMetadata;
     }
     catch(Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw ex;
     }
 }
开发者ID:Microsoft,项目名称:mattercenter,代码行数:31,代码来源:SPContentTypes.cs

示例5: RemoveFieldFromContentType

        private void RemoveFieldFromContentType(FieldCollection webFields, string fieldNameToRemove,
            ContentType contentType)
        {
            // Need to load content type fields every iteration because fields are added to the collection
            Field webField = webFields.GetByInternalNameOrTitle(fieldNameToRemove);
            FieldLinkCollection contentTypeFields = contentType.FieldLinks;
            ClientContext.Load(contentTypeFields);
            ClientContext.Load(webField);
            ClientContext.ExecuteQuery();

            var fieldLink =
                contentTypeFields.FirstOrDefault(
                    existingFieldName => existingFieldName.Name == fieldNameToRemove);
            if (fieldLink != null)
            {
                fieldLink.DeleteObject();
            }
            contentType.Update(true);
            ClientContext.ExecuteQuery();
        }
开发者ID:olemp,项目名称:sherpa,代码行数:20,代码来源:ContentTypeManager.cs

示例6: AddOrUpdateFieldOfContentType

        private void AddOrUpdateFieldOfContentType(ShContentType configContentType, FieldCollection webFields,
            string fieldName,
            ContentType contentType)
        {
            // Need to load content type fields every iteration because fields are added to the collection
            Field webField = webFields.GetByInternalNameOrTitle(fieldName);
            FieldLinkCollection contentTypeFields = contentType.FieldLinks;
            ClientContext.Load(contentTypeFields);
            ClientContext.Load(webField);
            ClientContext.ExecuteQuery();

            var fieldLink = contentTypeFields.FirstOrDefault(existingFieldName => existingFieldName.Name == fieldName);
            if (fieldLink == null)
            {
                var link = new FieldLinkCreationInformation {Field = webField};
                fieldLink = contentType.FieldLinks.Add(link);
            }

            fieldLink.Required = configContentType.RequiredFields.Contains(fieldName);
            fieldLink.Hidden = configContentType.HiddenFields.Contains(fieldName);

            contentType.Update(true);
            ClientContext.ExecuteQuery();
        }
开发者ID:olemp,项目名称:sherpa,代码行数:24,代码来源:ContentTypeManager.cs

示例7: SetItemValue

        private void SetItemValue(FieldCollection fields, ListItem item, string field, object value)
        {
            if (_doNotWantFields.IsMatch(field)) return;

            item[field] = value;
            var lookupField = fields.GetByInternalNameOrTitle(field) as FieldLookup;
            if (lookupField == null) return;

            int lookupId;
            if (!int.TryParse("" + value, out lookupId)) return;

            lookupId = GetId(lookupField.LookupList, lookupId);
            if (lookupId >= 0) item[field] = lookupId;
        }
开发者ID:eirikb,项目名称:jsonlist,代码行数:14,代码来源:Import.cs

示例8: Read

        private SPOField Read(FieldCollection fields)
        {
            var ctx = SPOSiteContext.CurrentSiteContext.Context;
            Field field = null;
            if (this.FieldId != Guid.Empty)
            {
                field = fields.GetById(this.FieldId);
            }
            else if (!string.IsNullOrEmpty(this.FieldNameOrTitle))
            {
                field = fields.GetByInternalNameOrTitle(this.FieldNameOrTitle);
            }
            if (field != null)
            {
                _field = field;
                ctx.Load(field);
                ctx.ExecuteQuery();

                if (field.ServerObjectIsNull.Value)
                    return null;

                return new SPOField(_field);
            }
            return null;
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:25,代码来源:SPOFieldPipeBind.cs

示例9: GetPrimaryLookupField

        protected virtual FieldLookup GetPrimaryLookupField(FieldCollection fields, DependentLookupFieldDefinition definition)
        {
            var context = fields.Context;

            Field result = null;

            if (definition.PrimaryLookupFieldId.HasGuidValue())
                result = fields.GetById(definition.PrimaryLookupFieldId.Value);

            if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldInternalName))
                result = fields.GetByInternalNameOrTitle(definition.PrimaryLookupFieldInternalName);

            if (!string.IsNullOrEmpty(definition.PrimaryLookupFieldTitle))
                result = fields.GetByTitle(definition.PrimaryLookupFieldTitle);

            context.Load(result);
            context.ExecuteQuery();

            return context.CastTo<FieldLookup>(result);
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:20,代码来源:DependentLookupFieldModelHandler.cs

示例10: GetDependentLookupField

        protected virtual FieldLookup GetDependentLookupField(FieldCollection fields, 
            DependentLookupFieldDefinition definition)
        {
            var context = fields.Context;

            Field field = null;

            var scope = new ExceptionHandlingScope(context);

            using (scope.StartScope())
            {
                using (scope.StartTry())
                {
                    fields.GetByInternalNameOrTitle(definition.InternalName);
                }

                using (scope.StartCatch())
                {

                }
            }

            TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "ExecuteQuery()");
            context.ExecuteQueryWithTrace();

            if (!scope.HasException)
            {
                field = fields.GetByInternalNameOrTitle(definition.InternalName);
                context.Load(field);

                context.ExecuteQueryWithTrace();

                return context.CastTo<FieldLookup>(field);
            }

            return null;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:37,代码来源:DependentLookupFieldModelHandler.cs

示例11: GetField

 internal static SPOField GetField(CmdletContext ctx, FieldCollection fields, string nameOrTitle)
 {
     Field field = fields.GetByInternalNameOrTitle(nameOrTitle);
     ctx.Load(field);
     ctx.ExecuteQuery();
     if (!field.ServerObjectIsNull.Value)
     {
         return new SPOField(field);
     }
     return null;
 }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:11,代码来源:SPOField.cs


注:本文中的FieldCollection.GetByInternalNameOrTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。