Adds a file to a list.
This example illustrates how to call a Templated Macro from an MSBuild project. (Please see the 'Templated Macro' tab.)
<?xml version="1.0" encoding="utf-8"?>
<!-- Defines a 'SAF Macro' containiing 'Actions' to be run on 'Do' and 'Undo' -->
<!-- Please visit http://www.collaboris.co.uk/Saf/Doc/default.html for more information. -->
<Project DefaultTargets="Do" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyName="Collaboris.Saf, Version=2.0.0.0, Culture=neutral, PublicKeyToken=182db3eac6a9e195" TaskName="Collaboris.Saf.Adapters.MSBuild.SAF" />
<ItemGroup>
<Macros Include="Collaboris.Saf.Actions.Wss.File.AddFile.macroTemplate">
<disabledo>false</disabledo>
<disableundo>false</disableundo>
<filename>hosts</filename>
<filedirectory>c:\windows\system32\drivers\etc\</filedirectory>
<folderurl>${CurrentWeb.Url}/Pages</folderurl>
<removefileifexist>True</removefileifexist>
<id>{47B640DD-64A9-493b-8445-789FC0D05FF1}</id>
<stopondoexception>true</stopondoexception>
<stoponundoexception>true</stoponundoexception>
<Url>http://localhost:4422</Url>
<InstanceId>{{156E17A5-A7BA-4e1f-8A48-1BC341A7C642}}</InstanceId>
</Macros>
</ItemGroup>
<Target Name="Do">
<SAF MacroPaths="@(Macros)" ProcessMode="Do" ContinueOnError="false" />
</Target>
<Target Name="Undo">
<SAF MacroPaths="@(Macros)" ProcessMode="Undo" ContinueOnError="false" />
</Target>
</Project>
This example illustrates how to create a macro directly with values inserted.
<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springframework.net" default-lazy-init="true">
<object id="MacroToProcess" type="Macro">
<constructor-arg name="templateid" value="{52a14be2-4c0d-4190-9802-8dd174d87fb6}" />
<constructor-arg name="actions">
<list element-type="IAction">
<object id="AddFileb5" type="Action.AddFile" lazy-init="true">
<property name="DisableDo" value="false" />
<property name="DisableUndo" value="false" />
<property name="EntityList">
<object id="AddFileInfoa4" type="Entity.AddFileInfo" lazy-init="true">
<property name="FileName" value="hosts" />
<property name="FileDirectory" value="c:\windows\system32\drivers\etc\" />
<property name="FolderUrl" value="${CurrentWeb.Url}/Pages" />
<property name="RemoveFileIfExist" value="True" />
<property name="FileUrl" value="#{FileUrl}" />
<property name="ListName" value="#{ListName}" />
<property name="ListItemID" value="#{ListItemID}" />
</object>
</property>
<property name="ID" value="{47B640DD-64A9-493b-8445-789FC0D05FF1}" />
<property name="StopOnDoException" value="true" />
<property name="StopOnUndoException" value="true" />
</object>
</list>
</constructor-arg>
</object>
</objects>
This example illustrates how to create the Macro as a template, (so that it can be called via MSBuild or a Feature).
<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springframework.net" default-lazy-init="true">
<object id="MacroToProcess" type="Macro">
<constructor-arg name="templateid" value="{b91a8097-9bf2-45c0-9d81-6d0cad2fdc89}" />
<constructor-arg name="actions">
<list element-type="IAction">
<object id="AddFileb9" type="Action.AddFile" lazy-init="true">
<property name="DisableDo" expression="Func.Eval('${disabledo}')" />
<property name="DisableUndo" expression="Func.Eval('${disableundo}')" />
<property name="EntityList">
<object id="AddFileInfo88" type="Entity.AddFileInfo" lazy-init="true">
<property name="FileName" expression="Func.Eval('${filename}')" />
<property name="FileDirectory" expression="Func.Eval('${filedirectory}')" />
<property name="FolderUrl" expression="Func.Eval('${folderurl}')" />
<property name="RemoveFileIfExist" expression="Func.Eval('${removefileifexist}')" />
<property name="FileUrl" value="#{FileUrl}" />
<property name="ListName" value="#{ListName}" />
<property name="ListItemID" value="#{ListItemID}" />
</object>
</property>
<property name="ID" expression="Func.Eval('${id}')" />
<property name="StopOnDoException" expression="Func.Eval('${stopondoexception}')" />
<property name="StopOnUndoException" expression="Func.Eval('${stoponundoexception}')" />
</object>
</list>
</constructor-arg>
</object>
</objects>
This example illustrates how to call a Templated Macro from a Feature Receiver. (Please see the 'Templated Macro' tab).
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="{156E17A5-A7BA-4e1f-8A48-1BC341A7C642}" Title="SAF Sample Feature - 'Action.AddFile'" Description="Sample Feature illustrating how to call and run 'AddFile' from a SAF Macro." Version="12.0.0.0" Hidden="FALSE" Scope="Web" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/" ReceiverAssembly="Collaboris.Saf, Version=2.0.0.0, Culture=neutral, PublicKeyToken=182db3eac6a9e195" ReceiverClass="Collaboris.Saf.Adapters.SafFeatureReceiver">
<Properties>
<!-- Defines a SAF Macro containiing Actions to be run on Do and Undo -->
<!-- Please visit http://www.collaboris.co.uk/Saf/Doc/default.html for more information. -->
<Property Key="MacroFile" Value="Collaboris.Saf.Actions.Wss.File.AddFile.macroTemplate" />
<Property Key="InstanceId" Value="{156E17A5-A7BA-4e1f-8A48-1BC341A7C642}" />
<Property Key="disabledo" Value="false" />
<Property Key="disableundo" Value="false" />
<Property Key="filename" Value="hosts" />
<Property Key="filedirectory" Value="c:\windows\system32\drivers\etc\" />
<Property Key="folderurl" Value="${CurrentWeb.Url}/Pages" />
<Property Key="removefileifexist" Value="True" />
<Property Key="id" Value="{47B640DD-64A9-493b-8445-789FC0D05FF1}" />
<Property Key="stopondoexception" Value="true" />
<Property Key="stoponundoexception" Value="true" />
<!-- You can also define your own properties to be resolved by PlaceHolders in the Macro ... <Property Key="YourKey" Value="YourValue" /> -->
</Properties>
</Feature>
This example illustrates how to call a Templated Macro from a custom Saf StsAdm Command. (Please see the 'Templated Macro' tab).
REM Defines a SAF Macro containiing Actions to be run on Do and/or Undo
REM Please visit http://www.collaboris.co.uk/Projects/SafWiki/SAF_WIKI/Contents_Page.aspx for more information.
REM IMPORTANT! If this macro needs a SharePoint context please amend the '-url http://localhost:4422' argument (below).
REM
REM If the macro DOESN'T require a SharePoint context, simply remove the '-url http://localhost:4422' argument.
SET STSADM=C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin\stsadm.exe
"%STSADM%" -o saf-run -macrofile Collaboris.Saf.Actions.Wss.File.AddFile.macroTemplate -mode "do" -url http://localhost:4422 -disabledo "false" -disableundo "false" -filename "hosts" -filedirectory "c:\windows\system32\drivers\etc\" -folderurl "${CurrentWeb.Url}/Pages" -removefileifexist "True" -id "{47B640DD-64A9-493b-8445-789FC0D05FF1}" -stopondoexception "true" -stoponundoexception "true"