コード例 #1
0
        // Failing !!! needs fix!!! in UserProfile have one list of recent as string and one as objects causin exception
        public void NewProfileSaveLoad()
        {
            //Arrange
            UserProfile userProfile = new UserProfile();
            // string UserProfileFileName = Path.Combine(TestResources.GetTempFile("UserProfile.Ginger.xml"));
            // UP.FileName = UserProfileFileName;
            // WorkSpace.Instance.UserProfile = userProfile;


            string   LastSolutionFolder = @"c:\ginger\sol1";
            Solution solution           = new Solution()
            {
                Name = "sol1", Folder = LastSolutionFolder
            };                                                                                 // just something to verify it is loaded later doesn't need to exist


            //Act
            userProfile.AddSolutionToRecent(solution);
            userProfile.SaveUserProfile();

            // WorkSpace.Instance.UserProfile = new UserProfile

            UserProfile UP2 = UserProfile.LoadUserProfile();

            //Assert
            Assert.AreEqual(LastSolutionFolder, UP2.RecentSolutions[0]);
        }
コード例 #2
0
ファイル: WorkSpace.cs プロジェクト: anthrax3/Ginger
        public bool OpenSolution(string solutionFolder)
        {
            try
            {
                Reporter.ToLog(eLogLevel.INFO, string.Format("Loading the Solution '{0}'", solutionFolder));
                LoadingSolution = true;

                //Cleaning previous Solution load
                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Cleaning previous Solution items");
                CloseSolution();

                //Load Solution file
                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Opening Solution located at: " + solutionFolder);
                string solutionFile = System.IO.Path.Combine(solutionFolder, @"Ginger.Solution.xml");
                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading Solution File: " + solutionFile);
                if (System.IO.File.Exists(solutionFile))
                {
                    Reporter.ToLog(eLogLevel.DEBUG, "Loading Solution- Solution File exist");
                }
                else
                {
                    if (!File.Exists(Amdocs.Ginger.IO.PathHelper.GetLongPath(solutionFile)))
                    {
                        //Reporter.ToUser(eUserMsgKey.BeginWithNoSelectSolution);
                        Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Solution File Not Found");
                        return(false);
                    }
                }

                //Checking if Ginger upgrade is needed
                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Checking if Ginger Solution items upgrade is needed");
                IEnumerable <string> solutionFiles = Solution.SolutionFiles(solutionFolder);
                SolutionUpgrade.ClearPreviousScans();
                if (SolutionUpgrade.IsGingerUpgradeNeeded(solutionFolder, solutionFiles))
                {
                    Reporter.ToLog(eLogLevel.WARN, "Loading Solution- Error: Current Ginger version can't load the Solution because it includes items from higher Ginger version");
                    return(false);
                }

                Reporter.ToLog(eLogLevel.DEBUG, "Loading Solution- Loading Solution.xml into object");
                Solution solution = Solution.LoadSolution(solutionFile);
                if (solution == null)
                {
                    Reporter.ToUser(eUserMsgKey.SolutionLoadError, "Failed to load the Solution file");
                    Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Failed to load the Solution file");
                    return(false);
                }

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Creating Items Repository");
                SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository();
                SolutionRepository.Open(solutionFolder);

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading needed Plugins");
                mPluginsManager = new PluginsManager();
                mPluginsManager.SolutionChanged(SolutionRepository);

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Doing Source Control Configurations");
                HandleSolutionLoadSourceControl(solution);

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Updating Application Functionalities to Work with Loaded Solution");
                ValueExpression.SolutionFolder = solutionFolder;
                BusinessFlow.SolutionVariables = solution.Variables;
                solution.SetReportsConfigurations();
                Solution = solution;
                UserProfile.LoadRecentAppAgentMapping();

                if (!RunningInExecutionMode)
                {
                    AppSolutionRecover.DoSolutionAutoSaveAndRecover();
                }

                //Solution items upgrade
                SolutionUpgrade.CheckSolutionItemsUpgrade(solutionFolder, solution.Name, solutionFiles.ToList());

                // No need to add solution to recent if running from CLI
                if (!RunningInExecutionMode)
                {
                    UserProfile.AddSolutionToRecent(solution);
                }

                // PlugInsManager = new PluginsManager();
                // mPluginsManager.Init(SolutionRepository);

                Reporter.ToLog(eLogLevel.INFO, string.Format("Finished Loading successfully the Solution '{0}'", solutionFolder));
                return(true);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Unexpected Error occurred while loading the solution", ex);
                CloseSolution();
                throw ex;
            }
            finally
            {
                LoadingSolution = false;
            }
        }