/// <summary> /// get corresponding Action object from all Action Managers /// </summary> /// <param name="actLine">the action line</param> /// <returns>the found action</returns> private IAction getAction(ActionLine actLine) { int i = 0; IAction action = null; while (action == null && i < ActionManagers.Count) { action = ActionManagers[i++].getAction(actLine); } return(action); }
public ActionLine ParseActionLine(string logLine) { var match = Regex.Match(logLine, REGEX_ACTIONLINE); var actionLine = new ActionLine(); actionLine.Hour = int.Parse(match.Groups[1].Value); actionLine.Nick = match.Groups[2].Value; actionLine.Action = match.Groups[3].Value; return(actionLine); }
void ProcessActionLine(ActionLine l) { PlayerActionModel a = new PlayerActionModel(); a.ActionKey = l.Action; a.Seat = GetSeat(l.PlayerName); if (l.Amount.HasValue) { a.Amount = l.Amount.Value; } current.Actions.Add(a); }
public void tbPlay_Checked() { playItems = 0; if (timeLineItemList.Count > 0) { ActionLineArray = new ActionLine[timeLineItemList.Count]; ActionLineArray[playItems] = new ActionLine(StartPlayLine); ActionActionLineArray(); } }
/// <summary> /// manipulate action line with data from DataSet /// </summary> /// <param name="actLine">the raw action line</param> /// <returns>the manipulated action line</returns> private ActionLine ManipulateData(ActionLine actLine) { ActionLine newLine = new ActionLine(); newLine.ActionName = actLine.ActionName; newLine.WindowName = CheckForVariable(actLine.WindowName); newLine.ControlName = CheckForVariable(actLine.ControlName); foreach (string key in actLine.Arguments.Keys) { newLine.Arguments[key] = CheckForVariable(actLine.Arguments[key]); } return(newLine); }
private void Res_GotFocus(object sender, RoutedEventArgs e) { var ellipse = (Ellipse)sender; isFocuse = !isFocuse; if (isFocuse) { ellipse.Fill = (Brush)bc.ConvertFrom("#ff0000"); } else { ellipse.Fill = (Brush)bc.ConvertFrom("#00ffbf"); } ActionLine?.BeginInvoke(isFocuse, ellipse, callBack, ellipse); }
// Methods private static void ActionTextReaderLine(TextReader textReader, TextWriter textWriter, ActionLine lineAction) { string str; bool flag = true; while ((str = textReader.ReadLine()) != null) { if (!flag) { textWriter.WriteLine(); } else { flag = false; } lineAction(textWriter, str); } }
/// <summary> /// process script data from parser /// </summary> protected override void ProcessLoadedData() { base.ProcessLoadedData(); try { // process each source line: convert it to action line foreach (SourceLine line in Parser.Lines) { if (line.ColumnCount > 0) { ActionLine actLine = new ActionLine(); actLine.ActionName = line.Columns[0].ToLower(); for (int i = 1; i < line.ColumnCount; i++) { string[] pairs = line.Columns[i].Split(Constants.PropertyDelimeter.ToCharArray(), 2); if (pairs.Length != 2) { throw new FormatException(Constants.Messages.Error_Parsing_Script); } if (Constants.Keywords.KeywordWindow.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase)) { actLine.WindowName = pairs[1].ToLower(); } else if (Constants.Keywords.KeywordControl.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase)) { actLine.ControlName = pairs[1].ToLower(); } else { actLine.Arguments[pairs[0].ToLower()] = pairs[1]; } } ActionLines.Add(actLine); } } } catch { ActionLines.Clear(); throw; } }
/// <summary> /// get a Selenium Action for the line /// </summary> /// <param name="actLine">the action line</param> /// <returns>the Selenium Action</returns> public override IAction getAction(ActionLine actLine) { IWebElement targetControl = null; if (!Actions.ContainsKey(actLine.ActionName)) { return(null); } if (actLine.WindowName != null) { if (!CheckWindow(actLine.WindowName)) { throw new Exception(Constants.Messages.Error_Matching_Window_NotFound); } if (actLine.ControlName != null) { if (!Parent.Interfaces[actLine.WindowName].Controls.ContainsKey(actLine.ControlName)) { throw new Exception(Constants.Messages.Error_Matching_Control_NoDefinition); } targetControl = FindControl(Parent.Interfaces[actLine.WindowName].Controls[actLine.ControlName]); if (targetControl == null) { throw new Exception(Constants.Messages.Error_Matching_Control_NotFound); } } } // prepare the action SeleniumAction action = Actions[actLine.ActionName] as SeleniumAction; action.Control = targetControl; action.Params = actLine.Arguments; return(action); }
/// <summary> /// create an action for the line /// </summary> /// <param name="actLine">the action line</param> /// <returns>the action</returns> public override IAction getAction(ActionLine actLine) { Window targetWindow = null; IUIItem targetControl = null; if (!Actions.ContainsKey(actLine.ActionName)) { return(null); } if (actLine.WindowName != null && !Parent.Interfaces.ContainsKey(actLine.WindowName)) { throw new Exception(Constants.Messages.Error_Matching_Window_NoDefinition); } // search for the target control if (actLine.WindowName != null) { targetWindow = FindWindow(Parent.Interfaces[actLine.WindowName].Properties); if (targetWindow != null && actLine.ControlName != null) { if (!Parent.Interfaces[actLine.WindowName].Controls.ContainsKey(actLine.ControlName)) { throw new Exception(Constants.Messages.Error_Matching_Control_NoDefinition); } targetControl = FindControl(targetWindow, Parent.Interfaces[actLine.WindowName].Controls[actLine.ControlName]); } } // prepare the action UIAAction action = Actions[actLine.ActionName] as UIAAction; action.Window = targetWindow; action.Control = targetControl; action.Params = actLine.Arguments; return(action); }
/// <summary> /// write an error to the report /// </summary> /// <param name="actLine">the error action line</param> /// <param name="why">the reason</param> public void WriteError(ActionLine actLine, string why) { SourceLine line = new SourceLine(); for (int i = 0; i < Indent + 1; i++) { line.Columns.Add(string.Empty); } line.Columns.Add(actLine.ActionName); if (actLine.WindowName != null || actLine.ControlName != null) { line.Columns.Add(actLine.WindowName != null ? actLine.WindowName : string.Empty); line.Columns.Add(actLine.ControlName != null ? actLine.ControlName : string.Empty); } foreach (string key in actLine.Arguments.Keys) { line.Columns.Add(key + Constants.PropertyDelimeter + actLine.Arguments[key]); } line.Columns.Add(Constants.ReportText.ErrorLinePrefix + why); Lines.Add(line); }
/// <summary> /// write a line to the report /// </summary> /// <param name="actLine">information about the action</param> /// <param name="result">result of the action</param> public void WriteLine(ActionLine actLine, ActionResult result) { SourceLine line = new SourceLine(); for (int i = 0; i < Indent + 1; i++) { line.Columns.Add(string.Empty); } line.Columns.Add(actLine.ActionName); if (actLine.WindowName != null || actLine.ControlName != null) { line.Columns.Add(actLine.WindowName != null ? actLine.WindowName : string.Empty); line.Columns.Add(actLine.ControlName != null ? actLine.ControlName : string.Empty); } foreach (string key in actLine.Arguments.Keys) { line.Columns.Add(key + Constants.PropertyDelimeter + actLine.Arguments[key]); } line.Columns.Add(result != ActionResult.NORET ? result.ToString() : string.Empty); if (result == ActionResult.PASSED || result == ActionResult.FAILED) { TotalCheck++; if (result == ActionResult.PASSED) { TotalPassed++; } } else if (result == ActionResult.WARNING) { TotalWarning++; } Lines.Add(line); }
private static void ActionTextReaderLine(TextReader textReader, TextWriter textWriter, ActionLine lineAction) { string line; bool firstLine = true; while ((line = textReader.ReadLine()) != null) { if (!firstLine) textWriter.WriteLine(); else firstLine = false; lineAction(textWriter, line); } }
/// <summary> /// create an action for the line /// </summary> /// <param name="actLine">the action line</param> /// <returns>the action</returns> public virtual IAction getAction(ActionLine actLine) { return(null); }
public void SetActionActionLineArray(int parm) { ActionLineArray[parm] = new ActionLine(StartPlayLine); ActionActionLineArray(); }
/// <summary> /// execute the script /// </summary> private void Run(IReporter reporter) { while (Scripts.Count > 0 && !IsStopped) { // pop a script from stack CurrentScript = Scripts.Pop(); // begin new section in report if (CurrentScript.CurrentLineNumber == 0) { reporter.BeginScript(CurrentScript.Name); } // loop for each line of current script while (CurrentScript.HasNextLine && !IsStopped) { // get a action line from script ActionLine actLineRaw = CurrentScript.Next(); if (actLineRaw.ActionName.Length == 0) { continue; } // manipulate action line with DataSet ActionLine actLine = ManipulateData(actLineRaw); // notify about action that is going to be performed if (ActionPerforming != null) { string summary = actLine.ActionName; if (actLine.WindowName != null) { summary += "\t[window:" + actLine.WindowName + "]"; } if (actLine.ControlName != null) { summary += "\t[control:" + actLine.ControlName + "]"; } foreach (string key in actLine.Arguments.Keys) { summary += "\t[" + key + ":" + actLine.Arguments[key] + "]"; } ActionPerforming(summary); } // the action is 'use interface' if (actLine.ActionName == Constants.Keywords.ActionUseInterface) { if (!Interfaces.ContainsKey(actLine.Arguments[Constants.Keywords.KeywordInterface].ToLower())) { IInterface newInterface = new Interface(Parser.NewInstance); newInterface.FileName = actLine.Arguments[Constants.Keywords.KeywordInterface] + Parser.FileExtension; Interfaces.Add(newInterface.Name, newInterface); } } // the action is 'run script' else if (actLine.ActionName == Constants.Keywords.ActionStartScript) { Script newScript = new Script(Parser.NewInstance); newScript.FileName = actLine.Arguments[Constants.Keywords.KeywordScript] + Parser.FileExtension; // push current script to stack and run new script Scripts.Push(CurrentScript); CurrentScript = newScript; // begin new section in report reporter.BeginScript(CurrentScript.Name); } else { try { IAction action = getAction(actLine); if (action == null) { throw new Exception(Constants.Messages.Error_Executing_NoAction); } if (!action.IsValid()) { throw new Exception(Constants.Messages.Error_Executing_InvalidArg); } // execute the action int ret = action.Execute(); // write result of executing to report reporter.WriteLine(actLine, action.Result); // reset the action state action.Reset(); } catch (Exception e) { reporter.WriteError(actLine, e.Message); InteruptWithError(e.Message); } } // if the automation is paused, just sleep CheckPaused(); // check if user interupt the automation if (!CheckStopped()) { ProcessSpeed(); } } // if the automation is paused, just sleep CheckPaused(); // check if user interupt the automation CheckStopped(); // end section in report if (CurrentScript.CurrentLineNumber > 0) { reporter.EndScript(CurrentScript.Name); } } }
private static void ActionTextReaderLine(TextReader textReader, TextWriter textWriter, ActionLine lineAction) { string line; bool firstLine = true; while ((line = textReader.ReadLine()) != null) { if (!firstLine) { textWriter.WriteLine(); } else { firstLine = false; } lineAction(textWriter, line); } }
public void SceneInit() { try { if (null == _sceneData) { return; } listAction = new List <ActionBase>(); foreach (ActionDataBase item in _sceneData.listActionData) { #region GroupReadImage if (item.Group == ActionGroup.GroupReadImage) { // 图像采集 if (item.Type == ActionType.ActionGather) { ActionGather action = new ActionGather((ActionGatherData)item); listAction.Add(action); } } #endregion #region GroupEnhance if (item.Group == ActionGroup.GroupEnhance) { // 图像增强 if (item.Type == ActionType.ActionMatch) { ActionMatch action = new ActionMatch((ActionMatchData)item); listAction.Add(action); } if (item.Type == ActionType.ActionPreProcess) { ActionPreProcess action = new ActionPreProcess((ActionPreProcessData)item); listAction.Add(action); } if (item.Type == ActionType.ActionBrightCorrect) { ActionBrightCorrect action = new ActionBrightCorrect((ActionBrightCorrectData)item); listAction.Add(action); } if (item.Type == ActionType.ActionThreshold) { ActionThreshold action = new ActionThreshold((ActionThresholdData)item); listAction.Add(action); } } #endregion #region GroupDetectionAndMeasurement if (item.Group == ActionGroup.GroupDetectionAndMeasurement) { //检测和测量 if (item.Type == ActionType.ActionMultiSearch) { ActionMultiSearch action = new ActionMultiSearch((ActionMultiSearchData)item); listAction.Add(action); } if (item.Type == ActionType.ActionEdgePosition) { ActionEdgePosition action = new ActionEdgePosition((ActionEdgePositionData)item); listAction.Add(action); } if (item.Type == ActionType.ActionAccurateSearch) { ActionAccurateSearch action = new ActionAccurateSearch((ActionAccurateSearchData)item); listAction.Add(action); } if (item.Type == ActionType.ActionSimpleBlob) { ActionSimpleBlob action = new ActionSimpleBlob((ActionSimpleBlobData)item); listAction.Add(action); } if (item.Type == ActionType.ActionCircleSearch) { ActionCircleSearch action = new ActionCircleSearch((ActionCircleSearchData)item); listAction.Add(action); } } #endregion #region GroupAssist if (item.Group == ActionGroup.GroupAssist) { //辅助检查和测量 if (item.Type == ActionType.ActionLine) { ActionLine action = new ActionLine((ActionLineData)item); listAction.Add(action); } if (item.Type == ActionType.ActionCircle) { ActionCircle action = new ActionCircle((ActionCircleData)item); listAction.Add(action); } if (item.Type == ActionType.ActionCalculate) { ActionCalculate action = new ActionCalculate((ActionCalculateData)item); listAction.Add(action); } } #endregion #region GroupBranch if (item.Group == ActionGroup.GroupBranch) { //分支处理 } #endregion #region GroupResultOutput if (item.Group == ActionGroup.GroupResultOutput) { //结果输出 } #endregion } } catch (Exception) { } }