private async void Button_Clicked(object sender, EventArgs e) { if (await DisplayAlert("Warnung", "Willst du dich wirklich ausloggen?", "Ja", "Nein")) { await WebHandler.Logout(); } }
private void LoadCars(CarMaxStore store) { var searchUrl = store.InventoryUrl; while (!String.IsNullOrEmpty(searchUrl)) { var content = WebHandler.DownloadContent(searchUrl); var xmlDocument = WebHandler.DownloadDocument(content); var aNodes = xmlDocument.SelectNodes("//div[@id='resultsList']/div[@class='car']"); if (aNodes != null) { foreach (XmlNode node in aNodes) { var carId = Convert.ToInt64(node.Attributes["sn"].Value); try { _commonManagementForm.UpdateCarMaxVehicleStore(carId, store.StoreId); } catch (Exception ex) { _logging.Error("CARMAX - InsertVehicleToDatabase", ex); Console.WriteLine("CARMAX - InsertVehicleToDatabase {0}", ex.Message); } } } var nextNode = xmlDocument.SelectSingleNode("//li[@id='next']"); searchUrl = nextNode != null && nextNode.Attributes["data-url"] != null ? store.InventoryUrl + "&" + nextNode.Attributes["data-url"].Value : string.Empty; } }
private List <CarMaxMake> LoadMakes() { var list = new List <CarMaxMake>(); var content = WebHandler.DownloadContent("http://www.carmax.com/enus/car-search/used-cars.html"); var xmlDocument = WebHandler.DownloadDocument(content); //var nsManager = WebHandler.GetXmlNamespaceManager(xmlDocument); var makeNodes = xmlDocument.SelectNodes("//*[@id='make']/*[.]"); if (makeNodes != null) { foreach (XmlNode node in makeNodes) { var makeName = node.InnerText.Trim(); if (new string[] { "All Makes", "All Domestic", "All Imports" }.Contains(makeName)) { continue; } var make = new CarMaxMake(); make.Value = Convert.ToInt64(node.Attributes["value"].Value); make.Name = makeName; make.Models = LoadModels(make.Value); list.Add(make); } } return(list); }
public void InsertStoresIntoDatabase() { //_logging.Info("*** START to scrap Car Max Stores ***"); Console.WriteLine("*** START to scrap Car Max Stores ***"); var states = LoadStates(); foreach (var state in states) { var stateUrl = String.Format("https://www.carmax.com/stores/states/{0}", state.Value); var content = WebHandler.DownloadContent(stateUrl); var xmlDocument = WebHandler.DownloadDocument(content); var storeNodes = xmlDocument.SelectNodes("//div[@class='store-locator--result']"); if (storeNodes != null) { foreach (XmlNode node in storeNodes) { try { var newStore = GetStoreDetail(node); _commonManagementForm.AddNewCarMaxStore(newStore); Console.WriteLine("{0}", newStore.Name); } catch (Exception ex) { //_logging.Error(String.Format("Failed to insert store at {0}", stateUrl), ex); Console.WriteLine(String.Format("Failed to insert store at {0}", stateUrl), ex); } } } } //_logging.Info("*** END to scrap Car Max Stores ***"); Console.WriteLine("*** END to scrap Car Max Stores ***"); }
protected static void HandleResult(IResult result) { if (result == null) { FBManager.LastResponse = "Null Response\n"; return; } if (!string.IsNullOrEmpty(result.Error)) { FBManager.Status = "Error - Check log for details"; FBManager.LastResponse = "Error Response:\n" + result.Error; } else if (result.Cancelled) { FBManager.Status = "Cancelled - Check log for details"; FBManager.LastResponse = "Cancelled Response:\n" + result.RawResult; } else if (!string.IsNullOrEmpty(result.RawResult)) { FBManager.Status = "Success - Check log for details"; FBManager.LastResponse = "Success Response:\n" + result.RawResult; string key = "accessToken"; string key2 = "userID"; if (result.ResultDictionary.TryGetValue(key, out BaseData.key) && result.ResultDictionary.TryGetValue(key2, out BaseData.uid)) { WebHandler.get_facebook_key(); } } else { FBManager.LastResponse = "Empty Response\n"; } }
/// <summary> /// Perform clip unload /// </summary> /// <param name="clipID"></param> private void OnUnloadBegin(TTSClipData clipData) { // Abort if currently preparing if (clipData.loadState == TTSClipLoadState.Preparing) { // Cancel web stream WebHandler?.CancelWebStream(clipData); // Cancel web download to cache WebHandler?.CancelWebDownload(clipData, GetDiskCachePath(clipData.textToSpeak, clipData.clipID, clipData.voiceSettings, clipData.diskCacheSettings)); // Cancel disk cache stream DiskCacheHandler?.CancelDiskCacheStream(clipData); } // Destroy clip else if (clipData.clip != null) { MonoBehaviour.DestroyImmediate(clipData.clip); } // Clip is now unloaded SetClipLoadState(clipData, TTSClipLoadState.Unloaded); // Unload LogClip($"Unload Clip", clipData); Events?.OnClipUnloaded?.Invoke(clipData); }
// Get all the files related to the submission id private List <Submission> getSubFiles(int subId) { string url = baseUrl + "api_submissions.php"; WebHandler webHandler = new WebHandler(); string data = string.Format("sid={0}&submission_ids={1}", sid, subId); string html = webHandler.getPage(url, data); dynamic json = JsonConvert.DeserializeObject(html); List <Submission> subs = new List <Submission>(); string username = json.submissions[0].username; string title = json.submissions[0].title; int iteration = 0; foreach (dynamic subJson in json.submissions[0].files) { Submission sub = new Submission(); sub.domain = domain; sub.site = SITES.InkBunny; sub.author = username; sub.title = string.Format("{0}-{1}", title, iteration++); sub.id = "fID" + subJson.file_id; sub.pageSource = string.Format("IB_{0}_{1}", subId, sub.id); subs.Add(sub); } return(subs); }
// Test Method Works public void UrlDoesNotContainHttp() { var wh = new WebHandler(); string url = "www.aftonbladet.se"; wh.GetHTMLFromUrl(url); }
/// <summary> /// Download the latest NKHook from the github releases section /// </summary> public static void DownloadNKH() { Log.Output("Downloading latest NKHook5..."); string git_Text = WebHandler.ReadText_FromURL(gitURL); if (!Guard.IsStringValid(git_Text)) { Log.Output("Failed to read release info for NKHook5"); return; } BgThread.AddToQueue(new Thread(() => { var gitApi = GitApi.FromJson(git_Text); foreach (var a in gitApi) { foreach (var b in a.Assets) { string link = b.BrowserDownloadUrl.ToString(); if (!Guard.IsStringValid(link)) { continue; } WebHandler.DownloadFile(link, nkhDir); } } Log.Output("NKHook5 successfully downloaded!"); })); }
public async void Chk() { if (!await WebHandler.TestInternet(this)) { System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow(); } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } if (!await WebHandler.HasInternet()) { return; } IsBusy = true; try { var items = await WebHandler.GetRecentActions(); if (items == null || items.Count == 0) { return; } Activities.Clear(); var now = DateTime.Now; for (var n = items.Count - 1; n >= 0; n--) { var dt = new DateTime(long.Parse(items[n].Time)); items[n].Time = dt.DayOfYear == now.DayOfYear && dt.Year == now.Year ? dt.ToShortTimeString() : dt.ToShortDateString(); Activities.Add(items[n]); } } catch { } /* * catch (Exception ex) { * Debug.WriteLine(ex); * }*/ finally { IsBusy = false; } }
public static string GetProvinceHtmlContent() { if (NationRegionOperaSql.IsExistsByLevel(1)) { return("0"); } string htmlString = WebHandler.GetHtmlStr(Const.WebSiteUri, "Default"); if (htmlString == "") { if (!NationRegionOperaSql.IsExistsExpetionByUri(Const.WebSiteUri, 1)) { NationRegionOperaSql.InsertExpetion(Const.WebSiteUri, 1); } return(""); } List <BasicModel> provinceModel = AnalysisProvHtmlstr.GetProvinceModel(htmlString); string insertStr = string.Format("INSERT INTO [dbo].[UCML_NationRegion]([ParentNode],[Node],[Code],[Name],[Href],[IsLowerUp],[Level]) VALUES "); foreach (BasicModel model in provinceModel) { insertStr += string.Format("('{0}','{1}','{2}','{3}','{4}','{5}','{6}'),", model.ParentNode, model.Node, model.Code, model.Name, model.Href, 0, model.Level); } NationRegionOperaSql.ExecuteSql(insertStr.Substring(0, insertStr.Length - 1)); return(""); }
private void ソースの表示VToolStripMenuItem_Click(object sender, EventArgs e) { HtmlDocument document = this.webBrowser1.Document; string encoding = document.Encoding; WebHandler.WebClientGet3(this.webBrowser1.Url.ToString(), encoding); }
/// <summary> /// Initializes a new instance of the <see cref="FallbackModule"/> class. /// </summary> /// <param name="action">The action.</param> public FallbackModule(WebHandler action) { AddHandler( ModuleMap.AnyPath, HttpVerbs.Any, action); }
/// <summary> /// Initializes a new instance of the <see cref="FallbackModule" /> class. /// </summary> /// <param name="action">The action.</param> /// <param name="verb">The verb.</param> public FallbackModule(WebHandler action, HttpVerbs verb = HttpVerbs.Any) { AddHandler( ModuleMap.AnyPath, verb, action); }
async void Register_Clicked(object sender, EventArgs e) { if (!Validate()) { return; } switch (await WebHandler.Register(user)) { case RegisterErrorState.Success: await WebHandler.Login(user); close(); break; case RegisterErrorState.EmailFound: eEmail.BackgroundColor = Meh; break; case RegisterErrorState.NameFound: eUsername.BackgroundColor = Meh; break; case RegisterErrorState.Fail: break; default: break; } }
public APIServer(WebHandler handler, string[] prefixes) { if (!HttpListener.IsSupported) { throw new NotSupportedException("Unsupported platform."); } // URI prefixes (routes) are required. if (prefixes == null || prefixes.Length == 0) { throw new ArgumentException("prefixes"); } // A responder method is required if (handler == null) { throw new ArgumentException("callback"); } Console.CancelKeyPress += new ConsoleCancelEventHandler(CtrlBreakHandler); foreach (string s in prefixes) { _listener.Prefixes.Add(s); } _handler = handler; }
// Performs download to disk cache protected virtual void DownloadToDiskCache(TTSClipData clipData, Action <TTSClipData, string, string> onDownloadComplete) { // Add delegates if needed AddDelegates(); // Check if cached to disk & log string downloadPath = DiskCacheHandler.GetDiskCachePath(clipData); bool found = DiskCacheHandler.IsCachedToDisk(clipData); LogClip($"Disk Cache {(found ? "Found" : "Missing")}\nPath: {downloadPath}", clipData); // Found if (found) { onDownloadComplete?.Invoke(clipData, downloadPath, string.Empty); return; } // Fail if not preloaded if (Application.isPlaying && clipData.diskCacheSettings.DiskCacheLocation == TTSDiskCacheLocation.Preload) { onDownloadComplete?.Invoke(clipData, downloadPath, "File is not Preloaded"); return; } // Return error clipData.onDownloadComplete += (error) => onDownloadComplete(clipData, downloadPath, error); // Download to cache & then stream WebHandler.RequestDownloadFromWeb(clipData, downloadPath); }
private void saveBtn_Click(object sender, EventArgs e) { var levels = GetAllLevels(); var webHandler = new WebHandler(); webHandler.SaveLevels(levels); }
public void Run(AuthObj auth, string twitterName) //Executes the task parsed by the ServerTask class { this.auth = auth; webHandler = new WebHandler(auth); //Sets the limits such that we do not exceed the limits LimitHelper.Instance(auth).InitPropertises(new WebHandler(auth).TwitterGetRequest <Limit>(TwitterRequestBuilder.BuildStartupRequest())); User user = webHandler.TwitterGetRequest <User>(TwitterRequestBuilder.BuildRequest(RequestType.user, auth, "screen_name=" + twitterName)); //Used for getting the users political value //Analyse the tweets of the user and post the result to the database. Does not use linking because of this is the user we need to ananlyse TweetRetriever.Instance.GetTweetsFromUserAndAnalyse(user, auth, CheckIfResultExistOnDB, ClassifyTweet, PostResultToDB); //Finds the posted users recordId and assigns it to the global userRecordId variable to be used in the CheckIfResultExistOnDBAndLink and PostResultToDBAndLink if (!GetUsersRecordIdOnDb(user, ref userRecordId)) { Log.Error("Could not find the posted user, something is wrong!"); return; } //Gets the friends for the user var friends = FriendsRetriever.Instance.GetFriends(user, auth); Log.Debug("Following " + friends.Users.Count + " users"); //Analyse the tweets of each friend and post the result to the database, then link the users result to the global userRecordId TweetRetriever.Instance.GetTweetsFromFriendsAndAnalyse(friends, auth, CheckIfResultExistOnDBAndLink, ClassifyTweet, PostResultToDBAndLink); //Finalizes the user by informing the database that the user has been proccessed. FinalizeUser(); Log.Debug("Done task with id " + auth.RequestID + "!!!"); }
public static string GetCityHtmlContent(int sleepTime) { List <BasicModel> list = NationRegionOperaSql.GetTopBasicModelByLevel(1); Thread.Sleep(sleepTime); /*我好累,休息一下!*/ foreach (BasicModel model in list) { string htmlString = WebHandler.GetHtmlStr(Const.WebSiteUri + "//" + model.Href + ".html", "Default"); if (htmlString == "") { if (!NationRegionOperaSql.IsExistsExpetionByUri(Const.WebSiteUri + "//" + model.Href + ".html", 2)) { NationRegionOperaSql.InsertExpetion(Const.WebSiteUri + "//" + model.Href + ".html", 2); } continue; } List <BasicModel> cityModels = AnalysisCityHtmlstr.GetCityModel(htmlString); string insertStr = string.Format("INSERT INTO [dbo].[UCML_NationRegion]([ParentNode],[Node],[Code],[Name],[Href],[IsLowerUp],[Level]) VALUES "); foreach (BasicModel cityModel in cityModels) { insertStr += string.Format("('{0}','{1}','{2}','{3}','{4}','{5}','{6}'),", cityModel.ParentNode, cityModel.Node, cityModel.Code, cityModel.Name, cityModel.Href, 0, cityModel.Level); } NationRegionOperaSql.ExecuteSql(insertStr.Substring(0, insertStr.Length - 1)); } return(""); }
public override async Task <bool> loginAsync(DataHandler datahandler, string username, string password, string captcha = null) { try { WebHandler webHandler = new WebHandler(); string html = await webHandler.getPageAsync(baseUrl + "api_login.php", string.Format("username={0}&password={1}", username, password)); dynamic json = JsonConvert.DeserializeObject(html); sid = json.sid; if (sid == "" || jsonError(json)) { return(false); } datahandler.setLogin(Name, sid, username, ""); } catch (Exception e) { Console.WriteLine(e); return(false); } loggedinUsername = username; return(true); }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { var items = await WebHandler.GetScoreboard(); if (items == null || items.Count == 0) { return; } Users.Clear(); int idx = 1; foreach (var item in items) { item.Password = idx++.ToString(); Users.Add(item); } } catch { } /* * catch (Exception ex) { * Debug.WriteLine(ex); * }*/ finally { IsBusy = false; } }
private void ResetUsernameButtonClicked(object sender, EventArgs e) { string email = EmailTextBox.Text; if (email.Length < 1) { EmailTextBox.Text = "Please enter your email here"; EmailTextBox.ForeColor = Color.Red; } else if (!IsValidEmail(email)) { EmailTextBox.ForeColor = Color.Red; } else { string tempUsername = GenerateRandomUsername(); string result = WebHandler.WebRequestToResetUsername(email, tempUsername); if (result == "SUCCESS") { MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress(email); SendUsernameResetEmail(from, to, tempUsername); } else { MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public WebRoute(string name, string rgx, WebHandler handler, string help) { Name = name; Regex = rgx; Handler = handler; Help = help; }
public void SendHttpContentTest() { var mockTcpHandler = new Mock <ITCP>(); var mockRequestContext = new Mock <IReqContext>(); var memoryStream = new MemoryStream(); memoryStream.Position = 0; mockTcpHandler.Setup(c => c.GetStream(It.IsAny <TcpClient>())).Returns(memoryStream); mockRequestContext.Setup(c => c.StatusCode).Returns("200 OK"); mockRequestContext.Setup(c => c.ContentType).Returns("text/plain"); mockRequestContext.Setup(c => c.Payload).Returns("SendHttpContentTest"); WebHandler contentWriter = new WebHandler(mockTcpHandler.Object, mockRequestContext.Object); contentWriter.SendHttpContent(); string expectedValue = "HTTP/1.1 200 OK\r\nServer: SEB-Server\r\n"; expectedValue += "Content-Type: text/plain\r\nContent-Length: 19\r\n\r\n"; expectedValue += "SendHttpContentTest\r\n"; string actualValue = Encoding.ASCII.GetString(memoryStream.ToArray()); Console.WriteLine(actualValue); Assert.AreEqual(expectedValue, actualValue); }
public override List <string> getWatchList(string author) { string url = baseUrl + "api_watchlist.php"; string data = string.Format("sid={0}", sid); WebHandler webHandler = new WebHandler(); string html = webHandler.getPage(url, data); dynamic json = JsonConvert.DeserializeObject(html); if (jsonError(json)) { return(null); } List <string> list = new List <string>(); foreach (dynamic subJson in json.watches) { list.Add((string)subJson.username); } return(list); }
private void Update() { if (Main.lastwidth != (float)Screen.width) { Main.lastwidth = (float)Screen.width; base.gameObject.BroadcastMessage("OnResize", SendMessageOptions.DontRequireReceiver); } if (UIManager.canvasActive) { UIManager.SetLoadingProgress((int)(ContentLoader2_.progress * 100f)); UIManager.SetCoolerAngle(this.coolerAngle); } if (!Main.inbuySteam) { return; } Steam.RunCallBacks(); ulong num = Steam.s_get_tnx_orderid(); if (num != 0uL) { Main.inbuySteam = false; WebHandler.get_buyfin("&orderid=" + num.ToString()); } }
public static void Draw() { Profile.DrawMenu(); Profile.DrawProfile(); Profile.DrawBadge(); Profile.DrawMask(); if (Event.current.isKey) { KeyCode keyCode = Event.current.keyCode; if (keyCode == KeyCode.Return || keyCode == KeyCode.KeypadEnter) { if (Profile.inEdit) { BaseData.Name = Profile.newname; Profile.inEdit = false; WebHandler.set_profile(); } Event.current.Use(); } } if (Event.current.isMouse && Profile.inEdit) { BaseData.Name = Profile.newname; Profile.inEdit = false; WebHandler.set_profile(); } }
public MainForm() { InitializeComponent(); mc = new MinecraftHandler("rules.txt", "kits.xml", "banned-players.txt", "player.txt", "admins.txt", "MineCraftAdmin.cfg"); Tunnel = new TcpTunnelServer(mc); mc.ServerStarted += new EventHandler(mc_ServerStarted); mc.ServerStopped += new EventHandler(mc_ServerStopped); mc.PlayerJoined += new MinecraftHandler.OnPlayerjoined(mc_PlayerJoined); mc.PlayerLeft += new MinecraftHandler.OnPlayerLeft(mc_PlayerLeft); mc.OutputDataReceived += new MinecraftHandler.OnOutputDataReceived(mc_OutputDataReceived); mc.ServerExited += new MinecraftHandler.OnServerExited(mc_ServerExited); LoadModules(); ReadFromConfig(); //CheckIfRestartOrBackup(); this.Text = "Zicore's Minecraft Admintool - © 2010-2011 - v" + Application.ProductVersion; mc.Version = Application.ProductVersion; restart = new Restart(mc); this.listLoadedPlugins.DataSource = mc.Plugins; //mc.SaveCompleted += new MinecraftHandler.OnSaveCompletedDelegate(mc_SaveCompleted); web = new WebHandler(mc, Tunnel); web.Start(); GenerateTaskColumns(); }
/** * @note default constructor * @return void **/ public WebConnection(string url, string method, string postData) { this.url = url; this.method = method; this.postData = postData; this.handler = new WebHandler(this.url, this.method, this.postData); this.handler.run(); }
internal void Handle(Video one_video, Seed seed) { if(one_video.Url!=null) { try { string html = ""; Uri uri = new Uri(one_video.Url); WebHandler webHandler = new WebHandler(); html = webHandler.GetResponseStr(uri, seed.Encoding); if (html.Length > 200) { string title = Regex.Match(html, seed.Title_Reg, RegexOptions.Singleline).ToString() ; } } catch (Exception) { Console.WriteLine("Something worry with HandleHelper GetDetail function"); } } }
internal IISHttpHandler(WebHandler.Router router) : base(router) { }
public WebServer(UInt16 port, WebHandler handler) { this.port = port; this.handler = handler; }