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


C# Microsoft.Update方法代码示例

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


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

示例1: Provision

        public override void Provision(Microsoft.SharePoint.Client.ClientContext context, Microsoft.SharePoint.Client.Web web)
        {
            //get the web's property bag
            var props = web.AllProperties;
            context.Load(props);
            context.ExecuteQuery();

            //set the ContosoBusinessImpact property and update
            props["ContosoBusinessImpact"] = cboSensitivity.SelectedValue;
            web.Update();
            context.ExecuteQuery();

            //call the base
            base.Provision(context, web);
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:15,代码来源:BusinessImpactProvisioningModule.ascx.cs

示例2: UpdateContentType

        private static void UpdateContentType(Web web, Microsoft.SharePoint.Client.ContentType existingContentType, ContentType templateContentType, TokenParser parser, PnPMonitoredScope scope)
        {
            var isDirty = false;
            if (existingContentType.Hidden != templateContentType.Hidden)
            {
                scope.LogPropertyUpdate("Hidden");
                existingContentType.Hidden = templateContentType.Hidden;
                isDirty = true;
            }
            if (existingContentType.ReadOnly != templateContentType.ReadOnly)
            {
                scope.LogPropertyUpdate("ReadOnly");
                existingContentType.ReadOnly = templateContentType.ReadOnly;
                isDirty = true;
            }
            if (existingContentType.Sealed != templateContentType.Sealed)
            {
                scope.LogPropertyUpdate("Sealed");
                existingContentType.Sealed = templateContentType.Sealed;
                isDirty = true;
            }
            if (templateContentType.Description != null && existingContentType.Description != parser.ParseString(templateContentType.Description))
            {
                scope.LogPropertyUpdate("Description");
                existingContentType.Description = parser.ParseString(templateContentType.Description);
                isDirty = true;
            }
            if (templateContentType.DocumentTemplate != null && existingContentType.DocumentTemplate != parser.ParseString(templateContentType.DocumentTemplate))
            {
                scope.LogPropertyUpdate("DocumentTemplate");
                existingContentType.DocumentTemplate = parser.ParseString(templateContentType.DocumentTemplate);
                isDirty = true;
            }
            if (existingContentType.Name != parser.ParseString(templateContentType.Name))
            {
                scope.LogPropertyUpdate("Name");
                existingContentType.Name = parser.ParseString(templateContentType.Name);
                isDirty = true;
            }
            if (templateContentType.Group != null && existingContentType.Group != parser.ParseString(templateContentType.Group))
            {
                scope.LogPropertyUpdate("Group");
                existingContentType.Group = parser.ParseString(templateContentType.Group);
                isDirty = true;
            }
            if (isDirty)
            {
                existingContentType.Update(true);
                web.Context.ExecuteQueryRetry();
            }
            // Delta handling
            List<Guid> targetIds = existingContentType.FieldLinks.AsEnumerable().Select(c1 => c1.Id).ToList();
            List<Guid> sourceIds = templateContentType.FieldRefs.Select(c1 => c1.Id).ToList();

            var fieldsNotPresentInTarget = sourceIds.Except(targetIds).ToArray();

            if (fieldsNotPresentInTarget.Any())
            {
                foreach (var fieldId in fieldsNotPresentInTarget)
                {
                    var fieldRef = templateContentType.FieldRefs.Find(fr => fr.Id == fieldId);
                    var field = web.Fields.GetById(fieldId);
                    scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Adding_field__0__to_content_type, field.Id);
                    web.AddFieldToContentType(existingContentType, field, fieldRef.Required, fieldRef.Hidden);
                }
            }

            isDirty = false;
            foreach (var fieldId in targetIds.Intersect(sourceIds))
            {
                var fieldLink = existingContentType.FieldLinks.FirstOrDefault(fl => fl.Id == fieldId);
                var fieldRef = templateContentType.FieldRefs.Find(fr => fr.Id == fieldId);
                if (fieldRef != null)
                {
                    scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Field__0__exists_in_content_type, fieldId);
                    if (fieldLink.Required != fieldRef.Required)
                    {
                        scope.LogPropertyUpdate("Required");
                        fieldLink.Required = fieldRef.Required;
                        isDirty = true;
                    }
                    if (fieldLink.Hidden != fieldRef.Hidden)
                    {
                        scope.LogPropertyUpdate("Hidden");
                        fieldLink.Hidden = fieldRef.Hidden;
                        isDirty = true;
                    }
                }
            }
            if (isDirty)
            {
                existingContentType.Update(true);
                web.Context.ExecuteQueryRetry();
            }
        }
开发者ID:rrocham,项目名称:PnP-Sites-Core,代码行数:95,代码来源:ObjectContentType.cs

示例3: UpdateContentType

        private static void UpdateContentType(Web web, Microsoft.SharePoint.Client.ContentType existingContentType, ContentType templateContentType, TokenParser parser, PnPMonitoredScope scope)
        {
            var isDirty = false;
            if (existingContentType.Hidden != templateContentType.Hidden)
            {
                scope.LogPropertyUpdate("Hidden");
                existingContentType.Hidden = templateContentType.Hidden;
                isDirty = true;
            }
            if (existingContentType.ReadOnly != templateContentType.ReadOnly)
            {
                scope.LogPropertyUpdate("ReadOnly");
                existingContentType.ReadOnly = templateContentType.ReadOnly;
                isDirty = true;
            }
            if (existingContentType.Sealed != templateContentType.Sealed)
            {
                scope.LogPropertyUpdate("Sealed");
                existingContentType.Sealed = templateContentType.Sealed;
                isDirty = true;
            }
            if (templateContentType.Description != null && existingContentType.Description != parser.ParseString(templateContentType.Description))
            {
                scope.LogPropertyUpdate("Description");
                existingContentType.Description = parser.ParseString(templateContentType.Description);
                isDirty = true;
            }
            if (templateContentType.DocumentTemplate != null && existingContentType.DocumentTemplate != parser.ParseString(templateContentType.DocumentTemplate))
            {
                scope.LogPropertyUpdate("DocumentTemplate");
                existingContentType.DocumentTemplate = parser.ParseString(templateContentType.DocumentTemplate);
                isDirty = true;
            }
            if (existingContentType.Name != parser.ParseString(templateContentType.Name))
            {
                scope.LogPropertyUpdate("Name");
                existingContentType.Name = parser.ParseString(templateContentType.Name);
                isDirty = true;
                // CT is being renamed, add an extra token to the tokenparser
                parser.AddToken(new ContentTypeIdToken(web, existingContentType.Name, existingContentType.StringId));
            }
            if (templateContentType.Group != null && existingContentType.Group != parser.ParseString(templateContentType.Group))
            {
                scope.LogPropertyUpdate("Group");
                existingContentType.Group = parser.ParseString(templateContentType.Group);
                isDirty = true;
            }
            if (templateContentType.DisplayFormUrl != null && existingContentType.DisplayFormUrl != parser.ParseString(templateContentType.DisplayFormUrl))
            {
                scope.LogPropertyUpdate("DisplayFormUrl");
                existingContentType.DisplayFormUrl = parser.ParseString(templateContentType.DisplayFormUrl);
                isDirty = true;
            }
            if (templateContentType.EditFormUrl != null && existingContentType.EditFormUrl != parser.ParseString(templateContentType.EditFormUrl))
            {
                scope.LogPropertyUpdate("EditFormUrl");
                existingContentType.EditFormUrl = parser.ParseString(templateContentType.EditFormUrl);
                isDirty = true;
            }
            if (templateContentType.NewFormUrl != null && existingContentType.NewFormUrl != parser.ParseString(templateContentType.NewFormUrl))
            {
                scope.LogPropertyUpdate("NewFormUrl");
                existingContentType.NewFormUrl = parser.ParseString(templateContentType.NewFormUrl);
                isDirty = true;
            }
            #if !CLIENTSDKV15
            if (templateContentType.Name.ContainsResourceToken())
            {
                existingContentType.NameResource.SetUserResourceValue(templateContentType.Name, parser);
                isDirty = true;
            }
            if (templateContentType.Description.ContainsResourceToken())
            {
                existingContentType.DescriptionResource.SetUserResourceValue(templateContentType.Description, parser);
                isDirty = true;
            }
            #endif
            if (isDirty)
            {
                existingContentType.Update(true);
                web.Context.ExecuteQueryRetry();
            }
            // Delta handling
            existingContentType.EnsureProperty(c => c.FieldLinks);
            List<Guid> targetIds = existingContentType.FieldLinks.AsEnumerable().Select(c1 => c1.Id).ToList();
            List<Guid> sourceIds = templateContentType.FieldRefs.Select(c1 => c1.Id).ToList();

            var fieldsNotPresentInTarget = sourceIds.Except(targetIds).ToArray();

            if (fieldsNotPresentInTarget.Any())
            {
                foreach (var fieldId in fieldsNotPresentInTarget)
                {
                    var fieldRef = templateContentType.FieldRefs.Find(fr => fr.Id == fieldId);
                    var field = web.Fields.GetById(fieldId);
                    scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Adding_field__0__to_content_type, fieldId);
                    web.AddFieldToContentType(existingContentType, field, fieldRef.Required, fieldRef.Hidden);
                }
            }

//.........这里部分代码省略.........
开发者ID:itacs,项目名称:PnP-Sites-Core,代码行数:101,代码来源:ObjectContentType.cs

示例4: DeployWebWorkflowAssociationDefinition

        private void DeployWebWorkflowAssociationDefinition(WebModelHost modelHost, Microsoft.SharePoint.SPWeb web, WorkflowAssociationDefinition definition)
        {
            var existingWorkflowAssotiation = FindExistringWorkflowAssotiation(modelHost, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = existingWorkflowAssotiation,
                ObjectType = typeof(SPWorkflowAssociation),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            bool isNew = false;

            if (existingWorkflowAssotiation == null)
            {
                var workflowTemplate = GetWorkflowTemplate(modelHost, definition);

                if (workflowTemplate == null)
                {
                    throw new SPMeta2Exception(
                        string.Format("Cannot find workflow template by definition:[{0}]", definition));
                }

                existingWorkflowAssotiation = SPWorkflowAssociation.CreateListAssociation(workflowTemplate,
                           definition.Name,
                           web.Lists[definition.TaskListTitle],
                           web.Lists[definition.HistoryListTitle]);

                isNew = true;
            }

            MapProperties(definition, existingWorkflowAssotiation);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = existingWorkflowAssotiation,
                ObjectType = typeof(SPWorkflowAssociation),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            if (isNew)
            {
                web.WorkflowAssociations.Add(existingWorkflowAssotiation);
                web.Update();
            }
            else
            {
                web.WorkflowAssociations.Update(existingWorkflowAssotiation);
            }
        }
开发者ID:maratbakirov,项目名称:spmeta2,代码行数:58,代码来源:WorkflowAssociationModelHandler.cs

示例5: UpdateContentType

        private static void UpdateContentType(Web web, Microsoft.SharePoint.Client.ContentType existingContentType, ContentType templateContentType)
        {
            var isDirty = false;
            if (existingContentType.Hidden != templateContentType.Hidden)
            {
                existingContentType.Hidden = templateContentType.Hidden;
                isDirty = true;
            }
            if (existingContentType.ReadOnly != templateContentType.ReadOnly)
            {
                existingContentType.ReadOnly = templateContentType.ReadOnly;
                isDirty = true;
            }
            if (existingContentType.Sealed != templateContentType.Sealed)
            {
                existingContentType.Sealed = templateContentType.Sealed;
                isDirty = true;
            }
            if (templateContentType.Description != null && existingContentType.Description != templateContentType.Description.ToParsedString())
            {
                existingContentType.Description = templateContentType.Description.ToParsedString();
                isDirty = true;
            }
            if (templateContentType.DocumentTemplate != null && existingContentType.DocumentTemplate != templateContentType.DocumentTemplate.ToParsedString())
            {
                existingContentType.DocumentTemplate = templateContentType.DocumentTemplate.ToParsedString();
                isDirty = true;
            }
            if (existingContentType.Name != templateContentType.Name.ToParsedString())
            {
                existingContentType.Name = templateContentType.Name.ToParsedString();
                isDirty = true;
            }
            if (templateContentType.Group != null && existingContentType.Group != templateContentType.Group.ToParsedString())
            {
                existingContentType.Group = templateContentType.Group.ToParsedString();
                isDirty = true;
            }
            if (isDirty)
            {
                existingContentType.Update(true);
                web.Context.ExecuteQueryRetry();
            }
            // Delta handling
            List<Guid> targetIds = existingContentType.FieldLinks.AsEnumerable().Select(c1 => c1.Id).ToList();
            List<Guid> sourceIds = templateContentType.FieldRefs.Select(c1 => c1.Id).ToList();

            var fieldsNotPresentInTarget = sourceIds.Except(targetIds).ToArray();
            
            if (fieldsNotPresentInTarget.Any())
            {
                foreach (var fieldId in fieldsNotPresentInTarget)
                {
                    var fieldRef = templateContentType.FieldRefs.Find(fr => fr.Id == fieldId);
                    var field = web.Fields.GetById(fieldId);
                    web.AddFieldToContentType(existingContentType, field, fieldRef.Required, fieldRef.Hidden);
                }
            }

            isDirty = false;
            foreach (var fieldId in targetIds.Intersect(sourceIds))
            {
                var fieldLink = existingContentType.FieldLinks.FirstOrDefault(fl => fl.Id == fieldId);
                var fieldRef = templateContentType.FieldRefs.Find(fr => fr.Id == fieldId);
                if (fieldRef != null)
                {
                 
                    if (fieldLink.Required != fieldRef.Required)
                    {
                        fieldLink.Required = fieldRef.Required;
                        isDirty = true;
                    }
                    if (fieldLink.Hidden != fieldRef.Hidden)
                    {
                        fieldLink.Hidden = fieldRef.Hidden;
                        isDirty = true;
                    }
                }
            }
            if (isDirty)
            {
                existingContentType.Update(true);
                web.Context.ExecuteQueryRetry();
            }
        }
开发者ID:nats31,项目名称:PnP,代码行数:85,代码来源:ObjectContentType.cs

示例6: CreateContentType

 /// <summary>
 /// Creates the type of the content.
 /// </summary>
 /// <param name="clientContext">The client context.</param>
 /// <param name="web">Object of site</param>
 /// <param name="siteColumns">The site columns.</param>
 /// <param name="contentTypeName">Name of Content Type</param>
 internal static bool CreateContentType(ClientContext clientContext, Microsoft.SharePoint.Client.Web web, List<string> siteColumns, string contentTypeName, string contentTypegroup)
 {
     bool status = true;
     ContentType parentContentType = null;
     try
     {
         ContentTypeCollection contentTypeCollection = web.ContentTypes;
         clientContext.Load(contentTypeCollection);
         clientContext.Load(web.Fields);
         clientContext.ExecuteQuery();
         parentContentType = (from ct in contentTypeCollection
                              where ct.Name == ServiceConstantStrings.OneDriveParentContentType
                              select ct).FirstOrDefault();
         ContentTypeCreationInformation contentType = new ContentTypeCreationInformation();
         contentType.Name = contentTypeName;
         contentType.Group = contentTypegroup;
         ///// contentType.Id = "0x010100B1ED198475FB3A4AABC59AAAD89B7EAD";
         if (parentContentType != null)
         {
             contentType.ParentContentType = parentContentType;
         }
         ContentType finalObj = web.ContentTypes.Add(contentType);
         AddColumnsToContentType(web, siteColumns, finalObj);
         web.Update();
         clientContext.ExecuteQuery();
     }
     catch (Exception exception)
     {
         status = false;
         Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
     }
     return status;
 }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:40,代码来源:BriefcaseContentTypeHelperFunctions.cs

示例7: CreateSiteColumn

 /// <summary>
 /// Creates site column.
 /// </summary>
 /// <param name="clientContext">Client Context</param>
 /// <param name="web">Object of site</param>
 /// <param name="siteColumns">List of site columns</param>
 /// <returns>Success or Failure</returns>
 internal static bool CreateSiteColumn(ClientContext clientContext, Microsoft.SharePoint.Client.Web web, List<string> siteColumns)
 {
     bool result = false;
     try
     {
         FieldCollection fieldCol = web.Fields;
         clientContext.Load(fieldCol);
         clientContext.ExecuteQuery();
         List<Field> existingFields = fieldCol.ToList<Field>();
         foreach (string columns in siteColumns)
         {
             Field field = (from fld in existingFields
                            where fld.Title == columns && fld.TypeAsString == ServiceConstantStrings.OneDriveSiteColumnType
                            select fld).FirstOrDefault();
             if (null == field)
             {
                 web.Fields.AddFieldAsXml(string.Format(CultureInfo.InvariantCulture, ServiceConstantStrings.OneDriveSiteColumnSchema, ServiceConstantStrings.OneDriveSiteColumn, ServiceConstantStrings.OneDriveContentTypeGroup), true, AddFieldOptions.DefaultValue);
                 web.Update();
                 clientContext.ExecuteQuery();
             }
         }
         result = true;
     }
     catch (Exception exception)
     {
         Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
         result = false;
     }
     return result;
 }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:37,代码来源:BriefcaseContentTypeHelperFunctions.cs

示例8: IsContentTypePresentCheck

        /// <summary>
        /// Determines whether the content type exists in the content type group under the specified client context.  
        /// </summary>
        /// <param name="clientContext">Client context</param>
        /// <param name="web">Object of site</param>
        /// <param name="receivedContentType">Type of the received content</param>
        /// <param name="contentTypeGroup">The content type group</param>
        /// <param name="siteColumns">List of site columns</param>
        internal static bool IsContentTypePresentCheck(ClientContext clientContext, Microsoft.SharePoint.Client.Web web, string receivedContentType, string contentTypeGroup, List<string> siteColumns)
        {
            bool status = true;
            try
            {
                ContentTypeCollection contentTypeCollection = web.ContentTypes;
                clientContext.Load(contentTypeCollection, contentTypes => contentTypes.Include(contentTypeProperties => contentTypeProperties.Group, contentTypeProperties => contentTypeProperties.Name).Where(contentTypeValues => (contentTypeValues.Group == ServiceConstantStrings.OneDriveContentTypeGroup) && (contentTypeValues.Name == ServiceConstantStrings.OneDriveContentTypeName)));
                clientContext.ExecuteQuery();

                if (0 < contentTypeCollection.Count)
                {
                    FieldCollection fields = contentTypeCollection[0].Fields;
                    clientContext.Load(fields, field => field.Include(fieldType => fieldType.Title).Where(column => column.Title == ServiceConstantStrings.OneDriveSiteColumn));
                    clientContext.ExecuteQuery();
                    if (0 == fields.Count)
                    {
                        BriefcaseContentTypeHelperFunctions.AddColumnsToContentType(web, siteColumns, contentTypeCollection[0]);
                        web.Update();
                        clientContext.ExecuteQuery();
                    }
                }
                else
                {
                    status = BriefcaseContentTypeHelperFunctions.CreateContentType(clientContext, web, siteColumns, receivedContentType, contentTypeGroup);
                }
            }
            catch (Exception exception)
            {
                status = false;
                Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
            }
            return status;
        }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:41,代码来源:BriefcaseContentTypeHelperFunctions.cs

示例9: SendIndividualDocument

 /// <summary>
 /// Sends individual document to OneDrive
 /// </summary>
 /// <param name="clientContext">SP client context</param>
 /// <param name="collectionOfAttachments">Dictionary object containing attachment URLs and their stream data</param>
 /// <param name="listItemsColl">List item collection of Legal Briefcase folder</param>
 /// <param name="allAttachmentUrl">A string array containing all the attachment URLs</param>
 /// <param name="web">Object of site</param>
 /// <param name="usersMySite">My Site URL of the user</param>
 /// <param name="collectionOfOriginalAttachments">Dictionary object containing attachment URLs</param>
 /// <param name="defaultContentTypeId">Default content type Id</param>
 /// <param name="status">Status of documents sent to OneDrive</param>
 /// <returns>Status of documents sent to OneDrive</returns>
 internal static string SendIndividualDocument(ClientContext clientContext, Dictionary<string, Stream> collectionOfAttachments, ListItemCollection listItemsColl, string[] allAttachmentUrl, Microsoft.SharePoint.Client.Web web, string usersMySite, Dictionary<string, string> collectionOfOriginalAttachments, string defaultContentTypeId, string status)
 {
     int documentCount = 0, count = 0;
     string fileNameKey = string.Empty;
     string overwriteDocumentURLs = string.Empty;
     foreach (string key in collectionOfAttachments.Keys)
     {
         fileNameKey = key.Split(new string[] { ConstantStrings.DOLLAR }, StringSplitOptions.RemoveEmptyEntries)[0];
         var selectedItems = from li in listItemsColl.Cast<ListItem>()
                             from files in li.Folder.Files
                             where files.Name.ToUpperInvariant() == fileNameKey.ToUpperInvariant()
                             select files;
         if (selectedItems.FirstOrDefault() != null)
         {
             overwriteDocumentURLs += allAttachmentUrl[count] + ConstantStrings.Semicolon;
         }
         else
         {
             SendDocumentToOneDrive(web, usersMySite, fileNameKey, collectionOfAttachments[key], collectionOfOriginalAttachments[key], defaultContentTypeId);
             documentCount++;
         }
         count++;
         web.Update();
         clientContext.ExecuteQuery();
         MailAttachmentDetails.CheckoutFailedPosition++;
         status = string.Concat(usersMySite, ServiceConstantStrings.OneDriveDocumentLibraryTitle, ConstantStrings.Semicolon, documentCount, ConstantStrings.Semicolon, collectionOfAttachments.Count, ConstantStrings.Semicolon, overwriteDocumentURLs);
     }
     return status;
 }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:42,代码来源:BriefcaseUtilityHelperFunctions.cs


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