コード例 #1
0
 /// <summary>
 /// setup necessary stuff for the client
 /// </summary>
 void Setup()
 {
     settings             = FlowSettings;
     FlowActions.settings = settings;
     FlowActions.isClient = true;
     flowActions          = gameObject.AddComponent <FlowActions>();
     IsEnabled            = true;
 }
コード例 #2
0
        public static FlowActions <T> If <T>(
            this FlowActions <T> actions,
            Func <FlowContext <T>, Boolean> condition,
            Action <FlowActions <T> > trueActions,
            Action <FlowActions <T> > falseActions)
        {
            IFlowAction <T> ifaction = new IfAction <T>(condition, trueActions).Else(falseActions);

            return(actions.Add(ifaction));
        }
コード例 #3
0
 public static FlowActions <T> StartActionsGroup <T>(
     this FlowActions <T> actions,
     String text,
     Action <FlowActions <T> > groupActions)
 {
     return(actions.Add(new ActionsGroupAction <T>(groupActions)
     {
         Text = text
     }));
 }
コード例 #4
0
        private async void AsyncDisconnect()
        {
            await Task.Delay((int)Math.Abs(DISCONNECT_DELAY * 1000));

            // peer.Disconnect();
            FlowServer.clients.Remove(id);
            Logger.Debug($"Client ({id}) has disconnected");
            DisconnectFlowServerAction action = FlowActions.GetActionByName("Disconnect") as DisconnectFlowServerAction;

            action.SendFrom(id);
        }
コード例 #5
0
        public static IfFlowActions <T> If <T>(
            this FlowActions <T> actions,
            Func <FlowContext <T>, Boolean> condition,
            Action <FlowActions <T> > action,
            String conditionText = Defaults.ConditionText,
            String actionText    = Defaults.ConditionActionText)
        {
            IfAction <T>      ifaction      = new IfAction <T>(condition, action, conditionText, actionText);
            IfFlowActions <T> ifFlowActions = new IfFlowActions <T>(actions, ifaction);

            return(ifFlowActions);
        }
コード例 #6
0
        /// <summary>
        /// Sets up rudimentary stuff for the server
        /// </summary>
        void Setup()
        {
            settings             = FlowSettings;
            FlowActions.settings = FlowSettings;
            flowActions          = gameObject.AddComponent <FlowActions>();


            // setup unity to run on the defined tickrate
            Time.fixedDeltaTime         = 1f / settings.TICK_RATE;
            QualitySettings.vSyncCount  = 0;
            Application.targetFrameRate = settings.TICK_RATE;
        }
コード例 #7
0
        public static FlowActions <T> Else <T>(
            this IfFlowActions <T> ifactions,
            Action <FlowActions <T> > action,
            String actionText = Defaults.ConditionActionText)
        {
            ifactions.IfAction.Else(action, actionText);

            var actions = new FlowActions <T>(ifactions);

            actions.Add(ifactions.IfAction);

            return(actions);
        }
コード例 #8
0
ファイル: dbHelper.cs プロジェクト: Juanjojara/SimpleFlow
        public Actions GetNextAction(int flowId, int currentStep)
        {
            FlowActions nextAction = model.FlowActions.Include("Actions").Where <FlowActions>(f => f.Flows.FlowId == flowId && f.Position == currentStep + 1).FirstOrDefault <FlowActions>();

            //Actions nextAction = model.Actions.Where<Actions>(f => f.FlowActions. .FlowId == flowId && f.Position == currentStep + 1).FirstOrDefault<Actions>();
            if (nextAction == null)
            {
                return(null);
            }
            else
            {
                return(nextAction.Actions);
            }
        }
コード例 #9
0
        /// <summary>
        /// Connect this client to the passed peer
        /// </summary>
        /// <param name="_peer"></param>
        public FlowClientServer Connect(NetPeer _peer, bool wasConnected = false)
        {
            if (isConnected)
            {
                return(this);
            }
            peer        = _peer;
            endPoint    = $"{peer.EndPoint.Address}:{peer.EndPoint.Port}";
            id          = Flow.CreateClientId(peer);
            isConnected = true;
            ConnectFlowServerAction action = FlowActions.GetActionByName("Connect") as ConnectFlowServerAction;

            if (wasConnected)
            {
                Logger.Debug($"Client ({id}) has reconnected");
                if (action != null)
                {
                    action.SendFrom(id, "You reconnected succesfully.");
                }
            }
            else
            {
                if (FlowServer.clients.ContainsKey(id))
                {
                    FlowServer.clients.Remove(id);
                }
                Logger.Debug($"Client ({id}) has connected");
                FlowServer.clients.Add(id, this);
                if (action != null)
                {
                    action.SendFrom(id, "You connected succesfully.");
                }
            }


            return(this);
        }
コード例 #10
0
 /// <summary>
 /// unity method to start the server as soon as this behaviour is created
 /// </summary>
 void Start()
 {
     Setup();
     FlowActions.RegisterOnStartedCallback(StartServer);
 }
コード例 #11
0
ファイル: Flow.cs プロジェクト: lanicon/NFlow
 public Flow()
 {
     Actions = new FlowActions <T>();
 }
コード例 #12
0
ファイル: Design.aspx.cs プロジェクト: Juanjojara/SimpleFlow
        private Flows SaveFlow()
        {
            if (dt.Rows.Count <= 0)
            {
                return(null);
            }
            dbHelper          helper   = new dbHelper();
            bool              isUpdate = true;
            FlowActionOptions fao;
            FlowActionInputs  faIn;
            FlowActionOutputs faOut;
            FlowMultiOptions  fmo;
            ActionOptions     actOpt;
            ActionInputs      actInput;
            ActionOutputs     actOutput;
            Users             flowUser = helper.GetUserbyName(_user.UserName);
            Flows             myflow   = helper.GetFlowByName(TextBox1.Text, flowUser);

            if (myflow == null)
            {
                myflow                   = new Flows();
                myflow.FlowName          = TextBox1.Text;
                myflow.Users             = flowUser;
                myflow.FlowUseCaseNumber = _useCaseNumber;
                myflow.FlowStartTime     = _useCaseStartTime;
                myflow.FlowEndTime       = DateTime.Now;
                isUpdate                 = false;
            }
            else
            {
                myflow.FlowEndTime = DateTime.Now;
                helper.DeleteFlowDetailsById(myflow.FlowId);
            }

            int rowCount = 0;

            FlowActions flowAction;
            Actions     curAction;

            foreach (DataRow gridRow in dt.Rows)
            {
                rowCount++;
                curAction           = helper.GetActionById(gridRow["Id"].ToString());
                flowAction          = new FlowActions();
                flowAction.Actions  = curAction;
                flowAction.Position = rowCount;
                myflow.FlowActions.Add(flowAction);
            }

            SaveActionOptions(dt.Rows.Count);
            foreach (FlowActionOptions itemFlowActOpt in _listFlowActOpt)
            {
                fao               = new FlowActionOptions();
                actOpt            = helper.GetActionOptionById(itemFlowActOpt.ActionOptions.ActionOptionId);
                fao.ActionOptions = actOpt;
                fao.FlowPosition  = itemFlowActOpt.FlowPosition;
                fao.Value         = itemFlowActOpt.Value;
                myflow.FlowActionOptions.Add(fao);
            }
            foreach (FlowActionInputs itemFlowActIn in _listFlowActInput)
            {
                faIn              = new FlowActionInputs();
                actInput          = helper.GetActionInputById(itemFlowActIn.ActionInputs.InputId);
                faIn.ActionInputs = actInput;
                faIn.FlowPosition = itemFlowActIn.FlowPosition;
                faIn.Value        = itemFlowActIn.Value;
                myflow.FlowActionInputs.Add(faIn);
            }
            foreach (FlowActionOutputs itemFlowActOut in _listFlowActOutput)
            {
                faOut               = new FlowActionOutputs();
                actOutput           = helper.GetActionOutputById(itemFlowActOut.ActionOutputs.OutputId);
                faOut.ActionOutputs = actOutput;
                faOut.FlowPosition  = itemFlowActOut.FlowPosition;
                faOut.Value         = itemFlowActOut.Value;
                myflow.FlowActionOutputs.Add(faOut);
            }

            foreach (FlowMultiOptions itemFlowMultiOpt in _listFlowMultiOpt)
            {
                fmo = new FlowMultiOptions();
                fmo.FlowPosition = itemFlowMultiOpt.FlowPosition;
                fmo.OptionValue  = itemFlowMultiOpt.OptionValue;
                myflow.FlowMultiOptions.Add(fmo);
            }
            if (isUpdate)
            {
                helper.UpdateChanges();
            }
            else
            {
                helper.AddToModel(myflow);
            }

            return(myflow);
        }
コード例 #13
0
ファイル: PromptExtensions.cs プロジェクト: lanicon/NFlow
 public static FlowActions <T> WriteLine <T>(this FlowActions <T> task, String text)
 {
     return(task.Add(new PromptAction <T>(text)));
 }
コード例 #14
0
 public static FlowActions <T> StartActionsGroup <T>(
     this FlowActions <T> actions,
     Action <FlowActions <T> > groupActions)
 {
     return(actions.Add(new ActionsGroupAction <T>(groupActions)));
 }
コード例 #15
0
ファイル: BasicWorkflow.cs プロジェクト: ArtTorres/TWidgets
 /// <summary>
 /// Sets the flow to the initial state.
 /// </summary>
 public void Start()
 {
     this.State  = FlowStates.Start;
     this.Action = FlowActions.Continue;
 }
コード例 #16
0
 /// <summary>
 /// Connects the client when this behavriour is initialized
 /// </summary>
 void Start()
 {
     Setup();
     FlowActions.RegisterOnStartedCallback(Connect);
 }
コード例 #17
0
ファイル: VariableExtensions.cs プロジェクト: lanicon/NFlow
 public static FlowActions <T> Set <T>(this FlowActions <T> tasks, String name, DateTime value)
 {
     return(tasks.Add(new SetVariableAction <T>(name, value)));
 }
コード例 #18
0
ファイル: VariableExtensions.cs プロジェクト: lanicon/NFlow
        //public static FlowActions<T> Set<T>(this FlowActions<T> tasks, Action<T> model)
        //{
        //    return tasks.Add(new SetVariableAction<T>(model));
        //}

        public static FlowActions <T> Set <T>(this FlowActions <T> tasks, Action <FlowContext <T> > context)
        {
            return(tasks.Add(new SetVariableAction <T>(context)));
        }
コード例 #19
0
        private (List <DotNode <T> > Nodes, List <DotNode <T> > TerminalNodes) ReadFlow(FlowActions <T> actions)
        {
            var _nodes = new List <DotNode <T> >();
            List <DotNode <T> > prevNodes = null;

            foreach (var action in actions)
            {
                DotNode <T> dot = null;  // current node dot notation

                if (action is ActionsGroupAction <T> )
                {
                    // assumes that ActionsGroup only has one inner flow

                    dot = DotNode <T> .FromGenericNotation(((IDefineSplitNotation <T>)action).ToNotation().Action);

                    var innerFlows = ((IDefineSplitNotation <T>)action).ToNotation().InnerFlows;
                    if (innerFlows != null && innerFlows.Keys.Count == 1)
                    {
                        var nodes = ReadFlow(innerFlows.Keys.First());

                        dot.SubNodes.AddRange(nodes.Nodes);

                        // set the parent node(s)
                        if (prevNodes != null && (nodes.Nodes != null || nodes.Nodes.Count > 0))
                        {
                            nodes.Nodes.First().ParentNodes.AddRange(DotNodeReference <T> .FromDotNodeList(prevNodes));
                        }

                        // set the last node as one of the previous for the next
                        if (nodes.Nodes != null || nodes.Nodes.Count > 0)
                        {
                            prevNodes = nodes.TerminalNodes;
                        }
                    }
                    else
                    {
                        throw new Exception("Invalid Action Group configuration");
                    }
                }
                else if (action is IDefineSplitNotation <T> )
                {
                    dot = DotNode <T> .FromGenericNotation(((IDefineSplitNotation <T>)action).ToNotation().Action);

                    // set parent node(s)
                    if (prevNodes != null)
                    {
                        dot.ParentNodes.AddRange(DotNodeReference <T> .FromDotNodeList(prevNodes));
                    }

                    // handle the inner flows
                    var innerFlows = ((IDefineSplitNotation <T>)action).ToNotation().InnerFlows;
                    prevNodes = new List <DotNode <T> >();

                    if (innerFlows != null)
                    {
                        var innerPrevNode = dot;
                        foreach (var flowKey in innerFlows.Keys)
                        {
                            var nodes = ReadFlow(flowKey);

                            _nodes.AddRange(nodes.Nodes);

                            // set the first node parent as the main split node
                            if (nodes.Nodes != null && nodes.Nodes.Count > 0)
                            {
                                nodes.Nodes.First().ParentNodes.Add(DotNodeReference <T> .FromDotNode(dot, innerFlows[flowKey]));
                            }

                            // set the last node as one of the previous for the next
                            if (nodes.Nodes != null && nodes.Nodes.Count > 0)
                            {
                                prevNodes.AddRange(nodes.TerminalNodes);
                            }
                        }
                    }
                }
                else if (action is IDefineSimpleNotation)
                {
                    var nAction = (IDefineSimpleNotation)action;
                    dot = DotNode <T> .FromGenericNotation(nAction);

                    // set parent node(s)
                    if (prevNodes != null)
                    {
                        dot.ParentNodes.AddRange(DotNodeReference <T> .FromDotNodeList(prevNodes));
                    }

                    // finish off by setting this node as the previous of the next one(s)
                    prevNodes = new List <DotNode <T> >()
                    {
                        dot
                    };
                }
                else
                {
                    dot = DotNode <T> .GetDefaultRepresentation(action);

                    // set parent node(s)
                    dot.ParentNodes.AddRange(DotNodeReference <T> .FromDotNodeList(prevNodes));

                    // finish off by setting this node as the previous of the next one(s)
                    prevNodes = new List <DotNode <T> >()
                    {
                        dot
                    };
                }

                if (dot != null)
                {
                    _nodes.Add(dot);
                }
            }

            return(_nodes, prevNodes);
        }
コード例 #20
0
 public static FlowActions <T> Action <T>(this FlowActions <T> tasks, String text, Action <FlowContext <T> > action)
 {
     return(tasks.Add(new AdHocAction <T>(text, action)));
 }