// process incoming commands for edit mode public void ProcessEditCommand() { reply = w.RecvString(); if (reply != null && reply != "Null") { Debug.Log("Processing Command"); FlowEvent incoming = JsonUtility.FromJson <FlowEvent>(reply); if (incoming.command >= Commands.Project.MIN && incoming.command <= Commands.Project.MAX) { CommandProcessor.processProjectCommand(JsonUtility.FromJson <FlowProjectCommand>(reply)); } else { CommandProcessor.processCommand(incoming); } } // if (w.error != null) // { // Debug.Log("[unity] Error: " + w.error); // connected = false; // yield return new WaitForSeconds(5); // #if !UNITY_WSA || UNITY_EDITOR // DoOnMainThread.ExecuteOnMainThread.Enqueue(() => // { // StartCoroutine(ConnectWebsocket()); // }); // Debug.Log("Connect connection"); // CommandProcessor.sendCommand(Commands.LOGIN, uid.ToString()); // loggedIn = false; // #endif // } // yield return 0; }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.LoginCompleted)) { var externalUserUuid = GetUserExternalUuid(); var cvrNumber = _parser.MatchCvrNumber(); if (externalUserUuid.IsNone) { _logger.Warning("No external UUID passed from STS Adgangsstyring"); context.TransitionTo(_stateFactory.CreateErrorState(), _ => _.HandleUnknownError()); } else if (cvrNumber.IsNone) { _logger.Warning("CVR number not provided from STS Adgangsstyring"); context.TransitionTo(_stateFactory.CreateErrorState(), _ => _.HandleUnknownError()); } else if (CurrentUserHasKitosPrivilege()) { _logger.Debug("User with UUID {uuid} and CVR {cvr} did have privilege", externalUserUuid.Value, cvrNumber.Value); context.TransitionTo(_stateFactory.CreatePrivilegeVerifiedState(externalUserUuid.Value, cvrNumber.Value), _ => _.HandleUserPrivilegeVerified()); } else { var privileges = GetPrivilegesString(); _logger.Information("Missing privilege for user with UUID {uuid} and CVR {cvr}. Failed with XML privileges {xmlPrivilegesBase64}", externalUserUuid.Value, cvrNumber.Value, privileges); context.TransitionTo(_stateFactory.CreateErrorState(), _ => _.HandleUserPrivilegeInvalid()); } } }
/// <summary> /// 创建工作流运行时 /// </summary> /// <param name="IsPer">是否使用持久化</param> /// <returns></returns> public static WorkflowRuntime CreateWorkFlowRuntime(bool IsPer) { try { WorkflowRuntime WfRuntime = new WorkflowRuntime(); if (IsPer) { ConnectionStringSettings defaultConnectionString = ConfigurationManager.ConnectionStrings["OracleConnection"]; WfRuntime.AddService(new AdoPersistenceService(defaultConnectionString, true, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); WfRuntime.AddService(new AdoTrackingService(defaultConnectionString)); WfRuntime.AddService(new AdoWorkBatchService()); } FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); ManualWorkflowSchedulerService scheduleService = new ManualWorkflowSchedulerService(); WfRuntime.AddService(scheduleService); TypeProvider typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); WfRuntime.StartRuntime(); return(WfRuntime); } catch (Exception ex) { LogHelper.WriteLog("CreateWorkFlowRuntime异常信息 :" + ex.ToString()); throw new Exception(ex.Message); } }
public override void Handle(FlowEvent @event, FlowContext context) { _logger.Information("SSO entered {errorStateName} with error: {errorEvent}", nameof(ErrorState), @event); switch (@event) { case FlowEvent.UserPrivilegeInvalid: ErrorCode = SsoErrorCode.MissingPrivilege; break; case FlowEvent.NoOrganizationAndRole: ErrorCode = SsoErrorCode.NoOrganizationAndRole; break; case FlowEvent.UnableToResolveUserInStsOrganization: ErrorCode = SsoErrorCode.UserNotFoundInSTS; break; case FlowEvent.UnableToLocateUser: ErrorCode = SsoErrorCode.UnableToCreateUserWithUnknownOrganization; break; default: ErrorCode = SsoErrorCode.Unknown; break; } }
public async Task <ActionResult <string> > FlowEventStart([FromBody] FlowEvent message, [FromServices] DaprClient daprClient) { _logger.LogInformation(message.Id); await daprClient.PublishEventAsync(PubSubName, PubSubTopic, message); return(Ok("Thanks")); }
public static int processCommand(FlowEvent incoming) { int retValue = 0; if (cmdCbDictionary.ContainsKey(incoming.command)) { delegate_flow_cmd cb; cmdCbDictionary.TryGetValue(incoming.command, out cb); cb(incoming); cmdCbDictionary.Remove(incoming.command); } if (listenerCmdDictionary.ContainsKey(incoming.command)) { List <delegate_flow_cmd> callbacks; listenerCmdDictionary.TryGetValue(incoming.command, out callbacks); foreach (delegate_flow_cmd cb in callbacks) { cb(incoming); } } string debug_updates = recieveEvents[incoming.command](); if (FlowNetworkManager.debug) { Debug.Log(debug_updates); } return(retValue); }
/// <summary> /// 创建工作流运行时 /// </summary> /// <param name="IsPer">是否使用持久化</param> /// <returns></returns> public static WorkflowRuntime CreateWorkFlowRuntime(bool IsPer) { try { WorkflowRuntime WfRuntime = new WorkflowRuntime(); if (IsPer) { String connStringPersistence = ConfigurationManager.ConnectionStrings["SqlPersistenceConnection"].ConnectionString;//Data Source=172.30.50.110;Initial Catalog=WorkflowPersistence;Persist Security Info=True;User ID=sa;Password=fbaz2012;MultipleActiveResultSets=True"; SqlWorkflowPersistenceService persistence = new SqlWorkflowPersistenceService(connStringPersistence, true, new TimeSpan(0, 0, 30), new TimeSpan(0, 1, 0)); WfRuntime.AddService(persistence); WfRuntime.WorkflowPersisted += new EventHandler <WorkflowEventArgs>(WfRuntime_WorkflowPersisted); WfRuntime.ServicesExceptionNotHandled += new EventHandler <ServicesExceptionNotHandledEventArgs>(WfRuntime_ServicesExceptionNotHandled); // ConnectionStringSettings defaultConnectionString = ConfigurationManager.ConnectionStrings["OracleConnection"]; // WfRuntime.AddService(new AdoPersistenceService(defaultConnectionString, true, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); // WfRuntime.AddService(new AdoTrackingService(defaultConnectionString)); // WfRuntime.AddService(new AdoWorkBatchService()); } FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); TypeProvider typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); WfRuntime.StartRuntime(); return(WfRuntime); } catch (Exception ex) { LogHelper.WriteLog("CreateWorkFlowRuntime异常信息 :" + ex.ToString()); throw new Exception(ex.Message); } }
/// <summary> /// 从持久化库在恢复实例 /// </summary> /// <param name="WfRuntime"></param> /// <param name="INSTANCEID"></param> /// <returns></returns> public static WorkflowInstance GetWorkflowInstance(WorkflowRuntime WfRuntime, string INSTANCEID) { try { WfRuntime = new WorkflowRuntime(); if (WfRuntime.GetService(typeof(AdoPersistenceService)) == null) { ConnectionStringSettings defaultConnectionString = ConfigurationManager.ConnectionStrings["OracleConnection"]; WfRuntime.AddService(new AdoPersistenceService(defaultConnectionString, true, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); WfRuntime.AddService(new AdoTrackingService(defaultConnectionString)); WfRuntime.AddService(new AdoWorkBatchService()); } FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); TypeProvider typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); WfRuntime.StartRuntime(); WorkflowInstance instance = null; try { instance = WfRuntime.GetWorkflow(new Guid(INSTANCEID)); } catch { instance = null; } if (instance == null) //try find instance in sql server persistence { WfRuntime = new WorkflowRuntime(); ExternalEvent = new FlowEvent(); objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); String connStringPersistence = ConfigurationManager.ConnectionStrings["SqlPersistenceConnection"].ConnectionString;//Data Source=172.30.50.110;Initial Catalog=WorkflowPersistence;Persist Security Info=True;User ID=sa;Password=fbaz2012;MultipleActiveResultSets=True"; SqlWorkflowPersistenceService persistence = new SqlWorkflowPersistenceService(connStringPersistence, true, new TimeSpan(0, 2, 0), new TimeSpan(0, 0, 5)); WfRuntime.AddService(persistence); WfRuntime.StartRuntime(); instance = WfRuntime.GetWorkflow(new Guid(INSTANCEID)); } //WfRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) //{ // instance = null; //}; return(instance); } catch (Exception ex) { LogHelper.WriteLog("GetWorkflowInstance异常信息 :" + ex.ToString()); throw new Exception(ex.Message); } }
public override void Handle(FlowEvent @event, FlowContext context) { switch (@event) { case FlowEvent.UnableToLocateUser: var organizationByCvrResult = _organizationRepository.GetByCvr(_stsBrugerInfo.MunicipalityCvr); if (organizationByCvrResult.HasValue) { var organization = organizationByCvrResult.Value; var user = CreateAutoProvisonedUser(); _organizationRoleService.MakeUser(user, organization); context.TransitionTo(_ssoStateFactory.CreateUserLoggedIn(user), _ => _.HandleUserAutoProvisioned()); } else { context.TransitionTo(_ssoStateFactory.CreateErrorState(), _ => _.HandleUnableToLocateUser()); } break; default: throw new ArgumentOutOfRangeException(nameof(@event), @event, null); } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.UserHasNoRoleInOrganization)) { _organizationRoleService.MakeUser(_user, _ssoOrganization); context.TransitionTo(_ssoStateFactory.CreateUserLoggedIn(_user), _ => _.HandleRoleAssigned()); } }
public static void processCommand(FlowEvent incoming) { // runs the receive delegate that corresponds to the incoming command and stores any debug logs in debug_updates string debug_updates = receiveEvents[incoming.command](); // logs debug updates FlowNetworkManager.log(debug_updates); }
public async Task <ActionResult <string> > FlowEventReceive([FromBody] FlowEvent message, [FromServices] DaprClient daprClient) { _logger.LogInformation($"Received message with Id: {message.Id}"); await daprClient.SaveStateAsync(StateStoreName, message.Id, message.Content); return(Ok("Thanks")); }
public static FlowNode getFlowNode(string tmpkey, string nodeKey, FlowEvent endFlow) { FlowNode flo = GetNodeByNodeType(tmpkey, nodeKey); flo.NodeKey = nodeKey; flo.TmpKey = tmpkey; flo.endFlow += endFlow; return(flo); }
public void CreateText() { FlowEvent createCubeEvent = new FlowEvent(); createCubeEvent.cmd = Commands.Droplet.types.TEXT; createCubeEvent.value = new FlowPayload(Commands.Droplet.types.TEXT.ToString()); // CommandProcessor.EditorCommandProcessor(createCubeEvent); CommandProcessor.sendCommand(createCubeEvent); }
public static void sendCommand(int command, string value) { FlowEvent newCmd = new FlowEvent(); newCmd.command = command; newCmd.value = new FlowPayload(); newCmd.value.data = value; cmdBuffer.Add(newCmd); }
public void Execute(FlowEvent initialEvent) { var links = flowClass.GetTypeInfo().GetCustomAttributes <LinkEventToCommandAttribute>(); foreach (var link in links) { AddEventMapping(link); } eventStore.AddEvent(initialEvent); }
public void OnApplicationQuit() { FlowEvent closeEvent = new FlowEvent(); closeEvent.cmd = -1; CommandProcessor.sendCommand(closeEvent); Debug.Log("Closing!!"); if (w != null && w.connected) { w.Close(); } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.UserFirstTimeSsoVisit)) { AssociateUserWithExternalIdentity(); HandleUserWithSsoIdentity(context); } else if (@event.Equals(FlowEvent.ExistingSsoUserWithoutRoles)) { HandleUserWithSsoIdentity(context); } }
private static void sendCommand(int command, string value, delegate_flow_cmd callback) { FlowEvent newCmd = new FlowEvent(); newCmd.command = command; newCmd.value.data = value; cmdBuffer.Add(newCmd); if (cmdCbDictionary.ContainsKey(command)) { cmdCbDictionary.Remove(command); } cmdCbDictionary.Add(command, callback); }
private void OnEventRaised(FlowEvent flowEvent) { if (flowEvent == null) { return; } IList <Tuple <string, ICommand> > commands = GetCommands(flowEvent); foreach (var command in commands) { if (!(flowEvent is CommandProcessingEvent)) { eventStore.AddEvent(new OnStartProcessingCommand(flowEvent.ContextOfEvent, command.Item2)); } var observableEvents = command.Item2.Execute(); Action onComplete = () => { if (!(flowEvent is CommandProcessingEvent)) { eventStore.AddEvent(new OnEndProcessingCommand(flowEvent.ContextOfEvent, command.Item2)); } }; observableEvents.IgnoreElements().Subscribe((e) => { }, onComplete); string commandName = command.Item1;// This is needed to capture variable also, we should use command variable in this lambda observableEvents.Subscribe(currentEvent => { if (currentEvent == null) { return; } if (currentEvent.ContextOfEvent == null) { currentEvent.ContextOfEvent = flowEvent.ContextOfEvent; } if (currentEvent.CommandName == DEFAULT_COMMAND_NAME && commandName != DEFAULT_COMMAND_NAME) { currentEvent.CommandName = commandName; } eventStore.AddEvent(currentEvent); }, ex => Console.WriteLine(ex)); } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.UserPrivilegeVerified)) { var userResult = _ssoUserIdentityRepository.GetByExternalUuid(_userUuid); if (userResult.HasValue) // User has used the same SSO identity before and exists { var user = userResult.Value.User; if (user.CanAuthenticate()) { context.TransitionTo(_ssoStateFactory.CreateUserLoggedIn(user), _ => _.HandleUserSeenBefore()); } else { var stsBrugerInfo = _stsBrugerInfoService.GetStsBrugerInfo(_userUuid, _cvrNumber); if (!stsBrugerInfo.HasValue) { context.TransitionTo(_ssoStateFactory.CreateErrorState(), _ => _.HandleUnableToResolveUserInStsOrganisation()); } else { context.TransitionTo(_ssoStateFactory.CreateUserIdentifiedState(user, stsBrugerInfo.Value), _ => _.HandleExistingSsoUserWithoutRoles()); } } } else // Try to find the user by email { var stsBrugerInfo = _stsBrugerInfoService.GetStsBrugerInfo(_userUuid, _cvrNumber); if (!stsBrugerInfo.HasValue) { context.TransitionTo(_ssoStateFactory.CreateErrorState(), _ => _.HandleUnableToResolveUserInStsOrganisation()); } else { var userByKitosEmail = FindUserByEmail(stsBrugerInfo); if (userByKitosEmail.HasValue) { context.TransitionTo(_ssoStateFactory.CreateUserIdentifiedState(userByKitosEmail.Value, stsBrugerInfo.Value), _ => _.HandleUserFirstTimeSsoVisit()); } else { context.TransitionTo(_ssoStateFactory.CreateFirstTimeUserNotFoundState(stsBrugerInfo.Value), _ => _.HandleUnableToLocateUser()); } } } } }
private IList <Tuple <string, ICommand> > GetCommands(FlowEvent flowEvent) { var eventType = flowEvent.GetType(); if (eventToCommandMapping.ContainsKey(eventType)) { IEnumerable <EventToCommand> filteredEventToCommands = GetFilteredEvents(flowEvent.CommandName, eventType); return(commandFactory.Get(flowEvent.ContextOfEvent, filteredEventToCommands)); } else { return(new List <Tuple <string, ICommand> >()); } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.OrganizationNotFound)) { if (_user.CanAuthenticate()) { context.TransitionTo(_stateFactory.CreateUserLoggedIn(_user), _ => _.HandleUserHasRoleInOrganization()); } else { context.TransitionTo(_stateFactory.CreateErrorState(), _ => _.HandleNoRoleAndOrganization()); } } }
public override void Handle(FlowEvent @event, FlowContext context) { if (@event.Equals(FlowEvent.OrganizationFound)) { var rolesInOrganization = _organizationRoleService.GetRolesInOrganization(_user, _ssoOrganization.Id); if (rolesInOrganization.Any()) { context.TransitionTo(_ssoStateFactory.CreateUserLoggedIn(_user), _ => _.HandleUserHasRoleInOrganization()); } else { context.TransitionTo(_ssoStateFactory.CreateAssigningRoleState(_user, _ssoOrganization), _ => _.HandleUserHasNoRoleInOrganization()); } } }
public override void Handle(FlowEvent @event, FlowContext context) { switch (@event) { case FlowEvent.UserSeenBefore: case FlowEvent.UserHasRoleInOrganization: case FlowEvent.RoleAssigned: case FlowEvent.UserAutoProvisioned: _authenticationState.SetAuthenticatedUser(User, AuthenticationScope.Session); break; default: throw new ArgumentOutOfRangeException(nameof(@event), @event, null); } }
public virtual void Send(WebSocket w, FlowEvent evt) { timestamp = DateTime.UtcNow.Ticks; string stringCmd = JsonUtility.ToJson(evt); FlowNetworkManager.log("Sending " + stringCmd); try { w.SendString(stringCmd); } catch { FlowNetworkManager.log("The update didnt send, and the websocket connection status is: " + w.connected + "\nthe json is: " + stringCmd); } }
IEnumerator ConnectWebsocket() { log("Connecting..."); yield return(StartCoroutine(w.Connect())); log("Connecting...2"); while (w.error == "Closed") { yield return(StartCoroutine(ReconnectWebsocket())); log("Closed connection"); } connected = true; log("CONNECTED WEBSOCKET"); while (true) { reply = w.RecvString(); if (reply != null && reply != "Null") { FlowEvent incoming = JsonUtility.FromJson <FlowEvent>(reply); CommandProcessor.processCommand(incoming); } if (w.error != null) { log("[unity] Error: " + w.error); connected = false; yield return(new WaitForSeconds(5)); #if !UNITY_WSA DoOnMainThread.ExecuteOnMainThread.Enqueue(() => { StartCoroutine(ConnectWebsocket()); }); #endif } yield return(0); } }
public virtual void Send(WebSocket w, FlowEvent evt) { timestamp = DateTime.UtcNow.Ticks; string stringCmd = JsonUtility.ToJson(evt); if (FlowNetworkManager.debug) { Debug.Log(stringCmd); } try { w.SendString(stringCmd); } catch { Debug.Log("The update didnt send, and the websocket connection status is: " + w.connected); Debug.Log("the json is: " + stringCmd); } Debug.Log("Sent successfully! Json: " + stringCmd); }
private void Handle(FlowEvent eventToHandle) { CurrentState.Handle(eventToHandle, this); }
public static void sendCommand(FlowEvent evt) { cmdBuffer.Add(evt); }