sharepoint知识点总结
{
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 )item["Users"];
SPFieldLookupValueCollection values = item["Users "].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 byte[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型
<FieldRef Name="GMP" LookupId="TRUE"/>
<Value Type="Lookup">1</Value>
用户型
"<FieldRef Name=""User"" LookupId=""TRUE""/>" +
"<Value Type=""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();
多文件上传
SPFileCollection destFiles =
siteCollection.AllWebs["Destination_Site"]
.Folders["Destination_DocLib"].Files;
foreach (SPFile srcFile in srcFolder.Files)
{
if (srcFile.TimeLastModified <
Convert.ToDateTime("12/5/2002 12:00:00 AM"))
{
string destURL = 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
检查权限
public void CheckPermissions (SPBasePermissions permissionMask)
检查当前用户是否有permissionMask的权限,如果没有返回一个UnauthorizedAccessException的异常。
Bool havePermission = SPList.DoesUserHavePermissions(SPBasePermissions permissionMask)
添加权限
SPList DTTasks = web2.Lists["Document Tasks"];
SPRoleAssignment roleAssignForMember = new SPRoleAssignment((SPPrincipal)newGroup); //为newGroup这个组分配权限
SPRoleDefinition roleDefForMemberr = 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' "
|
Member name |
Description |
Default |
Show only the files and subfolders of a specific folder. |
|
FilesOnly |
Show only the files of a specific folder. |
|
Recursive |
Show all files of all folders. |
|
RecursiveAll |
Show all files and all subfolders of all folders. |
The SPViewScope enumeration is used with the Scope property of the SPView class.
EventHandler中的Adding Updating等操作如何赋值
public override void ItemAdding(SPItemEventProperties properties)
{
// Demo1: 在新建时取用户输入的值并作修改
string newValue = "新的值是:" + properties.AfterProperties["Title"].ToString();
properties.AfterProperties.ChangedProperties.Add("Title", newValue);
}
如何从SPAttachmentCollection中获取到SPfile
SPAttachmentCollection attachments = item.Attachments;
if (attachments.Count > 0)
{
for (int i = 0; i < attachments.Count; i++)
{
string url = attachments.UrlPrefix + attachments[i];//得到附件的共同前缀再加上附件的名称
SPFile file = web.GetFile(url);
string customerName = item["Customer Name"].ToString().Split('#')[1];
file.CopyTo(properties.WebUrl + "/CRM Document/" + customerName + "/04 Customer Scoring/" + attachments[i], true);
}
在MOSS开发自定义功能后,出现错误页面只显示“出现未知错误”的提示,查看很不方面,通过下面方法就可以直接在出错页面查看错误信息。
修改Web应用程序根目录上的Web.config文件中的两个地方:
查找以下位置并更改即可(红色为更改前后的值)
一、MaxControls="200" CallStack="false" 改为 MaxControls="200" CallStack="true"
二、customErrors mode="On" 改为 customErrors mode="Off"
Webpart出错,无法打开页面,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(item["URL"].ToString());
Console.WriteLine(value.Description);
Console.WriteLine(value.Url);
或
SPFieldUrl fieldUrl = (SPFieldUrl)item.Fields["URL"];
SPFieldUrlValue value = (SPFieldUrlValue)fieldUrl.GetFieldValue(item["URL"].ToString());
Console.WriteLine(value.Description);
Console.WriteLine(value.Url);
赋值
SPFieldUrl fieldUrl = (SPFieldUrl)supplierNew.Fields[dgi.Cells[0].Text];
SPFieldUrlValue fieldUrlValue = new SPFieldUrlValue();
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字段的使用
赋值
|
||||
|
实际使用如下代码(经过测试):
SPWeb web = SPContext.Current.Web;
SPList customerList = web.Lists["Customer"];
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + DropDownList1.SelectedItem.Text + "</Value></Eq></Where>";
SPListItemCollection customerC = customerList.GetItems(query);
int cu1 = customerC[0].ID;
SPList projectList = web.Lists["Project"];
SPListItem projectNew = projectList.Items.Add();
projectNew["Customer"] = cu1;
projectNew["Title"] = 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不允许多选的时候,Item["LookUp"]得到的是一个string
String C = (item["Created By"] == null) ? "" : item["Created By"].ToString().Remove(0, item["Created By"].ToString().IndexOf(";#") + 2);
否则是一个SPFieldLookUpValueCollection
用户类型为SPFieldUserValueCollection
List<SPUser> Users = new List<SPUser>();
List<SPGroup> Groups = new List<SPGroup>();
using (SPSite Site = new SPSite("http://windbell"))
{
SPWeb Web = Site.RootWeb;
SPList List = Web.Lists["测试列表"];
SPItem Item = List.Items[0];
SPFieldUserValueCollection Values = (SPFieldUserValueCollection)Item["用户和用户组"];
foreach (SPFieldUserValue Value in Values)
{
if (User != null)
{
SPUser User = Value.User;
Users.Add(User);
}
else
{
SPGroup Group = Web.Groups.GetByID(Value.LookupId);
Groups.Add(Group);
Users.AddRange(Group.Users);
}
}
}
定义一个Group
SPGroupCollection groups = oWebsite.SiteGroups;
SPUser user = oWebsite.Users["xxx""xxxxxx"];
SPMember member = oWebsite.Users["xxxxx""xxx"];
groups.Add("TestGroup", member, user, "Description");
将一个Group分配进一个Role
if (SPWeb.HasUniqueRoleAssignments == true)//web是否有自己的角色分配,有True
{
SPWeb.AllowUnsafeUpdates = true;
SPRoleAssignment roleAssign = new SPRoleAssignment((SPPrincipal)SPSite.RootWeb.SiteGroups["Style Resource Readers"]);
SPRoleDefinition roleDef = SPWeb.RoleDefinitions["Open Access"];
roleAssign.RoleDefinitionBindings.Add(roleDef);
SPWeb.RoleAssignments.Add(roleAssign);
}
读取User Profile
ServerContext spcontext2 = ServerContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(spcontext2);
string userName = member.Name;
SPListItem newMember = projectMember.Items.Add();
newMember["User Name"] = member.Name;
newMember["Project"] = Project;
newMember["Group"] = newGroup.Name;
newMember["E-mail Address"] = member.Email;
if (profileManager.UserExists(userName))
{
UserProfile profile = profileManager.GetUserProfile(userName);
newMember["Business Phone"] = profile["BusinessPhone"].Value;
newMember["Mobile Phone"] = profile["CellPhone"].Value;
newMember["Fax"] = profile["Fax"].Value;
//newMember["Notes"] = member[PropertyConstants.CellPhone].
newMember["SkypeMSN"] = profile["SkypeMSN"].Value;
newMember["Principalship"] = profile["Principalship"].Value;
newMember["Location"] = profile["Location"].Value;
}
newMember.Update();
关闭EventHandler
this.DisableEventFiring();//关闭EventHandler,防止多重触发
//save changes
addedItem.Update();
this.EnableEventFiring();
workflowProperties.OriginatorUser得到当前workflow instance的发起者
workflowProperties.Item不就可以直接拿到SPListItem
SharePoint中访问AD
System.DictionaryService
sharepoint知识点总结的更多相关文章
- Sharepoint学习笔记—习题系列--70-576习题解析 --索引目录
Sharepoint学习笔记—习题系列--70-576习题解析 为便于查阅,这里整理并列出了70-576习题解析系列的所有问题,有些内容可能会在以后更新. 需要事先申明的是: 1. ...
- Sharepoint学习笔记—习题系列--70-573习题解析 -(Q142-Q143)
Question 142You have a Feature that contains an image named ImageV1.png.You plan to create a new ver ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q128-Q130)
Question 128 You are designing a SharePoint 2010 solution that includes a custom site definition an ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q116-Q120)
Question 116 You are helping a corporate IT department create a SharePoint 2010 information archite ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q112-Q115)
Question 112 You are designing a public-facing SharePoint 2010 Web site for an elementary school th ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q105-Q108)
Question 105 You are designing a SharePoint 2010 application that contains a single list named Us ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q99-Q101)
Question 99 You have designed a new SharePoint 2010 Web Part that was deployed to the testing envir ...
- 无废话SharePoint入门教程四[创建SharePoint母版页]
一.前言 文章成体系,如果有不明白的地方请查看前面的文章. 二.目录 1.创建HTML页面 2.将HTML文件转换为SharePoint母版页 3.在 SPD中修改母版页“PlaceHolderMai ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q1-Q3)
这里我把从网上搜集到的针对Sharepoint 70-576的有关练习进行系统的解析,整理成一个系列, 分期.分批次共享出来,供大家研究. 70-573考试注重的是"知道"相关知识 ...
随机推荐
- 基础线程机制--Executor线程池框架
基础线程机制 Executor线程池框架 1.引入Executor的原因 (1)new Thread()的缺点 每次new Thread()耗费性能 调用new Thread()创建的线程 ...
- Linux中Mysql安装卸载
参考博客:https://www.cnblogs.com/xrog/p/6862669.html安装步骤:#wget http://dev.mysql.com/get/mysql57-communit ...
- 75th LeetCode Weekly Contest Champagne Tower
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so ...
- delete ELK index
Go to tab “Dev Tools”4. On the left console type:GET _cat/indices?v&s=store.size:descand execute ...
- java向数据库插入数据时的错误: Duplicate entry '' for key 'PRIMARY' 问题解决
错误提示为:你插入的记录与数据表中原有记录的主键重复了(Duplicate).所以插入失败 mysql主键设置成auto_increment时,进行并发性能测试出现主键反复Duplicate entr ...
- my01_Mysql router 安装
Mysql router 主要用途是读写分离,主主故障自动切换,负载均衡,连接池等.安装如下 下载地址:https://dev.mysql.com/downloads/router/ tar -zxv ...
- linux的shell脚本
一.遇到的问题: 1.在Documents/shell_Document的文件夹下创建第一个脚本. 但是发现在图形化界面不能执行shell脚本.只能到命令行模式下才能执行.感觉太麻烦,我的虚拟机从图形 ...
- 《mac的git安装手册-2》
<mac的git安装手册-2> 下载地址 https://git-scm.com/downloads 如果遇到打不开的情况,请在系统偏好设置内——>安全性与隐私下 ——>选择仍 ...
- component: resolve => require(['../pages/home.vue'], resolve)
component: resolve => require(['../pages/home.vue'], resolve) vue 路由的懒加载 import Vue from 'vue' im ...
- SpringBoot中通过实现WebMvcConfigurer完成参数校验
在Spring5.0和SpringBoot2.0中废弃了WebMvcConfigurerAdapter类. 现有两种解决方案 1 直接实现WebMvcConfigurer (官方推荐)2 直接继承We ...