private static void CreateDebugState(string result, string workflowName, string taskName)
{
string user = Thread.CurrentPrincipal.Identity.Name.Replace("\\", "-");
var state = new DebugState
{
HasError = true,
ID = Guid.NewGuid(),
Message = string.Format("{0}", result),
StartTime = DateTime.Now,
EndTime = DateTime.Now,
ErrorMessage = string.Format("{0}", result),
DisplayName = workflowName
};
var debug = new DebugItem();
debug.Add(new DebugItemResult
{
Type = DebugItemResultType.Label,
Value = "Warewolf Execution Error:",
Label = "Scheduler Execution Error",
Variable = result
});
var js = new Dev2JsonSerializer();
Thread.Sleep(5000);
string correlation = GetCorrelationId(WarewolfTaskSchedulerPath + taskName);
if (!Directory.Exists(OutputPath))
Directory.CreateDirectory(OutputPath);
File.WriteAllText(
string.Format("{0}DebugItems_{1}_{2}_{3}_{4}.txt", OutputPath, workflowName.Replace("\\","_"),
DateTime.Now.ToString("yyyy-MM-dd"), correlation, user),
js.SerializeToBuilder(new List<DebugState> { state }).ToString());
}