APPDEV Sharepoint 2010 For Developers. 笔记

2010-12-10:

Module 01 -> 03.Basic Architecture:

  • 14\TEMPLATE\GLOBAL\v4.master
  • To enable code blocks, add a tag like the following in the web.config of the site:
代码
<SharePoint>
<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
<PageParserPaths>
<PageParserPath VirtualPath="/*" IncludeSubFolders="true" CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>
</SafeMode>
......
  • Farm vs. Sandbox deployment

Module 02 -> 04. Feature Basics

14\Template\Features

FeatureName subdirectory

Feature.xml

  Must be named feature.xml

0 or more files containing feature elements

  By convention named elements.xml

0 or more files used by the feature

Feature Scopes

  • Farm
  • Web Application
  • Site
  • Web

Feature Schema

  • ActivationDependencies
  • ElementManifests
  • Properties
  • UpgardActions

Installing and Activating Features

Install

  Web Solution Package

  Stsadm.exe

Activate feature

  Site settings in browser

  Stsadm -o ActivateFeature


Lab: create feature.xml; can use wss.xsd as the xml schema.

关于Module参见:

http://msdn.microsoft.com/zh-cn/library/ms441170(v=office.12).aspx

http://msdn.microsoft.com/zh-cn/library/ms441170(v=office.14).aspx

注意事项:

Module的Url属性为该文档库的url地址,具体呈现在浏览器中,如地址为:

http://sp2010/TestWiki/Shared%20Documents1/Forms/AllItems.aspx

则Url属性值应为:Shared Documents1

如果出错了,更改elements文件后要重新install feature,不能简单地用-force选项:

stsadm -o installfeature -name DemoFeature -force

而应该先uninstall:

stsadm -o uninstallfeature -name DemoFeature

再重新安装

2010-12-11:

Module 02 -> 05.Feature Types

Sharepoint Manager 2010:

http://spm.codeplex.com/releases/view/51438

ContentType Element

Defines a type

Supports inheritance via ID

  • 0x - System
  • 0x01 - Item
  • 0x0101 - Document
  • 0x010102 - Picture

Custom types use GUIDs separated by 00

  • 0x010102008ee23f39......................

FieldRefs identify columns

错误排查:

记录下Correlation ID;然后到14\Logs下找到最近修改的log文件, ctrl+F Correlation ID。

ContentType Feature Activate成功后,可到site的Content Type Library中查找刚Activate的Content Type。如果找不到,需要iisreset一下。

继承类型:例如,继承自Item,则可以拥有Item的Title Column。

List Instance:

FeatureId:对应的List Type的Feature Id.例如,如果是一个CustomList,则到14\TEMPLATE\FEATURES\CustomList\Feature.xml下去查看Feature Id。

TemplateType:系统类型中,Feature Id最后的三位就是TemplateType。如果不确定,可以在上述的Feature.xml文件中找到ElementManifest的Location,然后按此Location找到对应文件查看其中记录的Type。

Content Type Binding:

Binds a content type to a list instance

Requires: ContentTypeId and ListUrl

Does not affect views(如果要affect views,应通过.net code做这个事情manually,通过Feature Receiver)

Feature Event Receivers
.NET code to run on

  • Install
  • Activate
  • Deactivate
  • Uninstall
  • Upgrade 

Solutions: Package features and other resources for deployment

VS 2010可以做到

pre-vs2010: WSPBuilder, STSDev

Solutions Files:

WSP extension

Cabinet file

Contains

  Manifest describing contents and install targets

  Features

  Assemblies

  Other files to target any location in SharePoint root

例如,MOSS自带的功能就能够生成一个这样的Package:

Site Settings->Site Actions->Save site as template

生成后,可以在Site Settings->Galleries->Solutions中找到它。(下载后,rename它为cab文件,即可打开)

安装solution(SandBox Solution):

在一个其他的Site,Site Settings->Galleries->Solutions->Upload Solution->Activate。

Site Actions->More Options...->Filter By: Site,找到刚才upload的solution,创建;

如果出错,通常是因为有一些Feature没有默认激活。所以查看原先的站点(since we are deploying a wsp saved as a template from an original site),对比一下,激活应该激活的feature,然后重试。

Module 03 -> 06. Visual Studio 2010

Avoiding Common Problems

  • Always run as administrator
  • Platform target should be "Any CPU" for console applications
  • References window won't show Microsoft.SharePoint(and others) when Client Profile is selected

Tricks: the missing asp.net page template

如果我们要在Module中添加ASP.NET页面,目前没有现成的模板。可以这样:在VS Solution中添加一个ASP.NET Web Application的项目,在其中创建ASP.NET页面。对于需要添加到Module中的文件,复制一份到Module中,这样,vs会自动替我们在Module的Elements.xml中添加这些文件;之后,在Web Application项目的Post Build Event Command中(或Pre Build?)添加指令,编译后复制对应文件即可。


Module 03 ->07. VS 2010 Visual Designers

Replaceable Parameters

Token for values unknown at design time

Works in the following file types by default

XML,ASCX,ASPX,Webpart,DWP

Examples

  • $SharePoint.Project.AssemblyFullName$
  • $SharePoint.Feature.Id$

2010-12-13:

Module 04->09.Exploring the Object Model

SharePoint Manager 2010 + VS Object Browser: 在SPM中查看各项属性,对应在Object Browser中查看属性的具体信息

Core Foundation Assemblies

  • Located in 14\ISAPI
  • Microsoft.SharePoint - Core classes
  • Microsoft.SharePoint.Client - Core classes for client applications
  • Microsoft.SharePoint.Linq - Linq to SharePoint
  • SharePoint specific workflow actions

Core Classes

SPSite

  SPWeb

    SPField

    SPContentType

    SPFile

    SPList

      SPListItem

    SPUser


SPContext

Security, Identity, and Impersonation

  • Default runtime identity: Authenticated user
  • Execution context: Current site collection; SPContext.Current.Site
  • Elevate Permissions: Via impersonation; New site collection object instance(例如,用new SPSite(guid)的方法或new SPSite(url)的方法)

SPSecurity.RunWithElevatedPrivileges

  • Delegate
  • Impersonate service account
  • Does not require user id or password
  • Permissions constrained by service account permissions
  • Requires a new instance of SPSite for security context

AllowUnsafeUpdates

Property of 

  • SPSite
  • SPWeb

Set to true to disable security validation on Update()

Required if persisting anything within RunWithElevatedPrivileges

Any exception, handled or otherwise, sets AllowUnsafeUpdates to False.


Custom Master Pages

startermasterpages.codeplex.com

code.msdn.microsoft.com/odcSP14StarterMaster

Key PlaceHolders:

  1. PlaceHolderAdditionalPageHead
  2. PlaceHolderMain
  3. PlaceHolderPageTitle
  4. PlaceHolderPageTitleInTitleArea
  5. PlaceHolderTopNavBar and related
  6. PlaceHolderLeftNavBar and related
原文地址:https://www.cnblogs.com/damnedmoon/p/1902742.html