Esempio n. 1
0
        /// <summary>
        /// Select Project Command through command interface
        /// </summary>
        private void SelectProject(Object p)
        {
            ProjectModel selectedProject = GetProject((int)p);

            Globals.Project_ID         = (int)p;
            Globals.ProjectSelected    = true;
            ProjectSelected            = true;
            Globals.ProjectName        = selectedProject.ProjectName;
            Globals.ContractNo         = selectedProject.ContractNo;
            selectedProject.LastOpened = DateTime.Now;

            // Store the current DateTime in the selected project record so it can be used to sort the project list
            EDBEntities eDB = new EDBEntities();
            tblProject  Rec = eDB.tblProjects.Where(o => o.ID == selectedProject.ID).FirstOrDefault();

            Rec.LastOpened   = selectedProject.LastOpened;
            Rec.LastOpenedBy = Environment.UserName;
            eDB.SaveChanges();

            IsBackStageOpen = false;
            MainTitle       = Globals.ContractNo + Globals.ProjectName;
            TypeViewModelLocator.GetTypeVM();
            ObjectViewModelLocator.GetObjectVM();
            TemplateViewModelLocator.GetTemplateVM();
            PropertyViewModelLocator.GetPropertyVM();
            AspectViewModelLocator.GetAspectVM();
            AttributeViewModelLocator.GetAttributeVM();
            ObjectAssociationViewModelLocator.GetObjectAssociationVM();
            ObjectRequirementViewModelLocator.GetObjectRequirementVM();
            TemplateAssociationViewModelLocator.GetTemplateAssociationVM();
            TemplateRequirementViewModelLocator.GetTemplateRequirementVM();
        }
        public void AssociateWithTemplate(TreeListViewRow destination)
        {
            try
            {
                foreach (var templateItem in TemplateViewModelLocator.GetTemplateVM().SelectedItems)
                {
                    switch (Globals.DraggedItem.Type)
                    {
                    case "Property":
                        foreach (var propertyItem in PropertyViewModelLocator.GetPropertyVM().SelectedItems)
                        {
                            TemplateAssociationModel templateAssociationItem = new TemplateAssociationModel
                            {
                                ID                = Guid.NewGuid(),
                                IsNew             = true,
                                IsChanged         = false,
                                IsDeleted         = false,
                                Project_ID        = Globals.Project_ID,
                                Template_ID       = templateItem.ID,
                                AssociationType   = Globals.DraggedItem.Type,
                                ChildAssociations = new TD.ObservableItemCollection <TemplateAssociationModel>(),
                            };
                            templateAssociationItem.Association_ID     = propertyItem.ID;
                            templateAssociationItem.Name               = propertyItem.PropertyName;
                            templateAssociationItem.Description        = propertyItem.Description;
                            templateAssociationItem.AssociationType_ID = propertyItem.PropertyType_ID;
                            templateAssociationItem.Value              = propertyItem.Value;

                            foreach (var childItem in propertyItem.ChildProperties)
                            {
                                TemplateAssociationModel templateAssociationChildItem = new TemplateAssociationModel
                                {
                                    IsNew           = true,
                                    IsChanged       = false,
                                    IsDeleted       = false,
                                    AssociationType = "Property",
                                    ID                 = Guid.NewGuid(),
                                    Project_ID         = Globals.Project_ID,
                                    Template_ID        = templateItem.ID,
                                    Association_ID     = childItem.ID,
                                    Name               = childItem.PropertyName,
                                    Description        = childItem.Description,
                                    AssociationType_ID = childItem.PropertyType_ID,
                                    Value              = childItem.Value,
                                    ChildAssociations  = new TD.ObservableItemCollection <TemplateAssociationModel>()
                                };
                                templateAssociationItem.ChildAssociations.Add(templateAssociationChildItem);
                            }
                            TemplateAssociations.Add(templateAssociationItem);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                RadWindow.Alert(ex.Message);
            }
            //}
        }
Esempio n. 3
0
 public TemplateView()
 {
     InitializeComponent();
     DataContext = TemplateViewModelLocator.GetTemplateVM();
     PropertyTreeListView.DataContext            = PropertyViewModelLocator.GetPropertyVM();
     RequirementTreeListView.DataContext         = RequirementViewModelLocator.GetRequirementVM();
     TemplateAssociationTreeListView.DataContext = TemplateAssociationViewModelLocator.GetTemplateAssociationVM();
     TemplateRequirementTreeListView.DataContext = TemplateRequirementViewModelLocator.GetTemplateRequirementVM();
 }
Esempio n. 4
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     // Link View Models to the Trees and popups
     DataContext = ObjectViewModelLocator.GetObjectVM();
     TemplateTreeListView.DataContext          = TemplateViewModelLocator.GetTemplateVM();
     PropertyTreeListView.DataContext          = PropertyViewModelLocator.GetPropertyVM();
     RequirementTreeListView.DataContext       = RequirementViewModelLocator.GetRequirementVM();
     ObjectAssociationTreeListView.DataContext = ObjectAssociationViewModelLocator.GetObjectAssociationVM();
     ObjectRequirementTreeListView.DataContext = ObjectRequirementViewModelLocator.GetObjectRequirementVM();
 }
        public void TemplateFilter(object sender, FilterEventArgs e)
        {
            TemplateViewModel ovm = TemplateViewModelLocator.GetTemplateVM();
            TemplateModel     om  = ovm.SelectedItem;

            if (e.Item != null && om != null)
            {
                e.Accepted = (e.Item as TemplateAssociationModel).Template_ID == TemplateViewModelLocator.GetTemplateVM().SelectedItem.ID&&
                             (e.Item as TemplateAssociationModel).IsDeleted == false;
            }
        }
        //TODO: fix hard code
        private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
        {
            if (e.Data != null && e.AllowedEffects != DragDropEffects.None)
            {
                var             treeListViewName = (sender as RadTreeListView).Name;
                TreeListViewRow destination      = e.OriginalSource as TreeListViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType <TreeListViewRow>();
                switch (treeListViewName)
                {
                case "ObjectTreeListView":
                    ObjectViewModelLocator.GetObjectVM().MoveSelection(destination);
                    break;

                case "TemplateTreeListView":
                    TemplateViewModelLocator.GetTemplateVM().MoveSelection(destination);
                    break;

                case "PropertyTreeListView":
                    PropertyViewModelLocator.GetPropertyVM().MoveSelection(destination);
                    break;

                case "ObjectAssociationTreeListView":
                    ObjectAssociationViewModel objectAssociationViewModel = ObjectAssociationViewModelLocator.GetObjectAssociationVM();
                    objectAssociationViewModel.AssociateWithObject(destination);
                    objectAssociationViewModel.FilteredObjectAssociations.View.Refresh();
                    break;

                case "ObjectRequirementTreeListView":
                    ObjectRequirementViewModel objectRequirementViewModel = ObjectRequirementViewModelLocator.GetObjectRequirementVM();
                    objectRequirementViewModel.AssociateWithObject(destination);
                    objectRequirementViewModel.FilteredObjectRequirements.View.Refresh();
                    break;

                case "TemplateAssociationTreeListView":
                    TemplateAssociationViewModel templateAssociationViewModel = TemplateAssociationViewModelLocator.GetTemplateAssociationVM();
                    templateAssociationViewModel.AssociateWithTemplate(destination);
                    templateAssociationViewModel.FilteredTemplateAssociations.View.Refresh();
                    break;

                case "TemplateRequirementTreeListView":
                    TemplateRequirementViewModel templateRequirementViewModel = TemplateRequirementViewModelLocator.GetTemplateRequirementVM();
                    templateRequirementViewModel.AssociateWithTemplate(destination);
                    templateRequirementViewModel.FilteredTemplateRequirements.View.Refresh();
                    break;

                case "RequirementTreeListView":
                    RequirementViewModelLocator.GetRequirementVM().MoveSelection(destination);
                    break;
                }
            }
        }
Esempio n. 7
0
        public void AssociateWithObject(TreeListViewRow destination)
        {
            try
            {
                foreach (var objectItem in ObjectViewModelLocator.GetObjectVM().SelectedItems)
                {
                    switch (Globals.DraggedItem.Type)
                    {
                    case "Template":
                        foreach (var templateItem in TemplateViewModelLocator.GetTemplateVM().SelectedItems)
                        {
                            ObjectAssociationModel objectAssociationItem = new ObjectAssociationModel
                            {
                                IsNew             = true,
                                IsChanged         = false,
                                IsDeleted         = false,
                                ID                = Guid.NewGuid(),
                                Project_ID        = Globals.Project_ID,
                                Object_ID         = objectItem.ID,
                                AssociationType   = Globals.DraggedItem.Type,
                                Value             = "",
                                ChildAssociations = new TD.ObservableItemCollection <ObjectAssociationModel>(),
                            };
                            objectAssociationItem.Association_ID     = templateItem.ID;
                            objectAssociationItem.Name               = templateItem.TemplateName;
                            objectAssociationItem.Description        = templateItem.Description;
                            objectAssociationItem.AssociationType_ID = templateItem.TemplateType_ID;

                            foreach (var childItem in templateItem.ChildTemplates)
                            {
                                ObjectAssociationModel objectAssociationChildItem = new ObjectAssociationModel
                                {
                                    IsNew              = true,
                                    IsChanged          = false,
                                    IsDeleted          = false,
                                    ID                 = Guid.NewGuid(),
                                    AssociationType    = "Template",
                                    Project_ID         = Globals.Project_ID,
                                    Object_ID          = objectItem.ID,
                                    Association_ID     = childItem.ID,
                                    Name               = childItem.TemplateName,
                                    Description        = childItem.Description,
                                    AssociationType_ID = childItem.TemplateType_ID,
                                    Value              = "",
                                    ChildAssociations  = new TD.ObservableItemCollection <ObjectAssociationModel>()
                                };
                                objectAssociationItem.ChildAssociations.Add(objectAssociationChildItem);
                                LoadTemplateProperties(objectAssociationChildItem);
                            }
                            ;
                            ObjectAssociations.Add(objectAssociationItem);
                            LoadTemplateProperties(objectAssociationItem);
                        }
                        break;

                    case "Property":
                        foreach (var propertyItem in PropertyViewModelLocator.GetPropertyVM().SelectedItems)
                        {
                            ObjectAssociationModel objectAssociationItem = new ObjectAssociationModel
                            {
                                IsNew             = true,
                                IsChanged         = false,
                                IsDeleted         = false,
                                ID                = Guid.NewGuid(),
                                Project_ID        = Globals.Project_ID,
                                Object_ID         = objectItem.ID,
                                AssociationType   = Globals.DraggedItem.Type,
                                Value             = "",
                                ChildAssociations = new TD.ObservableItemCollection <ObjectAssociationModel>(),
                            };

                            objectAssociationItem.Association_ID     = propertyItem.ID;
                            objectAssociationItem.Name               = propertyItem.PropertyName;
                            objectAssociationItem.Description        = propertyItem.Description;
                            objectAssociationItem.AssociationType_ID = propertyItem.PropertyType_ID;

                            foreach (var childItem in propertyItem.ChildProperties)
                            {
                                ObjectAssociationModel objectAssociationChildItem = new ObjectAssociationModel
                                {
                                    IsNew              = true,
                                    IsChanged          = false,
                                    IsDeleted          = false,
                                    AssociationType    = "Property",
                                    Project_ID         = Globals.Project_ID,
                                    Object_ID          = objectItem.ID,
                                    Association_ID     = childItem.ID,
                                    Name               = childItem.PropertyName,
                                    Description        = childItem.Description,
                                    AssociationType_ID = childItem.PropertyType_ID,
                                    Value              = "",
                                    ChildAssociations  = new TD.ObservableItemCollection <ObjectAssociationModel>()
                                };
                                objectAssociationItem.ChildAssociations.Add(objectAssociationChildItem);
                            }
                            ObjectAssociations.Add(objectAssociationItem);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                RadWindow.Alert(ex.Message);
            }
        }
Esempio n. 8
0
        private void Load(Guid?associationParent_ID)
        {
            // Check if the templates and properties have ben loaded. Necessary because of the various background workers
            //while (!TemplateViewModelLocator.IsLoaded() || !PropertyViewModelLocator.IsLoaded());
            try
            {
                using (EDBEntities eDB = new EDBEntities())
                {
                    foreach (tblObjectAssociation Rec in (from o in eDB.tblObjectAssociations where (o.Project_ID == Globals.Project_ID) orderby o.AssociationType select o))
                    {
                        ObjectAssociationModel objectAssociationItem = new ObjectAssociationModel
                        {
                            ID                = Rec.ID,
                            Project_ID        = Rec.Project_ID,
                            Object_ID         = Rec.Object_ID,
                            Association_ID    = Rec.Association_ID,
                            AssociationType   = Rec.AssociationType,
                            IsChanged         = false,
                            IsNew             = false,
                            IsDeleted         = false,
                            ChildAssociations = new TD.ObservableItemCollection <ObjectAssociationModel>()
                        };
                        switch (objectAssociationItem.AssociationType)
                        {
                        case "Template":
                            // Get detail info of the template
                            var templateItem = TemplateViewModelLocator.GetTemplateVM().GetTemplate(objectAssociationItem.Association_ID, null);
                            if (templateItem != null)
                            {
                                objectAssociationItem.Name               = templateItem.TemplateName;
                                objectAssociationItem.Description        = templateItem.Description;
                                objectAssociationItem.AssociationType_ID = templateItem.TemplateType_ID;
                                // and get any child items
                                foreach (var childItem in templateItem.ChildTemplates)
                                {
                                    ObjectAssociationModel item = new ObjectAssociationModel
                                    {
                                        ID                 = Rec.ID,
                                        Project_ID         = childItem.Project_ID,
                                        Object_ID          = objectAssociationItem.Object_ID,
                                        Association_ID     = childItem.ID,
                                        Name               = childItem.TemplateName,
                                        Description        = childItem.Description,
                                        AssociationType    = "Template",
                                        AssociationType_ID = childItem.TemplateType_ID,
                                        ChildAssociations  = new TD.ObservableItemCollection <ObjectAssociationModel>()
                                    };
                                    objectAssociationItem.ChildAssociations.Add(item);
                                    LoadTemplateProperties(item);
                                }
                                LoadTemplateProperties(objectAssociationItem);
                            }
                            else
                            {
                                throw new System.InvalidOperationException(String.Format("Association without source\nTemplate ID: {0}\nFix in database", objectAssociationItem.Association_ID));
                            }

                            break;

                        case "Property":
                            var propertyItem = PropertyViewModelLocator.GetPropertyVM().GetProperty(objectAssociationItem.Association_ID, null);
                            if (propertyItem != null)
                            {
                                objectAssociationItem.Name               = propertyItem.PropertyName;
                                objectAssociationItem.Description        = propertyItem.Description;
                                objectAssociationItem.AssociationType_ID = propertyItem.PropertyType_ID;

                                // If the Object Association has a value in the table, use this as the associated value
                                // otherwise use the value defined in the property
                                if (!String.IsNullOrEmpty(Rec.Value))
                                {
                                    objectAssociationItem.Value = Rec.Value;
                                }
                                else
                                {
                                    objectAssociationItem.Value = propertyItem.Value;
                                }

                                foreach (var childItem in propertyItem.ChildProperties)
                                {
                                    ObjectAssociationModel item = new ObjectAssociationModel
                                    {
                                        ID                 = Rec.ID,
                                        Project_ID         = childItem.Project_ID,
                                        Object_ID          = objectAssociationItem.Object_ID,
                                        Association_ID     = childItem.ID,
                                        Name               = childItem.PropertyName,
                                        Description        = childItem.Description,
                                        AssociationType    = "Property",
                                        AssociationType_ID = childItem.PropertyType_ID,
                                        ChildAssociations  = new TD.ObservableItemCollection <ObjectAssociationModel>()
                                    };
                                    objectAssociationItem.ChildAssociations.Add(item);
                                }
                            }
                            else
                            {
                                throw new System.InvalidOperationException(String.Format("Association without source\nProperty ID: {0}\nFix in database", objectAssociationItem.Association_ID));
                            }
                            break;

                        case "TemplateProperty":
                            break;
                        }

                        ObjectAssociations.Add(objectAssociationItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke((Action) delegate { RadWindow.Alert(ex.Message); });
            }
        }