Example #1
0
 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();
 }
Example #2
0
        private void Raise_Changed()
        {
            var arg = new ApiInformationChangedEventArgs();

            if (Changed != null)
            {
                Changed(this, arg);
            }

            maxCount           = arg.ApiInfo.MaxCount;
            remainCount        = arg.ApiInfo.RemainCount;
            resetTime          = arg.ApiInfo.ResetTime;
            resetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds;
        }
Example #3
0
        private void Raise_Changed()
        {
            var arg = new ApiInformationChangedEventArgs();
            if (Changed != null)
            {
                Changed(this, arg);
            }

            maxCount = arg.ApiInfo.MaxCount;
            remainCount = arg.ApiInfo.RemainCount;
            resetTime = arg.ApiInfo.ResetTime;
            resetTimeInSeconds = arg.ApiInfo.ResetTimeInSeconds;
        }
Example #4
0
 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();
 }
Example #5
0
 private void TwitterApiInfo_Changed(object sender, ApiInformationChangedEventArgs e)
 {
     SetStatusLabelApiLuncher();
 }
Example #6
0
 private void Twitter_ApiInformationChanged(object sender, ApiInformationChangedEventArgs e)
 {
 }
Example #7
0
        public bool GetInfoApi(ApiInfo info)
        {
            if (AccountState != AccountState.Valid)
            {
                return true;
            }

            if (MyCommon.IsEnding)
            {
                return true;
            }

            HttpStatusCode res;
            string content = string.Empty;
            try
            {
                res = _twitterConnection.RateLimitStatus(ref content);
            }
            catch (Exception)
            {
                MyCommon.TwitterApiInfo.Initialize();
                return false;
            }

            if (res != HttpStatusCode.OK)
            {
                return false;
            }

            try
            {
                var limit = D.CreateDataFromJson<RateLimitStatus>(content);
                var homeLimit = limit.ResourcesLimit.Statuses.HomeTimelime;
                var arg = new ApiInformationChangedEventArgs
                    {
                        ApiInfo =
                            {
                                MaxCount = homeLimit.Limit,
                                RemainCount = homeLimit.Remaining,
                                ResetTime = MyCommon.FromUnixTime(homeLimit.Reset),
                            }
                    };
                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;
            }
        }