I. UseEventhandlerCreate the start workflow bar in the list. First, obtain the list of trigger events and combineURL, WhereTemplateidBy reading the related list of workflows (List. workflowassociations) To obtain the list of trigger events.ID, SetURLAssign a value to the list item to update the list item.
Public Class Meeting:Spitemeventreceiver
{
Public StringStartwfstring =String. Empty;
Public Override VoidItemadded (SpitemeventpropertiesProperties)//Heavy LoadItemaddedFunction to monitor new List entry events
{
Spsecurity. Runwithelevatedprivileges (Delegate()//Use this method to simulate the Administrator account to run this event.Program
{
Using(SpsiteSite =New Spsite(Properties. siteid ))//This method is not required.Dispose ()Now
{
Using(SpwebWeb = site. openweb (properties. openweb (). Id ))//Note thatWebMethod !!!
{
Try
{
Startwfstring = web. url;
If(! Startwfstring. endswith ("/"))
Startwfstring = startwfstring +"/";
Startwfstring + ="_ Layouts/iniwrkflip. aspx? List =";
SplistList = web. Lists [properties. listid];//Obtain the list of trigger events
SpworkflowassociationcollectionWfcollection = List. workflowassociations;
//Start workflow Column
System. xml.XmldocumentDoc =NewSystem. xml.Xmldocument();
Doc. loadxml (wfcollection. soapxml );
System. xml.XmlnodeNode = Doc. selectsinglenode ("Workflowtemplates/workflowtemplate/workflowtemplateidset/@ templateid");
If(List. enableminorversions)
{
List. enableminorversions =False;
}
Startwfstring + = List. ID +"& Id =";
SplistitemItem = List. Items. getitembyid (properties. listitemid );//Get the list of trigger events
Startwfstring + = properties. listitemid +"& Templateid =";
Startwfstring + = node. innertext +"& Source =";
StringPurl = web. parentweb. url;
StringListurl = List. defaultviewurl;
Startwfstring + = purl + listurl;
Item ["Startworkflow"] = Startwfstring;
Item ["Title"] = Item. file. Name;
Item. Update ();
StringTMP = item ["Startworkflow"]. Tostring ();
If(TMP. Contains (","))
{
String[] Arr = TMP. Split (New Char[] {','});
Item ["Startworkflow"] = Arr [0] +",Start Workflow";
Item. Update ();
}
List. enableminorversions =True;
}
Catch(ExceptionEx)
{
Properties. errormessage = ex. message;
}
}
}
});
}
}
II, DeploymentEventhandler
ExploitationD: "moss" eventhandlerexplorer "eventhandlerexplorerFor project deployment, clickEventhandlerpolicer.exe.
U2ucamlcreator.exeYou can query the basic information of the list.
Spcamleditor.exeModify the basic information of the list.