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


C# SPList类代码示例

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


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

示例1: BatchDeleteItems

        public static void BatchDeleteItems(SPList splTask, SPQuery query,SPWeb web)
        {
            // Set up the variables to be used.
            StringBuilder methodBuilder = new StringBuilder();
            string batch = string.Empty;
            string batchFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                                "<Batch onError=\"Return\">{0}</Batch>";

            string methodFormat = "<Method ID=\"{0}\">" +
                "<SetList Scope=\"Request\">{1}</SetList>" +
                "<SetVar Name=\"ID\">{2}</SetVar>" +
                "<SetVar Name=\"Cmd\">Delete</SetVar>" +
                "</Method>";

            // Get the list containing the items to update.
            //PList list = WorkFlowUtil.GetWorkflowList(listName);

            // Query to get the unprocessed items.

            SPListItemCollection unprocessedItems = splTask.GetItems(query);

            // Build the CAML delete commands.
            foreach (SPListItem item in unprocessedItems)
            {
                methodBuilder.AppendFormat(methodFormat, "1", item.ParentList.ID, item.ID.ToString());
            }

            // Put the pieces together.
            batch = string.Format(batchFormat, methodBuilder.ToString());

            // Process the batch of commands.
            string batchReturn = web.ProcessBatchData(batch.ToString());
        }
开发者ID:porter1130,项目名称:C-A,代码行数:33,代码来源:Program.cs

示例2: SetLookupToList

        /// <summary>
        /// Sets the lookup to a list.
        /// </summary>
        /// <param name="fieldCollection">The field collection.</param>
        /// <param name="fieldId">The field identifier of the lookup field.</param>
        /// <param name="lookupList">The lookup list.</param>
        /// <exception cref="System.ArgumentNullException">
        /// fieldCollection
        /// or
        /// fieldId
        /// or
        /// lookupList
        /// </exception>
        /// <exception cref="System.ArgumentException">Unable to find the lookup field.;fieldId</exception>
        public void SetLookupToList(SPFieldCollection fieldCollection, Guid fieldId, SPList lookupList)
        {
            if (fieldCollection == null)
            {
                throw new ArgumentNullException("fieldCollection");
            }

            if (fieldId == null)
            {
                throw new ArgumentNullException("fieldId");
            }

            if (lookupList == null)
            {
                throw new ArgumentNullException("lookupList");
            }

            this.logger.Info("Start method 'SetLookupToList' for field id: '{0}'", fieldId);

            // Get the field.
            SPFieldLookup lookupField = this.fieldLocator.GetFieldById(fieldCollection, fieldId) as SPFieldLookup;
            if (lookupField == null)
            {
                throw new ArgumentException("Unable to find the lookup field.", "fieldId");
            }

            // Configure the lookup field.
            this.SetLookupToList(lookupField, lookupList);

            this.logger.Info("End method 'SetLookupToList'.");
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:45,代码来源:FieldLookupHelper.cs

示例3: GetListItemCollection

        internal SPListItemCollection GetListItemCollection(SPList spList, string keyOne, string valueOne, string keyTwo, string valueTwo,string keyThree, string valueThree)
        {
            // Return list item collection based on the lookup field

            SPField spFieldOne = spList.Fields[keyOne];
            SPField spFieldTwo = spList.Fields[keyTwo];
            SPField spFieldThree = spList.Fields[keyThree];
            var query = new SPQuery
            {
                Query = @"<Where>
                          <And>
                             <And>
                                <Eq>
                                   <FieldRef Name=" + spFieldOne.InternalName + @" />
                                   <Value Type=" + spFieldOne.Type.ToString() + @">" + valueOne + @"</Value>
                                </Eq>
                                <Eq>
                                   <FieldRef Name=" + spFieldTwo.InternalName + @" />
                                   <Value Type=" + spFieldTwo.Type.ToString() + @">" + valueTwo + @"</Value>
                                </Eq>
                             </And>
                             <Eq>
                                <FieldRef Name=" + spFieldThree.InternalName + @" />
                                <Value Type=" + spFieldThree.Type.ToString() + @">" + valueThree + @"</Value>
                             </Eq>
                          </And>
                       </Where>"
            };

            return spList.GetItems(query);
        }
开发者ID:Praveenmanne,项目名称:LeaveApplication,代码行数:31,代码来源:EmployeeLeavesListUserControl.ascx.cs

示例4: CreateField

        internal override void CreateField(SPList list)
        {
            if (!list.Fields.ContainsFieldWithStaticName(InternalName))
            {
                list.Fields.Add(InternalName, SPFieldType.Choice, Required);
            }

            var field = (SPFieldChoice) list.Fields.GetFieldByInternalName(InternalName);
            field.Description = Description;

            field.Choices.Clear();

            foreach (var choice in this.Choices)
            {
                field.Choices.Add(choice);
            }
            field.EditFormat = this.EditFormat;
            field.FillInChoice = this.FillInChoice;
            field.DefaultValue = this.DefaultValue;
            if (EnforceUniqueValues)
            {
                field.Indexed = true;
                field.EnforceUniqueValues = true;
            }
            field.ValidationFormula = ValidationFormula;
            field.ValidationMessage = ValidationMessage;
            field.Title = Name;
            field.AllowDeletion = true;
            field.Update();
        }
开发者ID:setsunafjava,项目名称:vpsp,代码行数:30,代码来源:ChoiceFieldCreator.cs

示例5: Execute

		// Executes the expression tree that is passed to it. 
		internal static object Execute(SPList list, Expression expression, bool isEnumerable)
		{
			// The expression must represent a query over the data source. 
			if (!IsQueryOverDataSource(expression))
				throw new InvalidProgramException("No query over the data source was specified.");

			var caml = (new CamlTranslator()).Translate(null, expression);

			var query = new SPQuery();

			var viewFieldsXml = caml.Element(Tags.ViewFields);
			var rowLimitXml = caml.Element(Tags.RowLimit);
			var queryXml = caml.Elements()
				.Where(n => n.Name != Tags.ViewFields && n.Name != Tags.RowLimit)
				.ToList();

			query.Query = (new XElement(Tags.Query, queryXml)).Value;
			if (viewFieldsXml != null)
			{
				query.ViewFields = viewFieldsXml.Value;
				query.ViewFieldsOnly = true;
			}
			if (rowLimitXml != null)
			{
				query.RowLimit = (int)rowLimitXml.Value;
			}

			return list.GetItems(query);
		}
开发者ID:s-KaiNet,项目名称:Untech.SharePoint,代码行数:30,代码来源:SpQueryContext.cs

示例6: CheckandAddEntry

 public static void CheckandAddEntry(SPList configurationList, Guid ProjectGuid, Project Project_Svc)
 {
     try
     {
         // Checking whether the project id is already available.
         var query = new SPQuery
         {
             Query =
                 @"<Where><Eq><FieldRef Name='" + ProjectUIDFieldName + "' /><Value Type='Text'>" + ProjectGuid.ToString() + "</Value></Eq></Where>"
         };
         var ProjectItemCollection = configurationList.GetItems(query);
         if (ProjectItemCollection.Count == 0)
         {
             configurationList.ParentWeb.Site.RootWeb.AllowUnsafeUpdates = true;
             SPListItem item = configurationList.Items.Add();
             //first project name
             item["Title"] = Project_Svc.GetProjectNameFromProjectUid(ProjectGuid, DataStoreEnum.WorkingStore);
             item[GroupFieldName] = DefaultGroupValue;
             item[ProjectUIDFieldName] = ProjectGuid.ToString();
             item.Update();
             configurationList.ParentWeb.Site.RootWeb.Update();
         }
     }
     catch (Exception ex)
     {
         ErrorLog("Error at adding configuration item to the list due to " + ex.Message, EventLogEntryType.Error);
     }
 }
开发者ID:Santhoshonet,项目名称:ProjectGovernanceReport,代码行数:28,代码来源:MyUtilities.cs

示例7: EnsureVersioningControl

        private void EnsureVersioningControl(SPList list)
        {
            var temp = list.ParentWeb.AllowUnsafeUpdates;

            try
            {
                list.ParentWeb.AllowUnsafeUpdates = true;

                list.EnableVersioning = true;
                list.EnableModeration = true;

                //enable minor versions for documents
                list.EnableMinorVersions = true;

                //set maximum limits for major/minor versions
                list.MajorVersionLimit = 5;
                list.MajorWithMinorVersionsLimit = 5;

                list.Update();
            }
            catch { }
            finally
            {
                list.ParentWeb.AllowUnsafeUpdates = temp;
            }
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:26,代码来源:PublishItemActivity.cs

示例8: Import_Firma

        private static void Import_Firma(Microsoft.SharePoint.SPWeb web, SPList list)
        {
            list.Items.Cast<SPListItem>()
                .Where(i => i["colTypRekordu"].ToString() == "Firma")
                .ToList()
                .ForEach(item =>
                {
                    string nazwaSkrocona = item["colNazwaSkrocona"] != null ? item["colNazwaSkrocona"].ToString() : string.Empty;
                    string nazwa = item["colNazwa"] != null ? item["colNazwa"].ToString() : string.Empty;
                    int klientId = tabKlienci.Get_KlientByNazwaSkrocona(web, nazwaSkrocona);

                    if (!string.IsNullOrEmpty(nazwa)
                        && !string.IsNullOrEmpty(nazwaSkrocona)
                        && klientId > 0)
                    {
                        int firmaId = tabKlienci.Get_FirmaByNazwa(web, nazwaSkrocona, nazwa);

                        if (firmaId == 0)
                        {
                            firmaId = tabKlienci.AddNew_Firma_Klient(web, item, klientId);

                            item["selKlient"] = firmaId;
                            item.SystemUpdate();
                        }

                    }
                });
        }
开发者ID:fraczo,项目名称:Animus,代码行数:28,代码来源:ImportKlientow.cs

示例9: CreateField

        internal override void CreateField(SPList list)
        {
            if (!list.Fields.ContainsFieldWithStaticName(InternalName))
            {
                list.Fields.Add(InternalName, SPFieldType.Note, Required);
            }
            else
            {
                var oldField = list.Fields.GetFieldByInternalName(InternalName);
                if (!oldField.Type.Equals(SPFieldType.Note))
                {
                    oldField.Type = SPFieldType.Note;
                    oldField.Update();
                }
            }

            var field = (SPFieldMultiLineText) list.Fields.GetFieldByInternalName(InternalName);
            field.Description = this.Description;
            field.NumberOfLines = this.NumberOfLines;
            field.RichText = this.RichText;
            if (this.RichText)
            {
                field.RichTextMode = this.RichTextMode;
            }

            field.AppendOnly = this.AppendOnly;
            field.Title = this.Name;
            field.AllowDeletion = true;
            field.Update();
        }
开发者ID:setsunafjava,项目名称:vpsp,代码行数:30,代码来源:MultipleLinesTextFieldCreator.cs

示例10: CleanList

        private static void CleanList(SPList list)
        {
            if (list == null)
                throw new ArgumentNullException("list");

            SPQuery spQuery = CreateGetAllItemsQuery();

            int batchNumber = 1;

            while (true)
            {
                // get ids of items to be deleted
                SPListItemCollection items = list.GetItems(spQuery);
                if (items.Count <= 0)
                    break;

                string batchDeleteXmlCommand = GetBatchDeleteXmlCommand(list, items);

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                RunDeleteBatch(list, batchDeleteXmlCommand);

                stopwatch.Stop();

                Console.WriteLine(string.Format("Processed batch #{0} of {1} items in {2} second(s)", batchNumber, BatchSize, stopwatch.ElapsedMilliseconds / 1000.0));
                batchNumber++;
            }
        }
开发者ID:Aleksey-Kudryavtsev,项目名称:BatchDelete,代码行数:29,代码来源:Program.cs

示例11: GenerateValidImageName

 public static string GenerateValidImageName(string fileName, SPList pictureLibrary)
 {
     //Check if new image name validates
     int i = 0;
     string temp = fileName;
     string extention = Path.GetExtension(fileName);
     SPQuery query = new SPQuery(pictureLibrary.DefaultView);
     SPListItemCollection imageCollection;
     do
     {
         i++;
         query.ViewFields = "<Where><Eq><FieldRef Name='LinkFilename' /><Value Type='Computed'>" + fileName + "</Value></Eq></Where>";
         imageCollection = pictureLibrary.GetItems(query);
         if (imageCollection.Count > 0)
         {
             fileName = temp;
             string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName) + " " + i;
             fileName = fileNameWithoutExtension + extention;
         }
         else {
             break;
         }
     } while (imageCollection.Count > 0);
     return fileName;
 }
开发者ID:chutinhha,项目名称:news-announcement,代码行数:25,代码来源:NewsUtil.cs

示例12: GetCostsFromMonth

        private static SPListItemCollection GetCostsFromMonth(SPList costs, SPListItemCollection delegationsForSelectedMonth)
        {
            StringBuilder delegationIDBuilder = new StringBuilder();
            foreach (SPListItem delegationItem in delegationsForSelectedMonth)
            {
                delegationIDBuilder.AppendFormat("<Value Type='Lookup'>{0}</Value>", delegationItem["ID"]);
            }

            string costsForSelectedDelagationsQueryString = string.Format(
                "<Where>" +
                    "<In>" +
                        "<FieldRef Name='{0}' LookupId='TRUE'/>" +
                            "<Values>" +
                                "{1}" +
                            "</Values>" +
                    "</In>" +
                "</Where>",
                DelegationsFields.Delegation.Name,
                delegationIDBuilder);

            SPQuery costsForSelectedDelegationsQuery = new SPQuery();
            costsForSelectedDelegationsQuery.Query = costsForSelectedDelagationsQueryString;

            SPListItemCollection monthlyCosts = costs.GetItems(costsForSelectedDelegationsQuery);
            return monthlyCosts;
        }
开发者ID:radata,项目名称:lsolilo-sharepoint,代码行数:26,代码来源:ReportJobDefinition.cs

示例13: setColumnsToDisplayName

        private DataTable setColumnsToDisplayName(DataTable dat, SPList list)
        {
            foreach (DataColumn dc in dat.Columns)
            {

                dc.ColumnName = list.Fields.GetFieldByInternalName(dc.ColumnName).Id.ToString();

            }
            foreach (DataColumn dc in dat.Columns)
            {

                string colName = list.Fields[new Guid(dc.ColumnName)].Title;
                if (dat.Columns.Contains(colName))
                {
                    int i = 1;
                    while (dat.Columns.Contains(colName + "_" + i.ToString()))
                    {
                        i++;
                    }
                    colName = colName + "_" + i.ToString();
                }
                dc.ColumnName = colName;

            }

            return dat;
        }
开发者ID:SoftArtisans,项目名称:OfficeWriter-SharePoint-Solutions-Gallery,代码行数:27,代码来源:Gen.aspx.cs

示例14: AddFeedback

        /// <summary>
        /// Adds the Feedback.
        /// </summary>
        internal void AddFeedback(SPList feedbackList, string userID, Feedback feedbackInfo)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    //Adds the new Feedback to the current folder.
                    SPFolder currentFolder = feedbackList.Folders[feedbackList.Folders.Count - 1].Folder;
                    ;
                    SPListItem newItem = feedbackList.Items.Add(currentFolder.ServerRelativeUrl, SPFileSystemObjectType.File, null);
                    newItem["Title"] = userID + "_" + DateTime.Now.ToString("MMM-dd-yyyy");
                    newItem["Rating"] = feedbackInfo.Rating;
                    newItem["Reason for Rating"] = feedbackInfo.Reason;
                    newItem["Additional Information"] = feedbackInfo.AdditionalInformation;
                    newItem["Type of Feedback"] = feedbackInfo.TypeofFeedback;
                    newItem["Page Level Comment"] = feedbackInfo.Comment;
                    if(feedbackInfo.TypeofFeedback.ToString() == GENERALFEEDBACK)
                        newItem["Page Name"] = string.Empty;
                    else
                        newItem["Page Name"] = feedbackInfo.PageName;
                    if(feedbackInfo.FileAttached != null)
                    {
                        newItem.Attachments.Add(feedbackInfo.FileName, feedbackInfo.FileAttached);
                    }

                    newItem.Update();
                });
            }
            catch(Exception)
            {
                throw;
            }
        }
开发者ID:vijaymca,项目名称:Dotnet,代码行数:36,代码来源:FeedbackHandler.cs

示例15: Insert

        public void Insert(SPList mediaList, MediaAsset asset, out int id, out string contentTypeId)
        {
            var item = mediaList.Items.Add();
            item["ContentTypeId"] = GetContentTypeId(mediaList, asset.MediaType.ToString());
            item["Title"] = asset.Title;
            item[new Guid(MediaAssetsColumns.TempLocation)] = asset.TempLocation;
            item[new Guid(MediaAssetsColumns.Format)] = asset.Format;
            item[new Guid(MediaAssetsColumns.ProcStatus)] = Enum.GetName(typeof(ProcessingStatus), asset.Status);
            if (!String.IsNullOrEmpty(asset.Location))
            {
                item[new Guid(MediaAssetsColumns.Location)] = asset.Location;
            }
            if (!String.IsNullOrEmpty(asset.Thumbnail))
            {
                item[new Guid(MediaAssetsColumns.Thumbnail)] = asset.Thumbnail;
            }
            if (!String.IsNullOrEmpty(asset.Poster))
            {
                item[new Guid(MediaAssetsColumns.Poster)] = asset.Poster;
            }
            if ((asset.MediaType == MediaType.Audio || asset.MediaType == MediaType.Video) && asset.Duration != TimeSpan.MinValue)
            {
                item[new Guid(MediaAssetsColumns.Length)] = asset.Duration.TotalSeconds;
            }
            item.Update();

            id = item.ID;
            contentTypeId = item.ContentTypeId.ToString();
        }
开发者ID:TellagoDevLabs,项目名称:CloudPoint,代码行数:29,代码来源:MediaRepository.cs


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