sharepoint知识点总结大全.doc

上传人:laozhun 文档编号:2394575 上传时间:2023-02-17 格式:DOC 页数:20 大小:67KB
返回 下载 相关 举报
sharepoint知识点总结大全.doc_第1页
第1页 / 共20页
sharepoint知识点总结大全.doc_第2页
第2页 / 共20页
sharepoint知识点总结大全.doc_第3页
第3页 / 共20页
sharepoint知识点总结大全.doc_第4页
第4页 / 共20页
sharepoint知识点总结大全.doc_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《sharepoint知识点总结大全.doc》由会员分享,可在线阅读,更多相关《sharepoint知识点总结大全.doc(20页珍藏版)》请在三一办公上搜索。

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, )识别为垃圾邮件来历不明的软件发的邮件都是垃圾邮件。所以发邮件的时候要

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自带的方法发送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方式发送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发Mail的时候,我们要配置他的SMTP Server等,但是在Sharepoint里,已经提供了相关的封装的方法:SPUtility.SendEmail(SPWeb, false, false,to, MailTitle,MailBody);上面的方法只能以To的形式来发Mail,有的时候我们需要使用CC ,BCC,我们可以利用该函数的另一个重载来

10、实现: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等,当然使用上面的函数的前提是你在管理中心已经配置好了传出电子邮件的设置。更新工作流状态SPList list = web.ListTestList;SPListItem listItem = list.GetItemById(1);string state = listItem.Fields审批状态.InternalName;listItemstate = 0; /设置列表审批状态为“已批准”(0表示 已批准)listItem.SystemUpdate(); /列表使用SystemUpDate()方法来更新审批状态。/文

12、档库SPDocumentLibrary docLib = web.ListTestLib;SPListItem libItem = list.GetItemById(1);string state = libItem.Fields审批状态.InternalName;libItemstate = 0; /设置文档库审批状态为“已批准”(0表示已批准)libItem.UpdateOverwriteVersion(); /文档库使用UpdateOverwriteVersion()方法来更新审批状态。item_ModerationStatus = (int)SPModerationStatusType

13、.Approved; item.Update(); 这样好像就可以string转GuidGuid dd = new guid(str);Content TypeItem“ContentTypeId”或者Item“ContentType”显示个人信息用SPD打开根站点在根下 _catalogs 目录有 users(用户信息表)此表是网站集所管理的用户列表。默认为隐藏。点右键 属性-设置- 钩掉“在浏览器中隐藏”选项。此时,用户表 就可以像其他列表一样操作要实现 显示照片和姓名 职务 部门等信息可以通过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参数为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相对触发的layouts中Page

18、的地址The redirect occurs relative to the localized layouts page. Static静态地址,非相对地址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=开发部,administrator,pass, AuthenticationTypes.Secure);广州-jian(简) 说:这句应该是最关键的了广州-jian(简) 说:然后想在“开发部”下面增加用户,就用di.Children.Add就可以了List附件的读取怎么取得sharepoint表单库中的表单附件的数据,我想将附件数据单独的提取出来,但是提取的信息全是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实现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开发自定义功能后,出现错误页面只显示“出现未知错误”的提示,查看很不方面,通过下面方法就可以直接在出错页面查看错误信息。修改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数据库里面,修改表ContentTypes的Scope字段,特别方便,暂时没发现出错误SharePoint中LookUp字段的使用赋值如何在代码中使用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“Lookups” = lvsGDE;LookUp和User的读取如果LookUp不允许多选的时候,ItemLookUp得到的是一个stringString C = (itemCreated By = null) ? : itemCreated By.ToString().Remove(0, itemCreated By.ToString().IndexOf(;#) + 2);否则是一个SPFieldLookUpValueCollecti

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号