sharepoint知識點總結大全_第1頁
sharepoint知識點總結大全_第2頁
sharepoint知識點總結大全_第3頁
sharepoint知識點總結大全_第4頁
sharepoint知識點總結大全_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、sharepoint知識點總結大全splistcollection轉datatablesplistitemcollection unprocesseditems = list.getitems(query);datatable dt1 = unprocesseditems.getdatatable(); folder類型添加自定義屬性 mysite = new spsite(http:/richsql/);myweb = mysite.rootweb;spdocumentlibrary spdoc = myweb.listsjackdocuments as spdocumentlibrary;

2、spcontenttypecollection spcontents = spdoc.contenttypes;string strctname = string.empty;foreach (spcontenttype spcontexttype in spcontents)if (spcontexttype.name = folder)spcontexttype.sealed = false;spcontexttype.update();sealed 屬性設置成false就可以了.多行文本取出換行replace(rn, )識別為垃圾郵件來歷不明的軟件發(fā)的郵件都是垃圾郵件。所以發(fā)郵件的時候要

3、套個馬甲。這個代碼就是套個outlook作掩護。 public bool send(string subject, string body, string to, string mailfrom, string mailfromname, string maildomain, string mailserverusername, string mailserverpassword) try mailmessage msg = new mailmessage(); msg.from = new mailaddress(mailfrom, mailfromname); msg.to.add(new

4、 mailaddress(to, to);msg.subject = subject; msg.body = body; msg.isbodyhtml = true; msg.priority = mailpriority.normal; msg.subjectencoding = system.text.encoding.utf8; msg.bodyencoding = system.text.encoding.utf8;/以下附加頭用于避免被識別為垃圾郵件msg.headers.add(x-priority, 3); msg.headers.add(x-msmail-priority, n

5、ormal); msg.headers.add(x-mailer, microsoft outlook express 6.00.2900.2869); msg.headers.add(x-mimeole, produced by microsoft mimeole v6.00.2900.2869); msg.headers.add(returnreceipt, 1);/附加結束smtpclient client = new smtpclient(maildomain); client.usedefaultcredentials = false; client.credentials = ne

6、w networkcredential(mailserverusername, mailserverpassword); /帳號密碼 client.deliverymethod = smtpdeliverymethod.network;client.send(msg); return true; catch return false; 使用moss自帶的方法發(fā)送emailstringdictionary messageheaders = new stringdictionary();messageheaders.add(to, email);messageheaders.add(subject

7、, s_subject);/messageheaders.add(from, );messageheaders.add(content-type, text/html);/messageheaders.add(cc, );/messageheaders.add(bcc, );sputility.sendemail(this.web, messageheaders, s_body);.net方式發(fā)送emailpublic static bool sendmail(string to,string subject,string body)mailaddress from = new mailadd

8、ress(moss-test1xxx.com);mailaddress touser = new mailaddress(to);mailmessage mailobj = new mailmessage(from, touser);/完善mailmessage對象mailobj.subject = subject;mailobj.body = body;mailobj.isbodyhtml = true;mailobj.bodyencoding = system.text.encoding.getencoding(utf-8);mailobj.priority = mailpriority.

9、normal;/構建smtpclient對象smtpclient smtp = new smtpclient();trysmtp.send(mailobj);return true;catchreturn false;我們使用.net類庫中的api發(fā)mail的時候,我們要配置他的smtp server等,但是在sharepoint里,已經提供了相關的封裝的方法:sputility.sendemail(spweb, false, false,to, mailtitle,mailbody);上面的方法只能以to的形式來發(fā)mail,有的時候我們需要使用cc ,bcc,我們可以利用該函數(shù)的另一個重載來

10、實現(xiàn):sputility.sendemail(web, messageheaders, messagebody, appendfooter)我們需要設置messageheaders,代碼如下:stringdictionary headers = new stringdictionary(); headers.add(to,tom); headers.add(cc,ccm); headers.add(bcc,bbcm); headers.add(from,fromm); headers.add(subject,the mail title); headers.add(content-type,t

11、ext/html);在header中可以指定to cc bcc from等,當然使用上面的函數(shù)的前提是你在管理中心已經配置好了傳出電子郵件的設置。更新工作流狀態(tài)splist list = web.listtestlist;splistitem listitem = list.getitembyid(1);string state = listitem.fields審批狀態(tài).internalname;listitemstate = 0; /設置列表審批狀態(tài)為“已批準”(0表示 已批準)listitem.systemupdate(); /列表使用systemupdate()方法來更新審批狀態(tài)。/文

12、檔庫spdocumentlibrary doclib = web.listtestlib;splistitem libitem = list.getitembyid(1);string state = libitem.fields審批狀態(tài).internalname;libitemstate = 0; /設置文檔庫審批狀態(tài)為“已批準”(0表示已批準)libitem.updateoverwriteversion(); /文檔庫使用updateoverwriteversion()方法來更新審批狀態(tài)。item_moderationstatus = (int)spmoderationstatustype

13、.approved; item.update(); 這樣好像就可以string轉guidguid dd = new guid(str);content typeitem“contenttypeid”或者item“contenttype”顯示個人信息用spd打開根站點在根下 _catalogs 目錄有 users(用戶信息表)此表是網站集所管理的用戶列表。默認為隱藏。點右鍵 屬性-設置- 鉤掉“在瀏覽器中隱藏”選項。此時,用戶表 就可以像其他列表一樣操作要實現(xiàn) 顯示照片和姓名 職務 部門等信息可以通過webpart 顯示指定列信息,轉換為xslt視圖,進行定制注意設置篩選條件 為: id 列 =

14、 當前用戶最終可以自由定制。item.systemupdate();方法更改時間更改者事件更改和審核記錄訂閱properties are not demoted into documents增加版本systemupdate()systemupdate(bool)false不增長時間操作,不超時splongoperation oparetion = new splongoperation(this);tryoparetion.begin();try/啟動工作流/startinitdata參數(shù)為approvewfassociationdata類的序列化后的stringweb.site.workfl

15、owmanager.startworkflow(listitem, workflowassociation, startinitdata();catch (exception ex)throw new exception(ex.tostring();oparetion.end(list.defaultviewurl);finallyif (oparetion != null)oparetion.dispose();轉向/ 轉向到該list的工作流設置頁面sputility.redirect(wrksetng.aspx?list= + tasklist.id,spredirectflags.re

16、lativetolayoutspage, httpcontext.current);轉到錯誤頁sputility.transfertoerrorpage(the createchildcontrols function of the ajaxbasepart has not been called. you probably need to add base.createchildcontrols() to the top of your createchildcontrols override.);成員名稱說明checkurlcheck the redirect uniform resour

17、ce locator (url). defaultuse default settings for the redirect. donotencodeurldo not encode the redirect url. donotendresponsedo not end the response after the redirect. relativetolayoutspage相對layouts的地址the redirect occurs relative to the layouts page. relativetolocalizedlayoutspage相對觸發(fā)的layouts中page

18、的地址the redirect occurs relative to the localized layouts page. static靜態(tài)地址,非相對地址the redirect is static. trustedthe redirect is trusted. usesource使用url中的source的地址use the source for the redirect. 內容類型spweb.availablecontenttypes得到當前web所有活動的內容類型spweb.contenttypes 得到部署到當前web上的內容類型,不要用這個。web的用戶listweb.site

19、userinfolistad操作directoryentry di = new directoryentry(ldap:/adserver/ou=開發(fā)部,administrator,pass, authenticationtypes.secure);廣州-jian(簡) 說:這句應該是最關鍵的了廣州-jian(簡) 說:然后想在“開發(fā)部”下面增加用戶,就用di.children.add就可以了list附件的讀取怎么取得sharepoint表單庫中的表單附件的數(shù)據,我想將附件數(shù)據單獨的提取出來,但是提取的信息全是base64編碼,有沒有這方面的信息或資料,base64 解碼不就完了system.

20、convert.frombase64string模擬用戶代碼string siteurl = :82/sites/sjs ;/首先用管理員身份取到某個用戶的token,必須,非管理員無法模擬spsite site = new spsite(siteurl);/此時用戶為sharepointsystem response.write(site.rootweb.currentuser);spuser user = site.rootweb.siteuserssaicmotorlabuser1;/利用用戶token構造新的site對象spsite sitewithuser = new spsite(

21、siteurl, user.usertoken);spweb webwithuser = sitewithuser.rootweb;/此時用戶為saicmotorlabuser1 response.write( webwithuser.currentuser );splist listwithuser = webwithuser.listssimelist;/dother codepeople editor控件peopleeditor.selectionset = user,dl,secgroup;代表可以選擇用戶,也可以選擇組工作流歷史記錄表http:/cnsh-10apl1/project

22、management/lists/workflow history/infopath中為下拉框添加值testnode.appendchildelement(testnode.prefix, addelm,testnode.namespaceuri, string.empty);ajax實現(xiàn)3:在相關masterpage的里添加_sporiginalformaction = document.forms0.action;_spsuppressformonsubmitwrapper=true;4.在你寫好的usercontrol的page_load事件里添加if (this.page.form !

23、= null)string formonsubmitatt = this.page.form.attributesonsubmit;if (formonsubmitatt = return _spformonsubmitwrapper();)this.page.form.attributesonsubmit =_spformonsubmitwrapper();scriptmanager.registerstartupscript(this,typeof(你usercontrol的classname), updatepanelfixup, _sporiginalformaction =docum

24、ent.forms0.action; _spsuppressformonsubmitwrapper=true;, true);當person or group字段允許多人時,通過sdk對象讀取用戶信息list users = new list(); list groups = new list();spfielduservaluecollection values = (spfielduservaluecollection)item人員或組欄;foreach (spfielduservalue value in values) if (value.user != null) users.add

25、(value.user); else spgroup group = web.groups.getbyid(value.lookupid); groups.add(group); foreach (spuser user in group.users) users.add(user); spfieldlookupvaluecollection values = (spfieldlookupvaluecollection )itemusers;spfieldlookupvaluecollection values = itemusers .tostring();string initusers

26、= ;foreach (spfieldlookupvalue value in values)int valueid = value.lookupid;string valuetitle = value.lookupvalue;代碼啟動工作流獲取spworkflowmanager 獲取spworkflowassociation,針對一個item啟動向item中添加附件if (fileuploadattach.hasfile)stream stream = fileuploadattach.postedfile.inputstream;stream.position = 0;byte buffe

27、r = new bytestream.length;stream.read(buffer, 0, (int)stream.length);itemnew.attachments.add(fileuploadattach.postedfile.filename, buffer);itemnew.update();itemnew.parentlist.update();stream.close();caml查找lookup型1用戶型 + + user.id + +web頁面顯示word如果想讓web頁面顯示出word文檔要加response.contenttype = application/ms

28、word;response.addheader(content-disposition,attachment;filename= +httputility.urlencode(file.filename).replace(+,%20);/ 防止亂碼response.charset=utf-8;response.contentencoding=system.text.encoding.default;response.binarywrite(文件流);response.end();多文件上傳spfilecollection destfiles =sitecollection.allwebsdes

29、tination_site.foldersdestination_doclib.files;foreach (spfile srcfile in srcfolder.files)if (srcfile.timelastmodified 0)for (int i = 0; i attachments.count; i+)string url = attachments.urlprefix + attachmentsi;/得到附件的共同前綴再加上附件的名稱spfile file = web.getfile(url);string customername = itemcustomer name.t

30、ostring().split(#)1;file.copyto(properties.weburl + /crm document/ + customername + /04 customer scoring/ + attachmentsi, true);如何查看sharepoint未知錯誤在moss開發(fā)自定義功能后,出現(xiàn)錯誤頁面只顯示“出現(xiàn)未知錯誤”的提示,查看很不方面,通過下面方法就可以直接在出錯頁面查看錯誤信息。修改web應用程序根目錄上的web.config文件中的兩個地方:查找以下位置并更改即可(紅色為更改前后的值)一、maxcontrols=200 callstack=false

31、改為 maxcontrols=200 callstack=true二、customerrors mode=on 改為 customerrors mode=offwebpart出錯,無法打開頁面,contents=1 ,會轉到webpart管理頁面,把出問題的刪掉在url后面加入“?&toolpaneview=2”打開設計頁或者加“displaymode=design”http:/cnsh-10vms1/_layouts/spcontnt.aspx?&url=/_catalogs/wp/forms/editform.aspx這頁面是維護頁面“超鏈接或圖片”類型欄的值,對應的對象模型為spfiel

32、durl和spfieldurlvalue,可以這樣讀?。?spfieldurlvalue value = new spfieldurlvalue(itemurl.tostring();console.writeline(value.description);console.writeline(value.url);或spfieldurl fieldurl = (spfieldurl)item.fieldsurl;spfieldurlvalue value = (spfieldurlvalue)fieldurl.getfieldvalue(itemurl.tostring();console.w

33、riteline(value.description);console.writeline(value.url);賦值spfieldurl fieldurl = (spfieldurl)suppliernew.fieldsdgi.cells0.text;spfieldurlvalue fieldurlvalue = new spfieldurlvalue();fieldurlvalue.url = web.url + / + supplierdocument.rootfolder.url + / + suppliernewtitle.tostring() + - + suppliernew.i

34、d;fieldurlvalue.description = dgi.cells0.text;suppliernewdgi.cells0.text = fieldurlvalue;將子網站移動到主網站?修改子網站下的網站欄到網站集下解決了,直接到wss_content數(shù)據庫里面,修改表contenttypes的scope字段,特別方便,暫時沒發(fā)現(xiàn)出錯誤sharepoint中l(wèi)ookup字段的使用賦值如何在代碼中使用lookup字段 對于lookup字段在可視界面時,感覺挺方便,但是在寫代碼的時候,對它進行賦值的時候,就感覺很麻煩。不知道哪位高手對這個賦值有更好的方法,謝謝。 方法一(聽11同學說

35、的) spfieldlookupvaluecollection lookupvalues;lookupvalues = (spfieldlookupvaluecollection)listitemmylookupfield;lookupvalues.add(new spfieldlookupvalue(1, somelookupvalue); listitemmylookupfield = lookupvalues;listitem.update();這方法感覺賦值就是受罪,寫這么多代碼。 方法二。直接用 listitemmylookupfield =1,2,3 但這此方法要知道字符串所對應的

36、id。,有什么最有效的方法。請教高手 實際使用如下代碼(經過測試):spweb web = spcontext.current.web;splist customerlist = web.listscustomer;spquery query = new spquery();query.query = + dropdownlist1.selecteditem.text + ;splistitemcollection customerc = customerlist.getitems(query);int cu1 = customerc0.id;splist projectlist = web.

37、listsproject;splistitem projectnew = projectlist.items.add();projectnewcustomer = cu1;projectnewtitle = txtboxprojectname.text;projectnew.update();lookupcollection的賦值spfieldlookupvaluecollection lvsgde = new spfieldlookupvaluecollection();foreach (listitem item in lbgdecurrent.items) /lbgdecurrent為下

38、拉框spfieldlookupvalue lvgde = new spfieldlookupvalue();lvgde.lookupid = int.parse(item.value);lvsgde.add(lvgde);item“l(fā)ookups” = lvsgde;lookup和user的讀取如果lookup不允許多選的時候,itemlookup得到的是一個stringstring c = (itemcreated by = null) ? : itemcreated by.tostring().remove(0, itemcreated by.tostring().indexof(;#)

39、+ 2);否則是一個spfieldlookupvaluecollection用戶類型為spfielduservaluecollectionlist users = new list();list groups = new list();using (spsite site = new spsite(http:/windbell)spweb web = site.rootweb;splist list = web.lists測試列表;spitem item = list.items0;spfielduservaluecollection values = (spfielduservaluecol

40、lection)item用戶和用戶組;foreach (spfielduservalue value in values)if (user != null)spuser user = value.user;users.add(user);elsespgroup group = web.groups.getbyid(value.lookupid);groups.add(group);users.addrange(group.users);定義一個groupspgroupcollection groups = owebsite.sitegroups;spuser user = owebsite.usersxxxxxxxxx;spmember member = owebsite.usersxxxxxxxx;groups.add(testgroup, member, user, description);將一個group分配進一個roleif (spweb.hasuniqueroleassignments = true)/web是否有

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論