private List <ITask> GetTasks() { var res = new List <ITask>(1000); var sb = new StringBuilder(); long lastMouseTick = 0; foreach (var e in RawEvents) { if (e.Type == "TransitionEvent" && ((TransitionEvent)e).TransitionType == TransitionType.ActiveWindowChanged && sb.Length > 0) { DoProcessKey(res, sb, e); } if (e.Type == "KeyEvent") { AppendKeyEvents(e, sb); } if (e.Type == "MouseEvent") { if (sb.Length > 0) { DoProcessKey(res, sb, e); } if (lastMouseTick <= 0) { lastMouseTick = e.Tick; } var m = (MouseEvent)e; res.Add(MouseTask.FromData(m)); AddWait(res, (new TickInterval() { Start = lastMouseTick, End = e.Tick }).ToMilliseconds()); lastMouseTick = e.Tick; } } res.Remove(res.Last()); return(res); }
public ITask Create(IAction action) { ITask task = null; if (taskDic.TryGetValue(action.ActionType, out task)) { return(task); } if (action.ActionType == ActionType.PageAction) { task = new PageTask(manager); } else if (action.ActionType == ActionType.BrowserAction) { task = new BrowserTask(manager); } else if (action.ActionType == ActionType.FindAction) { task = new FindTask(manager); } else if (action.ActionType == ActionType.MouseAction) { task = new MouseTask(manager); } else if (action.ActionType == ActionType.AttributeAction) { task = new AttributeTask(manager); } else if (action.ActionType == ActionType.ScrollAction) { task = new ScrollTask(manager); } else if (action.ActionType == ActionType.ClearDataAction) { task = new ClearDataTask(manager); } else if (action.ActionType == ActionType.WaitAction) { task = new WaitTask(manager); } else if (action.ActionType == ActionType.ClickAction) { task = new ClickTask(manager); } else if (action.ActionType == ActionType.KeyboardAction) { task = new KeyboardTask(manager); } else if (action.ActionType == ActionType.SendKeyAction) { task = new SendKeyTask(manager); } else if (action.ActionType == ActionType.ConditionAction) { task = new ConditionTask(manager); } else if (action.ActionType == ActionType.ClearHistoryAction) { task = new ClearHistoryTask(manager); } else if (action.ActionType == ActionType.TextAction) { task = new TextTask(manager); } else if (action.ActionType == ActionType.ScriptAction) { task = new ScriptTask(manager); } else if (action.ActionType == ActionType.PackageAction) { task = new PackageTask(manager); } taskDic.Add(action.ActionType, task); return(task); }