




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、sharepoint知識(shí)點(diǎn)總結(jié)大全splistcollection轉(zhuǎn)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 屬性設(shè)置成false就可以了.多行文本取出換行replace(rn, )識(shí)別為垃圾郵件來歷不明的軟件發(fā)的郵件都是垃圾郵件。所以發(fā)郵件的時(shí)候要
3、套個(gè)馬甲。這個(gè)代碼就是套個(gè)outlook作掩護(hù)。 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;/以下附加頭用于避免被識(shí)別為垃圾郵件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);/附加結(jié)束smtpclient client = new smtpclient(maildomain); client.usedefaultcredentials = false; client.credentials = ne
6、w networkcredential(mailserverusername, mailserverpassword); /帳號(hào)密碼 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對(duì)象mailobj.subject = subject;mailobj.body = body;mailobj.isbodyhtml = true;mailobj.bodyencoding = system.text.encoding.getencoding(utf-8);mailobj.priority = mailpriority.
9、normal;/構(gòu)建smtpclient對(duì)象smtpclient smtp = new smtpclient();trysmtp.send(mailobj);return true;catchreturn false;我們使用.net類庫中的api發(fā)mail的時(shí)候,我們要配置他的smtp server等,但是在sharepoint里,已經(jīng)提供了相關(guān)的封裝的方法:sputility.sendemail(spweb, false, false,to, mailtitle,mailbody);上面的方法只能以to的形式來發(fā)mail,有的時(shí)候我們需要使用cc ,bcc,我們可以利用該函數(shù)的另一個(gè)重載來
10、實(shí)現(xiàn):sputility.sendemail(web, messageheaders, messagebody, appendfooter)我們需要設(shè)置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等,當(dāng)然使用上面的函數(shù)的前提是你在管理中心已經(jīng)配置好了傳出電子郵件的設(shè)置。更新工作流狀態(tài)splist list = web.listtestlist;splistitem listitem = list.getitembyid(1);string state = listitem.fields審批狀態(tài).internalname;listitemstate = 0; /設(shè)置列表審批狀態(tài)為“已批準(zhǔn)”(0表示 已批準(zhǔn))listitem.systemupdate(); /列表使用systemupdate()方法來更新審批狀態(tài)。/文
12、檔庫spdocumentlibrary doclib = web.listtestlib;splistitem libitem = list.getitembyid(1);string state = libitem.fields審批狀態(tài).internalname;libitemstate = 0; /設(shè)置文檔庫審批狀態(tài)為“已批準(zhǔn)”(0表示已批準(zhǔn))libitem.updateoverwriteversion(); /文檔庫使用updateoverwriteversion()方法來更新審批狀態(tài)。item_moderationstatus = (int)spmoderationstatustype
13、.approved; item.update(); 這樣好像就可以string轉(zhuǎn)guidguid dd = new guid(str);content typeitem“contenttypeid”或者item“contenttype”顯示個(gè)人信息用spd打開根站點(diǎn)在根下 _catalogs 目錄有 users(用戶信息表)此表是網(wǎng)站集所管理的用戶列表。默認(rèn)為隱藏。點(diǎn)右鍵 屬性-設(shè)置- 鉤掉“在瀏覽器中隱藏”選項(xiàng)。此時(shí),用戶表 就可以像其他列表一樣操作要實(shí)現(xiàn) 顯示照片和姓名 職務(wù) 部門等信息可以通過webpart 顯示指定列信息,轉(zhuǎn)換為xslt視圖,進(jìn)行定制注意設(shè)置篩選條件 為: id 列 =
14、 當(dāng)前用戶最終可以自由定制。item.systemupdate();方法更改時(shí)間更改者事件更改和審核記錄訂閱properties are not demoted into documents增加版本systemupdate()systemupdate(bool)false不增長時(shí)間操作,不超時(shí)splongoperation oparetion = new splongoperation(this);tryoparetion.begin();try/啟動(dòng)工作流/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();轉(zhuǎn)向/ 轉(zhuǎn)向到該list的工作流設(shè)置頁面sputility.redirect(wrksetng.aspx?list= + tasklist.id,spredirectflags.re
16、lativetolayoutspage, httpcontext.current);轉(zhuǎn)到錯(cuò)誤頁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相對(duì)layouts的地址the redirect occurs relative to the layouts page. relativetolocalizedlayoutspage相對(duì)觸發(fā)的layouts中page
18、的地址the redirect occurs relative to the localized layouts page. static靜態(tài)地址,非相對(duì)地址the redirect is static. trustedthe redirect is trusted. usesource使用url中的source的地址use the source for the redirect. 內(nèi)容類型spweb.availablecontenttypes得到當(dāng)前web所有活動(dòng)的內(nèi)容類型spweb.contenttypes 得到部署到當(dāng)前web上的內(nèi)容類型,不要用這個(gè)。web的用戶listweb.site
19、userinfolistad操作directoryentry di = new directoryentry(ldap:/adserver/ou=開發(fā)部,administrator,pass, authenticationtypes.secure);廣州-jian(簡(jiǎn)) 說:這句應(yīng)該是最關(guān)鍵的了廣州-jian(簡(jiǎn)) 說:然后想在“開發(fā)部”下面增加用戶,就用di.children.add就可以了list附件的讀取怎么取得sharepoint表單庫中的表單附件的數(shù)據(jù),我想將附件數(shù)據(jù)單獨(dú)的提取出來,但是提取的信息全是base64編碼,有沒有這方面的信息或資料,base64 解碼不就完了system.
20、convert.frombase64string模擬用戶代碼string siteurl = :82/sites/sjs ;/首先用管理員身份取到某個(gè)用戶的token,必須,非管理員無法模擬spsite site = new spsite(siteurl);/此時(shí)用戶為sharepointsystem response.write(site.rootweb.currentuser);spuser user = site.rootweb.siteuserssaicmotorlabuser1;/利用用戶token構(gòu)造新的site對(duì)象spsite sitewithuser = new spsite(
21、siteurl, user.usertoken);spweb webwithuser = sitewithuser.rootweb;/此時(shí)用戶為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實(shí)現(xiàn)3:在相關(guān)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);當(dāng)person or group字段允許多人時(shí),通過sdk對(duì)象讀取用戶信息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;代碼啟動(dòng)工作流獲取spworkflowmanager 獲取spworkflowassociation,針對(duì)一個(gè)item啟動(dòng)向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未知錯(cuò)誤在moss開發(fā)自定義功能后,出現(xiàn)錯(cuò)誤頁面只顯示“出現(xiàn)未知錯(cuò)誤”的提示,查看很不方面,通過下面方法就可以直接在出錯(cuò)頁面查看錯(cuò)誤信息。修改web應(yīng)用程序根目錄上的web.config文件中的兩個(gè)地方:查找以下位置并更改即可(紅色為更改前后的值)一、maxcontrols=200 callstack=false
31、改為 maxcontrols=200 callstack=true二、customerrors mode=on 改為 customerrors mode=offwebpart出錯(cuò),無法打開頁面,contents=1 ,會(huì)轉(zhuǎn)到webpart管理頁面,把出問題的刪掉在url后面加入“?&toolpaneview=2”打開設(shè)計(jì)頁或者加“displaymode=design”http:/cnsh-10vms1/_layouts/spcontnt.aspx?&url=/_catalogs/wp/forms/editform.aspx這頁面是維護(hù)頁面“超鏈接或圖片”類型欄的值,對(duì)應(yīng)的對(duì)象模型為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;將子網(wǎng)站移動(dòng)到主網(wǎng)站?修改子網(wǎng)站下的網(wǎng)站欄到網(wǎng)站集下解決了,直接到wss_content數(shù)據(jù)庫里面,修改表contenttypes的scope字段,特別方便,暫時(shí)沒發(fā)現(xiàn)出錯(cuò)誤sharepoint中l(wèi)ookup字段的使用賦值如何在代碼中使用lookup字段 對(duì)于lookup字段在可視界面時(shí),感覺挺方便,但是在寫代碼的時(shí)候,對(duì)它進(jìn)行賦值的時(shí)候,就感覺很麻煩。不知道哪位高手對(duì)這個(gè)賦值有更好的方法,謝謝。 方法一(聽11同學(xué)說
35、的) spfieldlookupvaluecollection lookupvalues;lookupvalues = (spfieldlookupvaluecollection)listitemmylookupfield;lookupvalues.add(new spfieldlookupvalue(1, somelookupvalue); listitemmylookupfield = lookupvalues;listitem.update();這方法感覺賦值就是受罪,寫這么多代碼。 方法二。直接用 listitemmylookupfield =1,2,3 但這此方法要知道字符串所對(duì)應(yīng)的
36、id。,有什么最有效的方法。請(qǐng)教高手 實(shí)際使用如下代碼(經(jīng)過測(cè)試):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不允許多選的時(shí)候,itemlookup得到的是一個(gè)stringstring c = (itemcreated by = null) ? : itemcreated by.tostring().remove(0, itemcreated by.tostring().indexof(;#)
39、+ 2);否則是一個(gè)spfieldlookupvaluecollection用戶類型為spfielduservaluecollectionlist users = new list();list groups = new list();using (spsite site = new spsite(http:/windbell)spweb web = site.rootweb;splist list = web.lists測(cè)試列表;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);定義一個(gè)groupspgroupcollection groups = owebsite.sitegroups;spuser user = owebsite.usersxxxxxxxxx;spmember member = owebsite.usersxxxxxxxx;groups.add(testgroup, member, user, description);將一個(gè)group分配進(jìn)一個(gè)roleif (spweb.hasuniqueroleassignments = true)/web是否有
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 七年級(jí)歷史下冊(cè) 第二單元 遼宋夏金元時(shí)期 民族關(guān)系發(fā)展和社會(huì)變化 第9課 宋代經(jīng)濟(jì)的發(fā)展教學(xué)設(shè)計(jì) 新人教版
- 早教報(bào)名協(xié)議書8篇
- 七年級(jí)語文上冊(cè) 9從百草園到三味書屋第3課時(shí)教學(xué)設(shè)計(jì) 新人教版
- 電子商務(wù)發(fā)展動(dòng)態(tài)
- 車輛安全隱患課件
- Unit6 Section A Grammar Focus3a-3d 教學(xué)設(shè)計(jì) 2024-2025學(xué)年人教版英語七年級(jí)上冊(cè)
- 七年級(jí)體育與健康 基本體操2教學(xué)設(shè)計(jì)
- 直腸肛管疾病護(hù)理
- Unit 8 How are you (教學(xué)設(shè)計(jì))-2023-2024學(xué)年譯林版(三起)英語四年級(jí)下冊(cè)
- 耳科手術(shù)一般護(hù)理
- DL∕T 5210.4-2018 電力建設(shè)施工質(zhì)量驗(yàn)收規(guī)程 第4部分:熱工儀表及控制裝置
- 高空作業(yè)安全專項(xiàng)施工方案完整版
- 《藥品經(jīng)營和使用質(zhì)量監(jiān)督管理辦法》試題
- 高中數(shù)學(xué) 6.3.2 空間線面關(guān)系的判定教學(xué)設(shè)計(jì) 蘇教版選擇性必修第二冊(cè)
- 胸腔穿刺術(shù)評(píng)分標(biāo)準(zhǔn)
- 2024版ODM合作合同協(xié)議書范本
- 2024年全國初中數(shù)學(xué)競(jìng)賽試題含答案
- 2023-2024學(xué)年山東省濟(jì)南市歷城區(qū)八年級(jí)(下)期中數(shù)學(xué)試卷(含解析)
- 靜夜思 第2課時(shí)(公開課一等獎(jiǎng)創(chuàng)新教學(xué)設(shè)計(jì)含反思)
- 2023-2024學(xué)年上海市楊浦區(qū)八年級(jí)(下)期中英語試卷
- 4-1-1 土石料料場(chǎng)規(guī)劃與開采講解
評(píng)論
0/150
提交評(píng)論