Beispiel #1
0
        public override void BuildBOMForm(BOMTool bomForm)
        {
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;

            string catName;
            string busName;
            string iniName;

            NewCategory category;
            NewObjective objective;
            NewImperative imperative;

            foreach (BOM bom in client.BOM)
            {
                catName = bom.IMPERATIVE.BUSINESSOBJECTIVE.CATEGORY.NAME.TrimEnd();
                category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                bomForm.CategoryWorkspace.SelectTab(category.name);

                busName = bom.IMPERATIVE.BUSINESSOBJECTIVE.NAME.TrimEnd();
                objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                iniName = bom.IMPERATIVE.NAME.TrimEnd();
                imperative = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperative == null)
                {
                    imperative = objective.AddImperative(iniName);
                    imperative.Effectiveness = bom.EFFECTIVENESS.HasValue ? bom.EFFECTIVENESS.Value : 0;
                    imperative.Criticality = bom.CRITICALITY.HasValue ? bom.CRITICALITY.Value : 0;
                    imperative.Differentiation = bom.DIFFERENTIAL.HasValue ? bom.DIFFERENTIAL.Value : 0;
                }
            }
        }
Beispiel #2
0
        public override void BuildBOMForm(BOMTool bomForm)
        {
            XElement client = ClientDataControl.Client.EntityObject as XElement;

            string catName;
            string busName;
            string iniName;

            NewCategory category;
            NewObjective objective;
            NewImperative imperative;

            foreach (XElement bom in client.Element("BOMS").Elements("BOM"))
            {
                catName = bom.Element("CATEGORY").Value.TrimEnd();
                category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                busName = bom.Element("BUSINESSOBJECTIVE").Value.TrimEnd();
                objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                iniName = bom.Element("IMPERATIVE").Value.TrimEnd();
                imperative = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperative == null)
                {
                    imperative = objective.AddImperative(iniName);
                    imperative.Effectiveness = Convert.ToSingle(bom.Element("EFFECTIVENESS").Value);
                    imperative.Criticality = Convert.ToSingle(bom.Element("CRITICALITY").Value);
                    imperative.Differentiation = Convert.ToSingle(bom.Element("DIFFERENTIAL").Value);
                }
            }
        }
Beispiel #3
0
        public override bool AddImperativeToBOM(string iniName, string busName, string catName, BOMTool bomForm)
        {
            IMPERATIVE imperative;
            if (!GetImperative(iniName, out imperative))
            {
                imperative = new IMPERATIVE();
                imperative.NAME = iniName;
                BUSINESSOBJECTIVE objective;
                if (!GetObjective(busName, out objective))
                {
                    objective = new BUSINESSOBJECTIVE();
                    objective.NAME = busName;
                    CATEGORY category;
                    if (!GetCategory(catName, out category))
                    {
                        category = new CATEGORY();
                        category.NAME = catName;
                        if (!AddCategory(category))
                        {
                            MessageBox.Show("Failed to add Category to Database", "Error");
                            return false;
                        }
                    }

                    objective.CATEGORY = category;
                    if (!AddObjective(objective))
                    {
                        MessageBox.Show("Failed to add Objective to Database", "Error");
                        return false;
                    }
                }

                else if (objective.CATEGORY.NAME.TrimEnd() != catName)
                {
                    MessageBox.Show("Objective already exists under category " + objective.CATEGORY.NAME.TrimEnd(), "Error");
                    return false;
                }

                imperative.BUSINESSOBJECTIVE = objective;
                if (!AddImperative(imperative))
                {
                    MessageBox.Show("Failed to add Imperative to Database", "Error");
                    return false;
                }
            }

            else if (imperative.BUSINESSOBJECTIVE.NAME.TrimEnd() != busName)
            {
                MessageBox.Show("Imperative already exists under objective " + imperative.BUSINESSOBJECTIVE.NAME.TrimEnd(), "Error");
                return false;
            }

            BUSINESSOBJECTIVE testObjective;
            if (GetObjective(busName, out testObjective) && testObjective.CATEGORY.NAME.TrimEnd() != catName)
            {
                MessageBox.Show("Objective already exists under category " + testObjective.CATEGORY.NAME.TrimEnd(), "Error");
                return false;
            }

            BOM bom = new BOM();
            bom.IMPERATIVE = imperative;
            if (!AddBOM(bom, ClientDataControl.Client.EntityObject))
            {
                MessageBox.Show("Failed to add Imperative to BOM", "Error");
                return false;
            }
            if (!SaveChanges())
            {
                MessageBox.Show("Failed to save changes to database", "Error");
                return false;
            }

            else
            {
                //Successfully added to database, update GUI
                catName = bom.IMPERATIVE.BUSINESSOBJECTIVE.CATEGORY.NAME.TrimEnd();
                NewCategory category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                bomForm.CategoryWorkspace.SelectTab(category.name);

                busName = bom.IMPERATIVE.BUSINESSOBJECTIVE.NAME.TrimEnd();
                NewObjective objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                iniName = bom.IMPERATIVE.NAME.TrimEnd();
                NewImperative imperativeObj = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperativeObj == null)
                {
                    imperativeObj = objective.AddImperative(iniName);
                }
                else
                {
                    MessageBox.Show("Imperative already exists in BOM", "Error");
                }
            }

            return true;
        }
Beispiel #4
0
        public override bool AddImperativeToBOM(string iniName, string busName, string catName, BOMTool bomForm)
        {
            XElement categoryXML;
            if (!GetCategory(catName, out categoryXML))
            {
                categoryXML = new XElement("CATEGORY");
                categoryXML.Add(new XElement("NAME", catName));
                if (!AddCategory(categoryXML))
                {
                    MessageBox.Show("Failed to add Category to File", "Error");
                    return false;
                }
            }

            XElement objectiveXML;
            if (!GetObjective(busName, out objectiveXML))
            {
                objectiveXML = new XElement("BUSINESSOBJECTIVE");
                objectiveXML.Add(new XElement("NAME", busName));
                if (!AddObjective(objectiveXML, categoryXML))
                {
                    MessageBox.Show("Failed to add Objective to File", "Error");
                    return false;
                }
            }

            else if (objectiveXML.Parent.Parent.Element("NAME").Value != catName)
            {
                MessageBox.Show("Objective already exists under category " + objectiveXML.Parent.Parent.Element("NAME").Value, "Error");
                return false;
            }

            XElement imperativeXML;
            if (!GetImperative(iniName, out imperativeXML))
            {
                imperativeXML = new XElement("IMPERATIVE");
                imperativeXML.Add(new XElement("NAME", iniName));
                if (!AddImperative(imperativeXML, objectiveXML, categoryXML))
                {
                    MessageBox.Show("Failed to add Imperative to File", "Error");
                    return false;
                }
            }

            else if (imperativeXML.Parent.Parent.Element("NAME").Value != busName)
            {
                MessageBox.Show("Imperative already exists under objective " + imperativeXML.Parent.Parent.Element("NAME").Value, "Error");
                return false;
            }

            XElement bom = new XElement("BOM");
            bom.Add(new XElement("IMPERATIVE", imperativeXML.Element("NAME").Value));
            bom.Add(new XElement("BUSINESSOBJECTIVE", objectiveXML.Element("NAME").Value));
            bom.Add(new XElement("CATEGORY", categoryXML.Element("NAME").Value));

            if (!AddBOM(bom, ClientDataControl.Client.EntityObject))
            {
                MessageBox.Show("Failed to add Imperative to BOM", "Error");
                return false;
            }

            if (!SaveChanges())
            {
                MessageBox.Show("Failed to save changes to File", "Error");
                return false;
            }

            else
            {
                //Successfully added to database, update GUI
                NewCategory category = bomForm.Categories.Find(delegate(NewCategory cat)
                {
                    return cat.name == catName;
                });
                if (category == null)
                {
                    category = bomForm.AddCategory(catName);
                }

                NewObjective objective = category.Objectives.Find(delegate(NewObjective bus)
                {
                    return bus.ObjName == busName;
                });
                if (objective == null)
                {
                    objective = category.AddObjective(busName);
                }

                NewImperative imperativeObj = objective.Imperatives.Find(delegate(NewImperative ini)
                {
                    return ini.Name == iniName;
                });
                if (imperativeObj == null)
                {
                    imperativeObj = objective.AddImperative(iniName);
                }
                else
                {
                    MessageBox.Show("Imperative already exists in BOM", "Error");
                }
            }

            return true;
        }