Exemplo n.º 1
0
        public MainRequestHandler(ISecurityCheck security)
        {
            _security = security;


            ExternalEndpoint = AnySetting("PrimaryCallbackAddress");

            var settingValid = bool.TryParse(AnySetting("UpgradeHttp"), out var httpUpgradeSetting);

            UpgradeHttp = HttpsAvailable && httpUpgradeSetting && settingValid;

            var timer = new Stopwatch();

            timer.Start();
            _versionTable = new VersionTable <SiteHost>();

            _baseFolder = AppDomain.CurrentDomain.BaseDirectory;
            if (Directory.Exists(AnySetting("HostedSitesRootDirectory")))
            {
                // use directly specified folder
                _watchFolder = AnySetting("HostedSitesRootDirectory");
            }
            else
            {
                // use general working folder (best for Azure?)
                _watchFolder = Path.Combine(_baseFolder, "uploads");
                Directory.CreateDirectory(_watchFolder);
            }

            AvailableAppScanner = new PluginScanner(_watchFolder);
            AvailableAppScanner.PluginsChanged += AvailableAppWatcher_PluginsChanged;

            // Load initial versions out-of-band so we don't appear dead at start-up
            new Thread(() =>
            {
                try
                {
                    _firstScan = true;
                    Trace.TraceInformation("Initial scan started");
                    AvailableAppScanner.RefreshPlugins();
                    Trace.TraceInformation("Initial scan complete");
                }
                finally
                {
                    _firstScan = false;
                    timer.Stop();
                    _warmUp = timer.Elapsed;
                    Console.WriteLine("Ready");
                }
            })
            {
                IsBackground = true
            }.Start();
        }
Exemplo n.º 2
0
        private void testSourceButton_Click(object sender, EventArgs e)
        {
            var scan = new PluginScanner(sourceFolderTxt.Text);

            scan.RefreshPlugins();
            var table = new VersionTable <string>();

            sourceTestResult.Text = "Scanning";
            sourceTestResult.Refresh();

            string[] all   = null;
            var      task1 = new Thread(() =>
            {
                all = scan.CurrentlyAvailable.ToArray();
            });

            task1.Start();
            while (task1.IsAlive)
            {
                Application.DoEvents();
            }

            if (!all.Any())
            {
                sourceTestResult.Text = "No binaries found";
                return;
            }

            List <string> versions = null;
            var           task2    = new Thread(() =>
            {
                foreach (var path in all)
                {
                    table.SubmitVersion(path, (typePath, versionName, major) => versionName.Replace("_", "."));
                }

                versions = table.AllVersions().ToList();
            });

            task2.Start();
            while (task2.IsAlive)
            {
                Application.DoEvents();
            }

            if (!versions.Any())
            {
                sourceFolderTxt.Text = "No versioned entry points found";
                return;
            }

            sourceTestResult.Text = "Found: " + string.Join("; ", versions);
        }