Ejemplo n.º 1
0
        public ProjectTemplateViewModel(IRegionManager regionManager, IGlobalProperties globalProperties)
        {
            _globalProperties = globalProperties;
            //_regionManager = regionManager;
            //LoadProjects();
            // AddAccessoryViewModel obj= new AddAccessoryViewModel();

            EditCommand = new DelegateCommand <object>((projectID) =>
            {
                //Button senderButton = sender as Button;
                //var item = senderButton.DataContext;
                //var projectID = ((Project)item).ProjectID;
                int projectId = (int)projectID;
                Application.Current.Properties["ProjectId"] = projectId;
                ProjectInfoBLL bll = new ProjectInfoBLL();

                JCHVRF.Entity.ProjectInfo projectNextGen = bll.GetProjectInfo(projectId);
                if (projectNextGen.ProjectLegacy.RoomList == null)
                {
                    projectNextGen.ProjectLegacy.RoomList = new List <JCHVRF.Model.Room>();
                }
                JCHVRF.Model.Project.CurrentProject = projectNextGen.ProjectLegacy;
                //This case only for old created project
                if (projectNextGen.ProjectLegacy.projectID.Equals(0))
                {
                    JCHVRF.Model.Project.CurrentProject.projectID = projectId;
                }

                //projectNextGen.ProjectLegacy.RegionCode = "EU_W";
                //projectNextGen.ProjectLegacy.SubRegionCode = "GBR";
                //projectNextGen.ProjectLegacy.projectID = projectId;

                NavigationParameters param = new NavigationParameters();
                param.Add("Project", projectNextGen.ProjectLegacy);
                _globalProperties.ProjectTitle = JCHVRF.Model.Project.CurrentProject.Name;
                regionManager.RequestNavigate(RegionNames.ContentRegion, ViewKeys.MasterDesigner, param);
                //var winMain = new MasterDesigner(projectNextGen.ProjectLegacy);
                //winMain.ShowDialog();
            });

            //SearchType = "all";
            // LoadProjects("All");
        }
Ejemplo n.º 2
0
        //ACC - RAG END

        //IRegionManager regionManager;
        private void CreateClick()
        {
            var proj = JCHVRF.Model.Project.GetProjectInstance;

            _eventAggregator.GetEvent <BeforeCreate>().Publish();

            SystemBase newSystem = WorkFlowContext.NewSystem;

            int sysTypeAsInt = System.Convert.ToInt32(newSystem.HvacSystemType);

            switch (sysTypeAsInt)
            {
            case 1:
                proj.SystemListNextGen.Add((JCHVRF.Model.NextGen.SystemVRF)newSystem);
                break;

            case 2:
                proj.HeatExchangerSystems.Add((SystemHeatExchanger)newSystem);
                break;

            case 6:
                proj.ControlSystemList.Add((ControlSystem)newSystem);
                break;
            }


            if (_projectBAL.CreateProject(proj))
            {
                var w = Application.Current.MainWindow;

                RefreshDashBoard();
                var projectId = proj.projectID;
                int projectid = (int)projectId;
                Application.Current.Properties["ProjectId"] = projectId;
                ProjectInfoBLL            bll            = new ProjectInfoBLL();
                JCHVRF.Entity.ProjectInfo projectNextGen = JCHVRF.Entity.ProjectInfo.create();
                projectNextGen = bll.GetProjectInfo(projectId);


                if (projectNextGen != null)
                {
                    if (WorkFlowContext.Systemid == "2")
                    {
                        if (TotalHeatExUnitInfoViewModel.flgValidateUnit == false)
                        {
                            //JCHMessageBox.Show("Unit name of Heat Exchanger can not be blank");
                            //---------------- Below code added for multi-language----------//
                            JCHMessageBox.Show(Language.Current.GetMessage("ALERT_HEATEXCHANGER_UNITNAME"));
                            return;
                        }

                        //JCHMessageBox.Show("Heat Exchanger has no system available for connection");
                        //---------------- Below code added for multi-language----------//
                        JCHMessageBox.Show(Language.Current.GetMessage("ALERT_EXCHANGER_NO_SYSTEM"));
                    }

                    else if (WorkFlowContext.Systemid == "6")
                    {
                        //JCHMessageBox.Show("Central Controller has no system available for connection");
                        //---------------- Below code added for multi-language----------//

                        _eventAggregator.GetEvent <ErrorMessageUC>().Publish(Language.Current.GetMessage("CENTRAL_CONTROLLER_BLANK"));
                        Views.ucDesignerCanvas.__errorMessage = Language.Current.GetMessage("CENTRAL_CONTROLLER_BLANK");
                        //   JCHMessageBox.Show(Language.Current.GetMessage("ALERT_CENTRALCONTROLLER_NO_SYSTEM"));
                    }
                    else
                    {
                        //  JCHMessageBox.Show("Project Saved Successfully");
                        //---------------- Below code added for multi-language----------//
                        JCHMessageBox.Show(Language.Current.GetMessage("ALERT_PROJECT_SAVED"));
                        _globalProperties.ProjectTitle = JCHVRF.Model.Project.CurrentProject.Name;
                        _globalProperties.Notifications.Insert(0, new JCHVRF.Model.NextGen.Notification(JCHVRF.Model.NextGen.NotificationType.APPLICATION, String.Format("Project: {0} Created !", _globalProperties.ProjectTitle)));
                    }

                    // ACC - RAG END
                }

                projectNextGen.ProjectLegacy.RegionCode    = JCHVRF.Model.Project.CurrentProject.RegionCode;
                projectNextGen.ProjectLegacy.SubRegionCode = JCHVRF.Model.Project.CurrentProject.SubRegionCode;
                projectNextGen.ProjectLegacy.projectID     = projectid;

                w.Hide();
                NavigationParameters param = new NavigationParameters();
                param.Add("Project", projectNextGen.ProjectLegacy);

                //event to trigger to all view models to unsubscribe events they have subscibed to
                _eventAggregator.GetEvent <Cleanup>().Publish();
                //Test this
                _eventAggregator.GetEvent <CleanupOnClose>().Publish();
                _eventAggregator.GetEvent <ErrorLogVMClearAll>().Publish();
                RegionManager.RequestNavigate(RegionNames.ContentRegion, ViewKeys.Splash, (a) => {
                    _winService.Close("CreateProjectWizard");
                }, param);
                //RegionManager.RequestNavigate(RegionNames.ContentRegion, ViewKeys.MasterDesigner, (a) => { win.Close(); }, param);

                w.Show();
            }
        }