public async Task EnumerateSolutionsInRepository(RepositoryInfo repository)
        {
            Dictionary <string, Stream?> SolutionStreamTable = await GitHubApi.GitHub.EnumerateFiles(repository.Source, "/", ".sln");

            NotifyStatusUpdated();

            bool IsMainProjectExe = false;

            foreach (KeyValuePair <string, Stream?> Entry in SolutionStreamTable)
            {
                if (Entry.Value != null)
                {
                    string SolutionName   = Path.GetFileNameWithoutExtension(Entry.Key);
                    Stream SolutionStream = Entry.Value;

                    using StreamReader Reader = new(SolutionStream, Encoding.UTF8);
                    SlnExplorer.Solution Solution          = new(SolutionName, Reader);
                    List <ProjectInfo>   LoadedProjectList = new();

                    foreach (SlnExplorer.Project ProjectItem in Solution.ProjectList)
                    {
                        bool IsIgnored = ProjectItem.ProjectType > SlnExplorer.ProjectType.KnownToBeMSBuildFormat;

                        if (!IsIgnored)
                        {
                            byte[]? Content = await GitHubApi.GitHub.DownloadFile(repository.Source, ProjectItem.RelativePath);

                            NotifyStatusUpdated();

                            if (Content != null)
                            {
                                using MemoryStream Stream = new MemoryStream(Content);
                                ProjectItem.LoadDetails(Stream);
                            }

                            ProjectInfo NewProject = new(ProjectList, ProjectItem);
                            ProjectList.Add(NewProject);
                            LoadedProjectList.Add(NewProject);
                        }
                    }

                    if (LoadedProjectList.Count > 0)
                    {
                        SolutionInfo NewSolution = new(SolutionList, repository, Solution, LoadedProjectList);
                        SolutionList.Add(NewSolution);

                        foreach (ProjectInfo Item in NewSolution.ProjectList)
                        {
                            Item.ParentSolution = NewSolution;
                        }

                        repository.SolutionList.Add(NewSolution);

                        IsMainProjectExe |= CheckMainProjectExe(NewSolution);
                    }
                }
            }

            repository.IsMainProjectExe = IsMainProjectExe;
        }
예제 #2
0
        private async void GetProjectsCommand()
        {
            ProjectList.Clear();
            List <Project> tmp = new List <Project>();

            if (Mode == "my")
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading " + CurrentUser + "'s project(s)...", Level = "debug"
                });
                _logService.Write(this, "Loading " + CurrentUser + "'s project(s)...", "debug");
                tmp = await _dbService.GetProjects(Person);
            }
            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading all project(s)...", Level = "debug"
                });
                _logService.Write(this, "Loading all project(s)...", "debug");
                tmp = await _dbService.GetProjects();
            }
            OutputMessages.Add(new OutputMessage {
                Message = tmp.Count + " project(s) loaded!", Level = "debug"
            });
            _logService.Write(this, tmp.Count + " project(s) loaded", "debug");
            foreach (var item in tmp)
            {
                ProjectList.Add(item);
            }
        }
        /// <summary>
        /// Reads the directory and processes project files.
        /// </summary>
        /// <param name="projectFilePath">The project file path.</param>
        private void ReadDirectory(string projectFilePath)
        {
            if (!Directory.Exists(projectFilePath))
            {
                FireOnProcessingProject("    -> " + projectFilePath + " DOES NOT EXIST");
                return;
            }

            // Clean up the project file path in case it contains relative elements
            string projectFileDir = new DirectoryInfo(projectFilePath).FullName;

            foreach (string projectFile in Directory.GetFiles(projectFileDir, "*.csproj"))
            {
                ProcessProjectFile(projectFile);
                ProjectList.Add(projectFile);
            }

            foreach (string directory in Directory.GetDirectories(projectFileDir))
            {
                if (!directory.Contains(".svn"))
                {
                    //FireOnProcessingProject("Scanning  " + directory);
                    ReadDirectory(directory);
                }
            }
        }
예제 #4
0
        public void souldReturnFacsetSecuritiesWhenAddProject()
        {
            _projects = new ProjectList();

            var newProject = new ProjectTest.Builder()
                             .WithName("Facset")
                             .WithCode("ggn-001")
                             .Build();

            var expectedProject = new ProjectTest.Builder()
                                  .WithName("Facset")
                                  .WithCode("ggn-001")
                                  .Build();

            _projects.Add(newProject);

            Project firsElement;

            using (var e = _projects.GetEnumerator())
            {
                e.MoveNext();
                firsElement = e.Current;
            }

            Assert.True(firsElement.Name.Equals(expectedProject.Name));
        }
예제 #5
0
        /// <summary>
        /// In the given path and all folders below it, load all valid projects, currently only .csproj files
        /// </summary>
        /// <param name="SearchPath"></param>
        /// <returns></returns>
        public ProjectList GetAllProjects()
        {
            //return list of projects
            ProjectList projects = new ProjectList();
            Console.WriteLine("start to fetch .csproj files");
            //get list of all csproj files below current directory
            string[] FilePaths = Directory.GetFiles(SearchPath, "*.csproj", SearchOption.AllDirectories);
            foreach (string FilePath in FilePaths)
            {
                if (!FilePath.ToLower().Contains("mainline") && MainLineOnly.ToUpper().Equals("T"))
                    continue;
                else
                {
                    string FileName = new FileInfo(FilePath).Name;

                    //if not a unit test (Test or UnitTest.csproj, then add it
                    //TODO: refactor to allow exclusions to be passed in?
                    if (!FileName.StartsWith("Test") && !FileName.StartsWith("UnitTest"))
                    {
                        Console.WriteLine(string.Format("Adding project {0} ...", FilePath));
                        projects.Add(new Project(FilePath));
                    }
                }
            }
            return projects;
        }
예제 #6
0
 /// <summary>
 /// 试图加入
 /// </summary>
 /// <param name="project"></param>
 public void Add(ProjectConfig project)
 {
     if (!ProjectList.Contains(project))
     {
         ProjectList.Add(project);
     }
     GlobalConfig.Add(project);
 }
예제 #7
0
        /// <summary>
        /// Add a new ProjectDataJSON to the project manager
        /// You need to save the manager after adding an entry!
        /// </summary>
        /// <param name="newData">The new dataset to add</param>
        public void Add(ProjectDataJson newData)
        {
            string GUID = Guid.NewGuid().ToString();

            newData.Guid = GUID;

            _projects.Add(newData);
        }
        public void ShouldBeAbleToSaveProjectsThatALoaderCanLoad()
        {
            ExecutableTask builder = new ExecutableTask();

            builder.Executable = "foo";
            FileSourceControl sourceControl = new FileSourceControl();

            sourceControl.RepositoryRoot = "bar";
            // Setup
            Project project1 = new Project();

            project1.Name          = "Project One";
            project1.SourceControl = sourceControl;
            Project project2 = new Project();

            project2.Name          = "Project Two";
            project2.SourceControl = sourceControl;
            ProjectList projectList = new ProjectList();

            projectList.Add(project1);
            projectList.Add(project2);

            var mockConfiguration = new Mock <IConfiguration>();

            mockConfiguration.SetupGet(_configuration => _configuration.Projects).Returns(projectList).Verifiable();

            FileInfo configFile = new FileInfo(TempFileUtil.CreateTempFile(TempFileUtil.CreateTempDir(this), "loadernet.config"));

            // Execute
            DefaultConfigurationFileSaver saver = new DefaultConfigurationFileSaver(new NetReflectorProjectSerializer());

            saver.Save((IConfiguration)mockConfiguration.Object, configFile);

            DefaultConfigurationFileLoader loader = new DefaultConfigurationFileLoader();
            IConfiguration configuration2         = loader.Load(configFile);

            // Verify
            Assert.IsNotNull(configuration2.Projects["Project One"]);
            Assert.IsNotNull(configuration2.Projects["Project Two"]);
            mockConfiguration.Verify();
        }
예제 #9
0
        public void LoadFromFile()
        {
            var dlg = new OpenFileDialog()
            {
                Filter = "back testing project|*." + BacktestingResource.BacktestingProjectFileExt + "|analyse project|*." + BacktestingResource.AnalyseProjectFileExt + "| (*.*)|*.*"
            };

            if (dlg.ShowDialog() == true)
            {
                if (!dlg.FileName.EndsWith(BacktestingResource.AnalyseProjectFileExt))
                {
                    try {
                        var bp = CommonLib.CommonProc.LoadObjFromFile <BacktestingProject>(dlg.FileName);
                        if (bp != null)
                        {
                            bp.RecoverySerialObject();
                            var svm = new BacktestingProjectSummaryViewModel()
                            {
                                TargetProject = bp, Open = Open, Delete = Delete, Start = Start, Pause = Pause, Stop = Stop
                            };
                            ProjectList.Add(svm);
                            OpenBacktestingProject(svm);
                        }
                        return;
                    }
                    catch (Exception ex)
                    {
                        LogSupport.Error(ex);
                    }
                }
                if (!dlg.FileName.EndsWith(BacktestingResource.BacktestingProjectFileExt))
                {
                    try {
                        var ap = CommonLib.CommonProc.LoadObjFromFile <AnalyseProject>(dlg.FileName);
                        if (ap != null)
                        {
                            ap.RecoverySerialObject();
                            var svm = new AnalyseProjectSummaryViewModel()
                            {
                                TargetProject = ap, Open = Open, Delete = Delete, Start = Start, Pause = Pause, Stop = Stop
                            };
                            ProjectList.Add(svm);
                            OpenAnalyseProject(svm);
                        }
                        return;
                    }
                    catch (Exception ex)
                    {
                        LogSupport.Error(ex);
                    }
                }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="projects">Project list</param>
        public ProjectsView(IList<string> projects)
        {
            InitializeComponent();
            DataContext = this;

            SelectAll = true;

            foreach (var project in projects.Select(p => new ProjectModel(p)).Where(p => !string.IsNullOrWhiteSpace(p.Key)))
            {
                ProjectList.Add(project);
                project.OnSelected += OnItemSelected;
            }

        }
예제 #11
0
        public void ShouldReturn2ElementsInList()
        {
            _projects = new ProjectList();

            var expectedProjectNumber = 2;

            var newProject = new ProjectTest.Builder()
                             .WithName("Facset")
                             .WithCode("ggn-001")
                             .Build();

            var newProject2 = new ProjectTest.Builder()
                              .WithName("Sentry")
                              .WithCode("ggn-002")
                              .Build();

            _projects.Add(newProject);
            _projects.Add(newProject2);

            var currentProjectNumber = _projects.Count;

            Assert.Equal(expectedProjectNumber, currentProjectNumber);
        }
예제 #12
0
        public void CreatesProjectIntegrators()
        {
            // Setup
            Project project1 = new Project();

            project1.Name = "Project 1";
            Project project2 = new Project();

            project2.Name = "Project 2";
            ProjectList projectList = new ProjectList();

            projectList.Add(project1);
            projectList.Add(project2);

            // Execute
            IntegrationQueueSet    integrationQueues = new IntegrationQueueSet();
            IProjectIntegratorList integrators       = new ProjectIntegratorListFactory().CreateProjectIntegrators(projectList, integrationQueues);

            // Verify
            Assert.AreEqual(2, integrators.Count);
            Assert.AreEqual(project1, integrators["Project 1"].Project);
            Assert.AreEqual(project2, integrators["Project 2"].Project);
        }
예제 #13
0
        void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectList.Clear();
            LoadOperation loadOperation = sender as LoadOperation;

            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectList.Add(projectEntity);
            }

            UpdateChanged("ProjectList");
            IsBusy = false;
        }
예제 #14
0
 private void LoadOperationProjectCompleted(LoadOperation <ProductManager.Web.Model.project> aLoadOperation)
 {
     ProjectList.Clear();
     foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
     {
         ProjectEntity projectEntity = new ProjectEntity();
         projectEntity.Project = project;
         projectEntity.Update();
         ProjectList.Add(projectEntity);
     }
     if (aLoadOperation.TotalEntityCount != -1)
     {
         this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
     }
     UpdateChanged("ProjectList");
     this.IsBusy = false;
 }
예제 #15
0
        private void Initialize(StreamReader reader)
        {
            ConstructorInfo Constructor    = ReflectionTools.GetFirstTypeConstructor(SolutionParserType);
            var             SolutionParser = Constructor.Invoke(null);

            SolutionParserReader.SetValue(SolutionParser, reader, null);
            SolutionParserParseSolution.Invoke(SolutionParser, null);

            Array ProjetctArray = (Array)ReflectionTools.GetPropertyValue(SolutionParserProjects, SolutionParser);

            for (int i = 0; i < ProjetctArray.Length; i++)
            {
                Contract.RequireNotNull(ProjetctArray.GetValue(i), out object SolutionProject);
                Project NewProject = new Project(this, SolutionProject);

                ProjectList.Add(NewProject);
            }
        }
예제 #16
0
        private void AddProjectFileNameToList(string projectRelativeName)
        {
            string project;

            if (!_projectNameOnly)
            {
                //string projectFullName = Path.Combine(File.Directory.FullName, projectRelativeName);
                project = Path.Combine(File.Directory.FullName, projectRelativeName);
            }
            else
            {
                project = Path.GetFileNameWithoutExtension(projectRelativeName);
            }

            ProjectList.Add(new ProjectNameAndSync {
                Name = project
            });
        }
예제 #17
0
 private void HandleResponse(Package package)
 {
     if (package.Sender == 10)
     {
         if (package.Event == 10)
         {
             Todo newTodo = XmlSerializationHelper.Desirialize <Todo>(package.Data);
             lock (todoLock) TodoList.Add(newTodo);
         }
         else if (package.Event == 9)
         {
             List <Todo> newTodos = XmlSerializationHelper.Desirialize <List <Todo> >(package.Data);
             lock (todoLock) foreach (Todo newTodo in newTodos)
                 {
                     TodoList.Add(newTodo);
                 }
         }
         else if (package.Event == 2)
         {
             //fillMode = false;
             //sw.Stop();//int packagesCount = 1000;//MessageBox.Show(string.Format("{0} Packages in {1} Milliseconds ~ {2} packages per millisecond and {3} packages per second.", packagesCount, sw.ElapsedMilliseconds, packagesCount / sw.ElapsedMilliseconds, (packagesCount / sw.ElapsedMilliseconds) * 1000));
         }
     }
     else if (package.Sender == 12)
     {
         if (package.Event == 10)
         {
             Project newProject = XmlSerializationHelper.Desirialize <Project>(package.Data);
             lock (todoLock) ProjectList.Add(newProject);
         }
         else if (package.Event == 9)
         {
             List <Project> newTodos = XmlSerializationHelper.Desirialize <List <Project> >(package.Data);
             lock (projectLock) foreach (Project newTodo in newTodos)
                 {
                     ProjectList.Add(newTodo);
                 }
         }
         else if (package.Event == 2)
         {
             //sw.Stop();//int packagesCount = 1000;//MessageBox.Show(string.Format("{0} Packages in {1} Milliseconds ~ {2} packages per millisecond and {3} packages per second.", packagesCount, sw.ElapsedMilliseconds, packagesCount / sw.ElapsedMilliseconds, (packagesCount / sw.ElapsedMilliseconds) * 1000));
         }
     }
 }
예제 #18
0
        void LoadWorkspace()
        {
            var dlg = new OpenFileDialog()
            {
                Filter = "work space|*.workspace|(*.*)|*.*"
            };

            if (dlg.ShowDialog() == true)
            {
                var sp = CommonLib.CommonProc.LoadObjFromFile <Workspace>(dlg.FileName);
                if (sp != null)
                {
                    var count = sp.AnalyseList.Count + sp.BacktestingList.Count;
                    var array = new ProjectSummaryViewModelBase[count];
                    foreach (var kv in sp.AnalyseList)
                    {
                        kv.Value.RecoverySerialObject();
                        var svm = new AnalyseProjectSummaryViewModel()
                        {
                            TargetProject = kv.Value, Open = Open, Delete = Delete, Start = Start, Pause = Pause, Stop = Stop
                        };
                        array[kv.Key] = svm;
                    }
                    foreach (var kv in sp.BacktestingList)
                    {
                        kv.Value.RecoverySerialObject();
                        var svm = new BacktestingProjectSummaryViewModel()
                        {
                            TargetProject = kv.Value, Open = Open, Delete = Delete, Start = Start, Pause = Pause, Stop = Stop
                        };
                        array[kv.Key] = svm;
                    }
                    ProjectList.Clear();
                    foreach (var p in array)
                    {
                        ProjectList.Add(p);
                    }
                }
                else
                {
                    MessageBox.Show("Load workspace faild from " + dlg.FileName);
                }
            }
        }
예제 #19
0
        public ModelSolution(string fullPath)
        {
            FullPath = fullPath;
            FileName = Path.GetFileName(FullPath);


            var solutionDirectory = Path.GetDirectoryName(FullPath);

            if (solutionDirectory == null)
            {
                return;
            }

            var fileLines = File.ReadAllLines(FullPath);

            foreach (var s in fileLines)
            {
                if (!s.Contains("Project("))
                {
                    continue;
                }


                var project = string.Empty;

                try
                {
                    project = (s.Split(',')[1]).Trim(' ').Trim('\"');
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }

                var csprojFilePath = Path.Combine(solutionDirectory, project);

                if (File.Exists(csprojFilePath))
                {
                    var mProject = new ModelProject(csprojFilePath);
                    ProjectList.Add(mProject);
                } //else it's a solution folder
            }
        }
예제 #20
0
        public virtual DBResult ProjectsGet(out ProjectList projects)
        {
            projects = new ProjectList();
            DBResult result;

            QueryString sql = DB.Format(
                $"SELECT * FROM timekeep.projects ORDER by name");
            DatabaseDataReader reader;

            result = DB.Query(sql, out reader);
            using (reader)
            {
                if (result.ResultCode == DBResult.Result.Success)
                {
                    while (reader.Read())
                    {
                        Project_DO project = DataReaderConverter.CreateClassFromDataReader <Project_DO>(reader);
                        projects.Add(project);
                    }
                }
            }
            return(result);
        }
예제 #21
0
        private void LoadProjects()
        {
            try
            {
                ProjectList.Clear();
                string task = "loadProjects";

                client = new TcpClient();
                client.Connect(ep);

                NetworkStream ns = client.GetStream();
                StreamWriter  sw = new StreamWriter(ns);
                sw.WriteLine(task);
                sw.Flush();


                byte[] data  = new byte[50000];
                int    bytes = ns.Read(data, 0, data.Length);
                ObservableCollection <ClassesLibaryBilling.Project> pl = new ObservableCollection <ClassesLibaryBilling.Project>();
                pl = FromByteArray <ObservableCollection <ClassesLibaryBilling.Project> >(data);

                foreach (var item in pl)
                {
                    ProjectList.Add(item);
                }


                sw.Close();
                ns.Close();
                client.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Сервер выключен либо отсутствует соидинение с интеренетом");
            }
        }
예제 #22
0
파일: ProjectData.cs 프로젝트: jbob24/KPFF
        private static ProjectList ConvertReaderDataToProjectList(SqlDataReader reader)
        {
            ProjectList projects = null;

            if (reader.HasRows)
            {
                projects = new ProjectList();
                while (reader.Read())
                {
                    var project = new Project();

                    project.Id = reader.GetValueOrDefault<int>("ID");
                    project.ProjectNumber = reader.GetValueOrDefault<decimal>("ProjectNo");
                    project.Name = reader.GetValueOrDefault<string>("ProjectName");
                    project.ClientId = reader.GetValueOrDefault<int>("ClientID");
                    project.StatusId = reader.GetValueOrDefault<int>("ProjectStatus");
                    project.Location = reader.GetValueOrDefault<string>("ProjectLocation");
                    project.ConstructionType = reader.GetValueOrDefault<string>("ConstructionType");
                    project.ProjectType = reader.GetValueOrDefault<string>("ProjectType");
                    project.PhaseId = reader.GetValueOrDefault<int>("PhaseID");
                    project.EstimatedStartDate = reader.GetValueOrDefault<DateTime>("EstimatedStartDate");
                    project.EstimatedCompletionDate = reader.GetValueOrDefault<DateTime>("EstimatedCompletionDate");
                    project.FeeAmount = reader.GetValueOrDefault<decimal>("FeeAmount");
                    project.FeeStructure = reader.GetValueOrDefault<string>("FeeStructure");
                    project.ContractTypeId = reader.GetValueOrDefault<int>("ContractType");
                    project.PICId = reader.GetValueOrDefault<int>("PIC");
                    project.PM1Id = reader.GetValueOrDefault<int>("PM1");
                    project.PM2Id = reader.GetValueOrDefault<int>("PM2");
                    project.LastModifiedByUserId = reader.GetValueOrDefault<int>("LastModifiedByUserID");
                    project.PICCode = reader.GetValueOrDefault<string>("PICCode");
                    project.PM1Code = reader.GetValueOrDefault<string>("PM1Code");
                    project.PM2Code = reader.GetValueOrDefault<string>("PM2Code");
                    project.Comments = reader.GetValueOrDefault<string>("Comments");
                    project.IsActive = reader.GetValueOrDefault<bool>("Active");
                    project.LastModifiedDate = reader.GetValueOrDefault<DateTime>("LastModifiedDate");

                    projects.Add(project);
                }
            }

            return projects;
        }
예제 #23
0
 private void NewProject()
 {
     SelectedProject = new Project();
     ProjectList.Add(SelectedProject);
 }
예제 #24
0
        /// <summary>
        /// Initialises the server.
        /// </summary>
        /// <param name="mocks">The mocks repository.</param>
        /// <param name="buildName">Name of the build.</param>
        /// <param name="buildLog">The build log.</param>
        /// <returns>The initialised server.</returns>
        private static CruiseServer InitialiseServer(MockRepository mocks, string buildName, string buildLog)
        {
            // Add some projects
            var projects = new ProjectList();
            var project  = new Project
            {
                Name = testProjectName
            };

            projects.Add(project);

            // Mock the configuration
            var configuration = mocks.StrictMock <IConfiguration>();

            SetupResult.For(configuration.Projects)
            .Return(projects);
            SetupResult.For(configuration.SecurityManager)
            .Return(new NullSecurityManager());

            // Mock the configuration service
            var configService = mocks.StrictMock <IConfigurationService>();

            SetupResult.For(configService.Load())
            .Return(configuration);
            Expect.Call(() => { configService.AddConfigurationUpdateHandler(null); })
            .IgnoreArguments();

            // Mock the integration repostory
            var repository = mocks.StrictMock <IIntegrationRepository>();

            SetupResult.For(repository.GetBuildLog(buildName))
            .Return(buildLog);

            // Mock the project integrator
            var projectIntegrator = mocks.StrictMock <IProjectIntegrator>();

            SetupResult.For(projectIntegrator.Project)
            .Return(project);
            SetupResult.For(projectIntegrator.IntegrationRepository)
            .Return(repository);

            // Mock the queue manager
            var queueManager = mocks.StrictMock <IQueueManager>();

            Expect.Call(() => { queueManager.AssociateIntegrationEvents(null, null); })
            .IgnoreArguments();
            SetupResult.For(queueManager.GetIntegrator(testProjectName))
            .Return(projectIntegrator);

            // Mock the queue manager factory
            var queueManagerFactory = mocks.StrictMock <IQueueManagerFactory>();

            SetupResult.For(queueManagerFactory.Create(null, configuration, null))
            .Return(queueManager);
            IntegrationQueueManagerFactory.OverrideFactory(queueManagerFactory);

            // Mock the execution environment
            var execEnviron = mocks.StrictMock <IExecutionEnvironment>();

            SetupResult.For(execEnviron.GetDefaultProgramDataFolder(ApplicationType.Server))
            .Return(string.Empty);

            // Initialise the server
            mocks.ReplayAll();
            var server = new CruiseServer(
                configService,
                null,
                null,
                null,
                null,
                execEnviron,
                null);

            return(server);
        }
예제 #25
0
        /// <summary>
        /// Initialises the server.
        /// </summary>
        /// <param name="mocks">The mocks repository.</param>
        /// <param name="buildName">Name of the build.</param>
        /// <param name="buildLog">The build log.</param>
        /// <returns>The initialised server.</returns>
        private static CruiseServer InitialiseServer(MockRepository mocks, string buildName, string buildLog)
        {
            // Add some projects
            var projects = new ProjectList();
            var project  = new Project
            {
                Name = testProjectName
            };

            projects.Add(project);

            // Mock the configuration
            var configuration = mocks.Create <IConfiguration>(MockBehavior.Strict).Object;

            Mock.Get(configuration).SetupGet(_configuration => _configuration.Projects)
            .Returns(projects);
            Mock.Get(configuration).SetupGet(_configuration => _configuration.SecurityManager)
            .Returns(new NullSecurityManager());

            // Mock the configuration service
            var configService = mocks.Create <IConfigurationService>(MockBehavior.Strict).Object;

            Mock.Get(configService).Setup(_configService => _configService.Load())
            .Returns(configuration);
            Mock.Get(configService).Setup(_configService => _configService.AddConfigurationUpdateHandler(It.IsAny <ConfigurationUpdateHandler>())).Verifiable();

            // Mock the integration repostory
            var repository = mocks.Create <IIntegrationRepository>(MockBehavior.Strict).Object;

            Mock.Get(repository).Setup(_repository => _repository.GetBuildLog(buildName))
            .Returns(buildLog);

            // Mock the project integrator
            var projectIntegrator = mocks.Create <IProjectIntegrator>(MockBehavior.Strict).Object;

            Mock.Get(projectIntegrator).SetupGet(_projectIntegrator => _projectIntegrator.Project)
            .Returns(project);
            Mock.Get(projectIntegrator).SetupGet(_projectIntegrator => _projectIntegrator.IntegrationRepository)
            .Returns(repository);

            // Mock the queue manager
            var queueManager = mocks.Create <IQueueManager>(MockBehavior.Strict).Object;

            Mock.Get(queueManager).Setup(_queueManager => _queueManager.AssociateIntegrationEvents(It.IsAny <EventHandler <IntegrationStartedEventArgs> >(), It.IsAny <EventHandler <IntegrationCompletedEventArgs> >())).Verifiable();
            Mock.Get(queueManager).Setup(_queueManager => _queueManager.GetIntegrator(testProjectName))
            .Returns(projectIntegrator);

            // Mock the queue manager factory
            var queueManagerFactory = mocks.Create <IQueueManagerFactory>(MockBehavior.Strict).Object;

            Mock.Get(queueManagerFactory).Setup(_queueManagerFactory => _queueManagerFactory.Create(null, configuration, null))
            .Returns(queueManager);
            IntegrationQueueManagerFactory.OverrideFactory(queueManagerFactory);

            // Mock the execution environment
            var execEnviron = mocks.Create <IExecutionEnvironment>(MockBehavior.Strict).Object;

            Mock.Get(execEnviron).Setup(_execEnviron => _execEnviron.GetDefaultProgramDataFolder(ApplicationType.Server))
            .Returns(string.Empty);

            // Initialise the server
            var server = new CruiseServer(
                configService,
                null,
                null,
                null,
                null,
                execEnviron,
                null);

            return(server);
        }
예제 #26
0
        private void GetDistinctProjects(ProjectList projects, ProjectList projectList)
        {
            // ProjectList projectList = new ProjectList();
            foreach (Project project in projects)
            {

                if (!projectList.Any(x => x.Name == project.Name))
                    projectList.Add(project);

                foreach (string refer in project.ReferenceList)
                {
                    Project tmp = new Project();
                    tmp.Name = refer;
                    if (!projectList.Any(x => x.Name == refer))
                        projectList.Add(tmp);
                }

                foreach (Project reference in project.ReferencedProjects)
                {
                    if (!projectList.Any(x => x.Name == reference.Name))
                    {
                        projectList.Add(reference);
                        GetDistinctProjects(reference.ReferencedProjects, projectList);
                    }
                }

            }
        }
예제 #27
0
 public void AddProject(IProject project)
 {
     projects.Add(project);
 }
예제 #28
0
 public virtual void AddProject(Project project)
 {
     ProjectList.Add(project);
 }
		/// <summary>コピーコンストラクタ。</summary>
		/// <param name="previous"></param>
		public ProjectManifestData(ProjectManifestData previous)
			{
			ManifestVisualizingLayer = new VirtualLayer();

			_SimulationRegion = new SimulationRegionData( previous.SimulationRegion );
			SimulationTime = previous.SimulationTime;
			Resolution = previous.Resolution;
			_BackgroundMaterial = new MaterialData( previous.BackgroundMaterial );

			Sources = new ProjectList<SourceData>();
			foreach( SourceData src in previous.Sources )
				Sources.Add( src.MakeDeepCopy() );

			FluxAnalyses = new ProjectList<FluxAnalysisData>( previous.FluxAnalyses );
			foreach( FluxAnalysisData flx in previous.FluxAnalyses )
				FluxAnalyses.Add( new FluxAnalysisData( flx ) );

			VisualizationOutputs = new ProjectList<VisualizationOutputData>( previous.VisualizationOutputs );
			foreach( VisualizationOutputData vis in previous.VisualizationOutputs )
				VisualizationOutputs.Add( new VisualizationOutputData( vis ) );

			ManifestVisualizingLayer.Shapes.AddRange( SimulationRegion.Shapes );
			SimulationRegion.Parent = this;
			BackgroundMaterial.Parent = this;
			}