Ejemplo n.º 1
0
        private Boolean isAlreadyLoggedIn()
        {
            accessToken       = MainUtil.GetKeyValue <string>("AccessToken");
            accessTokenSecret = MainUtil.GetKeyValue <string>("AccessTokenSecret");


            //TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
            //int seconds = (int)t.TotalSeconds;
            //var timestampcheck =  MainUtil.GetKeyValue<string>("Timestamp");
            //double duration = seconds - Convert.ToDouble(MainUtil.GetKeyValue<string>("Timestamp"));

            //if (duration > 3500)
            //{
            // //  SignOut();

            //    var RefreshTokenQuery = OAuthUtil.RefreshAccessTokenQuery();
            //    RefreshTokenQuery.RequestAsync(AppSettings.AccessTokenUri, null);

            //    RefreshTokenQuery.QueryResponse += new EventHandler<WebQueryResponseEventArgs>(RefreshTokenQuery_QueryResponse);

            //}

            if (string.IsNullOrEmpty(accessToken) || string.IsNullOrEmpty(accessTokenSecret))
            {
                return(false);
            }
            //add refresh token

            //
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
        // Constructor
        public MainPage()
        {
            //moved from is user login
            TimeSpan t              = (DateTime.UtcNow - new DateTime(1970, 1, 1));
            int      seconds        = (int)t.TotalSeconds;
            var      timestampcheck = MainUtil.GetKeyValue <string>("Timestamp");

            if (timestampcheck != null)
            {
                double duration = seconds - Convert.ToDouble(MainUtil.GetKeyValue <string>("Timestamp"));

                if (duration > 1800)
                {
                    //  SignOut();

                    var RefreshTokenQuery = OAuthUtil.RefreshAccessTokenQuery();
                    RefreshTokenQuery.RequestAsync(AppSettings.AccessTokenUri, null);

                    RefreshTokenQuery.QueryResponse += new EventHandler <WebQueryResponseEventArgs>(RefreshTokenQuery_QueryResponse);
                    if (isAlreadyLoggedIn())
                    {
                        Thread.Sleep(100);
                        userLoggedIn();
                    }
                }
                else
                {
                    if (isAlreadyLoggedIn())
                    {
                        Thread.Sleep(100);
                        userLoggedIn();
                    }
                }


                //end
            }

            InitializeComponent();



            if (isAlreadyLoggedIn())
            {
                userLoggedIn();
            }
        }
Ejemplo n.º 3
0
        public Page1()
        {
            TimeSpan t              = (DateTime.UtcNow - new DateTime(1970, 1, 1));
            int      seconds        = (int)t.TotalSeconds;
            var      timestampcheck = MainUtil.GetKeyValue <string>("Timestamp");

            if (timestampcheck != null)
            {
                double duration = seconds - Convert.ToDouble(MainUtil.GetKeyValue <string>("Timestamp"));

                if (duration > 1800)
                {
                    var RefreshTokenQuery = OAuthUtil.RefreshAccessTokenQuery();
                    RefreshTokenQuery.RequestAsync(AppSettings.AccessTokenUri, null);

                    RefreshTokenQuery.QueryResponse += new EventHandler <WebQueryResponseEventArgs>(RefreshTokenQuery_QueryResponse);
                }
                InitializeComponent();
            }
        }
Ejemplo n.º 4
0
        public Page2()
        {
            InitializeComponent();

            client.Authenticator = OAuth1Authenticator.ForProtectedResource(AppSettings.consumerKey, AppSettings.consumerKeySecret, MainUtil.GetKeyValue <string>("AccessToken"), MainUtil.GetKeyValue <string>("AccessTokenSecret"));
        }
Ejemplo n.º 5
0
        public void GetPositions()
        {
            string _teamKey     = (string)appSettings["teamKey"];
            string _currentWeek = (string)appSettings["currentWeek"] ?? "1";
            string _leagueKey   = _teamKey.Substring(0, _teamKey.IndexOf(".t"));
            ObservableCollection <StringObject> _positions = new ObservableCollection <StringObject>();

            client.Authenticator = OAuth1Authenticator.ForProtectedResource(AppSettings.consumerKey, AppSettings.consumerKeySecret, MainUtil.GetKeyValue <string>("AccessToken"), MainUtil.GetKeyValue <string>("AccessTokenSecret"));

            var request = new RestRequest(string.Format("league/{0}/settings", _leagueKey), Method.GET);  ///users;use_login=1/games;game_keys=273,314/teams

            client.ExecuteAsync(request, response =>
            {
                XDocument doc  = new XDocument();
                doc            = XDocument.Parse(response.Content.ToString());
                string newjson = "";
                newjson        = JsonConvert.SerializeXNode(doc);
                JObject o      = JObject.Parse(newjson);

                JArray _positionJArray = (JArray)o["fantasy_content"]["league"]["settings"]["roster_positions"]["roster_position"];

                for (int i = 0; i < _positionJArray.Count; i++)
                {
                    dynamic temp = JsonConvert.DeserializeObject <dynamic>(_positionJArray[i].ToString());

                    if (temp.position != null && temp.position.ToString() != "BN")
                    {
                        _positions.Add(new StringObject {
                            StringValue = temp.position.ToString()
                        });
                    }
                }

                //if (!appSettings.Contains("positions"))
                //{
                //    appSettings.Add("positions", _positions);
                //}
                //else
                //{
                //    appSettings["positions"] = _positions;
                //}
            });
        }