示例#1
0
        private void SaveActionOptions(int position)
        {
            FlowActionOptions fao;
            FlowActionInputs  faIn;
            FlowActionOutputs faOut;
            TextBox           tx;
            CheckBox          ck;
            RadioButtonList   rd;
            DropDownList      dd;

            _listFlowActOpt.RemoveAll(f => f.FlowPosition == position);
            _listFlowActInput.RemoveAll(f => f.FlowPosition == position);
            _listFlowActOutput.RemoveAll(f => f.FlowPosition == position);

            if (MultiViewSpecific.GetActiveView() == ViewPostMessage)
            {
                rd = RadioButtonListPostMessage;
            }
            else
            {
                rd = RadioButtonListPostComment;
            }
            foreach (ActionOptions itemActOpt in _listActOpt)
            {
                if (itemActOpt.ControlName != null)
                {
                    fao = new FlowActionOptions();
                    fao.ActionOptions = itemActOpt;
                    fao.FlowPosition  = position;
                    switch (itemActOpt.Options.OptionType)
                    {
                    case "textbox":
                        tx = (TextBox)FindControl(itemActOpt.ControlName);
                        if (tx != null)
                        {
                            fao.Value = tx.Text;
                        }
                        break;

                    case "check":
                        ck = (CheckBox)FindControl(itemActOpt.ControlName);
                        if (ck != null)
                        {
                            if (ck.Checked)
                            {
                                fao.Value = "true";
                            }
                            else
                            {
                                fao.Value = "false";
                            }
                        }
                        break;

                    case "radio":
                        if (rd.SelectedValue == itemActOpt.ControlName)
                        {
                            fao.Value = "true";
                        }
                        else
                        {
                            fao.Value = "false";
                        }

                        if (itemActOpt.ControlName == "MultOptCom" && fao.Value == "true")
                        {
                            FlowMultiOptions fmo;
                            _listFlowMultiOpt.RemoveAll(fm => fm.FlowPosition == position);
                            foreach (DataRow itemMultiOpt in dtOptions.Rows)
                            {
                                fmo = new FlowMultiOptions();
                                fmo.FlowPosition = position;
                                fmo.OptionValue  = itemMultiOpt["Option"].ToString();
                                _listFlowMultiOpt.Add(fmo);
                            }
                            if (dt.Rows.Count != position)
                            {
                                dtOptions.Clear();
                                AddToDataTableOptions("Add Options...");
                                BindGridOptions();
                            }
                        }
                        break;

                    case "dropdown":
                        dd = (DropDownList)FindControl(itemActOpt.ControlName);
                        if (dd != null)
                        {
                            fao.Value = dd.SelectedValue;
                        }
                        break;
                    }
                    _listFlowActOpt.Add(fao);
                }
            }
            dbHelper helper = new dbHelper();

            if (dt.Rows[position - 1].Field <String>("Input") != String.Empty)
            {
                List <ActionInputs> inputs = helper.GetActionInputsForAction(dt.Rows[position - 1].Field <String>("Id"));
                faIn = new FlowActionInputs();
                faIn.FlowPosition = position;
                faIn.ActionInputs = inputs[0];
                faIn.Value        = dt.Rows[position - 1].Field <String>("Input");
                _listFlowActInput.Add(faIn);
            }
            if (dt.Rows[position - 1].Field <String>("Output") != String.Empty)
            {
                List <ActionOutputs> outputs = helper.GetActionOutputsForAction(dt.Rows[position - 1].Field <String>("Id"));
                faOut = new FlowActionOutputs();
                faOut.FlowPosition  = position;
                faOut.ActionOutputs = outputs[0];
                faOut.Value         = dt.Rows[position - 1].Field <String>("Output");
                _listFlowActOutput.Add(faOut);
            }
        }
示例#2
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);
        }