Exemple #1
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (Page.IsValid)
            {
                if (e.CommandName == "Select")
                {
                    Users    newUser;
                    dbHelper helper = new dbHelper();
                    newUser = helper.GetUserbyName(TextBoxUser.Text);
                    if (newUser == null)
                    {
                        newUser          = new Users();
                        newUser.UserName = TextBoxUser.Text;
                        newUser.UserType = "local";
                        newUser.SNUserId = "local" + TextBoxUser.Text;
                        helper.AddToModel(newUser);
                    }
                    Session["user"] = newUser;

                    WebControl  wc  = e.CommandSource as WebControl;
                    GridViewRow row = wc.NamingContainer as GridViewRow;
                    Session["UseCaseStartTime"] = DateTime.Now;
                    Session["UseCaseNumber"]    = row.RowIndex + 1;
                    Session["UseCaseText"]      = row.Cells[1].Text;

                    Server.Transfer("Design.aspx");
                }
            }
        }
Exemple #2
0
        protected void ButtonPlay_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (dt.Rows.Count > 0)
                {
                    Flows playflow = SaveFlow();
                    if (playflow != null)
                    {
                        FlowInstances currentFlow = new FlowInstances();
                        dbHelper      helper      = new dbHelper();
                        DataRow       firstRow    = dt.Rows[0];
                        Actions       startAction = helper.GetActionById(firstRow["Id"].ToString());

                        currentFlow.Actions         = startAction;
                        currentFlow.CurrentPosition = 1;
                        currentFlow.Users           = playflow.Users;
                        currentFlow.Flows           = playflow;
                        helper.AddToModel(currentFlow);

                        Session["currentInstance"] = currentFlow;
                        Server.Transfer(currentFlow.Actions.ActionPage);
                    }
                }
            }
        }
Exemple #3
0
        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);
        }