For anyone looking for the same solution, this worked for me:
public class PublishAction
{
public void Process(WorkflowPipelineArgs args)
{
Item dataItem = args.DataItem;
Item innerItem = args.ProcessorItem.InnerItem;
NameValueCollection parameters = WebUtil.ParseUrlParameters(innerItem["parameters"]);
bool deep = this.GetDeep(parameters, innerItem);
bool related = this.GetRelated(parameters, innerItem);
bool smart = this.GetSmart(parameters, innerItem);
Database[] targets = Enumerable.ToArray<Database>(this.GetTargets(parameters, innerItem, dataItem));
Language[] languages = Enumerable.ToArray<Language>(this.GetLanguages(parameters, innerItem, dataItem));
if (!Settings.Publishing.Enabled || !Enumerable.Any<Database>((IEnumerable<Database>)targets) || !Enumerable.Any<Language>((IEnumerable<Language>)languages))
return;
PublishManager.PublishItem(dataItem, targets, languages, deep, smart, related);
}
private bool GetDeep(NameValueCollection parameters, Item actionItem)
{
return this.GetStringValue("deep", parameters, actionItem) == "1";
}
private bool GetRelated(NameValueCollection parameters, Item actionItem)
{
return this.GetStringValue("related", parameters, actionItem) == "1";
}
private bool GetSmart(NameValueCollection parameters, Item actionItem)
{
return this.GetStringValue("smart", parameters, actionItem) == "1";
}
private IEnumerable<Database> GetTargets(NameValueCollection parameters, Item actionItem, Item dataItem)
{
using (new SecurityDisabler())
{
IEnumerable<string> targetNames = this.GetEnumerableValue("targets", parameters, actionItem);
if (!Enumerable.Any<string>(targetNames))
{
Item obj = dataItem.Database.Items["/sitecore/system/publishing targets"];
if (obj != null)
targetNames = Enumerable.Where<string>(Enumerable.Select<Item, string>((IEnumerable<Item>)obj.Children, (Func<Item, string>)(child => child["Target database"])), (Func<string, bool>)(dbName => !string.IsNullOrEmpty(dbName)));
}
foreach (string name in targetNames)
{
Database database = Factory.GetDatabase(name, false);
if (database != null)
yield return database;
else
Log.Warn("Unknown database in PublishAction: " + name, (object)this);
}
}
}
private IEnumerable<Language> GetLanguages(NameValueCollection parameters, Item actionItem, Item dataItem)
{
using (new SecurityDisabler())
{
IEnumerable<string> languageNames = Enumerable.Empty<string>();
bool allLanguages = this.GetStringValue("alllanguages", parameters, dataItem) == "1";
if (allLanguages)
{
Item obj = dataItem.Database.Items["/sitecore/system/languages"];
if (obj != null)
languageNames = Enumerable.Select<Item, string>(Enumerable.Where<Item>((IEnumerable<Item>)obj.Children, (Func<Item, bool>)(child => child.TemplateID == TemplateIDs.Language)), (Func<Item, string>)(child => child.Name));
}
else
{
languageNames = this.GetEnumerableValue("languages", parameters, actionItem);
string current = this.GetStringValue("itemlanguage", parameters, dataItem);
if ((current == "1" || current == null) && !Enumerable.Contains<string>(languageNames, dataItem.Language.Name))
yield return dataItem.Language;
}
foreach (string name in languageNames)
{
Language language = (Language)null;
if (Language.TryParse(name, out language))
yield return language;
else
Log.Warn("Unknown language in PublishAction: " + name, (object)this);
}
}
}
private string GetStringValue(string name, NameValueCollection parameters, Item actionItem)
{
string str1 = actionItem[name];
if (!string.IsNullOrEmpty(str1))
return str1;
string str2 = parameters[name];
if (!string.IsNullOrEmpty(str2))
return str2;
else
return (string)null;
}
private IEnumerable<string> GetEnumerableValue(string name, NameValueCollection parameters, Item actionItem)
{
string str1 = actionItem[name];
if (!string.IsNullOrEmpty(str1))
{
return Enumerable.AsEnumerable<string>((IEnumerable<string>)str1.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries));
}
else
{
string str2 = parameters[name];
if (string.IsNullOrEmpty(str2))
return Enumerable.Empty<string>();
return Enumerable.AsEnumerable<string>((IEnumerable<string>)str2.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
}
}
}