public override void ResetSeed() { if ((DateTime.Now - LastSeedReset).TotalSeconds > 90) { try { LastSeedReset = DateTime.Now; Parent.updateStatus("Resetting Seed"); List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >(); pairs.Add(new KeyValuePair <string, string>("seed", Guid.NewGuid().ToString().Replace("-", "").Substring(0, 20))); FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs); string sEmitResponse = Client.PostAsync("seed?api_key=" + accesstoken, Content).Result.Content.ReadAsStringAsync().Result; PDseeds tmpSeed = json.JsonDeserialize <PDseeds>(sEmitResponse); sqlite_helper.InsertSeed(tmpSeed.seeds.previous_server_hashed, tmpSeed.seeds.previous_server); } catch (WebException e) { if (e.Response != null) { string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd(); Parent.updateStatus(sEmitResponse); if (e.Message.Contains("429")) { Thread.Sleep(2000); ResetSeed(); } } } } else { Parent.updateStatus("Too soon to reset seed. Delaying reset."); } }
public override void ResetSeed() { if ((DateTime.Now - LastSeedReset).TotalSeconds > 90) { try { LastSeedReset = DateTime.Now; Parent.updateStatus("Resetting Seed"); HttpWebRequest betrequest = (HttpWebRequest)HttpWebRequest.Create("https://api.primedice.com/api/seed?access_token=" + accesstoken); if (Prox != null) { betrequest.Proxy = Prox; } betrequest.Method = "POST"; string post = string.Format("seed={0}", Guid.NewGuid().ToString().Replace("-", "").Substring(0, 20)); betrequest.ContentLength = post.Length; betrequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; using (var writer = new StreamWriter(betrequest.GetRequestStream())) { writer.Write(post); } HttpWebResponse EmitResponse = (HttpWebResponse)betrequest.GetResponse(); string sEmitResponse = new StreamReader(EmitResponse.GetResponseStream()).ReadToEnd(); PDseeds tmpSeed = json.JsonDeserialize <PDseeds>(sEmitResponse); sqlite_helper.InsertSeed(tmpSeed.seeds.previous_server_hashed, tmpSeed.seeds.previous_server); } catch (WebException e) { if (e.Response != null) { string sEmitResponse = new StreamReader(e.Response.GetResponseStream()).ReadToEnd(); Parent.updateStatus(sEmitResponse); if (e.Message.Contains("429")) { Thread.Sleep(2000); ResetSeed(); } } } } else { Parent.updateStatus("Too soon to reset seed. Delaying reset."); } }