sharepoint知识点总结大全.doc_第1页
sharepoint知识点总结大全.doc_第2页
sharepoint知识点总结大全.doc_第3页
sharepoint知识点总结大全.doc_第4页
sharepoint知识点总结大全.doc_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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;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, )识别为垃圾邮件来历不明的软件发的邮件都是垃圾邮件。所以发邮件的时候要套个马甲。这个代码就是套个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 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, Normal); 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 = new 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, 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 MailAddress(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.Normal;/构建SmtpClient对象SmtpClient smtp = new SmtpClient();trysmtp.Send(mailobj);return true;catchreturn false;我们使用.NET类库中的API发Mail的时候,我们要配置他的SMTP Server等,但是在Sharepoint里,已经提供了相关的封装的方法:SPUtility.SendEmail(SPWeb, false, false,, MailTitle,MailBody);上面的方法只能以To的形式来发Mail,有的时候我们需要使用CC ,BCC,我们可以利用该函数的另一个重载来实现: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,text/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()方法来更新审批状态。/文档库SPDocumentLibrary docLib = web.ListTestLib;SPListItem libItem = list.GetItemById(1);string state = libItem.Fields审批状态.InternalName;libItemstate = 0; /设置文档库审批状态为“已批准”(0表示已批准)libItem.UpdateOverwriteVersion(); /文档库使用UpdateOverwriteVersion()方法来更新审批状态。item_ModerationStatus = (int)SPModerationStatusType.Approved; item.Update(); 这样好像就可以string转GuidGuid dd = new guid(str);Content TypeItem“ContentTypeId”或者Item“ContentType”显示个人信息用SPD打开根站点在根下 _catalogs 目录有 users(用户信息表)此表是网站集所管理的用户列表。默认为隐藏。点右键 属性-设置- 钩掉“在浏览器中隐藏”选项。此时,用户表 就可以像其他列表一样操作要实现 显示照片和姓名 职务 部门等信息可以通过webpart 显示指定列信息,转换为XSLT视图,进行定制注意设置筛选条件 为: ID 列 = 当前用户最终可以自由定制。Item.SystemUpdate();方法更改时间更改者事件更改和审核记录订阅properties are not demoted into documents增加版本SystemUpdate()SystemUpdate(Bool)False不增长时间操作,不超时SPLongOperation oparetion = new SPLongOperation(this);tryoparetion.Begin();try/启动工作流/StartInitData参数为ApproveWFAssociationData类的序列化后的stringweb.Site.WorkflowManager.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.RelativeToLayoutsPage, 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 Resource 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的地址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. /zh-cn/library/microsoft.sharepoint.utilities.spredirectflags.aspx内容类型SPWeb.AvailableContentTypes得到当前web所有活动的内容类型SPWeb.ContentTypes 得到部署到当前web上的内容类型,不要用这个。Web的用户listweb.SiteUserInfoListAD操作DirectoryEntry di = new DirectoryEntry(LDAP:/ADServer/OU=开发部,administrator,pass, AuthenticationTypes.Secure);广州-jian(简) 说:这句应该是最关键的了广州-jian(简) 说:然后想在“开发部”下面增加用户,就用di.Children.Add就可以了List附件的读取怎么取得sharepoint表单库中的表单附件的数据,我想将附件数据单独的提取出来,但是提取的信息全是BASE64编码,有没有这方面的信息或资料,BASE64 解码不就完了System.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(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/ProjectManagement/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 != null)string formOnSubmitAtt = this.Page.Form.Attributesonsubmit;if (formOnSubmitAtt = return _spFormOnSubmitWrapper();)this.Page.Form.Attributesonsubmit =_spFormOnSubmitWrapper();ScriptManager.RegisterStartupScript(this,typeof(你UserControl的ClassName), UpdatePanelFixup, _spOriginalFormAction =document.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(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 = ;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 buffer = 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/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();多文件上传SPFileCollection destFiles =siteCollection.AllWebsDestination_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.ToString().Split(#)1;file.CopyTo(properties.WebUrl + /CRM Document/ + customerName + /04 Customer Scoring/ + attachmentsi, true);如何查看SharePoint未知错误在MOSS开发自定义功能后,出现错误页面只显示“出现未知错误”的提示,查看很不方面,通过下面方法就可以直接在出错页面查看错误信息。修改Web应用程序根目录上的Web.config文件中的两个地方:查找以下位置并更改即可(红色为更改前后的值)一、MaxControls=200 CallStack=false 改为 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这页面是维护页面“超链接或图片”类型栏的值,对应的对象模型为SPFieldUrl和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.WriteLine(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.ID;fieldUrlValue.Description = dgi.Cells0.Text;supplierNewdgi.Cells0.Text = fieldUrlValue;将子网站移动到主网站?修改子网站下的网站栏到网站集下解决了,直接到WSS_Content数据库里面,修改表ContentTypes的Scope字段,特别方便,暂时没发现出错误SharePoint中LookUp字段的使用赋值如何在代码中使用lookup字段 对于lookup字段在可视界面时,感觉挺方便,但是在写代码的时候,对它进行赋值的时候,就感觉很麻烦。不知道哪位高手对这个赋值有更好的方法,谢谢。 方法一(听11同学说的) SPFieldLookupValueCollection lookupValues;lookupValues = (SPFieldLookupValueCollection)listItemMyLookupField;lookupValues.Add(new SPFieldLookupValue(1, SomeLookupValue); listItemMyLookupField = lookupValues;listItem.Update();这方法感觉赋值就是受罪,写这么多代码。 方法二。直接用 listItemMyLookupField =1,2,3 但这此方法要知道字符串所对应的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.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为下拉框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);否则是一个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 = (SPFieldUserValueCollection)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

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论