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


C# SPList.GetItemById方法代码示例

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


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

示例1: getApprovalEntryNames

 private void getApprovalEntryNames(SPList currentList)
 {
     SPListItem currentItem = currentList.GetItemById(__ListItem);
     if (currentItem[EntriesColumn] != null)
     {
         SPFieldLookupValueCollection entries = new SPFieldLookupValueCollection(currentItem[EntriesColumn].ToString());
         if (entries != null && entries.Count > 0)
         {
             foreach (SPFieldLookupValue entry in entries)
             {
                 _approvalEntries.Add(entry.LookupValue);
             }
             return;
         }
     }
     __ActivationProperties.LogToWorkflowHistory(SPWorkflowHistoryEventType.None, __ActivationProperties.Web.CurrentUser, "Skipped: There is no Approval Entry defined.", string.Empty);
 }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:17,代码来源:MultiEntriesApproval.cs

示例2: ClearOld

        private static void ClearOld(LinkedLookupSettings config, int listItemId, List<int> removeItems, SPField remoteLookup, SPList remoteList)
        {
            foreach (int id in removeItems)
            {
                SPListItem remoteItem;
                try
                {
                    remoteItem = remoteList.GetItemById(id);
                }
                catch
                {
                    continue;
                }

                // pokusit se z lookupu v remoteItemu smazat polozku, na ktere aktualne bezi receiver
                // pokud je to multilookup, chceme si zachovat zbytek hodnot
                if (( (SPFieldLookup) remoteLookup ).AllowMultipleValues && ( remoteItem[remoteLookup.InternalName] ?? "" ).ToString().Trim() != "")
                {
                    // stavajici obsah lookupu
                    SPFieldLookupValueCollection existingCollection = new SPFieldLookupValueCollection(( remoteItem[remoteLookup.InternalName] ?? "" ).ToString());
                    SPFieldLookupValue toRemove = existingCollection.FirstOrDefault(lookup => lookup.LookupId == listItemId);

                    // ze stavajiciho obsahu odstranime polozku, na ktere bezi receiver
                    if (toRemove != null) existingCollection.Remove(toRemove);

                    // upraveny obsah vratime zpatky
                    remoteItem[remoteLookup.InternalName] = existingCollection;
                }
                    // pokud je to jednoduchy lookup, a neni prazdny, proste tam nastavime aktualni polozku
                else if (( remoteItem[remoteLookup.InternalName] ?? "" ).ToString().Trim() != "")
                {
                    SPFieldLookupValue existingVal = new SPFieldLookupValue(( remoteItem[remoteLookup.InternalName] ?? "" ).ToString());
                    if (existingVal.LookupId == listItemId)
                    {
                        remoteItem[remoteLookup.InternalName] = null;
                    }
                }

                if (config.RegularUpdate)
                {
                    remoteItem.Update(false);
                }
                else
                {
                    // pokud jsou receivery na obou stranach, nechceme se dostat do smycky
                    remoteItem.SystemUpdate(config.UpdateVersion, false);
                }
            }
        }
开发者ID:NAVERTICA,项目名称:SPTools,代码行数:49,代码来源:LinkedLookup.cs

示例3: AddNew

        private static void AddNew(LinkedLookupSettings config, SPItemEventProperties props, List<int> addItems, SPField remoteLookup, SPList remoteList)
        {
            foreach (int id in addItems)
            {
                // najit odpovidajici remote listitem
                SPListItem remoteItem;
                try
                {
                    remoteItem = remoteList.GetItemById(id);
                }
                catch
                {
                    continue;
                }

                // do kazde z nich pridal lookup na nasi polozku
                // pokud je remoteLookup multilookup, overime, ze tam jeste neni, a pridame ke stavajicim
                if (( (SPFieldLookup) remoteLookup ).AllowMultipleValues)
                {
                    SPFieldLookupValueCollection existingCollection = ( remoteItem[remoteLookup.InternalName] ?? "" ).ToString().Trim() != "" ?
                        new SPFieldLookupValueCollection(remoteItem[remoteLookup.InternalName].ToString()) :
                        new SPFieldLookupValueCollection();

                    // zkontrolovat, jestli už tam dané ID není, ale ID, ktere menime!!!!
                    bool exists = existingCollection.Any(lookupVal => lookupVal.LookupId == props.ListItemId);

                    if (!exists)
                    {
                        existingCollection.Add(new SPFieldLookupValue(props.ListItemId,
                            ( props.AfterProperties[( (SPFieldLookup) remoteLookup ).LookupField] ??
                              props.ListItem[( (SPFieldLookup) remoteLookup ).LookupField] ).ToString()));

                        remoteItem[remoteLookup.InternalName] = existingCollection;
                    }
                }
                    // pokud je to single lookup, proste to tam pridame
                else
                {
                    if (props.AfterProperties[( (SPFieldLookup) remoteLookup ).LookupField] != null)
                    {
                        SPFieldLookupValue newVal = new SPFieldLookupValue(props.ListItemId,
                            props.AfterProperties[( (SPFieldLookup) remoteLookup ).LookupField].ToString());
                        remoteItem[remoteLookup.InternalName] = newVal;
                    }
                    else
                    {
                        SPFieldLookupValue newVal = new SPFieldLookupValue(props.ListItemId,
                            props.ListItem[( (SPFieldLookup) remoteLookup ).LookupField].ToString());
                        remoteItem[remoteLookup.InternalName] = newVal;
                    }
                }

                if (config.RegularUpdate)
                {
                    remoteItem.Update(false);
                }
                else
                {
                    // pokud jsou receivery na obou stranach, nechceme se dostat do smycky
                    remoteItem.SystemUpdate(config.UpdateVersion, false);
                }
            }
        }
开发者ID:NAVERTICA,项目名称:SPTools,代码行数:63,代码来源:LinkedLookup.cs

示例4: NewCompress

        void NewCompress(string sZipFileFullPathName,SPList sList)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                ZipOutputStream zs = new ZipOutputStream(File.Create(sZipFileFullPathName));//D:/project/Dowload/DownLoadFile/1-2-3.zip
                zs.SetLevel(0);

                foreach (string sId in sIDS.Split('-'))
                {
                    SPListItem item = sList.GetItemById(int.Parse(sId));
                    iParentFolderLength=item.Url.LastIndexOf('/')+1;
                    NewCreateZip(item, zs);
                }
                zs.Finish();
                zs.Close();
                GC.Collect();
            });
        }
开发者ID:porter1130,项目名称:C-A,代码行数:18,代码来源:DownloadZipRequest.aspx.cs

示例5: UpdateRequestDetail

 private SPFieldLookupValue UpdateRequestDetail(SPList RequestDetailList, int id, string productName, string quantity, string price, string description)
 {
     try
     {
         SPFieldLookupValue spFieldLookupValue = null;
         SPListItem RequestDetailItem = RequestDetailList.GetItemById(id);
         if (RequestDetailItem != null)
         {
             RequestDetailItem[SPBuiltInFieldId.Title] = productName;
             RequestDetailItem["Quantity"] = quantity;
             RequestDetailItem["Price"] = price;
             RequestDetailItem["Description"] = description;
             RequestDetailItem.Update();
             spFieldLookupValue = new SPFieldLookupValue(RequestDetailItem.ID, RequestDetailItem.Title);
         }
         return spFieldLookupValue;
     }
     catch (Exception ex)
     {
         return null;
         throw;
     }
 }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:23,代码来源:PurchaseEditForm.ascx.cs

示例6: Save

 public virtual void Save(SPList list)
 {
     if (ID == null)
     {
         // new item
         var item = list.Items.Add();
         SaveProperties(item);
         item.Update();
         ID = item.ID;
     }
     else
     {
         var item = list.GetItemById(ID.Value);
         SaveProperties(item);
         item.Update();
     }
 }
开发者ID:tiagosarri,项目名称:NoCaml,代码行数:17,代码来源:ListDefinition.cs

示例7: GetDataItem

        public virtual SPGENRepositoryDataItem GetDataItem(SPList list, int itemId, string[] fieldNames, bool includeAllItemFields, SPGENEntityFileOperationArguments fileOperationParams)
        {
            SPListItem listItem = (includeAllItemFields) ? list.GetItemById(itemId) : list.GetItemByIdSelectedFields(itemId, fieldNames);

            var dataItem = new SPGENRepositoryDataItem(fieldNames);
            ConvertToDataItem(listItem, dataItem, fileOperationParams);

            return dataItem;
        }
开发者ID:powareverb,项目名称:spgenesis,代码行数:9,代码来源:SPGENRepositoryManager.cs

示例8: Publish

        /// <summary>
        /// Publishes all list items for a given list.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="test">If true test the change only (don't make any changes).</param>
        /// <param name="comment">The comment.</param>
        /// <param name="takeOver">if set to <c>true</c> [take over].</param>
        /// <param name="filterExpression">The filter expression.</param>
        public void Publish(SPList list, bool test, string comment, bool takeOver, string filterExpression)
        {
            Logger.Write("Processing List: " + list.DefaultViewUrl);

            string source = "\"Publish-SPListItems\"";

            foreach (SPListItem item in list.Items)
            {
                PublishListItem(item, list, test, source, comment, filterExpression);
            }

            foreach (SPListItem item in list.Folders)
            {
                PublishListItem(item, list, test, source, comment, filterExpression);
            }

            if (list is SPDocumentLibrary && takeOver)
            {
                foreach (SPCheckedOutFile file in ((SPDocumentLibrary)list).CheckedOutFiles)
                {
                    file.TakeOverCheckOut();
                    SPListItem item = list.GetItemById(file.ListItemId);
                    PublishListItem(item, list, test, source, comment, filterExpression);
                }
            }

            Logger.Write("Finished Processing List: " + list.DefaultViewUrl + "\r\n");
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:36,代码来源:PublishItems.cs

示例9: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            ListId = Request.QueryString["List"];
            TaskList = Web.Lists[new Guid(ListId)];
            TaskItem = TaskList.GetItemById((Convert.ToInt32(Request.Params["ID"])));
            WorkflowInstanceId = new Guid((string)TaskItem["WorkflowInstanceID"]);
            WorkflowInstance = new SPWorkflow(Web, WorkflowInstanceId);
            ItemList = WorkflowInstance.ParentList;
            Item = ItemList.GetItemById(WorkflowInstance.ItemId);

            string urlToItem = Web.Site.MakeFullUrl(string.Format("{0}?ID={1}", ItemList.DefaultDisplayFormUrl, Item.ID.ToString()));

            string ItemName;
            if (Item.File != null)
            {
                ItemName = Item.File.Name;
            }
            else
            {
                ItemName = Item.Title;
            }

            lnkItem.Text = ItemName;
            lnkItem.NavigateUrl = urlToItem;

            lblListName.Text = ItemList.Title;
            lblSiteUrl.Text = Web.Url;

            if (TaskItem[SPBuiltInFieldId.TaskStatus].ToString()
                                                     .Equals(SPUtility.GetLocalizedString("$Resources:Completed;", "core", SPContext.Current.Web.Language)))
            {
                btnApprove.Visible = false;
                btnReject.Visible = false;
                txtComments.Text = TaskItem["Comments"].ToString();
                txtComments.Enabled = false;
            }
        }
开发者ID:porter1130,项目名称:Medalsoft,代码行数:37,代码来源:TaskEditForm.aspx.cs

示例10: CopyListItemsRoleAssignments

 public static void CopyListItemsRoleAssignments(SPList sourceList, SPList destinationList)
 {
     foreach (SPListItem sourceListitem in sourceList.Items) {
         CopyListItemRoleAssignments(sourceListitem, destinationList.GetItemById(sourceListitem.ID));
     }
 }
开发者ID:Netbah,项目名称:SharePoint,代码行数:6,代码来源:PermissionHelper.cs

示例11: GetItem

 public SPListItem GetItem(SPList list, int id)
 {
     SPListItem item = list.GetItemById(id);
     return item;
 }
开发者ID:porter1130,项目名称:C-A,代码行数:5,代码来源:SharePointService.cs

示例12: UpdateListItem

 public void UpdateListItem(SPList list, IDictionary dic , int id )
 {
     SPListItem item = list.GetItemById(id);
     foreach (string fieldName in dic.Keys)
     {
         item[fieldName] = dic[fieldName];
     }
     item.Update();
 }
开发者ID:porter1130,项目名称:C-A,代码行数:9,代码来源:SharePointService.cs

示例13: CopyNews

 private void CopyNews(int vnCatID, int enCatID, SPList enCatList, SPList vnNewsList, SPList enNewsList)
 {
     var enParentCat = new SPFieldLookupValue(enCatID, enCatList.GetItemById(enCatID).Title);
     string camlQuery = string.Format("<Where><Eq><FieldRef Name='{0}' LookupId='TRUE'/><Value Type='Lookup'>{1}</Value></Eq></Where>", FieldsName.NewsRecord.English.CategoryName, vnCatID);
     var query = new SPQuery();
     query.Query = camlQuery;
     var vnListItems = vnNewsList.GetItems(query);
     foreach (SPListItem item in vnListItems)
     {
         var enItem = enNewsList.Items.Add();
         enItem["Title"] = item["Title"];
         enItem[FieldsName.NewsRecord.English.CategoryName] = enParentCat;
         enItem[FieldsName.NewsRecord.English.PublishingPageContent] = item[FieldsName.NewsRecord.English.PublishingPageContent];
         enItem[FieldsName.NewsRecord.English.FocusNews] = item[FieldsName.NewsRecord.English.FocusNews];
         enItem[FieldsName.NewsRecord.English.LinkAdv] = item[FieldsName.NewsRecord.English.LinkAdv];
         enItem[FieldsName.NewsRecord.English.PublishingPageImage] = item[FieldsName.NewsRecord.English.PublishingPageImage];
         if (!string.IsNullOrEmpty(Convert.ToString(item[FieldsName.NewsRecord.English.PublishingPageContent])))
         {
             enItem[FieldsName.NewsRecord.English.PublishingPageContent] = item[FieldsName.NewsRecord.English.PublishingPageContent];
         }
         else
         {
             enItem[FieldsName.NewsRecord.English.PublishingPageContent] = item[FieldsName.NewsRecord.English.PublishingPageContent];
             item[FieldsName.NewsRecord.English.PublishingPageContent] = item[FieldsName.NewsRecord.English.PublishingPageContent];
             item.Update();
         }
         enItem[FieldsName.NewsRecord.English.ShortContent] = item[FieldsName.NewsRecord.English.ShortContent];
         enItem[FieldsName.NewsRecord.English.ShowInHomePage] = item[FieldsName.NewsRecord.English.ShowInHomePage];
         enItem[FieldsName.NewsRecord.English.Status] = item[FieldsName.NewsRecord.English.Status];
         enItem[FieldsName.NewsRecord.English.ThumbnailImage] = item[FieldsName.NewsRecord.English.ThumbnailImage];
         enItem.Update();
     }
 }
开发者ID:bebikashg,项目名称:ttqn,代码行数:33,代码来源:ShowVideoUS.ascx.cs

示例14: CopyCat

 private void CopyCat(int vnCatID, int enCatID, SPList vnCatList, SPList enCatList, SPList vnNewsList, SPList enNewsList)
 {
     var enParentCat = new SPFieldLookupValue(enCatID, enCatList.GetItemById(enCatID).Title);
     string camlQuery = string.Format("<Where><Eq><FieldRef Name='{0}' LookupId='TRUE'/><Value Type='Lookup'>{1}</Value></Eq></Where>", FieldsName.NewsCategory.English.ParentName, vnCatID);
     var query = new SPQuery();
     query.Query = camlQuery;
     var vnListItems = vnCatList.GetItems(query);
     foreach (SPListItem item in vnListItems)
     {
         var enItem = enCatList.Items.Add();
         enItem["Title"] = item["Title"];
         enItem[FieldsName.NewsCategory.English.ParentName] = enParentCat;
         enItem[FieldsName.NewsCategory.English.Status] = item[FieldsName.NewsCategory.English.Status];
         enItem[FieldsName.NewsCategory.English.TypeCategory] = item[FieldsName.NewsCategory.English.TypeCategory];
         enItem.Update();
         CopyNews(item.ID, enItem.ID, enCatList, vnNewsList, enNewsList);
         CopyCat(item.ID, enItem.ID, vnCatList, enCatList, vnNewsList, enNewsList);
     }
 }
开发者ID:bebikashg,项目名称:ttqn,代码行数:19,代码来源:ShowVideoUS.ascx.cs

示例15: UpdateReportForMonth

        private static void UpdateReportForMonth(SPList report, DateTime reportStart, SPListItemCollection monthlyCosts)
        {
            double monthlySum = 0;
            foreach (SPListItem cost in monthlyCosts)
            {
                monthlySum += (double)cost["Cost"];
            }

            string reportsQueryString = string.Format(
                "<Where>" +
                    "<Eq>" +
                        "<FieldRef Name='{0}'></FieldRef>" +
                        "<Value Type='DateTime'>{1}</Value>" +
                    "</Eq>" +
                "</Where>",
                DelegationsFields.MonthIndicator.Name,
                SPUtility.CreateISO8601DateTimeFromSystemDateTime(reportStart));

            SPQuery monthlyReportQuery = new SPQuery();
            monthlyReportQuery.Query = reportsQueryString;

            SPListItemCollection monthlyReports = report.GetItems(monthlyReportQuery);

            if (monthlyReports.Count > 0)
            {
                var item = report.GetItemById((int)(monthlyReports[0]["ID"]));
                item[DelegationsFields.MonthlyCost] = monthlySum;
                item.Update();
            }
            else
            {
                var item = report.AddItem();
                item[DelegationsFields.MonthIndicator] = reportStart;
                item[DelegationsFields.MonthlyCost] = monthlySum;
                item.Update();
            }
        }
开发者ID:radata,项目名称:lsolilo-sharepoint,代码行数:37,代码来源:ReportJobDefinition.cs


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