Example #1
0
        private void GetLoggedInCallback(IAsyncResult asyncResult)
        {
            HttpWebRequest   request  = (HttpWebRequest)asyncResult.AsyncState;
            HttpWebResponse  response = (HttpWebResponse)request.EndGetResponse(asyncResult);
            Stream           stream   = stream = response.GetResponseStream();
            StreamReader     reader   = new StreamReader(stream);
            CookieCollection cookies  = request.CookieContainer.GetCookies(new Uri("https://cas.sfu.ca/cgi-bin/WebObjects/cas.woa/wa/login"));


            if (CookieService.CookieExists("CASTGC"))
            {
                CookieService.RemoveCookieWithName("CASTGC");
            }
            foreach (Cookie cookie in cookies)
            {
                if (cookie.Name == "CASTGC")
                {
                    CookieService.AddCookie(cookie);
                }
            }
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                OnPropertyChanged("LoginStatus");
            });
        }
Example #2
0
        private void GetLoggedInCallback(IAsyncResult asyncResult)
        {
            HttpWebRequest   request  = (HttpWebRequest)asyncResult.AsyncState;
            HttpWebResponse  response = (HttpWebResponse)request.EndGetResponse(asyncResult);
            Stream           stream   = stream = response.GetResponseStream();
            StreamReader     reader   = new StreamReader(stream);
            CookieCollection cookies  = request.CookieContainer.GetCookies(new Uri("https://cas.sfu.ca/cgi-bin/WebObjects/cas.woa/wa/login"));


            if (CookieService.CookieExists("CASTGC"))
            {
                CookieService.RemoveCookieWithName("CASTGC");
            }
            foreach (Cookie cookie in cookies)
            {
                CookieService.AddCookie(cookie);
                if (cookie.Name == "CASTGC")
                {
                    //ServiceLocator.AddService<CookieCollection>(cookies);
                    FlurryWP8SDK.Api.SetUserId(Settings.ComputingId);
                    sLogInStatus = false;
                }
            }
            //getting cookie failed
            if (sLogInStatus == true)
            {
                ErrorVisibility = Visibility.Visible;
                Loading         = Visibility.Collapsed;
                sLogInStatus    = false;
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    OnPropertyChanged("Loading");
                    OnPropertyChanged("ErrorVisibility");
                });
            }
            else
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    OnPropertyChanged("Loading");
                    NavigationService service = ServiceLocator.GetService <NavigationService>();
                    if (service.BackStack.First().Source.OriginalString == "/Pages/ProtectedServicesPage.xaml")
                    {
                        service.Navigate(new Uri("/Pages/ProtectedServiceBrowserPage.xaml", UriKind.Relative));
                    }
                    else
                    {
                        service.GoBack();
                    }
                });
            }
        }
Example #3
0
 private void ExecuteCourses(object parameter)
 {
     if (Settings.ComputingId == string.Empty && Settings.Password == string.Empty)
     {
         MessageBox.Show("Please Login.", "Login Status", MessageBoxButton.OK);
     }
     else if (!CookieService.CookieExists("CASTGC"))
     {
         MessageBox.Show("Wrong Computing Id or Password or Not Logged In", "Login Status", MessageBoxButton.OK);
     }
     else
     {
         NavigationService navigationService = ServiceLocator.GetService <NavigationService>();
         navigationService.Navigate(new Uri("/Pages/SchedulePage.xaml", UriKind.Relative));
     }
 }
Example #4
0
        public MainPageVM()
        {
            if (!CookieService.CookieExists("CASTGC"))
            {
                if (Settings.ComputingId != string.Empty && Settings.Password != string.Empty)
                {
                    var available = !NetworkInterface.GetIsNetworkAvailable();
#if DEBUG
                    available = true;
#endif
                    if (!available)
                    {
                        MessageBox.Show("No internet connection is available. Some parts of the app may behave unexpectedly.");
                    }
                    else
                    {
                        HttpWebRequest request  = (HttpWebRequest)HttpWebRequest.Create("https://cas.sfu.ca/cgi-bin/WebObjects/cas.woa/wa/login");
                        IAsyncResult   response = request.BeginGetResponse(new AsyncCallback(GetLoginResponseCallback), request);
                    }
                }
            }
        }