public CodeProvider(CodeProviderArguments args) : base(args) { var executable = args?.TargetProcess?.MainModule.FileName; _builder.AppendLine(AddPowerShellHeader(executable)); _existingVariables.Add("window", GetMainWindow()); _existingVariables.Add("desktop", Automation.GetDesktop()); }
public override void Unmarshal(string data, bool withV = true) { XmlNode xmlNode1 = GetRoot(data).SelectSingleNode("node"); if (xmlNode1 == null) { throw new SerializingException("node tag not found"); } var heroClassDef = Type.Id.Definition as HeroClassDef; for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling) { if (xmlNode2.Name == "f") { string name = xmlNode2.Attributes["name"].Value; HeroFieldDef field = heroClassDef.GetField(name); if (field != null) { HeroAnyValue heroAnyValue = Create(field.FieldType); heroAnyValue.Unmarshal("<v>" + xmlNode2.InnerXml + "</v>", true); Variables.Add(new Variable(new DefinitionId(field.Id), 0, heroAnyValue)); } } } }
public void AddList(EmraldModel toAdd) { foreach (var i in toAdd.allDiagrams) { allDiagrams.Add(i.Value); } foreach (var i in toAdd.allStates) { allStates.Add(i.Value); } foreach (var i in toAdd.allEvents) { allEvents.Add(i.Value); } foreach (var i in toAdd.allActions) { allActions.Add(i.Value); } foreach (var i in toAdd.allExtSims) { allExtSims.Add(i.Value); } foreach (var i in toAdd.allVariables) { allVariables.Add(i.Value); } foreach (var i in toAdd.allLogicNodes) { allLogicNodes.Add(i.Value); } }
internal void Reset() { GremlinVariable inputVariable = null; if (VariableList.First() is GremlinContextVariable) { inputVariable = VariableList.First(); } PivotVariable = null; Predicates = null; VariableList.Clear(); TableReferences.Clear(); PathList.Clear(); StepList.Clear(); IsPopulateGremlinPath = false; CurrentContextPath = null; ProjectVariablePropertiesList.Clear(); ProjectedProperties.Clear(); //reserve the InputVariable if (inputVariable != null) { VariableList.Add(inputVariable); } }
internal void DropProperties(GremlinVariable belongToVariable, List <string> PropertyKeys) { List <object> properties = new List <object>(); foreach (var propertyKey in PropertyKeys) { properties.Add(propertyKey); properties.Add(null); } if (PropertyKeys.Count == 0) { properties.Add(GremlinKeyword.Star); properties.Add(null); } GremlinUpdatePropertiesVariable dropVariable = null; switch (belongToVariable.GetVariableType()) { case GremlinVariableType.Vertex: dropVariable = new GremlinUpdateVertexPropertiesVariable(belongToVariable, properties); break; case GremlinVariableType.Edge: dropVariable = new GremlinUpdateEdgePropertiesVariable(belongToVariable, properties); break; } VariableList.Add(dropVariable); TableReferences.Add(dropVariable); SetPivotVariable(dropVariable); }
public void AddVariable(string variableName, object variableValue) { if (VariableList.Any(f => f.VariableName == variableName)) { //update existing variable var existingVariable = VariableList.FirstOrDefault(f => f.VariableName == variableName); existingVariable.VariableName = variableName; existingVariable.VariableValue = variableValue; } else if (VariableList.Any(f => "{" + f.VariableName + "}" == variableName)) { //update existing edge-case variable due to user error var existingVariable = VariableList.FirstOrDefault(f => "{" + f.VariableName + "}" == variableName); existingVariable.VariableName = variableName; existingVariable.VariableValue = variableValue; } else { //add new variable var newVariable = new Script.ScriptVariable(); newVariable.VariableName = variableName; newVariable.VariableValue = variableValue; VariableList.Add(newVariable); } }
internal void Reset() { GremlinVariable inputVariable = null; if (VariableList.First() is GremlinContextVariable) { inputVariable = VariableList.First(); } ParentContext = null; PivotVariable = null; VariableList.Clear(); ProjectedProperties.Clear(); TableReferences.Clear(); MatchPathList.Clear(); Predicates = null; StepList.Clear(); ContextLocalPath = null; //TODO: reserve the InputVariable, used for repeat step, should be refactored later if (inputVariable != null) { VariableList.Add(inputVariable); } }
public LocalVariable AddUnnamedVariable() { var ret = new LocalVariable(this); VariableList.Add(ret); return(ret); }
internal void Value(GremlinVariable lastVariable) { GremlinValueVariable newVariable = new GremlinValueVariable(lastVariable.DefaultVariableProperty()); VariableList.Add(newVariable); TableReferences.Add(newVariable); SetPivotVariable(newVariable); }
internal void DropVertex(GremlinVariable dropVertexVariable) { GremlinVariableProperty variableProperty = dropVertexVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinDropVariable dropVariable = new GremlinDropVertexVariable(variableProperty); VariableList.Add(dropVariable); TableReferences.Add(dropVariable); SetPivotVariable(dropVariable); }
public Node VariableList() { var n1 = new VariableList(); n1.Add(new Identifier() { AnchorToken = Expect(TokenType.IDENTIFIER) }); while (CurrentToken == TokenType.LIST) { Expect(TokenType.LIST); n1.Add(new Identifier() { AnchorToken = Expect(TokenType.IDENTIFIER) }); } return(n1); }
internal void DropEdge(GremlinVariable dropEdgeVariable) { var sourceProperty = dropEdgeVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); var edgeProperty = dropEdgeVariable.GetVariableProperty(GremlinKeyword.EdgeID); GremlinDropVariable dropVariable = new GremlinDropEdgeVariable(sourceProperty, edgeProperty); VariableList.Add(dropVariable); TableReferences.Add(dropVariable); SetPivotVariable(dropVariable); }
internal void BothV(GremlinVariable lastVariable) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinVariableProperty sinkProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSinkV); GremlinBoundVertexVariable bothVertex = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), sourceProperty, sinkProperty); VariableList.Add(bothVertex); TableReferences.Add(bothVertex); SetPivotVariable(bothVertex); }
// Lua's productions allways take lists on both sides of the '=' public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); foreach (var parseTreeNode in treeNode.ChildNodes[0].ChildNodes) VariableList.Add(AddChild(String.Empty, parseTreeNode) as LuaNode); foreach (var parseTreeNode in treeNode.ChildNodes[2].ChildNodes) ExpressionList.Add(AddChild(String.Empty, parseTreeNode) as LuaNode); AsString = "(assignment)"; }
public LocalVariable AddVariable(Symbol s) { if (pos.ContainsKey(s)) { throw new SyntaxError(string.Format("Env: Redefined name {0}", s)); } pos.Add(s, VariableList.Count); var ret = new LocalVariable(s.Name, this); VariableList.Add(ret); return(ret); }
internal void OutE(GremlinVariable lastVariable, List <string> edgeLabels) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinVariableProperty adjEdge = lastVariable.GetVariableProperty(GremlinKeyword.EdgeAdj); GremlinVariableProperty labelProperty = lastVariable.GetVariableProperty(GremlinKeyword.Label); GremlinBoundEdgeTableVariable outEdgeTable = new GremlinBoundEdgeTableVariable(sourceProperty, adjEdge, labelProperty, WEdgeType.OutEdge); VariableList.Add(outEdgeTable); TableReferences.Add(outEdgeTable); AddLabelPredicateForEdge(outEdgeTable, edgeLabels); AddPath(new GremlinMatchPath(lastVariable, outEdgeTable, null)); SetPivotVariable(outEdgeTable); }
internal void PopulateGremlinPath() { if (IsPopulateGremlinPath) { return; } GremlinPathVariable newVariable = new GremlinPathVariable(GetCurrAndChildGremlinStepList()); VariableList.Add(newVariable); TableReferences.Add(newVariable); CurrentContextPath = newVariable; IsPopulateGremlinPath = true; }
internal void BothE(GremlinVariable lastVariable, List <string> edgeLabels) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinVariableProperty adjReverseEdge = lastVariable.GetVariableProperty(GremlinKeyword.ReverseEdgeAdj); GremlinVariableProperty adjEdge = lastVariable.GetVariableProperty(GremlinKeyword.EdgeAdj); GremlinVariableProperty labelProperty = lastVariable.GetVariableProperty(GremlinKeyword.Label); GremlinBoundEdgeTableVariable bothEdgeTable = new GremlinBoundEdgeTableVariable(sourceProperty, adjEdge, adjReverseEdge, labelProperty, WEdgeType.BothEdge); VariableList.Add(bothEdgeTable); TableReferences.Add(bothEdgeTable); AddLabelPredicateForEdge(bothEdgeTable, edgeLabels); SetPivotVariable(bothEdgeTable); }
internal void PopulateLocalPath() { if (ContextLocalPath != null) { return; } ProjectedProperties.Add(GremlinKeyword.Path); foreach (var step in StepList) { step.PopulateLocalPath(); } GremlinLocalPathVariable newVariable = new GremlinLocalPathVariable(StepList); VariableList.Add(newVariable); TableReferences.Add(newVariable); ContextLocalPath = newVariable; }
internal void Values(GremlinVariable lastVariable, List <string> propertyKeys) { if (propertyKeys.Count == 0) { lastVariable.Populate(GremlinKeyword.Star); } else { foreach (var property in propertyKeys) { lastVariable.Populate(property); } } GremlinValuesVariable newVariable = new GremlinValuesVariable(lastVariable, propertyKeys); VariableList.Add(newVariable); TableReferences.Add(newVariable); SetPivotVariable(newVariable); }
internal void OutV(GremlinVariable lastVariable) { if (lastVariable is GremlinFreeEdgeTableVariable) { var path = GetPathFromPathList(lastVariable); if (path != null && path.SourceVariable != null) { if (IsVariableInCurrentContext(path.SourceVariable)) { SetPivotVariable(path.SourceVariable); } else { GremlinContextVariable newContextVariable = GremlinContextVariable.Create(path.SourceVariable); VariableList.Add(newContextVariable); SetPivotVariable(newContextVariable); } } else { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinTableVariable outVertex = lastVariable.CreateAdjVertex(sourceProperty); if (path != null) { path.SetSourceVariable(outVertex); } VariableList.Add(outVertex); TableReferences.Add(outVertex); SetPivotVariable(outVertex); } } else { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinTableVariable outVertex = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), sourceProperty); VariableList.Add(outVertex); TableReferences.Add(outVertex); SetPivotVariable(outVertex); } }
internal void OtherV(GremlinVariable lastVariable) { switch (lastVariable.GetEdgeType()) { case WEdgeType.Undefined: case WEdgeType.BothEdge: GremlinVariableProperty otherProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeOtherV); GremlinBoundVertexVariable otherVertex = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), otherProperty); VariableList.Add(otherVertex); TableReferences.Add(otherVertex); SetPivotVariable(otherVertex); break; case WEdgeType.InEdge: OutV(lastVariable); break; case WEdgeType.OutEdge: InV(lastVariable); break; } }
internal void In(GremlinVariable lastVariable, List <string> edgeLabels) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinVariableProperty adjReverseEdge = lastVariable.GetVariableProperty(GremlinKeyword.ReverseEdgeAdj); GremlinVariableProperty labelProperty = lastVariable.GetVariableProperty(GremlinKeyword.Label); GremlinBoundEdgeTableVariable inEdgeTable = new GremlinBoundEdgeTableVariable(sourceProperty, adjReverseEdge, labelProperty, WEdgeType.InEdge); VariableList.Add(inEdgeTable); TableReferences.Add(inEdgeTable); AddLabelPredicateForEdge(inEdgeTable, edgeLabels); GremlinVariableProperty edgeProperty = inEdgeTable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinBoundVertexVariable outVertex = new GremlinBoundVertexVariable(inEdgeTable.GetEdgeType(), edgeProperty); VariableList.Add(outVertex); TableReferences.Add(outVertex); AddPath(new GremlinMatchPath(outVertex, inEdgeTable, lastVariable)); SetPivotVariable(outVertex); }
public override void Deserialize(PackedStream2 stream) { hasValue = true; Variables = new VariableList(); var deserializeClass = new DeserializeClass(stream, 1); for (uint index = 0U; index < deserializeClass.Count; ++index) { uint type1 = 0U; int variableId = 0; ulong fieldId; int d; deserializeClass.ReadFieldData(out fieldId, ref type1, ref variableId, out d); if (d != 2) { var type2 = new HeroType((HeroTypes)type1); var field = new DefinitionId(fieldId); if (field.Definition != null) { var heroFieldDef = field.Definition as HeroFieldDef; switch (heroFieldDef.FieldType.Type) { case HeroTypes.Enum: case HeroTypes.ScriptRef: type2.Id = heroFieldDef.FieldType.Id; break; case HeroTypes.LookupList: type2 = heroFieldDef.FieldType; break; } } HeroAnyValue heroAnyValue = Create(type2); heroAnyValue.Deserialize(stream); Variables.Add(new Variable(field, variableId, heroAnyValue)); } } }
public void AutoItemsForNewComponent(string compName, string desc, string[] demandNames, double[] demandFailProbs, SimVariable[] demandFailVars, string[] rateNames, double[] runningFailRates, string[] startStates, string[] turnOffStates, string sim3DComp = "", bool sepFailStates = false, EmraldModel refLookup = null) //only have this not null if trying to get the JSON for this. { if (refLookup == null) { refLookup = this; } if (demandNames.Count() != demandFailProbs.Count()) { throw new Exception("Not equal Demand names and prob list"); } if (rateNames.Count() != runningFailRates.Count()) { throw new Exception("Not equal Demand names and prob list"); } CompDiagram addComp = new CompDiagram(compName); addComp.desc = desc; allDiagrams.Add(addComp); //Action addAct; //Event addEv; //all items going to have active state and failed state State standbyState = new State(compName + "_Standby", EnStateType.stStandard, addComp); State activeState = new State(compName + "_Active", EnStateType.stStandard, addComp); allStates.Add(standbyState); allStates.Add(activeState); List <State> failStates = new List <State>(); State failedState = null; if (!sepFailStates) { failedState = new State(compName + "_Failed", EnStateType.stStandard, addComp); allStates.Add(failedState); addComp.AddEvalVal(failedState.id, false); failStates.Add(failedState); } addComp.AddEvalVal(activeState.id, true); //add event for a demand TransitionAct gotoDemandEv = new TransitionAct("Start_" + compName + "_Demand"); gotoDemandEv.AddToState(standbyState); allActions.Add(gotoDemandEv); //add all the start states to the related items foreach (string sName in startStates) { State stState = refLookup.allStates.FindByName(sName); if (stState != null) { stState.AddImmediateAction(gotoDemandEv); } else { throw new Exception("Failed to find start system State named " + stState); } } //add action to move from off to on or failed for the demand TransitionAct demandAct = new TransitionAct("From_" + compName + "_Demand"); NowTimerEvent demandEv = new NowTimerEvent(compName + "_Demand"); if (demandFailProbs.Count() > 0) { for (int i = 0; i < demandFailProbs.Count(); ++i) { if (sepFailStates) { failedState = new State(compName + "_Failed" + demandNames[i], EnStateType.stStandard, addComp); allStates.Add(failedState); addComp.AddEvalVal(failedState.id, false); failStates.Add(failedState); } //setup the probability of failure on demand //TODO : Add the demandNames[i] somehow to the path data when moving to the failed state. if ((demandFailVars != null) && (demandFailVars.Count() > 0) && (demandFailVars[i] != null)) { demandAct.AddToState(failedState, demandFailVars[i], demandNames[i]); } else { demandAct.AddToState(failedState, demandFailProbs[i], demandNames[i]); } } demandAct.AddToState(activeState); allActions.Add(demandAct); //add the events and movement to the standbyState standbyState.AddEvent(demandEv, true, demandAct); //standbyState.AddImmediateAction(demandAct); } else { //add the action to move to the active state automatically on start request when no fails to start. demandAct.AddToState(activeState); allActions.Add(demandAct); //add the events and movement to the standbyState standbyState.AddEvent(demandEv, true, demandAct); //standbyState.AddImmediateAction(demandAct); } //add event for a shutoff request StateCngEvent offEv = new StateCngEvent(compName + "_Stop", false); foreach (string sName in turnOffStates) { State endState = refLookup.allStates.FindByName(sName); if (endState != null) { offEv.AddRelatedItem(endState.id); } } allEvents.Add(offEv); //add action to move from off to on or failed for the demand TransitionAct offAct = new TransitionAct("Goto_" + compName + "_Off"); offAct.AddToState(standbyState); allActions.Add(offAct); //add the Events and movement back to the standby state activeState.AddEvent(offEv, true, offAct); foreach (State curSt in failStates) { curSt.AddEvent(offEv, true, offAct); } if ((runningFailRates.Count() > 0) || ((sim3DComp != null) && (sim3DComp != ""))) //add the fail to run links { //add transition leading from active to failed for the event above //TransitionAct failAct = new TransitionAct("Goto_" + compName + "_Failed"); //failAct.AddToState(failedState); //allActions.Add(failAct); for (int i = 0; i < runningFailRates.Count(); ++i) { if (sepFailStates) { failedState = new State(compName + "_Failed" + rateNames[i], EnStateType.stStandard, addComp); allStates.Add(failedState); addComp.AddEvalVal(failedState.id, false); failStates.Add(failedState); } TransitionAct failAct = new TransitionAct("Goto_" + compName + "_Had_" + rateNames[i] + "_Failure"); failAct.AddToState(failedState); allActions.Add(failAct); //add event leading from active to failed FailProbEvent failEv = new FailProbEvent(compName + rateNames[i], runningFailRates[i], Globals.HourTimeSpan, Globals.DayTimeSpan); allEvents.Add(failEv); activeState.AddEvent(failEv, true, failAct); } if ((sim3DComp != null) && (sim3DComp != "")) { if (sepFailStates) { failedState = new State(compName + "_Failed_3D", EnStateType.stStandard, addComp); allStates.Add(failedState); addComp.AddEvalVal(failedState.id, false); failStates.Add(failedState); } TransitionAct failAct = new TransitionAct("Goto_" + compName + "_Had_3D" + "_Failure"); failAct.AddToState(failedState); allActions.Add(failAct); Sim3DVariable simVar = (Sim3DVariable)refLookup.allVariables.FindByName(sim3DComp); VariableList varList = new VariableList(); varList.Add(simVar); EvalVarEvent sim3DEvent = (EvalVarEvent)allEvents.FindByName(sim3DComp, false); if (sim3DEvent == null) { sim3DEvent = new EvalVarEvent(sim3DComp, "if (" + simVar.name + " > 0) return true; else return false;", varList, simVar); allEvents.Add(sim3DEvent); } activeState.AddEvent(sim3DEvent, true, failAct); } } }
public ConditionListView() { InitializeComponent(); conditions = new ConditionList(); Variables = new VariableList(); Variables.Add(new Variable("Value0", 0)); Variables.Add(new Variable("Value1", 1)); Variables.Add(new Variable("Value2", 2)); Variables.Add(new Variable("Value3", 3)); Variables.Add(new Variable("Value4", 4)); Variables.Add(new Variable("Value5", 5)); Variables.Add(new Variable("Value6", 6)); Variables.Add(new Variable("Value7", 7)); Variables.Add(new Variable("Value8", 8)); Variables.Add(new Variable("Value9", 9)); Variables.Add(new Variable("Value10", 10)); int testNum = 6; switch (testNum) { case 1: conditions.Add(new Condition(Variables[5], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[4], Operator.EqualTo, 10)); conditions.Add(new Condition(Variables[5], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[5], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[5], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); // Outcome: break; case 2: conditions.Add(new Condition(Variables[10], Operator.GreaterThan, 8, Grouping.OpenGrouping, Connector.And)); // Outcome: break; case 3: conditions.Add(new Condition(Variables[7], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[5], Operator.EqualTo, 10)); // Outcome: break; case 4: conditions.Add(new Condition(Variables[1], Operator.NotEqualTo, 1, Grouping.OpenAndCloseGrouping, Connector.Or)); // Outcome: break; case 5: conditions.Add(new Condition(Variables[9], Operator.GreaterThanOrEqualTo, 8, Grouping.OpenGrouping, Connector.Xor)); conditions.Add(new Condition(Variables[6], Operator.EqualTo, 6, Grouping.CloseGrouping, Connector.And)); // Outcome: break; case 6: conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[1], Operator.GreaterThan, 4)); conditions.Add(new Condition(Variables[2], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.Or)); conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[1], Operator.GreaterThan, 4)); conditions.Add(new Condition(Variables[9], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.And)); conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[7], Operator.GreaterThan, 4)); conditions.Add(new Condition(Variables[2], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.And)); conditions.Add(new Condition(Variables[8], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[4], Operator.GreaterThanOrEqualTo, 4)); conditions.Add(new Condition(Variables[2], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.Or)); conditions.Add(new Condition(Variables[5], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[1], Operator.GreaterThan, 4)); conditions.Add(new Condition(Variables[8], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.Or)); conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.Or)); conditions.Add(new Condition(Variables[9], Operator.GreaterThan, 4, Grouping.NoGrouping, Connector.And)); conditions.Add(new Condition(Variables[2], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.And)); // Outcome: true break; case 7: conditions.Add(new Condition(Variables[1], Operator.LessThan, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[3], Operator.GreaterThan, 2, Grouping.OpenGrouping, Connector.Or)); conditions.Add(new Condition(Variables[5], Operator.EqualTo, 4)); conditions.Add(new Condition(Variables[6], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.And)); conditions.Add(new Condition(Variables[10], Operator.GreaterThan, 5, Grouping.CloseGrouping, Connector.Or)); // Outcome: break; case 8: conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[1], Operator.GreaterThan, 4)); conditions.Add(new Condition(Variables[2], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.And)); conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[1], Operator.GreaterThan, 4)); conditions.Add(new Condition(Variables[2], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.And)); // Outcome: break; case 9: conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[1], Operator.GreaterThan, 4)); conditions.Add(new Condition(Variables[2], Operator.LessThan, 5, Grouping.CloseGrouping, Connector.Or)); // Outcome: break; case 10: conditions.Add(new Condition(Variables[10], Operator.EqualTo, 8, Grouping.OpenGrouping, Connector.And)); conditions.Add(new Condition(Variables[9], Operator.LessThan, 15, Grouping.CloseGrouping, Connector.Or)); conditions.Add(new Condition(Variables[5], Operator.NotEqualTo, 6, Grouping.NoGrouping, Connector.Or)); // Outcome: break; default: break; } LoadList(); }
private static VariableList makeFromTable(DataTable tbl) { VariableList list = new VariableList(); foreach (DataRow r in tbl.Rows) { list.Add(new Variable(r)); } return list; }
public CodeProvider(CodeProviderArguments args) : base(args) { _existingVariables.Add("window", GetMainWindow()); _existingVariables.Add("desktop", Automation.GetDesktop()); }
protected void Page_Load(object sender, EventArgs e) { // HttpRequest를 이용하여 PlatformRequest 생성 PlatformRequest req = new PlatformRequest(Request.InputStream); // 데이터 수신 req.ReceiveData(); // 수신받은 데이터 획득 PlatformData reqData = req.GetData(); VariableList reqVarList = reqData.GetVariableList(); // 부서명 획득 string name = reqVarList.GetString("name"); // 송신할 데이터 생성 PlatformData resData = new PlatformData(); VariableList resVarList = resData.GetVariableList(); // 부서별 인원을 저장할 DataSet 생성 DataSet employees = new DataSet("employees"); // DataSet에 열(column) 추가 employees.AddColumn(new ColumnHeader("name", DataTypes.STRING, 8)); employees.AddColumn(new ColumnHeader("jobTitle", DataTypes.STRING)); employees.AddColumn(new ColumnHeader("number", DataTypes.INT)); employees.AddColumn(new ColumnHeader("manager", DataTypes.BOOLEAN)); // 부서별 인원 데이터 추가 if ("R&D Center".Equals(name)) { // 행(row) 추가 int row = employees.NewRow(); // 추가된 행(row)의 데이터 설정 employees.Set(row, "name", "John Jones"); employees.Set(row, "jobTitle", "developer"); employees.Set(row, "number", 1234); employees.Set(row, "manager", false); // ... // 정상 수행 resData.AddDataSet(employees); resVarList.Add("ERROR_CODE", 200); } else if ("Quality Assurance".Equals(name)) { // 행(row) 추가 int row = employees.NewRow(); // 추가된 행(row)의 데이터 설정 employees.Set(row, "name", "Tom Glover"); employees.Set(row, "jobTitle", "manager"); employees.Set(row, "number", 9876); employees.Set(row, "manager", true); // ... // 정상 수행 resData.AddDataSet(employees); resVarList.Add("ERROR_CODE", 200); } else { // 오류 발생 resVarList.Add("ERROR_CODE", 500); } // HttpServletResponse를 이용하여 PlatformResponse 생성 PlatformResponse res = new PlatformResponse(Response.OutputStream); res.SetData(resData); // 데이터 송신 res.SendData(); }
private void ExecuteScript(string data, bool dataIsFile, string projectPath) { try { _currentStatus = EngineStatus.Running; //create stopwatch for metrics tracking _stopWatch = new Stopwatch(); _stopWatch.Start(); //log starting ReportProgress("Bot Engine Started: " + DateTime.Now.ToString()); //get automation script Script automationScript; if (dataIsFile) { ReportProgress("Deserializing File"); Log.Information("Script Path: " + data); FileName = data; automationScript = Script.DeserializeFile(data); } else { ReportProgress("Deserializing JSON"); automationScript = Script.DeserializeJsonString(data); } //track variables and app instances ReportProgress("Creating Variable List"); //set variables if they were passed in if (VariableList != null) { foreach (var var in VariableList) { var variableFound = automationScript.Variables.Where(f => f.VariableName == var.VariableName).FirstOrDefault(); if (variableFound != null) { variableFound.VariableValue = var.VariableValue; } } } VariableList = automationScript.Variables; //update ProjectPath variable var projectPathVariable = VariableList.Where(v => v.VariableName == "ProjectPath").SingleOrDefault(); if (projectPathVariable != null) { projectPathVariable.VariableValue = projectPath; } else { projectPathVariable = new ScriptVariable { VariableName = "ProjectPath", VariableValue = projectPath }; VariableList.Add(projectPathVariable); } //track elements ReportProgress("Creating Element List"); //set elements if they were passed in if (ElementList != null) { foreach (var elem in ElementList) { var elementFound = automationScript.Elements.Where(f => f.ElementName == elem.ElementName).FirstOrDefault(); if (elementFound != null) { elementFound.ElementValue = elem.ElementValue; } } } ElementList = automationScript.Elements; ReportProgress("Creating App Instance Tracking List"); //create app instances and merge in global instances AppInstances = new Dictionary <string, object>(); var GlobalInstances = GlobalAppInstances.GetInstances(); foreach (var instance in GlobalInstances) { AppInstances.Add(instance.Key, instance.Value); } //execute commands foreach (var executionCommand in automationScript.Commands) { if (IsCancellationPending) { ReportProgress("Cancelling Script"); ScriptFinished(ScriptFinishedResult.Cancelled); return; } ExecuteCommand(executionCommand); } if (IsCancellationPending) { //mark cancelled - handles when cancelling and user defines 1 parent command or else it will show successful ScriptFinished(ScriptFinishedResult.Cancelled); } else { //mark finished ScriptFinished(ScriptFinishedResult.Successful); } } catch (Exception ex) { ScriptFinished(ScriptFinishedResult.Error, ex.ToString()); } }