//ACC - RAG START

        //ACC - RAG END

        //IRegionManager regionManager;
        private void CreateClick(Window win)
        {
            _eventAggregator.GetEvent <BeforeCreate>().Publish();

            var        proj      = Project.GetProjectInstance;
            SystemBase newSystem = WorkFlowContext.NewSystem;

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

            switch (sysTypeAsInt)
            {
            case 1:
                proj.SystemListNextGen.Add((JCHVRF.Model.NextGen.SystemVRF)newSystem);
                _eventAggregator.GetEvent <ErrorMessageUC>().Publish(string.Empty);
                Views.ucDesignerCanvas.__errorMessage = string.Empty;
                break;

            case 2:
                proj.HeatExchangerSystems.Add((SystemHeatExchanger)newSystem);
                _eventAggregator.GetEvent <ErrorMessageUC>().Publish(string.Empty);
                Views.ucDesignerCanvas.__errorMessage = string.Empty;
                break;

            case 6:
                if ((proj.SystemListNextGen.Count <= 0) && (proj.HeatExchangerSystems.Count <= 0))
                {
                    _eventAggregator.GetEvent <ErrorMessageUC>().Publish(JCHVRF_New.LanguageData.LanguageViewModel.Current.GetMessage("CENTRAL_CONTROLLER_BLANK"));
                    Views.ucDesignerCanvas.__errorMessage = JCHVRF_New.LanguageData.LanguageViewModel.Current.GetMessage("CENTRAL_CONTROLLER_BLANK");
                }
                else
                {
                    _eventAggregator.GetEvent <ErrorMessageUC>().Publish(string.Empty);
                    Views.ucDesignerCanvas.__errorMessage = string.Empty;
                }
                proj.ControlSystemList.Add((ControlSystem)newSystem);
                break;
            }

            if (_projectBAL.UpdateProject(proj))
            {
                Project.GetProjectInstance.SelectedSystemID = newSystem.Id;
                UndoRedoSetup.SetInstanceNull();
                //WorkFlowContext.Clear();
                JCHMessageBox.Show(Langauge.Current.GetMessage("SYSTEM_SAVED_SUCCESSFULLY"));//System Saved Successfully
                if (win != null)
                {
                    var w = Application.Current.MainWindow;
                    w.Hide();
                    //RefreshDashBoard();
                    var projectId = proj.projectID;
                    Application.Current.Properties["ProjectId"] = projectId;
                    ProjectInfoBLL            bll            = new ProjectInfoBLL();
                    JCHVRF.Entity.ProjectInfo projectNextGen = bll.GetProjectInfo(projectId);
                    projectNextGen.ProjectLegacy.RegionCode    = JCHVRF.Model.Project.CurrentProject.RegionCode;
                    projectNextGen.ProjectLegacy.SubRegionCode = JCHVRF.Model.Project.CurrentProject.SubRegionCode;
                    projectNextGen.ProjectLegacy.projectID     = projectId;

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

                    RegionManager.RequestNavigate(RegionNames.ContentRegion, ViewKeys.MasterDesigner, (a) => { win.Close(); }, param);
                    w.Show();
                }
                //event to trigger to all view models to unsubscribe events they have subscibed to
                _eventAggregator.GetEvent <Cleanup>().Publish();
                _eventAggregator.GetEvent <SystemCreated>().Publish(newSystem);
                _eventAggregator.GetEvent <RefreshSystems>().Publish();
            }
        }
Example #2
0
 public JCHVRF.Entity.ProjectInfo GetProjectInfo(int projectId)
 {
     JCHVRF.Entity.ProjectInfo objProjectInfo = _projectInfoDAL.GetProjectDetailsById(projectId);
     return(objProjectInfo);
 }
        //IRegionManager regionManager;
        //
        private void SaveClick(Window win)
        {
            try
            {
                var proj         = Project.GetProjectInstance;
                int sysTypeAsInt = System.Convert.ToInt32(_hvacSystem.HvacSystemType);
                NextGenModel.SystemVRF currentSystem = new NextGenModel.SystemVRF();
                switch (sysTypeAsInt)
                {
                case 1:
                    proj.SystemListNextGen = JCHVRF.Model.Project.CurrentProject.SystemListNextGen;
                    currentSystem          = proj.SystemListNextGen.Find(sys => sys.Id == JCHVRF.Model.Project.CurrentSystemId);
                    _eventAggregator.GetEvent <BeforeSaveVRF>().Publish(currentSystem);
                    if (this.SelectedTabIndex != 0)
                    {
                        _eventAggregator.GetEvent <ODUTypeTabSave>().Publish();
                        if (!currentSystem.IsOutDoorUpdated)
                        {
                            return;
                        }
                    }
                    else
                    {
                        currentSystem.IsOutDoorUpdated = false;
                    }
                    UtilTrace.SaveHistoryTraces();
                    //proj.CanvasODUList = null;
                    break;

                case 2:
                    _eventAggregator.GetEvent <BeforeHESave>().Publish();
                    int k = proj.HeatExchangerSystems.IndexOf((SystemHeatExchanger)_hvacSystem);
                    proj.HeatExchangerSystems[k] = ((SystemHeatExchanger)_hvacSystem);
                    if (PropertyInfoViewModel._strHEName != null)
                    {
                        if (proj.HeatExchangerSystems[k].Id.Equals(PropertyInfoViewModel._strHEName[0]))
                        {
                            proj.HeatExchangerSystems[k].Name = PropertyInfoViewModel._strHEName[1];
                        }
                    }

                    UtilTrace.SaveHistoryTraces();
                    break;

                case 6:
                    _eventAggregator.GetEvent <BeforeSave>().Publish();
                    int j = proj.ControlSystemList.IndexOf((ControlSystem)_hvacSystem);
                    proj.ControlSystemList[j] = ((ControlSystem)_hvacSystem);
                    UtilTrace.SaveHistoryTraces();
                    break;
                }

                if (_projectBAL.UpdateProject(proj))
                {
                    _eventAggregator.GetEvent <RefreshSystems>().Publish();
                    if (sysTypeAsInt == 1)
                    {
                        HeatExchangerCanvasEquipmentViewModel.IsPropOrNewExch = false;
                        if (currentSystem.IsOutDoorUpdated)
                        {
                            bool IsSystemValidated = ((NextGenModel.SystemVRF)_hvacSystem).IsPipingOK;
                            JCHMessageBox.Show(Langauge.Current.GetMessage("SYSTEM_SAVED_SUCCESSFULLY")); //"System Saved Successfully");
                            _eventAggregator.GetEvent <AuToPipingBtnSubscriber>().Publish((NextGenModel.SystemVRF)_hvacSystem);

                            if (IsSystemValidated == true)
                            {
                                currentSystem.IsPipingOK = true;
                                _eventAggregator.GetEvent <PipingValidationBtnSubscriber>().Publish((NextGenModel.SystemVRF)_hvacSystem);
                            }
                        }
                        else
                        {
                            JCHMessageBox.Show(Langauge.Current.GetMessage("SYSTEM_SAVED_SUCCESSFULLY")); //"System Saved Successfully");
                        }
                    }
                    else
                    {
                        JCHMessageBox.Show(Langauge.Current.GetMessage("SYSTEM_SAVED_SUCCESSFULLY"));// "System Saved Successfully");
                    }
                    if (win != null)
                    {
                        var w = Application.Current.MainWindow;
                        w.Hide();
                        //RefreshDashBoard();
                        var projectId = proj.projectID;
                        Application.Current.Properties["ProjectId"] = projectId;
                        ProjectInfoBLL            bll            = new ProjectInfoBLL();
                        JCHVRF.Entity.ProjectInfo projectNextGen = bll.GetProjectInfo(projectId);


                        projectNextGen.ProjectLegacy.RegionCode    = JCHVRF.Model.Project.CurrentProject.RegionCode;
                        projectNextGen.ProjectLegacy.SubRegionCode = JCHVRF.Model.Project.CurrentProject.SubRegionCode;
                        projectNextGen.ProjectLegacy.projectID     = projectId;
                        NavigationParameters param = new NavigationParameters();
                        param.Add("Project", projectNextGen.ProjectLegacy);
                        _eventAggregator.GetEvent <CleanupSystemWizard>().Publish();
                        //RegionManager.RequestNavigate(RegionNames.ContentRegion, ViewKeys.Splash, (a) => { win.Close(); }, param);
                        RegionManager.RequestNavigate(RegionNames.ContentRegion, ViewKeys.MasterDesigner, (a) => { win.Close(); }, param);
                        w.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                int?id = Project.GetProjectInstance?.projectID;
                Logger.LogProjectError(id, ex);
            }
        }