Skip to content

Instantly share code, notes, and snippets.

@celston
Last active July 7, 2017 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save celston/5e9b1951624004b7af42a6772a53a6f0 to your computer and use it in GitHub Desktop.
Save celston/5e9b1951624004b7af42a6772a53a6f0 to your computer and use it in GitHub Desktop.
public abstract class AsyncCommand : Command
{
public override void Execute(CommandContext context)
{
if (context == null)
return;
try
{
Context.ClientPage.Start(this, "Run", PrepareArgs(context));
}
catch (Exception ex)
{
Sitecore.Diagnostics.Log.Error(ex.Message, ex, this);
throw;
}
}
protected virtual NameValueCollection PrepareArgs(CommandContext context)
{
var item = context.Items[0];
var args = new NameValueCollection()
{
{ "id", item.ID.ToString() },
{ "language", item.Language.ToString() },
{ "version", item.Version.ToString() },
};
return args;
}
protected abstract void Run(ClientPipelineArgs args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment