Example #1
0
 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!");
     }
 }
Example #2
0
        public static bool updatetreeviaFeture(string path)
        {
            string[] feature_arr = FileProcess.readFeature(path);
            string[] text        = File.ReadAllLines("txtfolder\\model_subtree.txt");
            string   parent_child;

            string[] childs_arr;
            int      c    = 0;
            bool     flag = true;

            for (int i = 0; i < text.Length; i++)
            {
                parent_child = text[i].Split(':').ElementAt(0);
                childs_arr   = text[i].Split(':').ElementAt(1).Split(',');
                string chilstr = "";
                for (int j = c; j < feature_arr.Length; j++)
                {
                    if ((parent_child == feature_arr[j].Split(',').ElementAt(0)) && (feature_arr[j].Split(',').ElementAt(1) == "0"))
                    {
                        parent_child = "";
                        c            = j;
                        break;
                    }
                    else if ((parent_child == feature_arr[j].Split(',').ElementAt(0)) && (feature_arr[j].Split(',').ElementAt(1) == "1"))
                    {
                        for (int k = 0; k < childs_arr.Length; k++)
                        {
                            for (int l = j; l < feature_arr.Length; l++)
                            {
                                if ((childs_arr[k] == feature_arr[l].Split(',').ElementAt(0) && (feature_arr[l].Split(',').ElementAt(1) == "0")))
                                {
                                    childs_arr[k] = "null";
                                    c             = j;
                                    break;
                                }
                                else if ((childs_arr[k] == feature_arr[l].Split(',').ElementAt(0) && (feature_arr[l].Split(',').ElementAt(1) == "1")))
                                {
                                    chilstr = chilstr + childs_arr[k] + ",";
                                }
                                else
                                {
                                    flag = false;
                                }
                            }
                        }
                        c = j;
                        break;
                    }
                    else
                    {
                        flag = false;
                    }
                }
                if (parent_child != "")
                {
                    CreateLogFile(parent_child + ":" + chilstr.TrimEnd(',') + "\n");
                }
            }
            return(flag);
        }
        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();
            }
        }
Example #4
0
 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");
     }
 }
Example #5
0
        public static bool consistenceCheck(string path)
        {
            bool flag = true;

            string[] feature_arr = FileProcess.readFeature(path);
            string   text        = File.ReadAllText("txtfolder\\model_subtree.txt").ToLower();

            for (int i = 0; i < feature_arr.Length; i++)
            {
                if (!(text.Contains(feature_arr[i].Split(',').ElementAt(0).ToLower())))
                {
                    flag = false;
                    break;
                }
            }

            return(flag);
        }
Example #6
0
        public void eskifonk_calculatenewfeature_btn_Click()
        {
            string[]         feature_arr      = FileProcess.readFeature(openfeaturemodel_tb.Text);
            List <ModelTree> updatedModelTree = new List <ModelTree>(ModelUpdate.CreateModelTree());

            foreach (ModelTree item in ModelUpdate.CreateModelTree())
            {
                for (int i = 0; i < feature_arr.Length; i++)
                {
                    if ((item.parent == feature_arr[i].Split(',').ElementAt(0)) && (feature_arr[i].Split(',').ElementAt(1) == "1"))
                    {
                        foreach (string child in item.childs)
                        {
                            for (int j = i; j < feature_arr.Length; j++)
                            {
                                if (child == feature_arr[j].Split(',').ElementAt(0) && (feature_arr[j].Split(',').ElementAt(1) == "0"))
                                {
                                    List <string> childs_list = new List <string>(item.childs);
                                    childs_list.Remove(child);
                                    item.childs     = childs_list.ToArray();
                                    item.childvalue = 1 / item.childs.Length;
                                    //numbers.RemoveAt(numbers.IndexOf(4));
                                }
                            }
                        }
                    }
                    else if ((item.parent == feature_arr[i].Split(',').ElementAt(0)) && (feature_arr[i].Split(',').ElementAt(1) == "0"))
                    {
                        updatedModelTree.Remove(item);
                    }
                }
            }
            updatedModelTree = ModelUpdate.CreateModelTree();
            foreach (ModelTree item in updatedModelTree)
            {
                modeltreeshow_rtb.AppendText(item.parent.ToString().ToUpper() + "\n");
                foreach (var child in item.childs)
                {
                    modeltreeshow_rtb.AppendText("  --" + child.ToString().ToUpper() + " =>  child_value: " + item.childvalue.ToString() + "\n");
                }
            }
        }
Example #7
0
 private void chkfeaturetree_bttn_Click(object sender, EventArgs e)
 {
     if (openfeaturemodel_tb.Text == "")
     {
         MessageBox.Show("Please Select feature Model!");
     }
     else
     {
         int a = 1;
         feature_list_rtb.Clear();
         foreach (string item in FileProcess.readFeature(openfeaturemodel_tb.Text))
         {
             feature_list_rtb.AppendText(a + ". feature -> " + item + "\n");
             a++;
         }
         //status_rtb.Clear();
         status_rtb.AppendText("*** Feature tree imported ***\n");
     }
     info_pnl.Visible = true;
 }
        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);
            }
        }