private void btnStartProxy_Click(object sender, EventArgs e) { SuProxyConfiguration spc = new SuProxyConfiguration(8080, 100, 20, 2 * 60 * 1000, 2); spc.ConfigurationFiles = new String[] { Path.GetDirectoryName(Assembly.GetAssembly(typeof(SuProxyControlPanelForm)).Location) + "\\conf\\SuProxy.default.config", Path.GetDirectoryName(Assembly.GetAssembly(typeof(SuProxyControlPanelForm)).Location) + "\\conf\\SuProxy.Standalone.config" }; proxyServer = new SuProxyServer(spc); proxyServer.Start(); btnStartProxy.Enabled = false; }
public void Release() { try { if (_processSync != null) { _processSync.ReleaseMutex(); } _processSync = null; } catch { } if (_owned) { _owned = false; } try { if (generatedTempFilename != null) { File.Delete(generatedTempFilename); } } catch { } if (proxy != null) { try { proxy.Stop(); } catch { } try{ proxy.Dispose(); } catch { } } proxy = null; }
public int Run() { if (startInfo.IsValid() == false) { return((int)(PageDataCollectorErrors.InvalidOrMissingArguments)); } _processSync = new Mutex(true, Assembly.GetAssembly(typeof(PageDataCollector)).GetName().Name, out _owned); if (_owned == false) { return((int)(PageDataCollectorErrors.TestAlreadyRunning)); } //Start Proxy if (startInfo.IsStartProxy) { EngineSuProxyConfiguration spc = EngineSuProxyConfiguration.Default; if (startInfo.ConfigFiles == null) { return((int)PageDataCollectorErrors.InvalidConfiguration); } foreach (String s in startInfo.ConfigFiles) { if (s == null || File.Exists(s) == false) { return((int)PageDataCollectorErrors.InvalidConfiguration); } } spc.ProxyPort = startInfo.ProxyPort; spc.DumpFolder = startInfo.DumpFolder; spc.URL = startInfo.URL; spc.CollectionID = startInfo.CollectionID; spc.ConfigurationFiles = startInfo.ConfigFiles; try { proxy = new SuProxyServer(spc); proxy.Start(); } catch { Release(); return((int)(PageDataCollectorErrors.CantStartProxy)); } startInfo.ProxyAddress = "http://localhost:" + spc.ProxyPort; } String host = null; try { Uri i = new Uri(startInfo.URL); host = i.Host; } catch { } if (String.IsNullOrEmpty(host)) { host = "msfast.myspace.com"; } //Create "pre collection" test page String launchWith = String.Format("http://{0}?PRE_COLLECTION={1}&__r={2}&__c={3}", host, Convert.ToBase64String(Encoding.UTF8.GetBytes(new Uri(startInfo.URLWithCollectionArgs).AbsoluteUri.ToString())), startInfo.CollectionID, ((int)startInfo.CollectionType).ToString()); if (launchWith == null) { return((int)PageDataCollectorErrors.CantSaveTempFile); } startInfo.LaunchWithURL = launchWith; TestBrowser bw = null; #if InternetExplorer try { bw = new BrowserWrapperIEImpl(); return(bw.StartTest(startInfo)); } finally{ if (bw != null) { bw.Dispose(); } } #else return(0); #endif }