何小碩's profileGet More... ExperiencePhotosBlogListsMore ![]() | Help |
|
February 22 MOSS 2007 - Conditionally start a workflow with an eventhandler in SharePoint 2007One of the major improvements in both WSS 3.0 and Microsoft Office SharePoint Server 2007 is the enhanced event handler framework. In SPS 2003 only document libraries supported event handlers, in WSS 3.0 and MOSS2007 there are also event handlers at site level and for all types of lists (both document libraries and lists). Another change is the support for both synchronous and assynchronous events - this means that an event also fires before an action occurs. There is for example an ItemAdded event as well as an ItemAdding event - the "Ed" event occurs after committing to the database and "Ing" event before committing changes to the database. The base class for all eventhandling in SharePoint 2007 is the SPEventReceiverBase (Microsoft.SharePoint) class. The different classes you will need to inherit from to eventhandler are SPListEvenReceiver - for a list , SPWebEventReceiver - for site or site collection (deleted, deleting, moved, moving) and SPItemEventReceiver for individual items. In the next sample, I will create an event handler for a listitem which will start up a new workflow. To do this you will need to complete the next steps:
public override void ItemAdded(SPItemEventProperties properties)
private void ConditionalStartWorkflow(SPItemEventProperties properties)
In SharePoint 2003 you could use the user interface to register an event handler, this is not possible anymore. There are however two other options:
How to: Handle an Event using .NET in MOSS 2007This example shows how to add a simple event handler that prevents items from being deleted from a list. Two procedures are involved in this task:
8. In Solution Explorer, right-click the DeletingEventHandler node, and then click Properties. 9. In the Properties dialog box, click the Signing tab, select Sign the asembly, select Choose a strong name key file, and then click <New…>. 10. In the Create Strong Name Key dialog box, type DeletingEventHandler.snk in the Key file name box, optionally specify a password for the key, and then click OK. 11. To build the project, click Build Solution on the Build menu, or press CTRL+SHIFT+B. 12. Find the \DeletingEventHandler\bin\Debug folder in the Visual Studio Projects folder, and drag the DeletingEventHandler.dll file to Local_Drive:\WINDOWS\assembly to place the DLL in the global assembly cache. To add the event handler as a Windows SharePoint Services Feature 1. Create a folder in Local_Drive:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/FEATURES called DeletingEventHandler. 2. Create a Feature.xml Files file in this folder like the following that identifies the Feature and its element manifest file and sets the Feature scope to Web site. Xml
3. To replace the GUID placeholder in the previous Id attribute, generate a GUID by running guidgen.exe located in Local_Drive:\Program Files\Microsoft Visual Studio 8. 4. Create an Elements.xml file in the DeletingEventHandler folder that identifies the assembly, class, and method to implement as the event handler. This example applies the event handler to all announcements lists of a site, as specified by the ListTemplateId attribute. For the IDs of other default Windows SharePoint Services list template types, see the Type attribute description of the ListTemplate element. Xml
5. To get the Public Key Token of the assembly, in Windows Explorer find the DeletingEventHandler.dll file in the Local_Drive:\WINDOWS\assembly, right-click the file, click Properties, and on the General tab of the Properties dialog box, select and copy the token. 6. At a command prompt, navigate to \Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN on the local drive, and type each of the following commands to install the Feature in the deployment, activate the Feature on a specified subsite, and reset Microsoft Internet Information Services (IIS) so that the changes take effect: stsadm -o installfeature -filename DeletingEventHandler\Feature.xml stsadm -o activatefeature -filename DeletingEventHandler\Feature.xml -url http://Server/Site/Subsite iisreset 7. Try to delete an item in an announcements list on the specified Web site to see the effects of the event handler Feature.
Related Posts :MOSS 2007
comes form:http://www.sharepoint-tips.com/2006/06/event-handlers-in-moss-sharepoint-2007.html How to schedule MOSS 2007 backup1. Set path of stsadm.exe Related Posts :MOSS 2007
comes from:http://jopx.blogspot.com/2006/10/moss-2007-conditionally-start-workflow.html Convert Team site / blank site to a publishing site in MOSS 2007Publishing Site vs. Team Site Related Posts :MOSS 2007
comes from:http://urenjoy.blogspot.com/2008/12/convert-team-site-blank-site-to.html February 07 How to fix SharePoint 2007 and WSS Event Errors 6481 and 638910/30/2007I ran in to this error on a default Single Server install for my customer, a small real estate agency in San Diego. Normally I would have caught this DCOM authentication error in the system log, but instead focused on the symptoms of the problem in the application log, and wasted 60 minutes of time doing so (Bad John). So in order to help save some time in the future, I'll post the quick fix below. 1. Open Start Menu > Administrative Tools > Component Services Tool 2. Drill Down and Expand DCOM Config
3. Navigate to the OSearch, Right Click Properties
4. Select the Security Tab
5. Add the Network Service Account to Local and Activation Permissions
6. Add the Network Service Account to Access Permissions
7. Restart the Office SharePoint Server Search Service from Start Menu > Administrative Tools > Services Tool Related Errors:Application Event Log: Event ID 6398: Windows SharePoint Services ErrorEvent Type: Error Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed due to the following error: 80070005. Application Event Log: Event ID 6481: Office SharePoint Server Error Event Type: Error Reason: Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed due to the following error: 80070005. Techinal Support Details: System Event Log: Event ID 10016: DCOM Error Event Type: Error Posted at 11:56 AM by John Gilham | |
|
|