Handling transactions working on Windows Sharepoint Services lists
Leon O'Brien talks about SharePoint Transactions
пятница, 30 мая 2008 г.
Transactions in Sharepoint
вторник, 27 мая 2008 г.
Protect you custom list's fields.
If you have strong dependence between you code and structure of your list, you can protect it from changing and deleting fields by Handling events.
Use SPListEventReciever class override methods fieldDeleting and fieldChanging.
class FieldEventHandler : SPListEventReceiver
{
public override void FieldDeleting(SPListEventProperties properties)
{
base.FieldDeleting(properties);
String fieldsList = ConfigurationManager.AppSettings["Fields"];
if (fieldsList.Contains("#" + properties.FieldName + ";"))
{
properties.Cancel = true;
}
}
public override void FieldUpdating(SPListEventProperties properties)
{
base.FieldUpdating(properties);
String fieldsList = ConfigurationManager.AppSettings["Fields"];
if (fieldsList.Contains("#" + properties.FieldName + ";"))
{
properties.Cancel = true;
}
}
}
Use web config as a storage of key value where you put names of your fields.
<appsettings>
<add key="Fields" value="#name1;#name2;">
</add>
</appsettings>
Install your EventHandler with feature.
private string assemblyName = @"AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=key";
private string className = @"NameSpace.FieldEventHandler";
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = (SPWeb)properties.Feature.Parent;
SPList lst = web.Lists["ListName"];
lst.EventReceivers.Add(SPEventReceiverType.ItemAdding, assemblyName, className);
lst.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, className);
lst.Update();
}
ListViewWebPart my own filter.
Standard filter allows us using only equal statements.
If You need to extend your abilities, You can make your own webpart - ListViewWebPartModificator.
This webpart can modify representation of list in ListViewWebPart by changing it's schema on the fly.
I've made it recently, because I needed to show information depended on parameters or user.
You can write properties to url?property=value.
Read it in webpart class. Like a this.Context.Request["DocumentID"]
And change the schema Query tag.
In that way, you can modify anyone tag of view schema.
Code:
_DocumentID - you property from url.
_viewGuid - webpart property guid of the ListViewWebPart to modify.
SPWebPartManager spwp = (SPWebPartManager)this.WebPartManager;
foreach (System.Web.UI.WebControls.WebParts.WebPart wp in spwp.WebParts)
{
try
{
ListViewWebPart lv = (ListViewWebPart)wp;
if (lv.ViewGuid == _viewGuid)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.InnerXml = lv.ListViewXml;
XmlNode node;
node = xmlDoc.DocumentElement;
node["Query"].InnerXml = "<where>" + "<eq><fieldref name="ParentId"><value type="Text">" + _DocumentID + "</value></fieldref>" + "</eq>";
lv.ListViewXml = xmlDoc.InnerXml;
}
}
}
I initiate my cod in method: "protected override void OnInit(EventArgs e){}"
And all works.
If you want to make an interface for filtering you can add controls in your webpart, and create query in the SPQuery way.
And it also works.
понедельник, 26 мая 2008 г.
My own Field Propierties Changer.
You can view and change properties of you list's fields by web page.
I upload a solution for Visual Studio 2005.
There are compiled dll and aspx page, with code.
If I have more time, I'll make it better.
This is a link
Custom action.
Links about how to create custom actions:
Sample CustomActions for SharePoint
EditControlBlock (ECB) menu item in SharePoint Wiki and Blogs
Creating Hierarchical Menus with a CustomAction in SharePoint
Custom Actions - Simple Steps to Add Your Touch to Site Actions
Custom action schema from Microsoft:
ContentTypeId = "Text"
ControlAssembly = "Text"
ControlClass = "Text"
ControlSrc = "Text"
Description = "Text"
GroupId = "Text"
Id = "Text"
ImageUrl = "Text"
Location = "Text"
RegistrationId = "Text"
RegistrationType = "Text"
RequireSiteAdministrator = "TRUE" | "FALSE"
Rights = "Text"
Sequence = "Integer"
ShowInLists = "TRUE" | "FALSE"
ShowInReadOnlyContentTypes = "TRUE" | "FALSE"
ShowInSealedContentTypes = "TRUE" | "FALSE"
Title = "Text">
Description | |
ContentTypeId | Optional Text. Specifies the ID of a content type to associate with the custom action. |
ControlAssembly | Optional Text. Specifies the assembly of a control that supports the custom action. |
ControlClass | Optional Text. Specifies a control class that supports the custom action. |
ControlSrc | Optional Text. |
Description | Optional Text. Specifies a longer description for the action that is exposed as a tooltip or sub-description for the action. |
GroupId | Optional Text. Identifies an action group that contains the action, for example, "SiteManagement". If contained within a custom action group, the value of the GroupId attribute must equal the group ID of the CustomActionGroup element. |
Id | Optional Text. Specifies a unique identifier for the custom action. The ID may be a GUID, or it may be a unique term, for example, "HtmlViewer". |
ImageUrl | Optional Text. Specifies a virtual server relative link to an image that presents an icon for the item. |
Location | Optional Text. Specifies the location of this custom action, for example, "Microsoft.SharePoint.SiteSettings". If the custom action is a menu item or toolbar button, then the possible options include EditControlBlock, NewFormToolbar, DisplayFormToolbar, and EditFormToolbar. If contained within a custom action group, the value of the Location attribute must equal the location of the CustomActionGroup element. |
RegistrationId | Optional Text. Specifies the identifier of the list or item content type that this action is associated with, or the file type or programmatic identifier (ProgID). |
RegistrationType | Optional Text. Specifies the registration attachment for a per-item action. Possible values include:
|
RequireSiteAdministrator | Optional Boolean. TRUE to specify that the item be displayed only if the user is a site administrator; otherwise, FALSE. Using the RequireSiteAdministrator attribute for the drop-down menu of Windows SharePoint Services commands associated with list items is not supported. |
Rights | Optional Text. Specifies a set of rights that the user must have in order for the link to be visible, for example, "ViewListItems,ManageAlerts". If not specified, then the action always appears in the list of actions. To specify multiple rights, separate the values by using commas. The set of rights are grouped logically according to AND logic, which means that a user must have all the specified rights to see an action. For a list of possible values, see Microsoft.SharePoint.SPBasePermissions. |
Sequence | Optional Integer. Specifies the ordering priority for actions. |
ShowInReadOnlyContentTypes | Optional Boolean. TRUE if the custom action is only displayed for read-only content types on the page for managing content types. The default value is FALSE. |
ShowInSealedContentTypes | Optional Boolean. TRUE if the custom action is only displayed for sealed content types on the page for managing content types. The default value is FALSE. |
Title | Required Text. Specifies the end user description for this action. |
The most useful thing in Custom action url from: Parameters(Microsoft)
To build a custom action that points to the edit form of a single list/doc lib when selecting a list item you need to pass the itedmid and listid in the urlaction url.
Use the registrationId if you only want to have the feature for lists based on that particular content type.
<urlaction url="">url?ID={ItemId}&List={ListId}"/>
</urlaction></customaction>
Use the registrationId if you only want to have the feature for lists based on that particular content type.
<CustomAction
Id="MyId"
RegistrationType="ContentType"
RegistrationId="0x0101[Guid]"
Location="EditControlBlock"
ImageUrl="/_layouts/images/EDIT.GIF"
Sequence="106"
Title="Edit Procedure">
<UrlAction Url="~site/MyList/Forms/EditForm.aspx?ID={ItemId}&List={ListId}"/>
</CustomAction>
<urlaction url="">javascript:window.location= '{SiteUrl}/_layouts/mypage.aspx?List={ListId}&Source=' + window.location"/></urlaction>
How to make your first workflow. VisualStudio.
The best instruction how to make workflow.
Instruction
Good instruction with aspx form.
Creating Sequential Workflows in Visual Studio 2005 – A sample
Related Links:
If you have a problem with delay activity
Using Windows Workflow to Control ASP.NET Navigation
B# Workflow - Talking about Local Communication Services synchronization
State workflow:
State Machine Workflows in Windows Workflow Foundation
I think it's enough for a starter... :)