Skip to content

Commit

Permalink
added initialization of workflow deployment and rebuil tthe package
Browse files Browse the repository at this point in the history
  • Loading branch information
iamandycohen committed Oct 28, 2015
1 parent 48b7c91 commit 976a7d2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Hi.UrlRewrite/Processing/InboundRuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,67 @@ public void Process(PipelineArgs args)
{
using (new SecurityDisabler())
{

// cache all of the rules

foreach (var db in Factory.GetDatabases().Where(e => e.HasContentItem))
{
var rulesEngine = new RulesEngine(db);
rulesEngine.GetCachedInboundRules();
}

// make sure that the page event has been deployed
DeployEventIfNecessary();
}
}
catch (Exception ex)
{
Hi.UrlRewrite.Log.Error(this, ex, "Exception during initialization.");
}
}

private void DeployEventIfNecessary()
{
var database = Sitecore.Data.Database.GetDatabase("master");
if (database == null)
{
return;
}

var eventItem = database.GetItem(new ID(Constants.RedirectEventItemId));
if (eventItem == null)
{
return;
}

var workflow = database.WorkflowProvider.GetWorkflow(eventItem);
if (workflow == null)
{
return;
}

var workflowState = workflow.GetState(eventItem);
if (workflowState == null)
{
return;
}

const string analyticsDraftStateWorkflowId = "{39156DC0-21C6-4F64-B641-31E85C8F5DFE}";

if (!workflowState.StateID.Equals(analyticsDraftStateWorkflowId))
{
return;
}

const string analyticsDeployCommandId = "{4044A9C4-B583-4B57-B5FF-2791CB0351DF}";
var workflowResult = workflow.Execute(analyticsDeployCommandId, eventItem, "Deploying UrlRewrite Redirect event during initialization", false, new object[0]);

}



}



}
Binary file modified Package/URL Rewrite-1.8.zip
Binary file not shown.

0 comments on commit 976a7d2

Please sign in to comment.