Пример #1
0
        public List <ScenarioModel> Ungrouping(
            [NotNull, ItemNotNull] IEnumerable <ScenarioModel> scenarios,
            [NotNull] ModelContainer container,
            [CanBeNull] Func <ScenarioModel, bool> isIdoneous)
        {
            bool hasSequence(ScenarioModel model) => model.HasSequence;

            var groupedScenarios = scenarios.Where(isIdoneous ?? hasSequence);

            var result = new List <ScenarioModel>();

            foreach (var scenario in groupedScenarios)
            {
                var methods = scenario.Actions.OfType <MethodActionModel>();
                if (methods.Count() > 1)
                {
                    foreach (var method in methods)
                    {
                        var newScenario = CreateScenarioWithMethods(scenario, new[] { method }, container);
                        result.Add(newScenario);
                    }

                    Remove(scenario);
                    container.Remove(scenario.Id);
                }
            }

            return(result);
        }
Пример #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex = e.RowIndex;

            if (e.ColumnIndex == 5)
            {
                //删除
                FileOprateHelp.RemoveKeyComment(dataGridView1[0, rowIndex].Value.ToString());
                ModelContainer.Remove(dataGridView1[0, rowIndex].Value.ToString());
                dataGridView1.Rows.RemoveAt(rowIndex);
                if (rowIndex == dataGridView1.Rows.Count - 1)
                {
                    rowIndex--;
                }
            }
            if (dataGridView1[0, rowIndex].Value == null)
            {
                return;
            }
            this.textBox1.Text = dataGridView1[0, rowIndex].Value.ToString();
            this.textBox2.Text = dataGridView1[1, rowIndex].Value == null ? String.Empty : dataGridView1[1, rowIndex].Value.ToString();
            _lock = true;
            this.textBox3.Text = dataGridView1[2, rowIndex].Value == null ? String.Empty : dataGridView1[2, rowIndex].Value.ToString();
            oldText            = this.textBox3.Text;
            _lock   = false;
            operate = 0;
            SetTextEnable(int.Parse(dataGridView1[4, rowIndex].Value.ToString()) > 0);
        }
Пример #3
0
        public List <ScenarioModel> UngroupingByParameter <TParameterType>(
            [NotNull] ModelContainer container,
            [NotNull] string parameterName,
            [NotNull] Func <IEnumerable <MethodActionModel>, IEnumerable <IGrouping <TParameterType, MethodActionModel> > > groupMethod)
        {
            var scenarios    = container.GetAll <ScenarioModel>().Where(s => s.HasSequence);
            var newScenarios = new List <ScenarioModel>();

            var names = new HashSet <string>(container.GetAll <ScenarioModel>().Select(s => s.Name));

            foreach (var scenario in scenarios)
            {
                var scenarioParameterValue = scenario.Definitions.Where(d => d.Name == parameterName).Single().Expression.ToString();

                var methods = scenario.Actions.OfType <MethodActionModel>();
                var groups  = groupMethod(methods);

                if (groups.All(g => g.Key.ToString() == scenarioParameterValue.Trim('"')))
                {
                    continue;
                }

                if (groups.Count() == 1)
                {
                    UpdateScenarioDefinitionModel(scenario, parameterName, groups.First().Key);
                    continue;
                }

                names.Remove(scenario.Name);

                foreach (var group in groups)
                {
                    var newScenario = CreateScenarioWithMethods(scenario, group, container);
                    PrepareName(newScenario, names);
                    UpdateScenarioDefinitionModel(newScenario, parameterName, group.Key);
                    newScenarios.Add(newScenario);
                }

                Remove(scenario);
                container.Remove(scenario.Id);
            }

            return(newScenarios);
        }
Пример #4
0
        /// <summary>
        /// 删除模型关键字
        /// </summary>
        /// <param name="key"></param>
        public static void RemoveKeyComment(string key)
        {
            DataSet dt = new DataSet();

            dt.ReadXml("KeyComment.xml".GetFileResource("Xml"));
            if (dt != null && dt.Tables.Count > 0)
            {
                DataSet dtNew = new DataSet();
                dtNew.Merge(dt);
                int index = 0;
                for (index = 0; index < dt.Tables[0].Rows.Count; index++)
                {
                    if (dt.Tables[0].Rows[index][0].ToString() == key)
                    {
                        dtNew.Tables[0].Rows.Remove(dtNew.Tables[0].Rows[index]);
                        break;
                    }
                }
                dtNew.WriteXml("KeyComment.xml".GetFileResource("Xml"));
                ModelContainer.Remove(key);
            }
        }