internal override void Execute(BypassSheet sheet) { if (sheet.HaveStamp(conditionalStamp)) { sheet.PutStamp(event1.PutStampId); sheet.CrossStamp(event1.CrossStampId); sheet.SendToDepartment(event1.NextDepartmentId); } else { sheet.PutStamp(event2.PutStampId); sheet.CrossStamp(event2.CrossStampId); sheet.SendToDepartment(event2.NextDepartmentId); } }
private BypassResult Execute(string department) { bool ShouldContuinue(BypassSheet _sheet, int[] _path, BypassResult _result) { if (_sheet.LastDepartment.Equals(Configuration.EndDepartment)) { return(false); } if (IsLoop(_path)) { _result.IsLoop = true; _result.BypassSheetSnapshots = _result.BypassSheetSnapshots.Distinct().ToList(); return(false); } return(true); } Dictionary <string, int> departmetsNumericId = new Dictionary <string, int>(); string[] dep = Configuration.Departments.Select(x => x.Id).ToArray(); for (int i = 0; i < dep.Length; i++) { departmetsNumericId.Add(dep[i], i); } List <int> path = new List <int>(); BypassSheet sheet = new BypassSheet(Configuration.StartDepartment, Configuration); BypassResult result = new BypassResult(); do { sheet.CurrentDepartment.ExecuteRule(sheet); if (sheet.LastDepartment.Id.Equals(department)) { result.AddSnapshot(sheet.MakeSnaphot()); } path.Add(departmetsNumericId[sheet.LastDepartment.Id]); }while (ShouldContuinue(sheet, path.ToArray(), result)); result.Successful = true; return(result); }
internal override void Execute(BypassSheet sheet) { sheet.PutStamp(_event.PutStampId); sheet.CrossStamp(_event.CrossStampId); sheet.SendToDepartment(_event.NextDepartmentId); }
internal void ExecuteRule(BypassSheet sheet) { Rule.Execute(sheet); }