我希望能夠通過對象模型在我的MOSS 2007安裝中創建KPI列表。這可能嗎?如何在SharePoint中以編程方式創建KPI列表?
2
A
回答
0
http://alonsorobles.com/2010/03/17/important-custom-sharepoint-list-template-notes/
我發現一個狀態指標(KPI列表)模板ID是432谷歌爲此找上創建一個新的列表一些信息。我需要閱讀我可以在此列表上設置的屬性。
1
using (SPWeb web1 = properties.Feature.Parent as SPWeb)
{
using (SPSite objSite = new SPSite(web1.Site.ID))
{
using (SPWeb web = objSite.OpenWeb(web1.ID))
{
SPListTemplate template = null;
foreach (SPListTemplate t in web.ListTemplates)
{
if (t.Type.ToString() == "432")
{
template = t;
break;
}
}
Guid gG = Guid.Empty;
SPList list = null;
string sListTitle = "Status List";
SPSecurity.RunWithElevatedPrivileges(delegate
{
try
{
web.AllowUnsafeUpdates = true;
gG = web.Lists.Add(sListTitle, sListTitle, template);
list = web.Lists[gG];
}
catch
{
// exists
list = web.Lists[sListTitle];
}
SPContentType ct =
list.ContentTypes["SharePoint List based Status Indicator"];
//declare each item which u want to insert in the kpi list
SPListItem item1 = list.Items.Add();
SPFieldUrlValue value1 = new SPFieldUrlValue();
item1["ContentTypeId"] = ct.Id;
item1.SystemUpdate();
item1["Title"] = "Project Specific Doc.Lib.Rating";
value1.Url = web.Url + "/Lists/Project Specific Documents";
item1["DataSource"] = value1;
item1["Indicator Goal Threshold"] = "3";
item1["Indicator Warning Threshold"] = "3";
item1["Value Expression"] =
"Average;Average_x0020_Rating:Number";
item1.SystemUpdate();
}
}
}
average
是計算值和列是Average_x0020_Rating
。
0
這是爲我工作:
private void CreateKPIDocumentLibrary(List<PageStructure> list)
{
SPListTemplate kpi = null;
foreach (SPListTemplate t in web.ListTemplates)
{
if (t.Type.ToString() == "432")
{
kpi = t;
break;
}
}
foreach (PageStructure st in list)
{
bool find = false;
string[] periodType = st.tag.Split('_');
string name = periodType[0] + "-" + st.effdate + "-" + st.template;
SPListCollection lstCol = site.OpenWeb().GetListsOfType(SPBaseType.GenericList);
foreach (SPList l in lstCol)
{
string title = l.Title;
if (title == name)
{
find = true;
break;
}
}
if (find == false)
{
Guid docLibID = web.Lists.Add(name, "", kpi);
}
SPList itemList = web.Lists[name];
SPListItem item = itemList.Items.Add();
SPFieldUrlValue value = new SPFieldUrlValue();
item["Title"] = st.tag;
value.Url = st.docUrl;
item["DetailLink"] = st.url;
item["DataSource"] = value;
item["Indicator Goal Threshold"] = "2";
item["Indicator Warning Threshold"] = "1";
item["View Name"] = "All Documents";
item.SystemUpdate();
web.Update();
KpiObject kp = new KpiObject(name, SPContext.Current.Site.Url + itemList.DefaultViewUrl);
this.kpiList.Add(kp);
}
}
相關問題
- 1. 以聲明方式或編程方式創建Sharepoint列表?
- 2. 基於列以編程方式在Sharepoint中創建樹視圖
- 3. sharepoint 2010:如何以編程方式創建表單庫
- 4. 如何編程創建/構建的SharePoint PPS - 儀表板,記分卡,KPI的
- 5. 如何以編程方式在Sharepoint站點創建文件夾
- 6. SharePoint 2007 - 如何以編程方式創建網站模板
- 7. 在Sharepoint 2010中以編程方式創建我的網站
- 8. 以編程方式在Sharepoint中創建網站集
- 9. 如何以編程方式創建圖層列表可繪製?
- 10. 如何以編程方式在C#中創建MS Access表?
- 11. ViewPager以編程方式在其中創建recyclerView列表
- 12. 以編程方式在asp.net中創建列表視圖
- 13. 以編程方式在Android中創建列表視圖項目
- 14. 如何確定SharePoint列表的大小以編程方式
- 15. 如何以編程方式讀取SharePoint列表?
- 16. 如何以編程方式創建UIScrollview
- 17. 如何以編程方式創建UIViewController?
- 18. 如何以編程方式創建UIButton
- 19. 如何以編程方式創建NSTextField?
- 20. 如何以編程方式創建Tabbar
- 21. 如何以編程方式創建ProgressBar?
- 22. 如何以編程方式創建CustomCell?
- 23. 如何以編程方式創建NSPopover
- 24. 如何以編程方式創建GPO?
- 25. 如何以編程方式創建NSFetchedPropertyDescription?
- 26. 如何以編程方式創建UIScrollView?
- 27. 如何以編程方式創建TextView?
- 28. 如何以編程方式創建NSSearchField?
- 29. 如何以編程方式在Sharepoint中創建維基頁面(=項目)?
- 30. 創建具有甘特圖視圖的Sharepoint列表 - 以編程方式