public void Can_Get_All(int count) { Scaffold.Instances(count); IEnumerable <WorkflowInstancePoco> instances = _service.GetAll(); Assert.Equal(count, instances.Count()); }
public override void Up() { //Don't exeucte if the column is already there ColumnInfo[] columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("WorkflowInstance") && x.ColumnName.InvariantEquals("CompletedDate")) == false) { Create.Column("CompletedDate").OnTable("WorkflowInstance").AsDateTime().Nullable(); } // once the column has been added, check for any instances where status is not active, find the last task, and set complete date to match // this only impacts on charting, but allows more complete history as instances didn't previously store a completion date var instances = InstancesService.GetAll() .OrderByDescending(x => x.CreatedDate) .Where(x => x.Status != (int)WorkflowStatus.PendingApproval && x.Status != (int)WorkflowStatus.NotRequired) .ToList(); foreach (var instance in instances) { var finalTask = instance.TaskInstances.LastOrDefault(); if (null != finalTask) { instance.CompletedDate = finalTask.CompletedDate; Context.Database.Update(instance); } } }
public override void Up() { //Don't exeucte if the column is already there ColumnInfo[] columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("WorkflowInstance") && x.ColumnName.InvariantEquals("CompletedDate"))) { return; } // column doesn't exist, add it and populate the completed date for any existing instances Create.Column("CompletedDate").OnTable("WorkflowInstance").AsDateTime().Nullable(); // once the column has been added, check for any instances where status is not active, find the last task, and set complete date to match // this only impacts on charting, but allows more complete history as instances didn't previously store a completion date List <WorkflowInstancePoco> instances = InstancesService.GetAll() .Where(x => x.Status == (int)WorkflowStatus.Approved || x.Status == (int)WorkflowStatus.Cancelled) .ToList(); if (!instances.Any()) { return; } foreach (WorkflowInstancePoco instance in instances) { if (!instance.TaskInstances.Any()) { continue; } WorkflowTaskInstancePoco finalTask = instance.TaskInstances.OrderBy(x => x.Id).Last(); instance.CompletedDate = finalTask.CompletedDate; Context.Database.Update(instance); } }