public void Initialize() { HttpHeaders["X-RateLimit-Remaining"] = "-1"; HttpHeaders["X-RateLimit-Limit"] = "-1"; HttpHeaders["X-RateLimit-Reset"] = "-1"; HttpHeaders["X-Access-Level"] = "read-write-directmessages"; HttpHeaders["X-MediaRateLimit-Remaining"] = "-1"; HttpHeaders["X-MediaRateLimit-Limit"] = "-1"; HttpHeaders["X-MediaRateLimit-Reset"] = "-1"; _MaxCount = -1; _RemainCount = -1; _ResetTime = new DateTime(); _ResetTimeInSeconds = -1; AccessLevel = ApiAccessLevel.None; _MediaMaxCount = -1; _MediaRemainCount = -1; _MediaResetTime = new DateTime(); //_UsingCount = -1 var arg = new ApiInformationChangedEventArgs(); var changed = Changed; if (changed != null) { changed(this, arg); } }
public void WriteBackEventArgs(ApiInformationChangedEventArgs arg) { _MaxCount = arg.ApiInfo.MaxCount; _RemainCount = arg.ApiInfo.RemainCount; _ResetTime = arg.ApiInfo.ResetTime; _ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds; _UsingCount = arg.ApiInfo.UsingCount; Raise_Changed(); }
private void Raise_Changed() { var arg = new ApiInformationChangedEventArgs(); var changed = Changed; if (changed != null) { changed(this, arg); } _MaxCount = arg.ApiInfo.MaxCount; _RemainCount = arg.ApiInfo.RemainCount; _ResetTime = arg.ApiInfo.ResetTime; _ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds; //_UsingCount = arg.ApiInfo.UsingCount }
private void Twitter_ApiInformationChanged(object sender, ApiInformationChangedEventArgs e) { }
public bool GetInfoApi(ApiInfo info) { if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return true; if (MyCommon._endingFlag) return true; HttpStatusCode res = HttpStatusCode.BadRequest; var content = string.Empty; try { res = twCon.RateLimitStatus(ref content); } catch(Exception) { MyCommon.TwitterApiInfo.Initialize(); return false; } if (res != HttpStatusCode.OK) return false; try { var limit = MyCommon.CreateDataFromJson<TwitterDataModel.RateLimitStatus>(content); var arg = new ApiInformationChangedEventArgs(); arg.ApiInfo.MaxCount = limit.HourlyLimit; arg.ApiInfo.RemainCount = limit.RemainingHits; arg.ApiInfo.ResetTime = MyCommon.DateTimeParse(limit.RestTime); arg.ApiInfo.ResetTimeInSeconds = limit.RestTimeInSeconds; if (info != null) { arg.ApiInfo.UsingCount = info.UsingCount; info.MaxCount = arg.ApiInfo.MaxCount; info.RemainCount = arg.ApiInfo.RemainCount; info.ResetTime = arg.ApiInfo.ResetTime; info.ResetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds; } if (ApiInformationChanged != null) { ApiInformationChanged(this, arg); } MyCommon.TwitterApiInfo.WriteBackEventArgs(arg); return true; } catch(Exception ex) { MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); MyCommon.TwitterApiInfo.Initialize(); return false; } }
private void SetStatusLabelApiHandler(object sender, ApiInformationChangedEventArgs e) { try { if (InvokeRequired && !IsDisposed) { Invoke(new SetStatusLabelApiDelegate(SetStatusLabelApi)); } else { SetStatusLabelApi(); } } catch (ObjectDisposedException) { return; } catch (InvalidOperationException) { return; } }
public void Initialize() { if (HttpHeaders.ContainsKey("X-RateLimit-Remaining")) { HttpHeaders["X-RateLimit-Remaining"] = "-1"; } else { HttpHeaders.Add("X-RateLimit-Remaining", "-1"); } if (HttpHeaders.ContainsKey("X-RateLimit-Limit")) { HttpHeaders["X-RateLimit-Limit"] = "-1"; } else { HttpHeaders.Add("X-RateLimit-Limit", "-1"); } if (HttpHeaders.ContainsKey("X-RateLimit-Reset")) { HttpHeaders["X-RateLimit-Reset"] = "-1"; } else { HttpHeaders.Add("X-RateLimit-Reset", "-1"); } if (HttpHeaders.ContainsKey("X-Access-Level")) { HttpHeaders["X-Access-Level"] = "read-write-directmessages"; } else { HttpHeaders.Add("X-Access-Level", "read-write-directmessages"); } if (HttpHeaders.ContainsKey("X-MediaRateLimit-Remaining")) { HttpHeaders["X-MediaRateLimit-Remaining"] = "-1"; } else { HttpHeaders.Add("X-MediaRateLimit-Remaining", "-1"); } if (HttpHeaders.ContainsKey("X-MediaRateLimit-Limit")) { HttpHeaders["X-MediaRateLimit-Limit"] = "-1"; } else { HttpHeaders.Add("X-MediaRateLimit-Limit", "-1"); } if (HttpHeaders.ContainsKey("X-MediaRateLimit-Reset")) { HttpHeaders["X-MediaRateLimit-Reset"] = "-1"; } else { HttpHeaders.Add("X-MediaRateLimit-Reset", "-1"); } _MaxCount = -1; _RemainCount = -1; _ResetTime = new DateTime(); _ResetTimeInSeconds = -1; AccessLevel = ApiAccessLevel.None; _MediaMaxCount = -1; _MediaRemainCount = -1; _MediaResetTime = new DateTime(); //_UsingCount = -1 var arg = new ApiInformationChangedEventArgs(); var changed = Changed; if (changed != null) { changed(this, arg); } }