Пример #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");
            });
        }
Пример #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();
                    }
                });
            }
        }
Пример #3
0
        private void GetSIMSResponse(IAsyncResult result)
        {
            HttpWebRequest  request  = (HttpWebRequest)result.AsyncState;
            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);

            Cookie casCookie = CookieService.GetCookieWithName("CASTGC");

            CookieService.DeleteCookies();
            if (casCookie != null)
            {
                CookieService.AddCookie(casCookie);
            }
            CookieCollection cookies = request.CookieContainer.GetCookies(new Uri("https://go.sfu.ca"));

            foreach (Cookie cookie in cookies)
            {
                CookieService.AddCookie(cookie);
            }
            //Settings.GetStudentId();
            string         request2String = string.Format("https://sims-prd.sfu.ca/psc/csprd_1/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.SS_ES_STUDY_LIST.GBL?Page=SS_ES_STUDY_LIST&Action=U&ACAD_CAREER=UGRD&EMPLID=&INSTITUTION=SFUNV&STRM={0}", SemesterHelper.GetSemesterId());
            HttpWebRequest request2       = (HttpWebRequest)HttpWebRequest.Create(request2String);

            request2.Method          = "GET";
            request2.CookieContainer = new CookieContainer();

            foreach (Cookie cookie in cookies)
            {
                if (cookie.Domain == ".sfu.ca")
                {
                    request2.CookieContainer.Add(new Uri("http://www" + cookie.Domain), cookie);
                }
                else
                {
                    request2.CookieContainer.Add(new Uri("https://" + cookie.Domain), cookie);
                }
            }


            request2.BeginGetResponse(new AsyncCallback(GetClassesResponse), request2);
        }