// init set equal weight public virtual void InitDefaultValue() { Controller controller = Controller.getInstance(); VariableRelation variableRelationSetting = Controller.getInstance().XMLDeserializeVariableRelation(); this.DependenceRecordDict = variableRelationSetting.DependenceRecordDict; foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv in this.DependenceRecordDict) { VariableDependenceRecord record = kv.Value; SerializableDictionary <string, SerializableDictionary <string, SecondaryItem> > itemDependecDict = record.ItemDependencDict; foreach (KeyValuePair <string, SerializableDictionary <string, SecondaryItem> > kv2 in itemDependecDict) { SerializableDictionary <string, SecondaryItem> secondaryItemDict = kv2.Value; int number = secondaryItemDict.Count; double[] itemArray = ManualAssignmentPlatformWeightSetMethod.getAverageWeight(number); foreach (KeyValuePair <string, SecondaryItem> kv3 in secondaryItemDict) { kv3.Value.Weight = itemArray[0]; } string lastItemStr = new List <string>(secondaryItemDict.Keys)[secondaryItemDict.Count - 1]; secondaryItemDict[lastItemStr].Weight = itemArray[number - 1]; } } }
private void secondaryVariableDependenceListBoxControl_SelectedIndexChanged(object sender, EventArgs e) { ListBoxControl listBoxControl = sender as ListBoxControl; int selectIndex = listBoxControl.SelectedIndex; string temVariableStr = listBoxControl.SelectedItem as string; if (selectIndex >= 0 && listBoxControl.Focused) { string[] keyArray = Regex.Split(temVariableStr, " --- ", RegexOptions.IgnoreCase); if (keyArray.Length == 2) { string primaryKey = keyArray[0]; string secondaryKey = keyArray[1]; ManualAssignmentPlatformWeightSetMethod manualSet = (ManualAssignmentPlatformWeightSetMethod)this.Strategy.PlatformWeightSetMethod.Value; SerializableDictionary <VariableDependenceRecordKey, VariableDependenceRecord> primaryWeightDict = manualSet.SecondaryItemWeightSetMethod.Value.DependenceRecordDict; VariableDependenceRecord record = primaryWeightDict[new VariableDependenceRecordKey(primaryKey, secondaryKey)]; List <string> itemStrList = new List <string>(record.ItemDependencDict.Keys); this.secondaryPrimaryVariableListBoxControl.DataSource = itemStrList; this.secondaryPrimaryVariableListBoxControl.SelectedIndex = -1; this.secondarySecondaryVariablGridControl.DataSource = null; } else { throw new Exception("key array length error"); } } }
private bool checkDependenceRecordValid() { foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv1 in this.variableRelation.DependenceRecordDict) { VariableDependenceRecord record = kv1.Value; String primaryVarialbeStr = kv1.Key.PrimaryVariableKey; String secondaryVariableStr = kv1.Key.SecondaryVariableKey; Variable primaryVariable = this.variables[primaryVarialbeStr]; if (record.ItemDependencDict.Count < primaryVariable.PlatformList.Count) { MessageDxUnit.ShowWarning("The current dependence record has some primary item which doesn't has corresponding secondary item!"); return(false); } } return(true); }
public virtual void updateSecondaryItemData() { Controller controller = Controller.getInstance(); VariableRelation variableRelationSetting = Controller.getInstance().XMLDeserializeVariableRelation(); SerializableDictionary <VariableDependenceRecordKey, VariableDependenceRecord> newDependenceRecordDict = variableRelationSetting.DependenceRecordDict; // compare with the latest data from xml add the lack records and remove the redundant records. // add lack records foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv in newDependenceRecordDict) { if (!this.DependenceRecordDict.ContainsKey(kv.Key)) { VariableDependenceRecord record = kv.Value; SerializableDictionary <string, SerializableDictionary <string, SecondaryItem> > itemDependecDict = record.ItemDependencDict; foreach (KeyValuePair <string, SerializableDictionary <string, SecondaryItem> > kv2 in itemDependecDict) { SerializableDictionary <string, SecondaryItem> secondaryItemDict = kv2.Value; int number = secondaryItemDict.Count; double[] itemArray = ManualAssignmentPlatformWeightSetMethod.getAverageWeight(number); foreach (KeyValuePair <string, SecondaryItem> kv3 in secondaryItemDict) { kv3.Value.Weight = itemArray[0]; } string lastItemStr = new List <string>(secondaryItemDict.Keys)[secondaryItemDict.Count - 1]; secondaryItemDict[lastItemStr].Weight = itemArray[number - 1]; } // add the new record this.DependenceRecordDict.Add(kv.Key, kv.Value); } } // remove the redundant records List <VariableDependenceRecordKey> keyList = new List <VariableDependenceRecordKey>(this.DependenceRecordDict.Keys); for (int i = 0; i < keyList.Count; i++) { if (!newDependenceRecordDict.ContainsKey(keyList[i])) { this.DependenceRecordDict.Remove(keyList[i]); } } }
public override void InitDefaultValue() { Controller controller = Controller.getInstance(); VariableRelation variableRelationSetting = Controller.getInstance().XMLDeserializeVariableRelation(); this.DependenceRecordDict = variableRelationSetting.DependenceRecordDict; foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv in this.DependenceRecordDict) { VariableDependenceRecord record = kv.Value; SerializableDictionary <string, SerializableDictionary <string, SecondaryItem> > itemDependecDict = record.ItemDependencDict; foreach (KeyValuePair <string, SerializableDictionary <string, SecondaryItem> > kv2 in itemDependecDict) { SerializableDictionary <string, SecondaryItem> secondaryItemDict = kv2.Value; foreach (KeyValuePair <string, SecondaryItem> kv3 in secondaryItemDict) { kv3.Value.Weight = 0; } } } }
private void settingPrimaryItemListBoxControl_SelectedIndexChanged(object sender, EventArgs e) { ListBoxControl listBox = sender as ListBoxControl; this.settingSecondaryItemListBoxControl.UnCheckAll(); if (listBox.SelectedIndex >= 0) { this.settingSecondaryItemListBoxControl.Enabled = true; // load the according secondary checked item if (this.settingSecondaryVaraibleListBoxControl.SelectedIndex >= 0) { string primaryVariableStr = this.settingPrimaryVaraibleListBoxControl.SelectedItem as string; string secondVariableStr = this.settingSecondaryVaraibleListBoxControl.SelectedItem as string; string primaryItemStr = (listBox.DataSource as List <string>)[listBox.SelectedIndex]; if (this.variableRelation.containRecord(primaryVariableStr, secondVariableStr)) { VariableDependenceRecord record = this.variableRelation.getRecord(primaryVariableStr, secondVariableStr); if (record.ItemDependencDict.ContainsKey(primaryItemStr)) { SerializableDictionary <string, SecondaryItem> secondaryItemDict = record.ItemDependencDict[primaryItemStr]; foreach (KeyValuePair <string, SecondaryItem> kv in secondaryItemDict) { List <string> list = this.settingSecondaryItemListBoxControl.DataSource as List <string>; int index = list.IndexOf(kv.Value.SecondaryItemStr); this.settingSecondaryItemListBoxControl.SetItemChecked(index, true); } return; } } } } else { this.settingSecondaryItemListBoxControl.Enabled = false; } this.settingSecondaryItemListBoxControl.SelectedIndex = -1; return; }
private void secondaryRestoreButton_Click(object sender, EventArgs e) { BindingList <ItemWeightRecord> recordList = this.secondaryGridView.DataSource as BindingList <ItemWeightRecord>; int number = recordList.Count; double[] itemArray = ManualAssignmentPlatformWeightSetMethod.getAverageWeight(number); int variableSelectIndex = this.secondaryVariableDependenceListBoxControl.SelectedIndex; string variableRelationKey = secondaryVariableDependenceListBoxControl.SelectedItem as string; string[] keyArray = Regex.Split(variableRelationKey, " --- ", RegexOptions.IgnoreCase); string primaryKey = keyArray[0]; string secondaryKey = keyArray[1]; ManualAssignmentPlatformWeightSetMethod manualSet = (ManualAssignmentPlatformWeightSetMethod)this.Strategy.PlatformWeightSetMethod.Value; SerializableDictionary <VariableDependenceRecordKey, VariableDependenceRecord> secondaryWeightDict = manualSet.SecondaryItemWeightSetMethod.Value.DependenceRecordDict; VariableDependenceRecord record = secondaryWeightDict[new VariableDependenceRecordKey(primaryKey, secondaryKey)]; int itemSelectIndex = this.secondaryPrimaryVariableListBoxControl.SelectedIndex; string itemRelationKey = this.secondaryPrimaryVariableListBoxControl.SelectedItem as string; foreach (ItemWeightRecord itemRecord in recordList) { if (recordList.IndexOf(itemRecord) != recordList.Count - 1) { itemRecord.Weight = itemArray[0]; } else { itemRecord.Weight = itemArray[number - 1]; } string secondaryItemStr = itemRecord.Item; record.ItemDependencDict[itemRelationKey][secondaryItemStr].Weight = itemRecord.Weight; } this.secondarySecondaryVariablGridControl.DataSource = recordList; this.setSecondaryGridView(); this.secondarySecondaryVariablGridControl.RefreshDataSource(); }
private void secondaryGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { GridView gridView = sender as GridView; if (e.Column.FieldName.Equals("Weight")) { string cellValue = e.Value.ToString(); int variableSelectIndex = this.secondaryVariableDependenceListBoxControl.SelectedIndex; string variableRelationKey = secondaryVariableDependenceListBoxControl.SelectedItem as string; if (variableSelectIndex >= 0) { string[] keyArray = Regex.Split(variableRelationKey, " --- ", RegexOptions.IgnoreCase); if (keyArray.Length == 2) { string primaryKey = keyArray[0]; string secondaryKey = keyArray[1]; ManualAssignmentPlatformWeightSetMethod manualSet = (ManualAssignmentPlatformWeightSetMethod)this.Strategy.PlatformWeightSetMethod.Value; SerializableDictionary <VariableDependenceRecordKey, VariableDependenceRecord> secondaryWeightDict = manualSet.SecondaryItemWeightSetMethod.Value.DependenceRecordDict; VariableDependenceRecord record = secondaryWeightDict[new VariableDependenceRecordKey(primaryKey, secondaryKey)]; int itemSelectIndex = this.secondaryPrimaryVariableListBoxControl.SelectedIndex; string itemRelationKey = this.secondaryPrimaryVariableListBoxControl.SelectedItem as string; if (itemSelectIndex >= 0) { string secondaryItemStr = gridView.GetRowCellValue(e.RowHandle, gridView.Columns["Item"]) as string; record.ItemDependencDict[itemRelationKey][secondaryItemStr].Weight = (double)e.Value; } } else { throw new Exception("key array length error"); } } } }
public override void setPlatformWeight(int testRouds) { Controller controller = Controller.getInstance(); Project project = controller.project; List <string> languageList = project.Variables[project.MultiFactorVariableNameList[0]].FactorList; int languageNum = languageList.Count; int totalTimes = languageNum * testRouds; // count primary variable test times foreach (KeyValuePair <string, SerializableDictionary <string, double> > kv1 in this.PrimaryVariableWeightDict) { SerializableDictionary <string, double> itemWeightDict = kv1.Value; SerializableDictionary <string, double> doubleItemTestTimesDict = new SerializableDictionary <string, double>(); foreach (KeyValuePair <string, double> kv2 in itemWeightDict) { doubleItemTestTimesDict.Add(kv2.Key, kv2.Value * totalTimes); } SerializableDictionary <string, int> itemTestTimesDict = this.getItemTestTimes(doubleItemTestTimesDict, totalTimes); if (this.PrimaryVariableTestTimesDict.ContainsKey(kv1.Key)) { this.PrimaryVariableTestTimesDict[kv1.Key] = itemTestTimesDict; } else { this.PrimaryVariableTestTimesDict.Add(kv1.Key, itemTestTimesDict); } } // count secondary variable test times // SerializableDictionary<VariableDependenceRecordKey, SerializableDictionary<string, SerializableDictionary<string, int>>> foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv1 in this.SecondaryItemWeightSetMethod.Value.DependenceRecordDict) { SerializableDictionary <string, SerializableDictionary <string, int> > relationDict = new SerializableDictionary <string, SerializableDictionary <string, int> >(); VariableDependenceRecord record = kv1.Value; foreach (KeyValuePair <string, SerializableDictionary <string, SecondaryItem> > kv2 in record.ItemDependencDict) { int itemTimes = this.PrimaryVariableTestTimesDict[kv1.Key.PrimaryVariableKey][kv2.Key]; SerializableDictionary <string, double> doubleItemTestTimesDict = new SerializableDictionary <string, double>(); SerializableDictionary <string, SecondaryItem> itemDict = kv2.Value; foreach (KeyValuePair <string, SecondaryItem> kv3 in itemDict) { doubleItemTestTimesDict.Add(kv3.Key, kv3.Value.Weight * itemTimes); } SerializableDictionary <string, int> itemTestTimesDict = this.getItemTestTimes(doubleItemTestTimesDict, itemTimes); relationDict.Add(kv2.Key, itemTestTimesDict); } if (this.SecondaryItemWeightSetMethod.Value.DependenceRecordTestTimesDict.ContainsKey(kv1.Key)) { this.SecondaryItemWeightSetMethod.Value.DependenceRecordTestTimesDict[kv1.Key] = relationDict; } else { this.SecondaryItemWeightSetMethod.Value.DependenceRecordTestTimesDict.Add(kv1.Key, relationDict); } } }
public override void setPlatformWeight(int testRouds) { this.SecondaryItemWeightSetMethod.Value = this.SecondaryItemWeightSetMethodDict[typeof(AutoSecondaryItemWeightSetMethod).FullName]; // init the total test time Controller controller = Controller.getInstance(); Project project = controller.project; List <string> languageList = project.Variables[project.MultiFactorVariableNameList[0]].FactorList; int languageNum = languageList.Count; int totalTimes = languageNum * testRouds; // primary variable weight dictionary set value foreach (KeyValuePair <string, SerializableDictionary <string, double> > kv1 in this.PrimaryVariableWeightDict) { SerializableDictionary <string, double> itemWeightDict = kv1.Value; SerializableDictionary <string, double> doubleItemTestTimesDict = new SerializableDictionary <string, double>(); List <string> kv2KeyList = new List <string>(itemWeightDict.Keys); // firstly set weight double value to language measure value multiply by platform measure value; double totalWeight = 0; for (int i = 0; i < itemWeightDict.Count; i++) { itemWeightDict[kv2KeyList[i]] = computeAutoAssignWeight(kv1.Key, kv2KeyList[i]); totalWeight += itemWeightDict[kv2KeyList[i]]; } // secondary set weight double value to percentage weight; double totalPercentageWeight = 0; int index = 0; for (; index < itemWeightDict.Count - 1; index++) { double tempWeight = itemWeightDict[kv2KeyList[index]]; string percentageStr = String.Format("{0:F}", tempWeight / totalWeight); itemWeightDict[kv2KeyList[index]] = double.Parse(percentageStr); totalPercentageWeight += itemWeightDict[kv2KeyList[index]]; doubleItemTestTimesDict.Add(kv2KeyList[index], itemWeightDict[kv2KeyList[index]] * totalTimes); // set do } // set the last item value to the rest itemWeightDict[kv2KeyList[index]] = 1 - totalPercentageWeight; doubleItemTestTimesDict.Add(kv2KeyList[index], itemWeightDict[kv2KeyList[index]] * totalTimes); SerializableDictionary <string, int> itemTestTimesDict = this.getItemTestTimes(doubleItemTestTimesDict, totalTimes); if (this.PrimaryVariableTestTimesDict.ContainsKey(kv1.Key)) { this.PrimaryVariableTestTimesDict[kv1.Key] = itemTestTimesDict; } else { this.PrimaryVariableTestTimesDict.Add(kv1.Key, itemTestTimesDict); } } // secondary variable weight dictionary set value foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv1 in this.SecondaryItemWeightSetMethod.Value.DependenceRecordDict) { SerializableDictionary <string, SerializableDictionary <string, int> > relationDict = new SerializableDictionary <string, SerializableDictionary <string, int> >(); VariableDependenceRecord record = kv1.Value; foreach (KeyValuePair <string, SerializableDictionary <string, SecondaryItem> > kv2 in record.ItemDependencDict) { SerializableDictionary <string, double> doubleItemTestTimesDict = new SerializableDictionary <string, double>(); SerializableDictionary <string, SecondaryItem> itemDict = kv2.Value; int itemTimes = this.PrimaryVariableTestTimesDict[kv1.Key.PrimaryVariableKey][kv2.Key]; List <string> kv3KeyList = new List <string>(itemDict.Keys); // firstly set weight double value to language measure value multiply by platform measure value; double totalWeight = 0; for (int i = 0; i < itemDict.Count; i++) { itemDict[kv3KeyList[i]].Weight = computeAutoAssignWeight(kv1.Key.SecondaryVariableKey, kv3KeyList[i]); totalWeight += itemDict[kv3KeyList[i]].Weight; } // secondary set weight double value to percentage weight; double totalPercentageWeight = 0; int index = 0; for (; index < itemDict.Count - 1; index++) { double tempWeight = itemDict[kv3KeyList[index]].Weight; string percentageStr = String.Format("{0:F}", tempWeight / totalWeight); itemDict[kv3KeyList[index]].Weight = double.Parse(percentageStr); totalPercentageWeight += itemDict[kv3KeyList[index]].Weight; doubleItemTestTimesDict.Add(kv3KeyList[index], itemDict[kv3KeyList[index]].Weight * itemTimes); // set do } // set the last item value to the rest itemDict[kv3KeyList[index]].Weight = 1 - totalPercentageWeight; doubleItemTestTimesDict.Add(kv3KeyList[index], itemDict[kv3KeyList[index]].Weight * itemTimes); SerializableDictionary <string, int> itemTestTimesDict = this.getItemTestTimes(doubleItemTestTimesDict, itemTimes); relationDict.Add(kv2.Key, itemTestTimesDict); } if (this.SecondaryItemWeightSetMethod.Value.DependenceRecordTestTimesDict.ContainsKey(kv1.Key)) { this.SecondaryItemWeightSetMethod.Value.DependenceRecordTestTimesDict[kv1.Key] = relationDict; } else { this.SecondaryItemWeightSetMethod.Value.DependenceRecordTestTimesDict.Add(kv1.Key, relationDict); } } }
private void saveCurrentDependenceRecord() { if (this.settingPrimaryVaraibleListBoxControl.SelectedIndex >= 0 && this.settingSecondaryVaraibleListBoxControl.SelectedIndex >= 0 && this.settingPrimaryItemListBoxControl.SelectedIndex >= 0) { string primaryVariableStr = this.settingPrimaryVaraibleListBoxControl.SelectedItem as string; string secondVariableStr = this.settingSecondaryVaraibleListBoxControl.SelectedItem as string; string primaryItemStr = this.settingPrimaryItemListBoxControl.SelectedItem as string; SerializableDictionary <string, SecondaryItem> secondaryItemDict = new SerializableDictionary <string, SecondaryItem>(); foreach (string temp in this.settingSecondaryItemListBoxControl.CheckedItems) { if (!temp.Equals("Select All")) { secondaryItemDict.Add(temp, new SecondaryItem(temp)); } } // the secondaryItemList has checked items if (this.variableRelation.containRecord(primaryVariableStr, secondVariableStr)) { VariableDependenceRecord record = this.variableRelation.getRecord(primaryVariableStr, secondVariableStr); if (record.ItemDependencDict.ContainsKey(primaryItemStr)) { // in case of the checked item change to be no one checked ,so we use the last state secondaryItemList to decide whether is a empty or not; if (record.ItemDependencDict[primaryItemStr].Count > 0) { //if the secondaryItemList is not empty we just set it if (secondaryItemDict.Count > 0) { record.ItemDependencDict[primaryItemStr] = secondaryItemDict; } // else the record item becomes empty ,we just need to delete it else { record.ItemDependencDict.Remove(primaryItemStr); } // if the record key related record has no item relation just remove it if (record.ItemDependencDict.Count == 0) { this.variableRelation.DependenceRecordDict.Remove(new VariableDependenceRecordKey(primaryVariableStr, secondVariableStr)); } } } else { if (secondaryItemDict.Count > 0) { record.ItemDependencDict.Add(primaryItemStr, secondaryItemDict); } } } else { if (secondaryItemDict.Count > 0) { VariableDependenceRecord record = new VariableDependenceRecord(); record.PrimaryVariable = primaryVariableStr; record.SecondaryVarialbe = secondVariableStr; record.ItemDependencDict.Add(primaryItemStr, secondaryItemDict); // new added function : auto select all //List<string> primaryData = this.settingPrimaryItemListBoxControl.DataSource as List<string>; //List<string> secondaryData = this.settingSecondaryItemListBoxControl.DataSource as List<string>; //SerializableDictionary<string, SecondaryItem> allSecondaryItemDict = new SerializableDictionary<string, SecondaryItem>(); //foreach (string temp in secondaryData) //{ // if (!temp.Equals("Select All")) // { // allSecondaryItemDict.Add(temp, new SecondaryItem(temp)); // } //} //foreach (string primaryItem in primaryData) //{ // if (primaryItem.Equals(primaryItemStr)) // { // record.ItemDependencDict.Add(primaryItemStr, secondaryItemDict); // } // else // { // record.ItemDependencDict.Add(primaryItem, allSecondaryItemDict); // } //} this.variableRelation.DependenceRecordDict.Add(new VariableDependenceRecordKey(primaryVariableStr, secondVariableStr), record); } } } }