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


C# SPList.Update方法代码示例

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


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

示例1: Create_Column

        private static void Create_Column(SPList list, string targetColumn)
        {
            SPFieldText f = (SPFieldText)list.Fields.CreateNewField(SPFieldType.Text.ToString(), targetColumn);

            list.Fields.Add(f);
            list.Update();
        }
开发者ID:fraczo,项目名称:BR5,代码行数:7,代码来源:Tools.cs

示例2: Delete

        /// <summary>
        /// Deletes the specified list.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        internal static void Delete(SPList list, bool force)
        {
            if (list == null)
                throw new SPException("List not found.");

            if (!list.AllowDeletion && force)
            {
                list.AllowDeletion = true;
                list.Update();
            }
            else if (!list.AllowDeletion)
                throw new SPException("List cannot be deleted.  Try using the '-force' parameter to force the delete.");

            try
            {
                list.Delete();
            }
            catch (Exception)
            {
                if (force)
                {
                    using (SPSite site = new SPSite(list.ParentWeb.Site.ID))
                    {
                        Utilities.RunStsAdmOperation(
                            string.Format(" -o forcedeletelist -url \"{0}\"",
                                          site.MakeFullUrl(list.RootFolder.ServerRelativeUrl)), false);
                    }
                }
            }
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:35,代码来源:DeleteList.cs

示例3: BreakRoleInheritance

 /// <summary>
 ///   Breaks the role assignment inheritance for the list and gives the current list its own copy of the role assignments.
 /// </summary>
 /// <param name = "list"></param>
 /// <param name = "copyRoleAssigements"></param>
 public static void BreakRoleInheritance(SPList list, bool copyRoleAssigements)
 {
     if (!list.HasUniqueRoleAssignments)
     {
         list.BreakRoleInheritance(copyRoleAssigements);
         list.Update();
     }
 }
开发者ID:bebikashg,项目名称:ttqn,代码行数:13,代码来源:SecurityHelper.cs

示例4: SetTargeting

        internal static void SetTargeting(bool enabled, SPList list)
        {
            if (list == null)
                throw new SPException("List was not found.");

            SPField targetingField = GetTargetingField(list);
            if (enabled && (targetingField == null))
            {
                string createFieldAsXml = CreateFieldAsXml();
                list.Fields.AddFieldAsXml(createFieldAsXml);
                list.Update();
            }
            else if (!enabled && (targetingField != null))
            {
                list.Fields.Delete(targetingField.InternalName);
                list.Update();
            }
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:18,代码来源:ListAudienceTargeting.cs

示例5: DeleteField

        public static void DeleteField(string fieldName, SPList list)
        {
            if (list.Fields.ContainsField(fieldName))
            {
                list.Fields.Delete(fieldName);
            }

            list.Update();
        }
开发者ID:Mission3,项目名称:migrations,代码行数:9,代码来源:SPFieldHelper.cs

示例6: AddEventReceivers

        /// <summary>
        /// ����¼�������
        /// </summary>
        /// <param name="list">�б�</param>
        /// <param name="t">�¼�������������</param>
        /// <param name="eventTypes">�¼�����</param>
        public static void AddEventReceivers(SPList list, Type t, params SPEventReceiverType[] eventTypes)
        {
            string assambly = t.Assembly.FullName;
            string className = t.FullName;

            foreach (SPEventReceiverType et in eventTypes)
            {
                list.EventReceivers.Add(et, assambly, className);
            }

            list.Update();
        }
开发者ID:porter1130,项目名称:C-A,代码行数:18,代码来源:EventReceiverManager.cs

示例7: InsertDateFieldToList

        public static void InsertDateFieldToList(string fieldName, string displayName, SPList list)
        {
            if (list.Fields.ContainsField(fieldName))
            {
                list.Fields.Delete(fieldName);
            }

            SPFieldDateTime textField = (SPFieldDateTime)list.Fields.CreateNewField(SPFieldType.DateTime.ToString(), fieldName);
            textField.Title = displayName;
            list.Fields.Add(textField);

            list.Update();
        }
开发者ID:Mission3,项目名称:migrations,代码行数:13,代码来源:SPFieldHelper.cs

示例8: DeleteLookupField

        public static void DeleteLookupField(string lookupList, SPList list)
        {
            for (int i = 0; i < list.Fields.Count; i++)
            {
                SPField field = list.Fields[i];
                if (field.Title.Contains(lookupList + ":"))
                {
                    list.Fields.Delete(field.Title);
                    i--;
                }
            }

            list.Update();
        }
开发者ID:Mission3,项目名称:migrations,代码行数:14,代码来源:SPFieldHelper.cs

示例9: InsertFormulaFieldToList

        public static void InsertFormulaFieldToList(string fieldName, string displayName, SPList list, string formula, SPFieldType type, SPNumberFormatTypes format)
        {
            if (list.Fields.ContainsField(fieldName))
            {
                list.Fields.Delete(fieldName);
            }

            string temp = list.Fields.Add(displayName, SPFieldType.Calculated, false);
            SPFieldCalculated f = (SPFieldCalculated)list.Fields[temp];
            f.Formula = formula;
            f.OutputType = type;
            f.DisplayFormat = format;
            f.Update();
            list.Update();
        }
开发者ID:Mission3,项目名称:migrations,代码行数:15,代码来源:SPFieldHelper.cs

示例10: InsertDependentFields

        public static void InsertDependentFields(string primaryLookupName, SPList list, string relatedList, SPWeb web, string lookupColumn)
        {
            if (list.Fields.ContainsField(primaryLookupName + ":" + lookupColumn))
            {
                list.Fields.Delete(primaryLookupName + ":" + lookupColumn);
            }

            SPFieldLookup lookupField = (SPFieldLookup)list.Fields.GetField(primaryLookupName);

            string secondaryColumn = list.Fields.AddDependentLookup(primaryLookupName + ":" + lookupColumn, lookupField.Id);
            SPFieldLookup newDependencyLookupField = (SPFieldLookup)list.Fields.GetFieldByInternalName(secondaryColumn);
            newDependencyLookupField.LookupField = web.Lists.TryGetList(relatedList).Fields[lookupColumn].InternalName;
            newDependencyLookupField.Update();

            list.Update();
        }
开发者ID:Mission3,项目名称:migrations,代码行数:16,代码来源:SPFieldHelper.cs

示例11: FolderExists

        public static void FolderExists(SPWeb web, string folderName, SPList list, SPListItem listItem)
        {
            //Check folder exist in the SPWeb or not

            SPListItem listFolder = null;
            bool folderExists = false;
            // Check to see if folder already exists, if not create it
            for (int i = 0; i < list.Folders.Count; i++)
            {
                if (list.Folders[i].Folder.Name == folderName)
                {
                    listFolder = list.Folders[i];
                    listItem = list.Items.Add(listFolder.Folder.ServerRelativeUrl, SPFileSystemObjectType.File, null);
                    web.AllowUnsafeUpdates = true;
                    listItem.Update();
                }
            }

            // The folder does not exist so we create it and add the item

            if (!folderExists)
            {
                listFolder = list.Items.Add(list.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, folderName);
                listFolder.Update();
                listFolder["Title"] = folderName;

                SPListItem newListItem = list.Items.Add(listFolder.Folder.ServerRelativeUrl, SPFileSystemObjectType.File, null);
                web.AllowUnsafeUpdates = true;
                foreach (SPField field in listItem.Fields)
                {
                    if (field.ReadOnlyField
                     || field.Id == SPBuiltInFieldId.Attachments)
                        continue;
                    newListItem[field.Id] = listItem[field.Id];
                }

                newListItem.Update();

                list.Update();
            }
        }
开发者ID:fraczo,项目名称:bba-pumps,代码行数:41,代码来源:Folders.cs

示例12: EnsureSlaveFields

        public static bool EnsureSlaveFields(SPList list, string fieldInternalName)
        {
            bool unsafeUpdatesChanged = false;
            bool allowUnsafeUpdates = false;
            bool slaveFieldsHaveNotBeenCreated = true;

            foreach (SPField field in list.Fields)
            {
                //проверка, что это наш тип поля
                if (field.TypeAsString != "CustomExternalLookup" && field.TypeAsString != "CustomExternalLookupMulti")
                    continue;

                //попытка получения текущего поля
                if (list.Fields.TryGetFieldByStaticName(fieldInternalName + "ID") == null)
                {
                    SPFieldCollection fields = list.Fields;

                    var slaveField = new SPField(fields, SPFieldType.Note.ToString(), fieldInternalName + "ID")
                                         {
                                             Hidden = true,
                                             RelatedField = fieldInternalName
                                         };

                    allowUnsafeUpdates = list.ParentWeb.AllowUnsafeUpdates;
                    list.ParentWeb.AllowUnsafeUpdates = true;
                    unsafeUpdatesChanged = true;

                    fields.Add(slaveField);

                    list.Update();

                    slaveFieldsHaveNotBeenCreated = false;
                }
            }

            if(unsafeUpdatesChanged)
                list.ParentWeb.AllowUnsafeUpdates = allowUnsafeUpdates;

            return slaveFieldsHaveNotBeenCreated;
        }
开发者ID:BarsukovDmitry,项目名称:CustomExternalLookup,代码行数:40,代码来源:SharedModule.cs

示例13: AddListToPage

        public XsltListViewWebPart AddListToPage(SPList list, string title, string zone, SPLimitedWebPartManager webPartManager, int index)
        {
            // validation
            list.RequireNotNull("list");
            title.RequireNotNullOrEmpty("title");
            zone.RequireNotNullOrEmpty("zone");
            webPartManager.RequireNotNull("webPartManager");
            index.Require(index >= 0, "index");

            XsltListViewWebPart wp = new XsltListViewWebPart();
            wp.ListName = list.ID.ToString("B").ToUpper();
            wp.Title = title;
            wp.ZoneID = zone;
            ModifyViewClass viewOperations = new ModifyViewClass();
            SPView defaultView = viewOperations.GetDefaultView(list);
            SPView modifiedView = viewOperations.CopyView(defaultView, list);
            viewOperations.SetToolbarType(modifiedView, "Standard");
            modifiedView.Update();
            wp.ViewGuid = modifiedView.ID.ToString("B").ToUpper();
            webPartManager.AddWebPart(wp, zone, index);
            list.Update();
            webPartManager.SaveChanges(wp);
            return wp;
        }
开发者ID:utdcometsoccer,项目名称:MySP2010Utilities,代码行数:24,代码来源:WebPartOperations.cs

示例14: RemoveEventReceivers

        /// <summary>
        /// ɾ���¼�������
        /// </summary>
        /// <param name="list"></param>
        /// <param name="t"></param>
        public static void RemoveEventReceivers( SPList list, Type t )
        {
            string assambly = t.Assembly.FullName;
            string className = t.FullName;

            for (int i = list.EventReceivers.Count - 1; i >= 0; i--)
            {
                SPEventReceiverDefinition def = list.EventReceivers[i];

                if (def.Class == className)
                    def.Delete();
            }

            list.Update();
        }
开发者ID:porter1130,项目名称:C-A,代码行数:20,代码来源:EventUtil.cs

示例15: EnsureWorkflowAssociation

        // nie używana procedura

        //public static void AssociateWorkflowWithList(SPWeb web, string listName, string workflowTemplateBaseGuid, string workflowAssociationName)
        //{
        //    SPList list = web.Lists.TryGetList(listName);
        //    if (list != null)
        //    {
        //        var existingAssociation = list.WorkflowAssociations.GetAssociationByName(workflowAssociationName, CultureInfo.CurrentCulture);
        //        if (existingAssociation == null)
        //        {
        //            // Create the workflow association
        //            SPList taskList = EnsureListExist(web, workflowTaskListName);
        //            SPList historyList = EnsureListExist(web, workflowHistoryListName);

        //            //Create a worklow manager and associate the Workflow template to the list

        //            SPWorkflowManager workflowManager = web.Site.WorkflowManager;
        //            SPWorkflowTemplateCollection templates = workflowManager.GetWorkflowTemplatesByCategory(web, null);
        //            SPWorkflowTemplate template = templates.GetTemplateByBaseID(new Guid(workflowTemplateBaseGuid));
        //            SPWorkflowAssociation association = SPWorkflowAssociation.CreateListAssociation(template, template.Name, taskList, historyList);
        //            association.AllowManual = true;
        //            association.AutoStartCreate = true;
        //            list.WorkflowAssociations.Add(association);
        //            list.Update();
        //            association.Enabled = true;

        //            Debug.WriteLine("List.Workflow: " + workflowAssociationName + " associated");
                    
        //        }
        //    }
        //}


        public static void EnsureWorkflowAssociation(SPList list, string workflowTemplateName, string associationName, bool allowManual, bool startCreate, bool startUpdate)
        {
            var web = list.ParentWeb;
            var lcid = (int)web.Language;
            var defaultCulture = new CultureInfo(lcid);

            // Create the workflow association
            SPList taskList = EnsureListExist(web, workflowTaskListName);
            SPList historyList = EnsureListExist(web, workflowHistoryListName);

            var workflowAssociation =
                list.WorkflowAssociations.Cast<SPWorkflowAssociation>().FirstOrDefault(i => i.Name == associationName);
            if (workflowAssociation != null)
            {
                list.WorkflowAssociations.Remove(workflowAssociation);
                list.Update();
            }

            var template = web.WorkflowTemplates.GetTemplateByName(workflowTemplateName, defaultCulture);
            var association = SPWorkflowAssociation.CreateListAssociation(template, associationName, taskList, historyList);

            association.AllowManual = true;
            association.AutoStartChange = true;
            association.AutoStartCreate = true;

            list.WorkflowAssociations.Add(association);
            list.Update();

            association = list.WorkflowAssociations[association.Id];
            association.AllowManual = allowManual;
            association.AutoStartChange = startUpdate;
            association.AutoStartCreate = startCreate;
            association.AssociationData = "<Dummy></Dummy>";
            association.Enabled = true;
            list.WorkflowAssociations.Update(association);
            list.Update();

            Debug.WriteLine("Ensure.List.Workflow: " + associationName + " associated");

        }
开发者ID:fraczo,项目名称:Biuromagda,代码行数:73,代码来源:Workflows.cs


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