版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
sharepoint知识点总结大全SPListCollection转DatatableﻫSPListItemCollectionunprocessedItems=List.GetItems(query);ﻫDataTabledt1=unprocessedItems.GetDataTable();ﻫFolder类型添加自定义属性ﻫ
mySite=newSPSite("http://richsql/");
myWeb=mySite.RootWeb;SPDocumentLibraryspDoc=myWeb.Lists["JackDocuments"]asSPDocumentLibrary;SPContentTypeCollectionspcontents=spDoc.ContentTypes;stringstrCTName=string.Empty;ﻫforeach(SPContentTypespContextTypeinspcontents)
{if(spContextType.Name=="Folder")
{ﻫspContextType.Sealed=false;ﻫspContextType.Update();ﻫ}ﻫ}
Sealed属性设立成false就可以了.
多行文本取出换行Replace(""r"n","<br/>")辨认为垃圾邮件来历不明的软件发的邮件都是垃圾邮件。所以发邮件的时候要套个马甲。这个代码就是套个OutLook作掩护。
publicboolSend(stringSubject,stringBody,stringTo,stringMailFrom,stringMailFromName,stringMailDomain,stringMailServerUserName,stringMailServerPassWord)ﻫ{ﻫtryﻫ{
MailMessagemsg=newMailMessage();
msg.From=newMailAddress(MailFrom,MailFromName);ﻫmsg.To.Add(newMailAddress(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","Normal");
msg.Headers.Add("X-Mailer","MicrosoftOutlookExpress6.00.2900.2869");
msg.Headers.Add("X-MimeOLE","ProducedByMicrosoftMimeOLEV6.00.2900.2869");
msg.Headers.Add("ReturnReceipt","1");//附加结束SmtpClientclient=newSmtpClient(MailDomain);
client.UseDefaultCredentials=false;ﻫclient.Credentials=newNetworkCredential(MailServerUserName,MailServerPassWord);//帐号密码ﻫclient.DeliveryMethod=SmtpDeliveryMethod.Network;client.Send(msg);
returntrue;
}ﻫcatch{returnfalse;}ﻫ}使用MOSS自带的方法发送emailStringDictionarymessageHeaders=newStringDictionary();ﻫmessageHeaders.Add("to",email);ﻫmessageHeaders.Add("subject",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方式发送emailpublicstaticboolSendMail(stringto,stringsubject,stringbody){MailAddressfrom=newMailAddress("");MailAddresstoUser=newMailAddress(to);MailMessagemailobj=newMailMessage(from,toUser);//完善MailMessage对象mailobj.Subject=subject;mailobj.Body=body;mailobj.IsBodyHtml=true;mailobj.BodyEncoding=System.Text.Encoding.GetEncoding("UTF-8");mailobj.Priority=MailPriority.Normal;//构建SmtpClient对象SmtpClientsmtp=newSmtpClient("");try{
smtp.Send(mailobj);returntrue;}catch{returnfalse;}}我们使用.NET类库中的API发Mail的时候,我们要配置他的SMTPServer等,但是在Sharepoint里,已经提供了相关的封装的方法:ﻫSPUtility.SendEmail(SPWeb,false,false,"","MailTitle","MailBody");上面的方法只能以To的形式来发Mail,有的时候我们需要使用CC,BCC,我们可以运用该函数的另一个重载来实现:ﻫSPUtility.SendEmail(web,messageHeaders,messageBody,appendFooter)我们需要设立messageHeaders,代码如下:
StringDictionaryheaders=newStringDictionary();ﻫheaders.Add("To","");
headers.Add("CC","");ﻫheaders.Add("Bcc","");
headers.Add("From","");ﻫheaders.Add("subject","TheMailTitle");
headers.Add("content-type","text/html");在header中可以指定ToCCBCCFrom等,当然使用上面的函数的前提是你在管理中心已经配置好了传出电子邮件的设立。更新工作流状态SPListlist=web.List["TestList"];
SPListItemlistItem=list.GetItemById(1);
stringstate=listItem.Fields["审批状态"].InternalName;
listItem[state]=0;//设立列表审批状态为“已批准”(0表达已批准)ﻫlistItem.SystemUpdate();//列表使用SystemUpDate()方法来更新审批状态。
//文档库
SPDocumentLibrarydocLib=web.List["TestLib"];
SPListItemlibItem=list.GetItemById(1);ﻫstringstate=libItem.Fields["审批状态"].InternalName;
libItem[state]=0;//设立文档库审批状态为“已批准”(0表达已批准)ﻫlibItem.UpdateOverwriteVersion();//文档库使用UpdateOverwriteVersion()方法来更新审批状态。
item["_ModerationStatus"]=(int)SPModerationStatusType.Approved;
item.Update();ﻫ这样仿佛就可以string转GuidGuiddd=newguid(str);ContentTypeItem[“ContentTypeId”]或者Item[“ContentType”]显示个人信息用SPD打开根站点ﻫ在根下_catalogs目录有users(用户信息表)
此表是网站集所管理的用户列表。默认为隐藏。ﻫ点右键属性--设立--钩掉“在浏览器中隐藏”选项。ﻫ此时,用户表就可以像其他列表同样操作
要实现显示照片和姓名职务部门等信息ﻫ可以通过webpart显示指定列信息,转换为XSLT视图,进行定制ﻫ注意设立筛选条件为:ID列=[当前用户]ﻫ最终可以自由定制。ﻫ
Item.SystemUpdate();方法更改时间更改者事件更改和审核记录订阅propertiesarenotdemotedintodocuments增长版本SystemUpdate()××√√×××SystemUpdate(Bool)××√√××False不增长时间操作,不超时SPLongOperationoparetion=newSPLongOperation(this);try{oparetion.Begin();try{//启动工作流//StartInitData参数为ApproveWFAssociationData类的序列化后的stringweb.Site.WorkflowManager.StartWorkflow(listItem,workflowAssociation,StartInitData());}catch(Exceptionex){thrownewException(ex.ToString());}oparetion.End(list.DefaultViewUrl);}finally{if(oparetion!=null){oparetion.Dispose();}}转向//转向到该list的工作流设立页面SPUtility.Redirect("WrkSetng.aspx?List="+taskList.ID,SPRedirectFlags.RelativeToLayoutsPage,HttpContext.Current);转到错误页SPUtility.TransferToErrorPage("TheCreateChildControlsfunctionoftheAjaxBaseParthasnotbeencalled.Youprobablyneedtoadd""base.CreateChildControls()""tothetopofyourCreateChildControlsoverride.");
ﻫ
成员名称说明
CheckUrlChecktheredirectUniformResourceLocator(URL).
DefaultUsedefaultsettingsfortheredirect.ﻫ
DoNotEncodeUrlDonotencodetheredirectURL.
DoNotEndResponseDonotendtheresponseaftertheredirect.
RelativeToLayoutsPage相对Layouts的地址Theredirectoccursrelativetothelayoutspage.ﻫ
RelativeToLocalizedLayoutsPage相对触发的layouts中Page的地址Theredirectoccursrelativetothelocalizedlayoutspage.
Static静态地址,非相对地址Theredirectisstatic.
TrustedTheredirectistrusted.ﻫ
UseSource使用URL中的Source的地址Usethesourcefortheredirect.内容类型ﻫSPWeb.AvailableContentTypes得到当前web所有活动的内容类型
SPWeb.ContentTypes得到部署到当前web上的内容类型,不要用这个。ﻫWeb的用户listweb.SiteUserInfoListAD操作ﻫDirectoryEntrydi=newDirectoryEntry("LDAP://ADServer/OU=开发部,administrator,pass,AuthenticationTypes.Secure);广州㊣-jian(简)说:这句应当是最关键的了广州㊣-jian(简)说:然后想在“开发部”下面增长用户,就用di.Children.Add就可以了List附件的读取
怎么取得sharepoint表单库中的表单附件的数据,我想将附件数据单独的提取出来,但是提取的信息全是BASE64编码,有没有这方面的信息或资料,BASE64解码不就完了System.Convert.FromBase64String模拟用户代码
stringsiteUrl=":82/sites/sjs";//一方面用管理员身份取到某个用户的Token,必须,非管理员无法模拟ﻫSPSitesite=newSPSite(siteUrl);//此时用户为SHAREPOINT"system
Response.Write(site.RootWeb.CurrentUser);SPUseruser=site.RootWeb.SiteUsers["saicmotorlab""user1"];//运用用户Token构造新的Site对象
SPSitesiteWithUser=newSPSite(siteUrl,user.UserToken);SPWebwebWithUser=siteWithUser.RootWeb;//此时用户为SAICMOTORLAB"user1
Response.Write(webWithUser.CurrentUser);SPListlistWithUser=webWithUser.Lists["simeList"];//dothercodePeopleEditor控件
PeopleEditor.SelectionSet="User,DL,SecGroup";代表可以选择用户,也可以选择组工作流历史登记表ﻫhttp://cnsh-10apl1/ProjectManagement/Lists/WorkflowHistory/Infopath中为下拉框添加值
testNode.AppendChildElement(testNode.Prefix,"AddElm",testNode.NamespaceURI,string.Empty);
AJAX实现
3:在相关MasterPage的<head>里添加ﻫ<scripttype='text/javascript'>_spOriginalFormAction=document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;</script>4.在你写好的UserControl的Page_load事件里添加if(this.Page.Form!=null)
{ﻫstringformOnSubmitAtt=this.Page.Form.Attributes["onsubmit"];
if(formOnSubmitAtt=="return_spFormOnSubmitWrapper();")ﻫ{
this.Page.Form.Attributes["onsubmit"]="_spFormOnSubmitWrapper();";ﻫ}ﻫ}
ScriptManager.RegisterStartupScript(this,typeof([你UserControl的ClassName]),"UpdatePanelFixup","_spOriginalFormAction=document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;",true);当PersonorGroup字段允许多人时,通过sdk对象读取用户信息List<SPUser>users=newList<SPUser>();
List<SPGroup>groups=newList<SPGroup>();SPFieldUserValueCollectionvalues=(SPFieldUserValueCollection)item["人员或组栏"];foreach(SPFieldUserValuevalueinvalues)
{ﻫif(value.User!=null)ﻫ{
users.Add(value.User);ﻫ}ﻫelseﻫ{ﻫSPGroupgroup=web.Groups.GetByID(value.LookupId);ﻫgroups.Add(group);ﻫforeach(SPUseruseringroup.Users)ﻫ{
users.Add(user);ﻫ}
}ﻫ}SPFieldLookupValueCollectionvalues=(SPFieldLookupValueCollection)item["Users"];SPFieldLookupValueCollectionvalues=item["Users"].ToString();
stringinitUsers="";
foreach(SPFieldLookupValuevalueinvalues)
{intvalueID=value.LookupId;ﻫstringvalueTitle=value.LookupValue;}代码启动工作流ﻫ获取spworkflowmanager获取spworkflowassociation,针对一个item启动向Item中添加附件
if(fileUploadAttach.HasFile)
{
Streamstream=fileUploadAttach.PostedFile.InputStream;ﻫstream.Position=0;ﻫbyte[]buffer=newbyte[stream.Length];ﻫstream.Read(buffer,0,(int)stream.Length);ﻫitemNew.Attachments.Add(fileUploadAttach.PostedFile.FileName,buffer);
itemNew.Update();ﻫitemNew.ParentList.Update();
stream.Close();ﻫ}CAML查找Lookup型
<FieldRefName="GMP"LookupId="TRUE"/><ValueType="Lookup">1</Value>用户型"<FieldRefName=""User""LookupId=""TRUE""/>"+"<ValueType=""User"">"+user.ID+"</Value>"+WEB页面显示word
假如想让web页面显示出word文档要加Response.ContentType="application/msword";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();多文献上传
SPFileCollectiondestFiles=siteCollection.AllWebs["Destination_Site"].Folders["Destination_DocLib"].Files;
foreach(SPFilesrcFileinsrcFolder.Files){if(srcFile.TimeLastModified<Convert.ToDateTime("12/5/202312:00:00AM")){stringdestURL=destFiles.Folder.Url+"/"+srcFile.Name;byte[]binFile=srcFile.OpenBinary();destFiles.Add(destURL,binFile,true);}}工作流中权限ﻫ先HybridDictionary一个对象叫task1permission,然后task1permission.Add(taskProps.AssignedTo,SPRoleType.Contributor),最后将task1permission赋值给task的SpecialPermissions检查权限ﻫpublicvoidCheckPermissions(SPBasePermissionspermissionMask)检查当前用户是否有permissionMask的权限,假如没有返回一个UnauthorizedAccessException的异常。BoolhavePermission=SPList.DoesUserHavePermissions(SPBasePermissionspermissionMask)添加权限
SPListDTTasks=web2.Lists["DocumentTasks"];SPRoleAssignmentroleAssignForMember=newSPRoleAssignment((SPPrincipal)newGroup);//为newGroup这个组分派权限SPRoleDefinitionroleDefForMemberr=web2.RoleDefinitions["DTMembers"];roleAssignForMember.RoleDefinitionBindings.Add(roleDefForMemberr);
if(!DTTasks.hasUniqueRoleAssignments)//如文献夹没有独立的权限{DTTasks.BreakRoleInheritance(false);//删除文献夹继承的权限true删除的同时继承false删除的同时不继承}DTTasks.RoleAssignments.Add(roleAssignForMember);TTasks.Update();
无法查询文献夹下的item,只能查找根目录的解决办法:ﻫquery.ViewAttributes="Scope='Recursive'"
MembernameﻫDescriptionﻫ
DefaultﻫShowonlythefilesandsubfoldersofaspecificfolder.ﻫ
FilesOnlyﻫShowonlythefilesofaspecificfolder.
RecursiveﻫShowallfilesofallfolders.ﻫ
RecursiveAllﻫShowallfilesandallsubfoldersofallfolders.
TheSPViewScopeenumerationisusedwiththeScopepropertyoftheSPViewclass.EventHandler中的AddingUpdating等操作如何赋值
publicoverridevoidItemAdding(SPItemEventPropertiesproperties){ﻫ//Demo1:在新建时取用户输入的值并作修改ﻫstringnewValue="新的值是:"+properties.AfterProperties["Title"].ToString();properties.AfterProperties.ChangedProperties.Add("Title",newValue);
}如何从SPAttachmentCollection中获取到SPfile
SPAttachmentCollectionattachments=item.Attachments;if(attachments.Count>0){for(inti=0;i<attachments.Count;i++){stringurl=attachments.UrlPrefix+attachments[i];//得到附件的共同前缀再加上附件的名称SPFilefile=web.GetFile(url);stringcustomerName=item["CustomerName"].ToString().Split('#')[1];file.CopyTo(properties.WebUrl+"/CRMDocument/"+customerName+"/04CustomerScoring/"+attachments[i],true);}如何查看SharePoint未知错误在MOSS开发自定义功能后,出现错误页面只显示“出现未知错误”的提醒,查看很不方面,通过下面方法就可以直接在犯错页面查看错误信息。
修改Web应用程序根目录上的Web.config文献中的两个地方:
查找以下位置并更改即可(红色为更改前后的值)
一、MaxControls="200"CallStack="false"改为MaxControls="200"CallStack="true"ﻫ二、customErrorsmode="On"改为customErrorsmode="Off"
Webpart犯错,无法打开页面,contents=1,会转到webpart管理页面,把出问题的删掉
在URL后面加入“?&toolpaneview=2”打开设计页ﻫ或者加“DisplayMode=Design”
http://cnsh-10vms1/_layouts/spcontnt.aspx?&url=/_catalogs/wp/forms/editForm.aspx这页面是维护页面“超链接或图片”类型栏的值,相应的对象模型为SPFieldUrl和SPFieldUrlValue,可以这样读取:
SPFieldUrlValuevalue=newSPFieldUrlValue(item["URL"].ToString());
Console.WriteLine(value.Description);
Console.WriteLine(value.Url);或SPFieldUrlfieldUrl=(SPFieldUrl)item.Fields["URL"];ﻫSPFieldUrlValuevalue=(SPFieldUrlValue)fieldUrl.GetFieldValue(item["URL"].ToString());
Console.WriteLine(value.Description);ﻫConsole.WriteLine(value.Url);赋值SPFieldUrlfieldUrl=(SPFieldUrl)supplierNew.Fields[dgi.Cells[0].Text];SPFieldUrlValuefieldUrlValue=newSPFieldUrlValue();fieldUrlValue.Url=web.Url+"/"+supplierDocument.RootFolder.Url+"/"+supplierNew["Title"].ToString()+"-"+supplierNew.ID;fieldUrlValue.Description=dgi.Cells[0].Text;supplierNew[dgi.Cells[0].Text]=fieldUrlValue;
将子网站移动到主网站???ﻫ修改子网站下的网站栏到网站集下解决了,直接到WSS_Content数据库里面,修改表ContentTypes的Scope字段,特别方便,暂时没发现犯错误~SharePoint中LookUp字段的使用
赋值如何在代码中使用lookup字段ﻫ
对于lookup字段在可视界面时,感觉挺方便,但是在写代码的时候,对它进行赋值的时候,就感觉很麻烦。不知道哪位高手对这个赋值有更好的方法,谢谢。ﻫ方法一(听11同学说的)ﻫSPFieldLookupValueCollectionlookupValues;lookupValues=(SPFieldLookupValueCollection)listItem["MyLookupField"];lookupValues.Add(newSPFieldLookupValue(1,"SomeLookupValue"));ﻫlistItem["MyLookupField"]=lookupValues;listItem.Update();ﻫ这方法感觉赋值就是受罪,写这么多代码。ﻫ方法二。直接用
listItem["MyLookupField"]=1,2,3ﻫ但这此方法要知道字符串所相应的Id。,有什么最有效的方法。。请教高手ﻫ
ﻫ
实际使用如下代码(通过测试):
SPWebweb=SPContext.Current.Web;SPListcustomerList=web.Lists["Customer"];SPQueryquery=newSPQuery();query.Query="<Where><Eq><FieldRefName='Title'/><ValueType='Text'>"+DropDownList1.SelectedItem.Text+"</Value></Eq></Where>";SPListItemCollectioncustomerC=customerList.GetItems(query);intcu1=customerC[0].ID;SPListprojectList=web.Lists["Project"];SPListItemprojectNew=projectList.Items.Add();projectNew["Customer"]=cu1;projectNew["Title"]=txtboxProjectName.Text;projectNew.Update();LookUpCollection的赋值
SPFieldLookupValueCollectionlvsGDE=newSPFieldLookupValueCollection();foreach(ListItemiteminlbGDECurrent.Items)//lbGDECurrent为下拉框{SPFieldLookupValuelvGDE=newSPFieldLookupValue();lvGDE.LookupId=int.Parse(item.Value);lvsGDE.Add(lvGDE);}Item[“Lookups”]=lvsGDE;LookUp和User的读取ﻫ假如LookUp不允许多选的时候,Item["LookUp"]得到的是一个stringStringC=(item["CreatedBy"]==null)?"":item["CreatedBy"].ToString().Remove(0,item["CreatedBy"].ToString().IndexOf(";#")+2);否则是一个SPFieldLookUpValueCollection用户类型为SPFieldUserValueCollectionList<SPUser>Users=newList<SPUser>();
List<SPGroup>Groups=newList<SPGroup>();using(SPSiteSite=newSPSite("http://windbell"))ﻫ{
SPWebWeb=Site.RootWeb;
SPListList=Web.Lists["测试列表"];ﻫSPItemItem=List.Items[0];SPFieldUserValueCollectionValues=(SPFieldUserValueCollection)Item["用户和用户组"];foreach(SPFieldUserValueValueinValues)ﻫ{
if(User!=null)
{ﻫSPUserUser=Value.User;ﻫUsers.Add(User);ﻫ}ﻫelse
{
SPGroupGroup=Web.Groups.GetByID(Value.LookupId);
Groups.Add(Group);
Users.AddRange(Group.Users);
}ﻫ}
}
定义一个Group
SPGroupCollectiongroups=oWebsite.SiteGroups;SPUseruser=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 江苏省仪征市扬子中学2024届八年级物理第二学期期末达标检测试题及答案解析
- 员工合同样本
- 福建省福州市三校联考2023-2024学年高一数学第二学期期末监测试题含解析
- 著作权授权许可使用合同
- 2024届广东省执信中学八年级物理第二学期期末经典试题及答案解析
- 河北省沧州任丘市2023-2024学年八年级物理第二学期期末教学质量检测试题及答案解析
- 物业公司食品采购合同
- 新疆巴州三中2024年高一下数学期末统考模拟试题含解析
- 云南省玉溪市江川县2024届数学高一下期末综合测试模拟试题含解析
- 2024年智能卡质检分拣机项目合作计划书
- GB 19522-2024车辆驾驶人员血液、呼气酒精含量阈值与检验
- 2024年营养指导员理论知识考试题库及答案
- 人教版二年级《上册语文》期末试卷及参考答案
- 2024年四川省中考历史模拟训练试卷
- 教科版一年级下册第一单元《我们周围的物体》
- 中华民族发展史智慧树知到期末考试答案章节答案2024年云南大学
- 2024新高考生物临考冲刺预测押题:选择题专项
- 湖北省谷城县达标名校2024年中考冲刺卷物理试题含解析
- 2024年04月山东建筑大学招考聘用工作人员36人笔试历年(难与易错考点)高频考题后附答案详解
- 居住区绿地设计说明
- 2024年台球馆行业市场分析报告
评论
0/150
提交评论