private void ApplyNewSettings(ProxyInformation proxy, int port) { StopListener(); listener.Port = port; Proxy.Set(proxy); StartListener(); }
public SettingsViewPresenter(ISettingsView view, ProxyInformation proxyInformation) { this.view = view; this.proxyInformation = proxyInformation; view.Presenter = this; }
private static void Run(int port, ProxyInformation proxyInformation) { Proxy.Set(proxyInformation); var listener = Container.Resolve <Listener>(); listener.Port = port; var view = new ToolTrayForm(); var presenter = new ListenerViewPresenter( view, new ErrorsView(), listener); try { presenter.Show(); try { presenter.StartListener(); } catch (Exception e) { MessageBox.Show(string.Format("Could not start listening: {0}{1}{2}", e.Message, Environment.NewLine, e)); return; } Application.Run(view); } finally { presenter.StopListener(); } }
public static bool IsValidTFSUrl(string url, ProxyInformation proxyInformation) { try { WebRequest request = WebRequest.Create(url + "/Services/v1.0/Registration.asmx"); request.Credentials = CredentialCache.DefaultNetworkCredentials; request.Proxy = CreateProxy(proxyInformation); request.Timeout = 20000; using (WebResponse response = request.GetResponse()) { StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string output = reader.ReadToEnd(); return(output.Contains("Team Foundation Registration web service")); } } catch (WebException e) { HttpWebResponse response = e.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.Unauthorized) { // we need to ensure that common case of: // http://server:80 <- share point // htpp://server:8080 <- TFS return(response.Headers["MicrosoftSharePointTeamServices"] == null); } return(false); } catch { return(false); } }
public void SetInformation(ProxyInformation information) { portTxtBox.Text = information.Port.ToString(); usernameTxtBox.Text = information.Username; useDefaultCredetialsCheckBox.Checked = information.UseDefaultCredentails; passwordTxtBox.Text = information.Password; proxyUrlTxtBox.Text = information.Url; tfsProxyUrlTxtBox.Text = information.TfsProxyUrl; }
private bool Contains(ProxyInformation proxyInfo) { foreach (var item in this) { if (item.ID == proxyInfo.ID && item.Caption == proxyInfo.DisplayName && item.Component == item.Component && item.Library == proxyInfo.Library) return true; } return false; }
private bool Contains(ProxyInformation proxyInfo) { foreach (var item in this) { if (item.ID == proxyInfo.ID && item.Caption == proxyInfo.DisplayName && item.Component == item.Component && item.Library == (String.IsNullOrWhiteSpace(proxyInfo.Library) ? "<Unknown>" : proxyInfo.Library)) { return(true); } } return(false); }
/// <summary> /// Loads the provided paths from the DataObject based on the provided proxy information. /// </summary> /// <param name="dataObject">DataObject that has to be partially loaded (unproxied).</param> /// <param name="proxyInformation">Proxy information of the DataObject to be used in the loading process.</param> /// <param name="paths">Paths to be loaded (unproxied) on the provided DataObject.</param> public void Load(IDataObject dataObject, ProxyInformation proxyInformation, IList<String> paths) { if (OnLoadCompleted != null) { OnLoadCompleted(this, new LoadEventArgs() { DataObject = dataObject, ProxyInformation = proxyInformation, Paths = paths }); } }
private static bool TryGetSettings(ref int?port, ProxyInformation proxyInfo) { var view = new SettingsForm(); var presenter = new SettingsViewPresenter(view, proxyInfo); presenter.Port = port ?? Configuration.TfsPort; presenter.Show(); if (!presenter.Canceled) { port = presenter.Port; SaveSettings(proxyInfo, presenter.Port); } return(!presenter.Canceled); }
public static IWebProxy CreateProxy(ProxyInformation proxyInformation) { if (proxyInformation.UseProxy == false) { return(null); } IWebProxy proxy = new WebProxy(proxyInformation.Url, proxyInformation.Port); ICredentials credential; if (proxyInformation.UseDefaultCredentails) { credential = CredentialCache.DefaultNetworkCredentials; } else { credential = new NetworkCredential(proxyInformation.Username, proxyInformation.Password); } proxy.Credentials = credential; return(proxy); }
private static void Main(string[] args) { Logging.TraceEnabled = Configuration.TraceEnabled; Logging.MethodTraceEnabled = false; BootStrapper.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); int?port; if (args.Length > 0) { ushort tmp; if (ushort.TryParse(args[0], out tmp)) { port = tmp; } else { MessageBox.Show("Could not parse port: " + args[0] + ". If the port is explicitly specified it must be numeric 0 - 65536"); return; } } else { port = TryGetPortFromSettings(); } ProxyInformation proxyInfo = GetProxyInfo(); bool hasPortFromRequest = port != null && Helper.IsPortInUseOnLocalHost(port.Value) == false; if (hasPortFromRequest || TryGetSettings(ref port, proxyInfo)) { Run(port ?? 8081, proxyInfo); } }
public static void SaveSettings(ProxyInformation proxyInfo, int port) { byte[] password = null; if (proxyInfo.Password != null) { password = ProtectedData.Protect( Encoding.UTF8.GetBytes(proxyInfo.Password), Encoding.UTF8.GetBytes("ProxyEncryptedPassword"), DataProtectionScope.CurrentUser ); } Configuration.TfsPort = port; Configuration.TfsProxyUrl = proxyInfo.TfsProxyUrl; Configuration.UseProxy = proxyInfo.UseProxy; Configuration.ProxyUrl = proxyInfo.Url; Configuration.ProxyPort = proxyInfo.Port; Configuration.ProxyUseDefaultCredentials = proxyInfo.UseDefaultCredentails; Configuration.ProxyUsername = proxyInfo.Username; Configuration.ProxyEncryptedPassword = password; Configuration.Save(); }
public static ProxyInformation GetProxyInfo() { var proxyInfo = new ProxyInformation(); proxyInfo.UseProxy = Configuration.UseProxy; proxyInfo.TfsProxyUrl = Configuration.TfsProxyUrl; proxyInfo.Url = Configuration.ProxyUrl; proxyInfo.Port = Configuration.ProxyPort; proxyInfo.UseDefaultCredentails = Configuration.ProxyUseDefaultCredentials; proxyInfo.Username = Configuration.ProxyUsername; if (Configuration.ProxyEncryptedPassword != null) { byte[] password = ProtectedData.Unprotect( Configuration.ProxyEncryptedPassword, Encoding.UTF8.GetBytes("ProxyEncryptedPassword"), DataProtectionScope.CurrentUser ); proxyInfo.Password = Encoding.UTF8.GetString(password); } return(proxyInfo); }
/// <summary> /// Creates an instance of the class /// </summary> /// <param name="caller">calling instance</param> /// <param name="contractType">netoffice contract type, can be null</param> /// <param name="comProxy">native proxy type</param> public ResolveEventArgs(ICOMObject caller, Type contractType, object comProxy) { Caller = caller; Contract = contractType; Proxy = ProxyInformation.Create(comProxy); }
public static void Main(string[] args) { // Define db connections DBClient dbcli = new DBClient("facebook", "adam", "sutdigsevl"); IMongoCollection <object> coll = dbcli.ConnectToCollection("facebook", "posts_test2"); IMongoCollection <object> commentColl = dbcli.ConnectToCollection("facebook", "comments_test2"); IMongoCollection <object> feedColl = dbcli.ConnectToCollection("facebook", "feeds_test2"); // Retrieve Token TokenInformation tokenmodule = new TokenInformation(); tokenmodule.SetValue(); var token = tokenmodule.GetOAuthToken; // Retrieve Proxy Credentials ProxyInformation proxymodule = new ProxyInformation(); proxymodule.SetValue(); var proxyCredentials = proxymodule.GetProxyCredentials; // Setup API arguments APIArgs _apiArgs = new APIArgs(); var defaultPost = _apiArgs.GetArgs("DefaultPost"); var defaultComment = _apiArgs.GetArgs("DefaultComment"); var defaultFeed = _apiArgs.GetArgs("DefaultFeed"); // Setup clients var facebookClient = new FacebookClient(proxyCredentials); var clientOperator = new ClientGetOperations(facebookClient); var dbOperator = new ClientStoreOperations(dbcli); // Run Retrieval of posts // //string next = ""; //string arg = defaultPost; //do //{ // var getPostTask = clientOperator.GetPostsAsync(token, "youseedanmark", arg); // Task.WaitAll(getPostTask); // var posts = getPostTask.Result; // next = clientOperator.GetNextPostId; // arg = _apiArgs.AddNextKey("DefaultPost", next); // var storeTask = dbOperator.WritePostsAsync(coll, posts); // Task.WaitAll(storeTask); // Console.WriteLine(next); //} while (next != ""); // Run retrieval of feed // //string next = ""; //string arg2 = defaultFeed; //do //{ // var getFeedTask = clientOperator.GetFeedAsync(token, "youseedanmark", arg2); // Task.WaitAll(getFeedTask); // var feed = getFeedTask.Result; // next = clientOperator.GetNextFeedId; // arg2 = _apiArgs.AddNextKey("DefaultFeed", next); // var storeTask = dbOperator.WriteFeedAsync(feedColl, feed); // Task.WaitAll(storeTask); //} while (next != ""); // Run Retrieval of comments // // Setup postids var postIds = dbOperator.ReadDistinctAsync(coll, "post_id").Result; var next = ""; foreach (var idd in postIds) { try { Console.WriteLine("primo"); var id = idd.ToString(); var getCommentTask = clientOperator.GetCommentsAsync(token, id, defaultComment); Task.WaitAll(getCommentTask); var comments = getCommentTask.Result; next = clientOperator.GetNextCommentId; var storeTask = dbOperator.WriteCommentsAsync(commentColl, comments); Task.WaitAll(storeTask); List <string> checklist = new List <string>(); while (next != "") { var subargs = _apiArgs.AddNextKey("DefaultComment", next); var getSubCommentTask = clientOperator.GetCommentsAsync(token, id, subargs); Task.WaitAll(getSubCommentTask); next = clientOperator.GetNextCommentId; checklist.Add(next); if (checklist.Contains(next)) { break; } else { var subcomments = getSubCommentTask.Result; var storeSubTask = dbOperator.WriteCommentsAsync(commentColl, comments); Task.WaitAll(storeSubTask); } } } catch (System.AggregateException) { Console.WriteLine("Bad response"); continue; } } }