/// <summary> /// 寻找最优行动(场景匹配的评估值最大的那个) /// </summary> /// <returns></returns> public ActionRecord FindOptimaAction(bool positiveOnly = true, List <Vector> observation = null) { var scene = this.FindMatchedScene(observation); if (scene.Item1 == null) { return(null); } double e = double.MinValue; ActionRecord r = null; List <ActionRecord> actions = scene.Item1.records; foreach (ActionRecord action in actions) { if (action.evaluation > e) { e = action.evaluation; r = action; } } if (positiveOnly && e < 0) { return(null); } return(r); }
private static List <ActionRecord> FillActionRecordList(Member Creator, IEnumerable <Action> actions, List list, IEnumerable <string> organizationMembers) { var actionList = new List <ActionRecord>(); var currentActionRecord = new ActionRecord(); currentActionRecord.OpenRecord(actions.FirstOrDefault().Creator, DateTime.Now.ToUniversalTime(), list); foreach (var action in actions) { TrelloRequestCounter.TrelloPostCount += 1; if (action.Data.ListBefore != null && action.Data.ListBefore.Id == list.Id) { currentActionRecord = new ActionRecord(); currentActionRecord.OpenRecord(action.Creator, action.CreationDate, list); } else if (currentActionRecord.Opened && action.Data.ListAfter != null && action.Data.ListAfter.Id == list.Id) { currentActionRecord.CloseRecord(action.Creator, action.CreationDate); if (!organizationMembers.Contains(action.Creator.UserName)) { continue; } TrelloRequestCounter.TrelloPostCount += 1; actionList.Add(currentActionRecord); } } return(actionList); }
public IActionResult ReturnAnalysisVersion([FromQuery] int fileId, string fileName) //returns analysis version given by name { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId CsvFile file = _context.CsvFile.Where(f => f.UserId == userId && f.CsvFileId == fileId).FirstOrDefault(); if (file == null) { return(NotFound()); } string folderPath = Path.Combine(_targetFilePath, userId, file.FileNameStorage, "analysis"); string filePath = Path.Combine(folderPath, fileName); //return analysis given by index var json = System.IO.File.ReadAllText(filePath); //action record var record = new ActionRecord() { CsvFileId = file.CsvFileId, Action = "Load", Version = fileName, ActionTime = DateTime.Now }; _context.ActionRecord.Add(record); _context.SaveChanges(); return(Ok(json)); }
public IActionResult IsAnalysisComplete([FromQuery] int fileId) //checks analysis completion { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId CsvFile file = _context.CsvFile.Where(f => f.UserId == userId && f.CsvFileId == fileId).FirstOrDefault(); if (file == null) { return(NotFound()); } string folderPath = Path.Combine(_targetFilePath, userId, file.FileNameStorage, "analysis"); string filePath = Path.Combine(folderPath, "analysis_v1"); if (System.IO.File.Exists(filePath)) { file.IsAnalysing = false; _context.CsvFile.Update(file); //action record var record = new ActionRecord() { CsvFileId = file.CsvFileId, Action = "Analyze", Version = "analysis_v1", ActionTime = DateTime.Now }; _context.ActionRecord.Add(record); _context.SaveChanges(); return(Ok(file)); } return(NoContent()); }
public IActionResult SaveAnalysis([FromQuery] int fileId, [FromBody] JObject body) //saves a edited file { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); CsvFile file = _context.CsvFile.Where(f => f.UserId == userId && f.CsvFileId == fileId).FirstOrDefault(); if (file == null) { return(NotFound()); } string json = body.ToString(); string folderPath = Path.Combine(_targetFilePath, userId, file.FileNameStorage, "analysis"); int lastVersion = Int32.Parse(GetAnalysisFiles(userId, fileId).Last().Name.Split("_v")[1]); string version = "analysis_v" + (lastVersion + 1); string filePath = Path.Combine(folderPath, version); System.IO.File.WriteAllText(filePath, json); //action record var record = new ActionRecord() { CsvFileId = file.CsvFileId, Action = "Save", Version = version, ActionTime = DateTime.Now }; _context.ActionRecord.Add(record); _context.SaveChanges(); return(Created(nameof(WorkspaceController), null)); }
public static string StateListToText(ParserStateList states) { StringBuilder sb = new StringBuilder(); foreach (ParserState state in states) { sb.Append("State "); sb.AppendLine(state.Name); //LRItems foreach (LRItem item in state.Items) { sb.Append(" "); sb.AppendLine(item.ToString()); } //Transitions sb.Append(" TRANSITIONS: "); foreach (string key in state.Actions.Keys) { ActionRecord action = state.Actions[key]; if (action.NewState == null) { continue; //may be null in malformed grammars } string displayKey = key.EndsWith("\b") ? key.Substring(0, key.Length - 1) : key; sb.Append(displayKey); sb.Append("->"); sb.Append(action.NewState.Name); sb.Append("; "); } sb.AppendLine(); sb.AppendLine(); }//foreach return(sb.ToString()); }
public async Task <IActionResult> Put(long id, [FromBody] ActionRecord actionRecord) { if (!ModelState.IsValid || actionRecord == null) { return(BadRequest(ModelState)); } var existingActionRecord = await _context.ActionRecords.FindAsync(actionRecord.ActionRecordId); if (existingActionRecord == null) { return(NotFound()); } existingActionRecord.Description = actionRecord.Description; existingActionRecord.RecordDate = actionRecord.RecordDate; existingActionRecord.User = actionRecord.User; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { return(StatusCode((int)HttpStatusCode.Conflict)); } return(new NoContentResult()); }
private void SaveAction(ActionRecord actionInstance, string activityInstanceId, DbContext dbContext) { if (actionInstance.IsNew) { InsertAction(actionInstance, activityInstanceId, dbContext); } }
public virtual void InsertActionLog(ActionRecord model) { if (model == null) { throw new ArgumentNullException("actionRecord"); } this._actionRecordRepository.Insert(model); }
public static Form CreateInstance() { ApplicationRecord appRec = new ApplicationRecord(); appRec.ApplicationID = 5; appRec.Name = "WinForm Hello World"; appRec.Type = 0; appRec.Initialization = @" <initstring> <assemblyInfo> <URL>Microsoft.Ccf.Samples.Citrix.WinFormHelloWorld.dll</URL> <type>Microsoft.Ccf.Samples.Citrix.WinFormHelloWorld</type> </assemblyInfo> <displayGroup>MainPanel</displayGroup> <optimumSize x=""470"" y=""380"" /> <minimumSize x=""340"" y=""180"" /> </initstring>"; appRec.EnableAutoSignOn = false; appRec.LoginFields = null; BindingList <ActionRecord> list = new BindingList <ActionRecord>(); ActionRecord ar1 = new ActionRecord(); ar1.ActionID = 1; ar1.Name = "Default"; ar1.Initialization = @"<ActionInit/>"; list.Add(ar1); appRec.Actions = list; #pragma warning disable 0618 IHostedApplication stub = HostedAppFactory.CreateApplication(appRec); #pragma warning restore 0618 HostingForm hostingForm = new HostingForm(); hostingForm.Name = "StandAloneTestAppStub"; hostingForm.Text = stub.ApplicationName; hostingForm.ControlBox = false; hostingForm.MaximizeBox = false; hostingForm.MinimizeBox = false; hostingForm.ShowInTaskbar = false; hostingForm.FormBorderStyle = FormBorderStyle.None; hostingForm.StartPosition = FormStartPosition.Manual; hostingForm.ClientSize = stub.OptimumSize; hostingForm.MinimumSize = stub.MinimumSize; hostingForm.Closed += delegate { stub.Close(); }; stub.TopLevelWindow.Parent = hostingForm; stub.TopLevelWindow.Dock = DockStyle.Fill; stub.Initialize(); return(hostingForm); }
public async Task <List <ActionRecord> > searchActionRecordAsync(ActionRecord ActionRecord, ESearchOption filterOperator) { List <ActionRecord> result = new List <ActionRecord>(); try { result = await DAC.DALSecurity.searchActionRecordAsync(ActionRecord, filterOperator); } catch (Exception ex) { Log.error(ex.Message, EErrorFrom.SECURITY); } return(result); }
}//methods private bool CheckConflictResolutionByPrecedence(ActionRecord action) { SymbolTerminal opTerm = SymbolTerminal.GetSymbol(action.Key); if (opTerm != null && opTerm.IsSet(TermOptions.IsOperator)) { action.ActionType = ParserActionType.Operator; action.ConflictResolved = true; return(true); } return(false); }
public async Task <IActionResult> Post([FromBody] ActionRecord actionRecord) { if (!ModelState.IsValid || actionRecord == null) { return(BadRequest()); } await _context.ActionRecords.AddAsync(actionRecord); await _context.SaveChangesAsync(); return(CreatedAtRoute("GetActionById", new { id = actionRecord.ActionRecordId }, actionRecord)); }
private void SaveActionLog(HttpRequestMessage request) { int objType = HttpContext.Current.Request.Params["_objType"].ToInt(); int objId = HttpContext.Current.Request.Params["_objId"].ToInt(); string objName = HttpContext.Current.Request.Params["_objName"]; if (objId <= 0 || objType <= 0) // 没有操作对象,不执行 { return; } string payload = ""; // 开始记录日志 using (StreamReader reader = new StreamReader(request.Content.ReadAsStreamAsync().Result)) { payload = reader.ReadToEnd(); // payload 值 } // HttpContext.Current.Request.Params // post url值 // HttpContext.Current.Request.Form // form 提交值 var workcontext = EngineContext.Current.Resolve <IWorkContext>(); var logservice = EngineContext.Current.Resolve <ILogger>(); ActionRecord log = new ActionRecord() { Type = this._operateType, Operator = workcontext.CurrentUser.UserName, OperatorId = workcontext.CurrentUser.Id, OperateTime = DateTime.Now, Payload = payload, RequestParas = request.RequestUri.Query, ObjId = objId, ModuleName = objName, Info1 = objType.ToString() }; // 写入操作视图 string viewname = HttpContext.Current.Request.Params["extraView"]; if (!string.IsNullOrEmpty(viewname)) { log.ViewName = viewname; } // 写入操作存储过程 string procname = HttpContext.Current.Request.Params["procname"]; if (!string.IsNullOrEmpty(procname)) { log.ProcName = procname; } logservice.InsertActionLog(log); }
public async Task <List <ActionRecord> > searchActionRecordAsync(ActionRecord ActionRecord, ESearchOption filterOperator) { List <ActionRecord> result = new List <ActionRecord>(); try { result = (await _channel.get_filter_actionRecordAsync(_companyName, ActionRecord.ActionRecordTypeToFilterArray(filterOperator))).ArrayTypeToActionRecord(); } catch (FaultException) { Dispose(); throw; } catch (CommunicationException) { _channel.Abort(); throw; } catch (TimeoutException) { _channel.Abort(); } return(result); }
/// <summary> /// Default constructor. /// </summary> public SceneNode() { this.id = SceneNode.NewID; this.visible = true; this.distance = null; this.drawBoundsColor = Color.White; this.position = Vector3.Zero; this.rotation = Vector3.Zero; this.matrix = Matrix.Identity; this.action = new ActionRecord(); this.parent = null; this.children = new List <SceneNode>(); }
//Checks shift items for PreferShift grammar hint. Hints are associated with a particular position // inside production, which is in fact an LR0 item. The LR0 item is available thru shiftItem.Core property. // If PreferShift hint found, moves the hint-owning shiftItem to the beginning of the list and returns true. private bool CheckShiftHint(ActionRecord action) { foreach (LRItem shiftItem in action.ShiftItems) { GrammarHint shiftHint = GetHint(shiftItem.Core.Production, shiftItem.Core.Position, HintType.PreferShift); if (shiftHint != null) { action.ActionType = ParserActionType.Shift; action.ShiftItems.Remove(shiftItem); action.ShiftItems.Insert(0, shiftItem); action.ConflictResolved = true; return(true); } //if } //foreach shiftItem return(false); } //method
} //method //Checks Reduce productions of an action for a ReduceThis hint. If found, the production is moved to the beginning of the list. private bool CheckReduceHint(ActionRecord action) { foreach (Production prod in action.ReduceProductions) { GrammarHint reduceHint = GetHint(prod, prod.RValues.Count, HintType.ReduceThis); if (reduceHint != null) { action.ReduceProductions.Remove(prod); action.ReduceProductions.Insert(0, prod); action.ActionType = ParserActionType.Reduce; action.ConflictResolved = true; return(true); } //if } //foreach prod return(false); } //method
public ActionResult EditPost(int id, string category, string type, [DefaultValue(-1)] int actionId, FormCollection formCollection) { var rule = _rulesServices.GetRule(id); var actionRecord = rule.Actions.FirstOrDefault(a => a.Id == actionId); // add new action record if it's a newly created action if (actionRecord == null) { actionRecord = new ActionRecord { Category = category, Type = type, Position = rule.Actions.Count }; rule.Actions.Add(actionRecord); } var action = _rulesManager.DescribeActions().SelectMany(x => x.Descriptors).FirstOrDefault(x => x.Category == category && x.Type == type); // validating form values _formManager.Validate(new ValidatingContext { FormName = action.Form, ModelState = ModelState, ValueProvider = ValueProvider }); if (ModelState.IsValid) { var dictionary = formCollection.AllKeys.ToDictionary(key => key, formCollection.Get); // save form parameters actionRecord.Parameters = FormParametersHelper.ToString(dictionary); return(RedirectToAction("Edit", "Admin", new { id })); } // model is invalid, display it again var form = _formManager.Build(action.Form); // Cancel the current transaction to prevent records from begin created Services.TransactionManager.Cancel(); AddSubmitButton(form); _formManager.Bind(form, formCollection); var viewModel = new EditActionViewModel { Id = id, Action = action, Form = form }; return(View(viewModel)); }
private void InsertAction(ActionRecord actionInstance, string activityInstanceId, DbContext dbContext) { var actionRecordMapper = new ActionMapper(dbContext); var actionEntity = new ActionEntity { ACTION_ID = actionInstance.ActionId ?? Guid.NewGuid().ToString(), ACTIVITY_INSTANCE_ID = activityInstanceId, APPROVER_REQUIRED = "PLACEHOLDER", CREATED_ON = DateTime.Now, LAST_UPDATED_ON = DateTime.Now, OPERATION_CODE = "UNSET", REQUIRED_OPERATOR_TYPE = 1, REQUIRED_ROLE = actionInstance.RequiredRole }; actionRecordMapper.Insert(actionEntity); }
// Unity Fixed Methods. // --------------------------------------------------------------- void Awake() { recordList = new ActionRecord[NumRecords]; for (int index = 0; index < NumRecords; ++index) { recordList[index] = new ActionRecord(); recordList[index].texMap = new RenderTexture(DefaultTexSize, DefaultTexSize, 0, RenderTextureFormat.ARGB32); } if (debugQuads != null) { for (int index = 0; index < debugQuads.Length; ++index) { debugQuads[index].material.SetTexture("_MainTex", recordList[index].texMap); } } currentAction.texMap = new RenderTexture(DefaultTexSize, DefaultTexSize, 0, RenderTextureFormat.ARGB32); }
public async Task Connection() { string hashedPassword = PasswordHasher.HashPassword(Password); try { User u = await User.GetUserByUsername(Login); if (u.Password == hashedPassword) { if (u.AccessRights == organisatorAccess) { User.CurrentUser = u; User.CurrentUser.Password = hashedPassword; await User.CurrentUser.SetAuthentication(); await ActionRecord.AddActionRecord("Logged in"); _navigationService.NavigateTo("MainPage"); } else { throw new AccessNotGrantedException(); } } else { throw new IncorrectPasswordException(); } } catch (DAOConnectionException e) { await _dialogService.ShowMessage(e.Message, e.Title); } catch (LoginException e) { await _dialogService.ShowMessage(e.Message, e.Title); } }
private void CreateParserStates() { Data.States.Clear(); _stateHash = new ParserStateTable(); CreateInitialAndFinalStates(); string augmRootKey = Data.AugmentedRoot.Key; // Iterate through states (while new ones are created) and create shift transitions and new states for (int index = 0; index < Data.States.Count; index++) { ParserState state = Data.States[index]; AddClosureItems(state); //Get keys of all possible shifts ShiftTable shiftTable = GetStateShifts(state); //Each key in shifts dict is an input element // Value is LR0ItemList of shifted LR0Items for this input element. foreach (string input in shiftTable.Keys) { LR0ItemList shiftedCoreItems = shiftTable[input]; ParserState newState = FindOrCreateState(shiftedCoreItems); ActionRecord newAction = new ActionRecord(input, ParserActionType.Shift, newState, null); state.Actions[input] = newAction; //link original LRItems in original state to derived LRItems in newState foreach (LR0Item coreItem in shiftedCoreItems) { LRItem fromItem = FindItem(state, coreItem.Production, coreItem.Position - 1); LRItem toItem = FindItem(newState, coreItem.Production, coreItem.Position); if (!fromItem.PropagateTargets.Contains(toItem)) { fromItem.PropagateTargets.Add(toItem); } //copy hints from core items into the newAction newAction.ShiftItems.Add(fromItem); } //foreach coreItem } //foreach input } //for index Data.FinalState = Data.InitialState.Actions[augmRootKey].NewState; } //method
public override ActionRecord OnActionConflict(Parser parser, Token input, ActionRecord action) { throw new Exception (String.Format ("Action conflict: {0} {1}", ((AstNode) input).Location, action)); }
private void ExecuteShiftAction(ActionRecord action) { Stack.Push(_currentToken, _currentState); _currentState = action.NewState; NextToken(); }
private AstNode CreateNode(ActionRecord reduceAction, SourceSpan sourceSpan, AstNodeList childNodes) { NonTerminal nt = reduceAction.NonTerminal; AstNode result; AstNodeArgs args = new AstNodeArgs(nt, _context, sourceSpan, childNodes); result = nt.InvokeNodeCreator(args); if (result != null) return result; Type defaultNodeType = _context.Compiler.Grammar.DefaultNodeType; Type ntNodeType = nt.NodeType ?? defaultNodeType ?? typeof(AstNode); // Check if NonTerminal is a list // List nodes are produced by .Plus() or .Star() methods of BnfElement // In this case, we have a left-recursive list formation production: // ntList -> ntList + delim? + ntElem // We check if we have already created the list node for ntList (in the first child); // if yes, we use this child as a result directly, without creating new list node. // The other incoming child - the last one - is a new list member; // we simply add it to child list of the result ntList node. Optional "delim" node is simply thrown away. bool isList = nt.IsSet(TermOptions.IsList); if (isList && childNodes.Count > 1 && childNodes[0].Term == nt) { result = childNodes[0]; AstNode newChild = childNodes[childNodes.Count - 1]; newChild.Parent = result; result.ChildNodes.Add(newChild); return result; } //Check for StarList produced by MakeStarList; in this case the production is: ntList -> Empty | Elem+ // where Elem+ is non-empty list of elements. The child list we are actually interested in is one-level lower if (nt.IsSet(TermOptions.IsStarList) && childNodes.Count == 1) { childNodes = childNodes[0].ChildNodes; } // Check for "node-bubbling" case. For identity productions like // A -> B // the child node B is usually a subclass of node A, // so child node B can be used directly in place of the A. So we simply return child node as a result. // TODO: probably need a grammar option to enable/disable this behavior explicitly if (!isList && !nt.IsSet(TermOptions.IsPunctuation) && childNodes.Count == 1) { Type childNodeType = childNodes[0].Term.NodeType ?? defaultNodeType ?? typeof(AstNode); if (childNodeType == ntNodeType || childNodeType.IsSubclassOf(ntNodeType)) return childNodes[0]; } // Try using Grammar's CreateNode method result = Data.Grammar.CreateNode(_context, reduceAction, sourceSpan, childNodes); if (result == null) { //Finally create node directly. For perf reasons we try using "new" for AstNode type (faster), and // activator for all custom types (slower) if (ntNodeType == typeof(AstNode)) result = new AstNode(args); else #if PocketPC || SILVERLIGHT { ConstructorInfo ctor = ntNodeType.GetConstructor(new Type[] { typeof(AstNodeArgs) }); if (ctor == null) throw new Exception("Failed to located constructor: " + ntNodeType.ToString() + "(AstNodeArgs args)"); result = (AstNode)ctor.Invoke(new object[] { args }); } #else { result = (AstNode)Activator.CreateInstance(ntNodeType, args); } #endif } if (result != null) nt.OnNodeCreated(result); return result; }
// Override this method in language grammar if you want a custom node creation mechanism. public virtual AstNode CreateNode(CompilerContext context, ActionRecord reduceAction, SourceSpan sourceSpan, AstNodeList childNodes) { return null; }
public virtual ActionRecord OnActionConflict(Parser parser, Token input, ActionRecord action) { return action; }
public void UpdateRecord(ActionRecord record) { paintObjectID = record.paintObjectID; Graphics.Blit(record.texMap, texMap); actionId = record.actionId; }
}//method private AstNode CreateNode(ActionRecord reduceAction, SourceSpan sourceSpan, AstNodeList childNodes) { NonTerminal nt = reduceAction.NonTerminal; AstNode result; NodeArgs nodeArgs = new NodeArgs(_context, nt, sourceSpan, childNodes); if (nt.NodeCreator != null) { result = nt.NodeCreator(nodeArgs); if (result != null) return result; } Type defaultNodeType = _context.Compiler.Grammar.DefaultNodeType; Type ntNodeType = nt.NodeType ?? defaultNodeType ?? typeof(AstNode); // Check if NonTerminal is a list // List nodes are produced by .Plus() or .Star() methods of BnfElement // In this case, we have a left-recursive list formation production: // ntList -> ntList + delim? + ntElem // We check if we have already created the list node for ntList (in the first child); // if yes, we use this child as a result directly, without creating new list node. // The other incoming child - the last one - is a new list member; // we simply add it to child list of the result ntList node. Optional "delim" node is simply thrown away. bool isList = nt.IsSet(TermOptions.IsList); if (isList && childNodes.Count > 1 && childNodes[0].Term == nt) { result = childNodes[0]; AstNode newChild = childNodes[childNodes.Count - 1]; newChild.Parent = result; result.ChildNodes.Add(newChild); return result; } //Check for StarList produced by MakeStarRule; in this case the production is: ntList -> Empty | Elem+ // where Elem+ is non-empty list of elements. The child list we are actually interested in is one-level lower if (nt.IsSet(TermOptions.IsStarList) && childNodes.Count == 1) { childNodes = childNodes[0].ChildNodes; } // Check for "node-bubbling" case. For identity productions like // A -> B // the child node B is usually a subclass of node A, // so child node B can be used directly in place of the A. So we simply return child node as a result. // TODO: probably need a grammar option to enable/disable this behavior explicitly bool canBubble = (Data.Grammar.FlagIsSet(LanguageFlags.BubbleNodes)) && !isList && !nt.IsSet(TermOptions.IsPunctuation) && childNodes.Count == 1 && (childNodes[0].Term is NonTerminal); if (canBubble) { NonTerminal childNT = childNodes[0].Term as NonTerminal; Type childNodeType = childNT.NodeType ?? defaultNodeType ?? typeof(AstNode); if (childNodeType == ntNodeType || childNodeType.IsSubclassOf(ntNodeType)) return childNodes[0]; } // Try using Grammar's CreateNode method result = Data.Grammar.CreateNode(_context, reduceAction, sourceSpan, childNodes); if (result != null) return result; //Finally create node directly. For perf reasons we try using "new" for AstNode type (faster), and // activator for all custom types (slower) if (ntNodeType == typeof(AstNode)) return new AstNode(nodeArgs); // if (ntNodeType.GetConstructor(new Type[] {typeof(AstNodeList)}) != null) // return (AstNode)Activator.CreateInstance(ntNodeType, childNodes); if (ntNodeType.GetConstructor(new Type[] {typeof(NodeArgs)}) != null) return (AstNode) Activator.CreateInstance(ntNodeType, nodeArgs); //The following should never happen - we check that constructor exists when we validate grammar. string msg = string.Format( @"AST Node class {0} does not have a constructor for automatic node creation. Provide a constructor with a single NodeArgs parameter, or use NodeCreator delegate property in NonTerminal.", ntNodeType); throw new GrammarErrorException(msg); }
public override void OnActionSelected(Parser parser, Token input, ActionRecord action) { Console.WriteLine ("OnActionSelected: {0} / {1}", input, action); }
public async Task <List <ActionRecord> > searchActionRecordAsync(ActionRecord ActionRecord, ESearchOption filterOperator) { checkServiceCommunication(); return(await _gateWaySecurity.searchActionRecordAsync(ActionRecord, filterOperator)); }
public void InitializeFirstAction() { var actionRecord = new ActionRecord(); _actionRecords.Add(actionRecord); }
public virtual void OnActionSelected(Parser parser, Token input, ActionRecord action) { }
public ParserActionEventArgs(ParserState state, Token input, ActionRecord action) { State = state; Input = input; Action = action; }
protected void OnActionSelected(Token input, ActionRecord action) { Data.Grammar.OnActionSelected(this, _currentToken, action); if (ActionSelected != null) { ParserActionEventArgs args = new ParserActionEventArgs(this.CurrentState, input, action); ActionSelected(this, args); } }
private bool CreateDelayedAction(ActionContext context) { var amount = Convert.ToInt32(context.Properties["Amount"]); var type = context.Properties["Unity"]; var ruleId = Convert.ToInt32(context.Properties["RuleId"]); var scheduledActionTask = _contentManager.New("ScheduledActionTask").As <ScheduledActionTaskPart>(); var rule = _repository.Get(ruleId); var when = _clock.UtcNow; switch (type) { case "Minute": when = when.AddMinutes(amount); break; case "Hour": when = when.AddHours(amount); break; case "Day": when = when.AddDays(amount); break; case "Week": when = when.AddDays(7 * amount); break; case "Month": when = when.AddMonths(amount); break; case "Year": when = when.AddYears(amount); break; } foreach (var action in rule.Actions) { var actionRecord = new ActionRecord { Category = action.Category, Position = action.Position, Type = action.Type, Parameters = _tokenizer.Replace(action.Parameters, context.Tokens) }; _actionRecordRepository.Create(actionRecord); var scheduledAction = new ScheduledActionRecord { ActionRecord = actionRecord }; _scheduledActionRecordRepository.Create(scheduledAction); scheduledActionTask.ScheduledActions.Add(scheduledAction); } _contentManager.Create(scheduledActionTask, VersionOptions.Draft); _scheduledTaskManager.CreateTask("TriggerRule", when, scheduledActionTask.ContentItem); return(true); }
private void ExecuteReduceAction(ActionRecord action) { ParserState oldState = _currentState; int popCnt = action.PopCount; //Get new node's child nodes - these are nodes being popped from the stack AstNodeList childNodes = new AstNodeList(); for (int i = 0; i < action.PopCount; i++) { AstNode child = Stack[Stack.Count - popCnt + i].Node; if (!child.Term.IsSet(TermOptions.IsPunctuation)) childNodes.Add(child); } //recover state, location and pop the stack SourceSpan newNodeSpan; if (popCnt == 0) { newNodeSpan = new SourceSpan(_currentToken.Location, 0); } else { SourceLocation firstPopLoc = Stack[Stack.Count - popCnt].Node.Location; int lastPopEndPos = Stack[Stack.Count - 1].Node.Span.EndPos; newNodeSpan = new SourceSpan(firstPopLoc, lastPopEndPos - firstPopLoc.Position); _currentState = Stack[Stack.Count - popCnt].State; Stack.Pop(popCnt); } //Create new node AstNode node = CreateNode(action, newNodeSpan, childNodes); // Push node/current state into the stack Stack.Push(node, _currentState); //switch to new state ActionRecord gotoAction; if (_currentState.Actions.TryGetValue(action.NonTerminal.Key, out gotoAction)) { _currentState = gotoAction.NewState; } else //should never happen throw new CompilerException( string.Format("Cannot find transition for input {0}; state: {1}, popped state: {2}", action.NonTerminal, oldState, _currentState)); }
public static Form CreateInstance() { ApplicationRecord appRec = new ApplicationRecord(); appRec.ApplicationID = 7; appRec.Name = "HatStandaloneTestApp"; appRec.Type = 2; appRec.Initialization = @" <initstring> <interopAssembly> <URL>C:\CCFCITRIX\Microsoft.Ccf.Samples.StandAloneTestApp.exe</URL> <Arguments/> <WorkingDirectory>C:\CCFCITRIX</WorkingDirectory> <hostInside /> </interopAssembly> <DataDrivenAdapterBindings> <Type>Microsoft.Ccf.HostedApplicationToolkit.DataDrivenAdapter.WinDataDrivenAdapter, Microsoft.Ccf.HostedApplicationToolkit.DataDrivenAdapter</Type> <Controls> <AccControl name=""textbox_acc""> <Path> <Next match=""2"">Test:</Next> <Next>Test:</Next> </Path> </AccControl> <AccControl name=""button_acc""> <Path> <Next>Ok</Next> <Next>Ok</Next> </Path> </AccControl> <AccControl name=""checkbox_acc""> <Path> <Next>Test Checkbox</Next> <Next>Test Checkbox</Next> </Path> </AccControl> <AccControl name=""radio1_acc""> <Path> <Next>Radio1</Next> <Next>Radio1</Next> </Path> </AccControl> <AccControl name=""radio2_acc""> <Path> <Next>Radio2</Next> <Next>Radio2</Next> </Path> </AccControl> <AccControl name=""radio3_acc""> <Path> <Next>Radio3</Next> <Next>Radio3</Next> </Path> </AccControl> <AccControl name=""tab1_acc""> <Path> <Next offset=""-1"">Simulate Crash</Next> <Next offset=""1"">Application</Next> <Next>Tab Page 1</Next> </Path> </AccControl> <AccControl name=""tab2_acc""> <Path> <Next offset=""-1"">Simulate Crash</Next> <Next offset=""1"">Application</Next> <Next>Tab Page 2</Next> </Path> </AccControl> <AccControl name=""crashbutton_acc""> <Path> <Next>Simulate Crash</Next> <Next>Simulate Crash</Next> </Path> </AccControl> </Controls> </DataDrivenAdapterBindings> <displayGroup>None</displayGroup> <optimumSize x=""800"" y=""600"" /> <minimumSize x=""640"" y=""480"" /> </initstring>"; appRec.EnableAutoSignOn = false; appRec.LoginFields = null; BindingList<ActionRecord> list = new BindingList<ActionRecord>(); ActionRecord ar1 = new ActionRecord(); ar1.ActionID = 1; ar1.Name = "Default"; ar1.Initialization = @"<ActionInit/>"; list.Add(ar1); appRec.Actions = list; HatStandAloneStub stub = new HatStandAloneStub(appRec.ApplicationID, appRec.Name, appRec.Initialization); for (int i = 0; i < appRec.Actions.Count; i++) { stub.AddAction(appRec.Actions[i].ActionID, appRec.Actions[i].Name, appRec.Actions[i].Initialization); } HostingForm hostingForm = new HostingForm(); hostingForm.Name = "HatStandAloneTestAppStub"; hostingForm.Text = stub.ApplicationName; hostingForm.ControlBox = false; hostingForm.MaximizeBox = false; hostingForm.MinimizeBox = false; hostingForm.ShowInTaskbar = false; hostingForm.FormBorderStyle = FormBorderStyle.None; hostingForm.StartPosition = FormStartPosition.Manual; hostingForm.ClientSize = stub.OptimumSize; hostingForm.MinimumSize = stub.MinimumSize; hostingForm.Closed += delegate { stub.Close(); }; stub.TopLevelWindow.Parent = hostingForm; stub.TopLevelWindow.Dock = DockStyle.Fill; stub.Initialize(); return hostingForm; }
public static Form CreateInstance() { ApplicationRecord appRec = new ApplicationRecord(); appRec.ApplicationID = 7; appRec.Name = "StandaloneTestApp"; appRec.Type = 2; appRec.Initialization = @" <initstring> <interopAssembly> <URL>C:\CCFCITRIX\Microsoft.Ccf.Samples.StandAloneTestApp.exe</URL> <Arguments/> <WorkingDirectory>C:\CCFCITRIX</WorkingDirectory> <hostInside /> </interopAssembly> <adapter> <URL>C:\CCFCITRIX\Microsoft.Ccf.Samples.Citrix.ApplicationAdapter.dll</URL> <type>Microsoft.Ccf.Samples.Citrix.AppAdapter</type> </adapter> <displayGroup>None</displayGroup> <optimumSize x=""800"" y=""600"" /> <minimumSize x=""640"" y=""480"" /> </initstring>"; appRec.EnableAutoSignOn = false; appRec.LoginFields = null; BindingList <ActionRecord> list = new BindingList <ActionRecord>(); ActionRecord ar1 = new ActionRecord(); ar1.ActionID = 1; ar1.Name = "Default"; ar1.Initialization = @"<ActionInit/>"; list.Add(ar1); ActionRecord ar2 = new ActionRecord(); ar2.ActionID = 2; ar2.Name = "PushButton"; ar2.Initialization = @" <ActionInit><Steps> <GetControlByText>Tab Page 2</GetControlByText> <Push/> <GetControlByText>Test Checkbox</GetControlByText> <Push/> <GetControlByText>Radio1</GetControlByText> <SetCheck>1</SetCheck> <GetControlByPosition x=""88"" y=""48""/> <GetText>StandaloneText</GetText> <SetText>StandaloneText</SetText> <GetControlByText>&Ok</GetControlByText> <GetText>ButtonName</GetText> <Push/> </Steps></ActionInit>"; list.Add(ar2); appRec.Actions = list; StandAloneStub stub = new StandAloneStub(appRec.ApplicationID, appRec.Name, appRec.Initialization); for (int i = 0; i < appRec.Actions.Count; i++) { stub.AddAction(appRec.Actions[i].ActionID, appRec.Actions[i].Name, appRec.Actions[i].Initialization); } HostingForm hostingForm = new HostingForm(); hostingForm.Name = "StandAloneTestAppStub"; hostingForm.Text = stub.ApplicationName; hostingForm.ControlBox = false; hostingForm.MaximizeBox = false; hostingForm.MinimizeBox = false; hostingForm.ShowInTaskbar = false; hostingForm.FormBorderStyle = FormBorderStyle.None; hostingForm.StartPosition = FormStartPosition.Manual; hostingForm.ClientSize = stub.OptimumSize; hostingForm.MinimumSize = stub.MinimumSize; hostingForm.Closed += delegate { stub.Close(); }; stub.TopLevelWindow.Parent = hostingForm; stub.TopLevelWindow.Dock = DockStyle.Fill; stub.Initialize(); return(hostingForm); }
public async Task AddActionRecord(ActionRecord ar) { await ClientService.client.PostAsJsonAsync(actionRecordsURL, ar); }