/// <summary> /// Posts refresh messages to the ancestors of the specified entityToken /// </summary> /// <param name="childEntityToken"></param> /// <param name="parentLevel">1 means the first parent, 2 means the second, etc.</param> public void PostRefreshMessages(EntityToken childEntityToken, int parentLevel = 1) { Verify.ArgumentNotNull(childEntityToken, "childEntityToken"); if (_postRefreshMessagesCalled) { throw new InvalidOperationException("Only one PostRefreshMessages call is allowed"); } _postRefreshMessagesCalled = true; RelationshipGraph relationshipGraph = new RelationshipGraph(childEntityToken, RelationshipGraphSearchOption.Both); var levels = relationshipGraph.Levels.Evaluate(); if (levels.Count <= parentLevel) { return; } RelationshipGraphLevel relationshipGraphLevel = levels.ElementAt(parentLevel); IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); foreach (EntityToken entityToken in relationshipGraphLevel.AllEntities) { messageService.RefreshTreeSection(entityToken); Log.LogVerbose(this.GetType().Name, "Refreshing EntityToken: Type = {0}, Source = {1}, Id = {2}, EntityTokenType = {3}", entityToken.Type, entityToken.Source, entityToken.Id, entityToken.GetType()); } }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { UrlActionToken urlActionToken = (UrlActionToken)actionToken; string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); string url = urlActionToken.Url; string extendedUrl = $"{url}{(url.Contains("?") ? "&" : "?")}EntityToken={HttpUtility.UrlEncode(serializedEntityToken)}"; if (extendedUrl.IndexOf("consoleId", StringComparison.OrdinalIgnoreCase) == -1) { extendedUrl = $"{extendedUrl}&consoleId={currentConsoleId}"; } ConsoleMessageQueueFacade.Enqueue( new OpenViewMessageQueueItem { Url = extendedUrl, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = urlActionToken.Label, IconResourceHandle = urlActionToken.Icon }, currentConsoleId); return(null); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { MessageBoxActionToken messageBoxActionToken = (MessageBoxActionToken)actionToken; IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); managementConsoleMessageService.ShowMessage(messageBoxActionToken.DialogType, messageBoxActionToken.Title, messageBoxActionToken.Message); return(null); }
/// <exclude /> public void PostRefreshMessages(EntityToken specificEntityToken) { Verify.ArgumentNotNull(specificEntityToken, "specificEntityToken"); if (_postRefreshMessagesCalled) { throw new InvalidOperationException("Only one PostRefreshMessages call is allowed"); } IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); messageService.RefreshTreeSection(specificEntityToken); Log.LogVerbose(GetType().Name, "Refreshing EntityToken: Type = {0}, Source = {1}, Id = {2}, EntityTokenType = {3}", specificEntityToken.Type, specificEntityToken.Source, specificEntityToken.Id, specificEntityToken.GetType()); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { UrlActionToken urlActionToken = (UrlActionToken)actionToken; string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); string url = string.Format("{0}?EntityToken={1}", urlActionToken.Url, HttpUtility.UrlEncode(serializedEntityToken)); ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = urlActionToken.Label }, currentConsoleId); return(null); }
/// <exclude /> public void PostRefreshMessages(bool skipBeforeDeleteEntityToken = false) { if (_postRefreshMessagesCalled) { throw new InvalidOperationException("Only one PostRefreshMessages call is allowed"); } _postRefreshMessagesCalled = true; IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); foreach (EntityToken entityToken in RefreshDeleteEntityTokenFinder.FindEntityTokens(_beforeGraph, skipBeforeDeleteEntityToken)) { messageService.RefreshTreeSection(entityToken); } }
/// <exclude /> public void PostRefreshMesseges(EntityToken newChildEntityToken) { Verify.ArgumentNotNull(newChildEntityToken, "newChildEntityToken"); Verify.That(!_postRefreshMessegesCalled, "Only one PostRefreshMesseges call is allowed"); _postRefreshMessegesCalled = true; _afterGraph = new RelationshipGraph(newChildEntityToken, RelationshipGraphSearchOption.Both, false, false); IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); foreach (EntityToken entityToken in RefreshBeforeAfterEntityTokenFinder.FindEntityTokens(_beforeGraph, _afterGraph)) { messageService.RefreshTreeSection(entityToken); Log.LogVerbose("AddNewTreeRefresher", string.Format("Refreshing EntityToken: Type = {0}, Source = {1}, Id = {2}, EntityTokenType = {3}", entityToken.Type, entityToken.Source, entityToken.Id, entityToken.GetType())); } }
/// <exclude /> public void PostRefreshMessages(bool skipBeforeDeleteEntityToken = false) { if (_postRefreshMessagesCalled) { throw new InvalidOperationException("Only one PostRefreshMessages call is allowed"); } _postRefreshMessagesCalled = true; IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); foreach (EntityToken entityToken in RefreshDeleteEntityTokenFinder.FindEntityTokens(_beforeGraph, skipBeforeDeleteEntityToken)) { messageService.RefreshTreeSection(entityToken); Log.LogVerbose(this.GetType().Name, "Refreshing EntityToken: Type = {0}, Source = {1}, Id = {2}, EntityTokenType = {3}", entityToken.Type, entityToken.Source, entityToken.Id, entityToken.GetType()); } }
/// <exclude /> public void PostRefreshMessages(EntityToken afterUpdateEntityToken) { if (_postRefreshMessagesCalled) { throw new InvalidOperationException("Only one PostRefreshMessages call is allowed"); } _postRefreshMessagesCalled = true; _afterGraph = new RelationshipGraph(afterUpdateEntityToken, RelationshipGraphSearchOption.Both, false, false); IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); foreach (EntityToken entityToken in RefreshBeforeAfterEntityTokenFinder.FindEntityTokens(_beforeGraph, _afterGraph)) { messageService.RefreshTreeSection(entityToken); Log.LogVerbose(this.GetType().Name, "Refreshing EntityToken: Type = {0}, Source = {1}, Id = {2}, EntityTokenType = {3}", entityToken.Type, entityToken.Source, entityToken.Id, entityToken.GetType()); } }
/// <exclude /> public FlowToken Execute(string serializedEntityToken, string serializedActionToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { var dataEntityToken = (DataEntityToken)EntityTokenSerializer.Deserialize(serializedEntityToken); var data = dataEntityToken.Data; Verify.IsNotNull(data, "Failed to get the data from an entity token"); using (new DataScope(DataScopeIdentifier.Administrated)) { var treeRefresher = new AddNewTreeRefresher(dataEntityToken, flowControllerServicesContainer); var newData = (IData)StaticReflection.GetGenericMethodInfo(() => CloneData((IData)null)) .MakeGenericMethod(data.DataSourceId.InterfaceType).Invoke(this, new object[] { data }); var consoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; ConsoleCommandHelper.SelectConsoleElementWithoutPerspectiveChange(consoleId, newData.GetDataEntityToken()); treeRefresher.PostRefreshMessages(dataEntityToken); } return(null); }
/// <exclude /> public static FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer, TaskManagerEvent taskManagerEvent) { if (entityToken == null) { throw new ArgumentNullException("entityToken"); } if (actionToken == null) { throw new ArgumentNullException("actionToken"); } string username = UserValidationFacade.GetUsername(); #if NO_SECURITY #else HookingFacade.EnsureInitialization(); IEnumerable <UserPermissionDefinition> userPermissionDefinitions = PermissionTypeFacade.GetUserPermissionDefinitions(username); IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions = PermissionTypeFacade.GetUserGroupPermissionDefinitions(username); SecurityResult securityResult = SecurityResolver.Resolve(UserValidationFacade.GetUserToken(), actionToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinitions); if (securityResult != SecurityResult.Allowed && !(entityToken is SecurityViolationWorkflowEntityToken)) { return(ExecuteSecurityViolation(actionToken, entityToken, flowControllerServicesContainer)); } #endif bool ignoreLocking = actionToken.IsIgnoreEntityTokenLocking(); if (!ignoreLocking && ActionLockingFacade.IsLocked(entityToken)) { return(ExecuteEntityTokenLocked(actionToken, entityToken, flowControllerServicesContainer)); } IActionExecutor actionExecutor = ActionExecutorCache.GetActionExecutor(actionToken); ActionEventSystemFacade.FireOnBeforeActionExecution(entityToken, actionToken); FlowToken flowToken; using (TaskContainer taskContainer = TaskManagerFacade.CreateNewTasks(entityToken, actionToken, taskManagerEvent)) { ITaskManagerFlowControllerService taskManagerService = null; if (flowControllerServicesContainer.GetService(typeof(ITaskManagerFlowControllerService)) == null) { taskManagerService = new TaskManagerFlowControllerService(taskContainer); flowControllerServicesContainer.AddService(taskManagerService); } try { if (actionExecutor is IActionExecutorSerializedParameters) { string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); string serializedActionToken = ActionTokenSerializer.Serialize(actionToken); flowToken = Execute(actionExecutor as IActionExecutorSerializedParameters, serializedEntityToken, serializedActionToken, actionToken, flowControllerServicesContainer); } else { flowToken = Execute(actionExecutor, entityToken, actionToken, flowControllerServicesContainer); } } finally { if (taskManagerService != null) { flowControllerServicesContainer.RemoveService(taskManagerService); } } taskContainer.SetOnIdleTaskManagerEvent(new FlowTaskManagerEvent(flowToken)); taskContainer.UpdateTasksWithFlowToken(flowToken); taskContainer.SaveTasks(); } ActionEventSystemFacade.FireOnAfterActionExecution(entityToken, actionToken, flowToken); IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer .GetService <IManagementConsoleMessageService>(); if (managementConsoleMessageService != null) { FlowControllerFacade.RegisterNewFlowInformation(flowToken, entityToken, actionToken, managementConsoleMessageService.CurrentConsoleId); } else { Log.LogWarning(nameof(ActionExecutorFacade), "Missing ManagementConsoleMessageService, can not register the flow"); } return(flowToken); }