private void updatemodel_bttn_Click(object sender, EventArgs e) { if (status_rtb.Text.Contains("Feature tree imported") && status_rtb.Text.Contains("Model imported")) { if (flag = true) { if (File.Exists("txtfolder\\model_subtree_guncel.txt")) { File.Delete("txtfolder\\model_subtree_guncel.txt"); } flag = FeatureProcess.updatetreeviaFeture(openfeaturemodel_tb.Text); //ModelUpdate.updateModel(); ModelUpdate.updateModel_new(); //bu kısım mcm den parse edilerek oluşturlan txt lerde value değerlerini güncelleyerek mcm'e tekrar yazdıracak. foreach (ModelTree item in ModelUpdate.CreateModelTree()) { McmParser Xmlpars = new McmParser(openmodelpath_tb.Text, FileProcess.RemoveSpecialCharacters(item.parent) + ".mcm"); Xmlpars.WriteXmlNewValues(); } //status_rtb.Clear(); status_rtb.AppendText("*** Model updated ***\n"); button1.Enabled = true; openmatelo_btn.Visible = true; } } else { MessageBox.Show("Please Import Feature Model and MAtelo Model!"); } }
public static void updateModel() { List <ModelTree> model_tree_class = new List <ModelTree>(); string[] text = File.ReadAllLines("txtfolder\\model_subtree_guncel.txt"); string[] parent_child; string[] childs_arr; double childvalue_; foreach (string line in text) { parent_child = line.Split(':'); childs_arr = parent_child[1].Split(','); int a = 0; string[] childandvalue = File.ReadAllLines("modelparserresult\\" + FileProcess.RemoveSpecialCharacters(parent_child[0]) + ".txt"); for (int k = 0; k < childandvalue.Length; k++) { string tmp = childandvalue[k].Split(',').ElementAt(0) + "," + childandvalue[k].Split(',').ElementAt(1) + ",0"; childandvalue[k] = tmp; } for (int i = 0; i < childandvalue.Length; i++) { for (int j = 0; j < childs_arr.Length; j++) { if (childandvalue[i].Split(',').ElementAt(0) == (childs_arr[j])) { string str = childandvalue[i].Split(',').ElementAt(0) + "," + childandvalue[i].Split(',').ElementAt(1) + "," + childvalueList(childs_arr.Length).ElementAt(a).ToString(); childandvalue[i] = str; a++; } } } File.WriteAllLines("modelparserresult\\" + FileProcess.RemoveSpecialCharacters(parent_child[0]) + ".txt", childandvalue); /* * childvalue_ = 1 / Convert.ToDouble(childs_arr.Count()); * ModelTree modeltree = new ModelTree(); * modeltree.parent = parent_child[0]; * modeltree.childs = childs_arr; * modeltree.childvalue = childvalue_; * model_tree_class.Add(modeltree); */ // model_tree_class.Add(new ModelTree { parent = parent_child[0], childs= childs_arr, childvalue = childvalue_ }); //childs_arr.Clear(); } }
private void exportmodel_btn_Click(object sender, EventArgs e) { if (openmodelpath_tb.Text == "") { MessageBox.Show("Please Select Matelo Project!"); } else { foreach (ModelTree item in ModelUpdate.CreateModelTree()) { McmParser Xmlpars = new McmParser(openmodelpath_tb.Text, FileProcess.RemoveSpecialCharacters(item.parent) + ".mcm"); Xmlpars.XmlParsing(); } //status_rtb.Clear(); status_rtb.AppendText("*** Model imported ***\n"); } }
public static void updateModel_new() { List <ModelTree> model_tree_class = new List <ModelTree>(); string[] text = File.ReadAllLines("txtfolder\\model_subtree_guncel.txt"); string[] parent_child; string[] childs_arr; double childvalue_; foreach (string line in text) { parent_child = line.Split(':'); childs_arr = parent_child[1].Split(','); string[] childandvalue = File.ReadAllLines("modelparserresult\\" + FileProcess.RemoveSpecialCharacters(parent_child[0]) + ".txt"); for (int i = 0; i < childandvalue.Length; i++) { bool flag = false; for (int j = 0; j < childs_arr.Length; j++) { if (childandvalue[i].Split(',').ElementAt(0) == (childs_arr[j])) { string str = childandvalue[i].Split(',').ElementAt(0) + "," + childandvalue[i].Split(',').ElementAt(1) + "," + childandvalue[i].Split(',').ElementAt(2); childandvalue[i] = str; flag = true; } } if (!flag) { string str = childandvalue[i].Split(',').ElementAt(0) + "," + childandvalue[i].Split(',').ElementAt(1) + ",0"; childandvalue[i] = str; } } double total = 0; for (int k = 0; k < childandvalue.Length; k++) { total = total + Convert.ToDouble(childandvalue[k].Split(',').ElementAt(2)); } double lastvalue = 0; double childvalue; int c = 0; for (int l = 0; l < childandvalue.Length; l++) { childvalue = ChildValuenew(Convert.ToDouble(childandvalue[l].Split(',').ElementAt(2)), 1 - total); if (childvalue != 0) { c++; } if (c == childs_arr.Length && childs_arr.Length != 1) { string str = childandvalue[l].Split(',').ElementAt(0) + ',' + childandvalue[l].Split(',').ElementAt(1) + ',' + (1 - Math.Round(lastvalue, 3)).ToString(); childandvalue[l] = str; c = 0; } else { string str = childandvalue[l].Split(',').ElementAt(0) + ',' + childandvalue[l].Split(',').ElementAt(1) + ',' + childvalue.ToString(); childandvalue[l] = str; } lastvalue = lastvalue + childvalue; } File.WriteAllLines("modelparserresult\\" + FileProcess.RemoveSpecialCharacters(parent_child[0]) + ".txt", childandvalue); } }