Пример #1
0
        public void Build(BuildOptions options)
        {
            if (IsBuilding)
            {
                return;
            }

            _globalSettings = GlobalSettings.Load(_output);
            var settings = new Settings(_globalSettings, options, _output);

            if (options.CleanCache)
            {
                CacheCleaner.Run(settings);
                return;
            }

            lock (_lock)
            {
                _processLauncher     = new ProcessLauncher(settings);
                _lastBuildWasStopped = false;
                _isBeingStopped      = false;
                _buildThread         = new Thread(() => BuildThread(settings))
                {
                    IsBackground = true
                };
                _buildThread.Start();
            }
        }
Пример #2
0
        public static void Init()
        {
            //Path Setup
            DirectorySetup();
            LoadGwClientInfo();
            CheckGwClientVersion();

            //Updater Network Protocol
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            VersionSwitcher.DeleteUpdater();
            VersionSwitcher.CheckForUpdate();

            //Account Import Export
            AccountManager.ImportAccounts();
            ClientManager.ImportActiveClients();
            CrashAnalyzer.ReadCrashLogs();
            IconManager.Init();

            //Temp AddonManager
            AddOnManager.LoadAddons(LBAddonPath);
            AddOnManager.LaunchLbAddons();

            Hotkeys.RegisterAll();

            //Cleanup Plugin folder
            PluginManager.RemoveUninstalledPlugins();
            PluginManager.AddToInstallPlugins();

            //Cleanup CacheFolder
            CacheCleaner.Clean();
        }
Пример #3
0
        private int Run(string[] args)
        {
            _output = new ConsoleOutput();

            try
            {
                BuildOptions options = ParseBuildOptions(args);
                if (options == null || options.Solution == null)
                {
                    return(1);
                }

                GlobalSettings globalSettings = GlobalSettings.Load(_output);
                globalSettings.Save();
                var settings = new Settings(globalSettings, options, _output);

                var stopwatch = new Stopwatch();
                stopwatch.Start();

                int exitCode = 0;
                if (options.CleanCache)
                {
                    CacheCleaner.Run(settings);
                }
                else
                {
                    var          solutionReaderWriter = new SolutionReaderWriter(settings);
                    SolutionInfo solutionInfo         = solutionReaderWriter.ReadWrite(options.Solution.FullName);
                    settings.SolutionSettings = SolutionSettings.Load(settings, solutionInfo);
                    var projectReaderWriter = new ProjectReaderWriter(settings);
                    projectReaderWriter.ReadWrite(solutionInfo);
                    settings.SolutionSettings.UpdateAndSave(settings, solutionInfo);

                    if (!options.GenerateOnly)
                    {
                        var processLauncher = new ProcessLauncher(settings);
                        Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs cancelArgs)
                        {
                            _output.WriteLine("Stopping build...");
                            processLauncher.Stop();
                            cancelArgs.Cancel = true;
                        };

                        exitCode = processLauncher.Run(solutionInfo);
                    }
                }

                stopwatch.Stop();
                TimeSpan ts            = stopwatch.Elapsed;
                string   buildTimeText = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
                _output.WriteLine("Build time: " + buildTimeText);

                return(exitCode);
            }
            catch (Exception e)
            {
                _output.WriteLine("ERROR: " + e.Message);
                return(-1);
            }
        }
Пример #4
0
 public static void OnlineHost(int id)
 {
     using (var db = new BST_STATISTICSEntities())
     {
         var result = db.HOSTS.SingleOrDefault(b => b.id == id);
         if (result != null)
         {
             Log.FeedLog(string.Format("Host '{0}' has set online", result.name));
             result.inactive = null;
             db.SaveChanges();
         }
     }
     CacheCleaner.ResetCache();
 }
Пример #5
0
        public void DeletesCacheDirectory()
        {
            var be = new Mock <IBuilderEnumerator>();

            be.Setup(b => b.GetAllPersistentBuilders()).Returns(new Type[0]);

            var parameters = new Mock <ICleanParameters>();
            var cdir       = new TestFileSystemDirectory("cache");
            var cleaner    = new CacheCleaner(cdir, be.Object);

            cdir.IsDeleted.Should().BeFalse();
            cleaner.Clean(parameters.Object);
            cdir.IsDeleted.Should().BeTrue();
        }
Пример #6
0
        public void KeepsPersistentReferences()
        {
            var cdir = new TestFileSystemDirectory("cache",
                                                   new[]
            {
                new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"),
                new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"),
                new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"),
                new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4")
            });

            var be = new Mock <IBuilderEnumerator>();

            be.Setup(b => b.GetAllPersistentBuilders()).Returns(new[] { typeof(PersistentReference) });

            var predicates = new SoftCleanPredicates();
            var cleaner    = new CacheCleaner(new Lazy <IFileSystemDirectory>(() => cdir), be.Object, () => predicates);

            cdir.IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"))
            .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"))
            .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"))
            .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4"))
            .IsDeleted.Should().BeFalse();

            var parameters = new Mock <ICleanParameters>();

            parameters.SetupGet(p => p.KeepReferences).Returns(true);

            cleaner.Clean(parameters.Object);

            cdir.IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"))
            .IsDeleted.Should().BeTrue();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"))
            .IsDeleted.Should().BeTrue();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"))
            .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4"))
            .IsDeleted.Should().BeFalse();
        }
Пример #7
0
 public static void StartStopHost(int id, bool start)
 {
     using (var db = new BST_STATISTICSEntities())
     {
         var result = db.HOSTS.SingleOrDefault(b => b.id == id);
         if (result != null)
         {
             if (start)
             {
                 Log.FeedLog(string.Format("Host '{0}' has been started", result.name));
                 result.poweron = true;
             }
             else
             {
                 Log.FeedLog(string.Format("Host '{0}' has been stopped", result.name));
                 result.poweroff = true;
             }
             db.SaveChanges();
         }
     }
     CacheCleaner.ResetCache();
 }