Esempio n. 1
0
        private void LoadData()
        {
            //Testing
            mControlSystemTestingPropertiesControl = new ControlSystemTestingPropertiesControl(ControlSystem);
            View.TestingTab.Content = mControlSystemTestingPropertiesControl;

            //Issues
            mControlSystemRelatedIssuesView = new ControlSystemRelatedIssuesView(ControlSystem);
            mControlSystemRelatedIssuesView.CollectionChanged += count =>
            {
                ControlSystem.GeneralEquipmentRelatedItemsCount.Issues = count;
                SetTabHeadersText();
            };
            View.RelatedIssuesTab.Content = mControlSystemRelatedIssuesView;

            //INTERLOCK
            mControlSystemInterlocksView = new ControlSystemInterlocksView(ControlSystem);
            mControlSystemInterlocksView.CollectionChanged += count =>
            {
                ControlSystem.GeneralEquipmentRelatedItemsCount.Interlocks = count;
                SetTabHeadersText();
            };
            View.InterlocksTab.Content = mControlSystemInterlocksView;

            //AREAS
            Areas = new List<Area>(from x in CMS.Cache.Areas where x.IsActive && x.SiteId == CMS.AppSetting.DefaultSiteId select x);

            //Components
            mComponentsControl = new ControlSystemComponentsControl(ControlSystem);
            mComponentsLoaded = true;
            mComponentsControl.CollectionChanged += count =>
            {
                ControlSystem.GeneralEquipmentRelatedItemsCount.PropertyOrComponents = count;

                SetTabHeadersText();
            };
            View.ComponentsTab.Content = mComponentsControl;

            //Attachments
            mControlSystemAttachmentsControl = new ControlSystemAttachmentsControl(ControlSystem);
            mControlSystemAttachmentsControl.ModelLoaded += () =>
            {
                mAttachmentsLoaded = true;
                CheckAllLoaded();
            };
            mControlSystemAttachmentsControl.CollectionChanged += count =>
            {
                ControlSystem.GeneralEquipmentRelatedItemsCount.Attachments = count;
                SetTabHeadersText();
            };
            View.AttachmentsTab.Content = mControlSystemAttachmentsControl;

            mControlSystemDocumentsView = new ControlSystemDocumentsView(ControlSystem);

            mControlSystemDocumentsView.ControlLoaded += mDocumentsControl_ControlLoaded;
            RoutedEventHandler docsloaded = null;

            docsloaded = (s1, e1) =>
            {
                //This will hook up change events on all controls
                Utils.SetUpChangeEvents((UIElement) View.DocumentsTab.Content, EventAggregator, ControlSystem);
                View.DocumentsTab.Loaded -= docsloaded;
            };

            View.DocumentsTab.Loaded += docsloaded;

            var pidDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypePidCode);
            var specificationDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypeFuncspecCode);
            var getQuickControlSystemTypesTask = DatabaseLoader.GetQuickControlSystemTypes();
            var getUpperEquipmentsTask = DatabaseLoader.GetUpperEquipments();
            var getGraphicsTask = DatabaseLoader.GetGraphics();
            var getControlSystemComponentTypesTask = DatabaseLoader.GetControlSystemComponentTypes();

            var tasks = new List<Task>();
            tasks.Add(pidDocumentsTask);
            tasks.Add(specificationDocumentsTask);
            tasks.Add(getQuickControlSystemTypesTask);
            tasks.Add(getGraphicsTask);
            tasks.Add(getControlSystemComponentTypesTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    PandIDDocuments = pidDocumentsTask.Result;
                    SpecificationDocuments = specificationDocumentsTask.Result;

                    mAllUpperEquipments = getUpperEquipmentsTask.Result;
                    mAllUpperEquipments.Insert(0, new UpperEquipment {Name = CMS.Constants.UpperEquipmentNullName});
                    UpperEquipments = mAllUpperEquipments;

                    Graphics = getGraphicsTask.Result;

                    ControlSystemTypes = getQuickControlSystemTypesTask.Result;
                    RaisePropertyChanged("ControlSystemTypes");
                    RaisePropertyChanged("SelectedControlSystemType");

                    //ControlSystemComponentType
                    ControlSystemComponentTypes = getControlSystemComponentTypesTask.Result;
                    //SelectedControlSystemComponentType = ??
                    RaisePropertyChanged("SelectedControlSystemComponentType");

                    RaisePropertyChanged("PandIDDocuments");
                    RaisePropertyChanged("SelectedPAndIDDocument");

                    RaisePropertyChanged("SpecificationDocuments");
                    RaisePropertyChanged("SelectedSpecificationDocument");

                    RaiseLoaded();
                });
            });

            View.RevisionHistory.LoadRevisionHistory(CommonUtils.TabId.Control, ControlSystem.Id);

            RaisePropertyChanged("TuningParameters");
        }
Esempio n. 2
0
        private void BuildMoveComponentRevisionHistory(ControlSystemComponentsControl componentsControl)
        {
            if (componentsControl == null || componentsControl.Model == null || componentsControl.Model.MovedComponents == null)
            {
                return;
            }

            foreach (var movedComponent in componentsControl.Model.MovedComponents)
            {
                var rv = new ControlSystemRevisionHistory();
                rv.Date = DateTime.Now;
                rv.UserId = CMS.User.Id;
                rv.ControlSystemId = ControlSystem.Id;
                rv.Description = string.Format("Moved Component {0} to Intrument {1}.", movedComponent.Name, movedComponent.ControlSystem.Name);
                ControlSystem.ControlSystemRevisionHistories.Add(rv);
            }
        }