示例#1
0
        private void GoToWebsite(object sender, EventArgs e)
        {
            var browserTask = new WebBrowserTask();

            browserTask.URL = _sponsor.Website;
            browserTask.Show();
        }
        private void ShowSystemBrowser(string url)
        {
            WebBrowserTask webBrowserTask = new WebBrowserTask();

            webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
            webBrowserTask.Show();
        }
示例#3
0
        private void btnTutorial_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.Uri = new Uri(Constants.TutorialUrl);
            task.Show();
        }
        private void GitHubLink_Tap(object sender, GestureEventArgs e)
        {
            WebBrowserTask wbt = new WebBrowserTask();

            wbt.Uri = new Uri("https://github.com/Humple/ScheduleBSUIR");
            wbt.Show();
        }
        public void ViewLicences()
        {
            WebBrowserTask webTask = new WebBrowserTask();

            webTask.Uri = new Uri(AppConstants.LEGAL_URL, UriKind.Absolute);
            webTask.Show();
        }
        internal void ViewFacebook()
        {
            WebBrowserTask wbTask = new WebBrowserTask();

            wbTask.Uri = new Uri(AppConstants.FACEBOOK_URL, UriKind.Absolute);
            wbTask.Show();
        }
示例#7
0
        private void MoreInfo_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask moreInfo = new WebBrowserTask();

            moreInfo.Uri = new Uri("http://msdn.microsoft.com/library/windowsphone/develop/ff402561(v=vs.105).aspx");
            moreInfo.Show();
        }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask browser = new WebBrowserTask();

            browser.URL = "http://www.mels-bar.com/";
            browser.Show();
        }
示例#9
0
        private void b_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.URL = "http://plancast.com/p/glo0/smart-girl-summit-2013";
            task.Show();
        }
示例#10
0
        private void a_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.URL = "http://plancast.com/p/i3o0/fight-like-girl-womens-self-defense";
            task.Show();
        }
示例#11
0
        private void C_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.URL = "http://plancast.com/p/i8pe/women-networking-meeting-long-beach";
            task.Show();
        }
示例#12
0
        private void d_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.URL = "http://plancast.com/p/ib0i/return-work-win-wins-webinar-mentorhealth";
            task.Show();
        }
示例#13
0
        void link_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton link = sender as HyperlinkButton;
            Uri             uri;
            WebBrowserTask  browser;

            if (link == null || string.IsNullOrWhiteSpace(link.TargetName))
            {
                return;
            }

            if (Uri.TryCreate(link.TargetName, UriKind.Absolute, out uri) ||
                (link.TargetName.StartsWith("www.") && Uri.TryCreate("http://" + link.TargetName, UriKind.Absolute, out uri)))
            {
                browser     = new WebBrowserTask();
                browser.Uri = uri;
                browser.Show();
            }
            else if (link.TargetName[0] == '@')
            {
                NavigationService.Navigate(new Uri("/Pages/Elements/User.xaml?user=" + link.TargetName.Substring(0), UriKind.Relative));
            }
            else if (link.TargetName[0] == '#')
            {
                Ocell.Pages.Search.ResourceViewModel.Resource = new TwitterResource
                {
                    User = DataTransfer.CurrentAccount,
                    Type = ResourceType.Search,
                    Data = link.TargetName
                };

                NavigationService.Navigate(Uris.ResourceView);
            }
        }
示例#14
0
        private void OpenUrl(OpenUrlMessage message)
        {
            string url  = message.Data.Url;
            int    mail = string.Compare(url, 0, "mailto:", 0, 6); //url.compare(0, 7, "mailto:");
            int    link = string.Compare(url, 0, "http", 0, 3);    //4

            if (link == 0)
            {
                WebBrowserTask webBrowserTask = new WebBrowserTask();
                webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
                webBrowserTask.Show();
            }
            else if (mail == 0)
            {
                url = url.Substring(7);
                EmailComposeTask emailComposeTask = new EmailComposeTask();
                emailComposeTask.Subject = "message subject";
                emailComposeTask.Body    = "message body";
                emailComposeTask.To      = url;
                emailComposeTask.Show();
            }
            else
            {
                url = GetServerUrl();
                WebBrowserTask webBrowserTask = new WebBrowserTask();
                webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
                webBrowserTask.Show();
            }
        }
示例#15
0
        private void TextBlock_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            WebBrowserTask wbtask = new WebBrowserTask();

            wbtask.Uri = new Uri("http://www.youtube.com/watch?v=YfqzZhcr__o");
            wbtask.Show();
        }
        private void WebBrowser_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            WebBrowserTask wbt = new WebBrowserTask();

            wbt.Uri = new Uri("http://jeffblankenburg.com");
            wbt.Show();
        }
        /// <summary>
        /// Handler for launch button
        /// </summary>
        private void LaunchInBrowser(object sender, EventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.Uri = new Uri(item.Url, UriKind.RelativeOrAbsolute);
            task.Show();
        }
        public void ViewWebsite()
        {
            WebBrowserTask webTask = new WebBrowserTask();

            webTask.Uri = new Uri(AppConstants.WEBSITE_URL, UriKind.Absolute);
            webTask.Show();
        }
示例#19
0
        //---------------------------------------------------------------------------------------------------------



        //Button Support
        //---------------------------------------------------------------------------------------------------------
        private void LinkXtrose(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var wb = new WebBrowserTask();

            wb.URL = "http://www.xtrose.com";
            wb.Show();
        }
        public void GiveFeedback()
        {
            WebBrowserTask wbTask = new WebBrowserTask();

            wbTask.Uri = new Uri(AppConstants.FEEDBACK_URL, UriKind.Absolute);
            wbTask.Show();
        }
示例#21
0
 public AboutViewModel()
 {
     OpenEmail = new DelegateCommand <string>(email => {
         var emailTask = new EmailComposeTask()
         {
             Subject = "MusicPimp Feedback",
             Body    = "Great app! I'm using " + NameAndVersion + " for Windows Phone.",
             To      = email
         };
         emailTask.Show();
     });
     OpenWebsite = new DelegateCommand <string>(url => {
         var browserTask = new WebBrowserTask();
         var uri         = new Uri(url, UriKind.RelativeOrAbsolute);
         browserTask.Uri = uri;
         browserTask.Show();
     });
     OpenMarketPlace = new UnitCommand(() => {
         var reviewTask = new MarketplaceReviewTask();
         reviewTask.Show();
         //var marketplaceDetailTask = new MarketplaceDetailTask();
         //marketplaceDetailTask.ContentIdentifier = "d31b505b-ac9f-4d93-8812-6b649734a5a6";
         //marketplaceDetailTask.ContentType = MarketplaceContentType.Applications;
         //marketplaceDetailTask.Show();
     });
 }
示例#22
0
        internal void FireAcceptedPush()
        {
            Statistic.SendRequest();
            if (LastPush.Url != null || LastPush.HtmlId != -1)
            {
                WebBrowserTask webBrowserTask = new WebBrowserTask();

                if (LastPush.Url != null)
                {
                    webBrowserTask.Uri = LastPush.Url;
                }
                else if (LastPush.HtmlId != -1)
                {
                    webBrowserTask.Uri = new Uri(Constants.HtmlPageUrl + LastPush.HtmlId, UriKind.Absolute);
                }

                webBrowserTask.Show();
            }

            if (!string.IsNullOrEmpty(_pushPage) && Application.Current.RootVisual is PhoneApplicationFrame &&
                !_pushPage.EndsWith(((PhoneApplicationFrame)Application.Current.RootVisual).CurrentSource.ToString()))
            {
                ((PhoneApplicationFrame)Application.Current.RootVisual).Navigated += OnNavigated;
                ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(new Uri(_pushPage, UriKind.Relative));
            }
            else
            {
                PushAccepted();
            }
        }
示例#23
0
        private void btn_video_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask wtb = new WebBrowserTask();

            wtb.Uri = new Uri("http://www.youtube.com/watch?feature=player_embedded&v=2MfkRfuYePU", UriKind.Absolute);
            wtb.Show();
        }
示例#24
0
        private void OnOpenWebPageMessageReceived(OpenWebPageMessage message)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.Uri = new Uri(message.Url);
            task.Show();
        }
示例#25
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask wb = new WebBrowserTask();

            wb.URL = "http://studentnokiadeveloper.com/";
            wb.Show();
        }
示例#26
0
        private void Ptiik_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.Uri = new Uri("http://ptiik.ub.ac.id", UriKind.Absolute);
            task.Show();
        }
示例#27
0
        private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            var webBrowserTask = new WebBrowserTask();

            webBrowserTask.Uri = new Uri("http://www.biletall.com.tr", UriKind.RelativeOrAbsolute);
            webBrowserTask.Show();
        }
示例#28
0
        private void PageTitle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var browserTask = new WebBrowserTask();

            browserTask.URL = Model.WikiUrl;
            browserTask.Show();
        }
示例#29
0
        private void Crevion_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();

            task.Uri = new Uri("http://facebook.com/crevion", UriKind.Absolute);
            task.Show();
        }
示例#30
0
        //---------------------------------------------------------------------------------------------------------



        //Button Store
        //---------------------------------------------------------------------------------------------------------
        private void BtnStore(object sender, RoutedEventArgs e)
        {
            var wb = new WebBrowserTask();

            wb.URL = "http://windowsphone.com/s?appid=8d7478b1-8bde-429d-b55c-d03a21029b51";
            wb.Show();
        }
示例#31
0
 public static void OpenUrl(String url)
 {
     #if WINDOWS
         System.Diagnostics.Process.Start(url);
     #elif WINDOWS_PHONE
         WebBrowserTask webBrowserTask = new WebBrowserTask();
         webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
         webBrowserTask.Show();
     #endif
 }
示例#32
0
 /*
 public static void launchMarket(String address, String windowName)
 {
     MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
     marketplaceDetailTask.ContentIdentifier = address;
     marketplaceDetailTask.ContentType = MarketplaceContentType.Applications;
     marketplaceDetailTask.Show();
 }
 */
 public static void launchBrowser(String address, String windowName)
 {
     #if WINDOWS
     System.Diagnostics.Process.Start(address);
     #elif WINDOWS_PHONE
     WebBrowserTask webBrowserTask = new WebBrowserTask();
     webBrowserTask.Uri = new Uri(address, UriKind.Absolute);
     webBrowserTask.Show();
     #endif
 }
示例#33
0
 /// <summary>
 /// Function read worksite names for current authorized user.
 /// </summary>
 private void ReadWorksitesAsync()
 {
     bool renavigate = (webBrowserTask == WebBrowserTask.Idle);
     webBrowserTask = WebBrowserTask.GetMembershipLink;
     if (renavigate)
     {
         webBrowser.Navigate(webBrowser.Url);
     }
 }
示例#34
0
 /// <summary>
 /// Initializes program passing Login in.
 /// </summary>
 public void Initialize()
 {
     webBrowserTask = WebBrowserTask.LogIn;
     webBrowser.Navigate(InitialUrl);
 }
示例#35
0
 private void GetAssignmentItemMessage()
 {
     String message = "";
     HtmlElementCollection Release = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("div");
     foreach (HtmlElement divs in Release)
     {
         if (divs.GetAttribute("className") == "alertMessage")
         {
             message = divs.InnerText;
             break;
         }
         else
         {
             message = String.Empty;
         }
     }
     webBrowserTask = WebBrowserTask.Idle;
     AddNewAssignmentItemProvider(message);
 }
示例#36
0
 private void InvokeAssignmentItemPost()
 {
     webBrowserTask = WebBrowserTask.Waiting;
     HtmlElementCollection asPosts = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("input");
     foreach (HtmlElement asPost in asPosts)
     {
         if (asPost.GetAttribute("name") == "post")
         {
             asPost.InvokeMember("CLICK");
         }
     }
     confidentLoad = true;
     webBrowserTask = WebBrowserTask.AddAssignmentItemsResultMessage;
 }
示例#37
0
 public void AddAssignmentItem(  string title, string description, string grade,
                                 string openday, string openmonth, string openyear,
                                 string dueday, string duemonth, string dueyear,
                                 string closeday, string closemonth, string closeyear)
 {
     AssignmentItemTitle = title;
     AssignmentItemDecription = description;
     AssignmentItemGrade = grade;
     AssignmentItemOpenDay = openday;
     AssignmentItemOpenMonth = openmonth;
     AssignmentItemOpenYear = openyear;
     AssignmentItemDueDay = dueday;
     AssignmentItemDueMonth = duemonth;
     AssignmentItemDueYear = dueyear;
     AssignmentItemCloseDay = closeday;
     AssignmentItemCloseMonth = closemonth;
     AssignmentItemCloseYear = closeyear;
     webBrowserTask = WebBrowserTask.AddAssignmentItems;
     webBrowser.Navigate(linkToAssignments);
 }
示例#38
0
        public bool DeleteGroup(string groupName)
        {
            bool result = true;

            if (String.IsNullOrWhiteSpace(linkToSiteEditor)) throw new Exception("Link to SiteEditor is empty. Can't delete new group.");
            if (String.IsNullOrWhiteSpace(groupName)) throw new ArgumentNullException("The given GroupName is incorrect. Can't delete new group.");

            deletingGroupName = groupName;
            groupSectionTask = GroupEditorSectionTask.DeleteExistingGroup;
            webBrowserTask = WebBrowserTask.OpenManageGroupsSection;
            webBrowser.Navigate(linkToSiteEditor);

            return result;
        }
示例#39
0
        /// <summary>
        /// Renames User. Web browser should be navigated to the User tab in Administration Workspace
        /// </summary>
        public void RenameUser(string id, string firstName, string lastName)
        {
            renamingStudentLastname = lastName;
            renamingStudentName = firstName;
            renamingStudentID = id;

            webBrowserTask = WebBrowserTask.RenameStudent;
            confidentLoad = true;
            webBrowser_DocumentCompleted(webBrowser, null);
        }
示例#40
0
 /// <summary>
 /// Opens Users tab. Web browser should be navigated to Administration Workspace
 /// </summary>
 public void OpenAdministrationWorkspaceUsersTab()
 {
     webBrowserTask = WebBrowserTask.GoToAdministrationWorkspaceUsersTab;
     confidentLoad = true;
     webBrowser_DocumentCompleted(webBrowser, null);
 }
示例#41
0
 public void GradeStudent(string assignmentName, string studentID, String mark)
 {
     Assignment assignment = dctAssignmentItems[assignmentName];
     studentmark = mark;
     webBrowserTask = WebBrowserTask.SelectStudentToGrade;
     gradeStudentID = studentID;
     confidentLoad = true;
     webBrowser.Document.Window.Frames[1].Navigate(assignment.Link);
 }
示例#42
0
 public void SetDelayOfTestDueDate(String testName, uint delay)
 {
     if (linkToTestsAndQuizzes != String.Empty)
     {
         currentTestDelay = delay;
         currentTestName = testName;
         webBrowserTask = WebBrowserTask.OpenTestAndQuizzesSettings;
         confidentLoad = true;
         webBrowser.Navigate(linkToTestsAndQuizzes);
     }
     
 }
示例#43
0
        public void UpdateAssignmentSubmissions(string assignmentTitle)
        {
            // We should find indexOfProcessingAssignment for assignmentTitle
            indexOfProcessingAssignment = -1;
            for (int i = 0; i < dctAssignmentItems.Count; i++ )
            {
                string keyTrimed = dctAssignmentItems.ElementAt(i).Key.Trim();
                if (keyTrimed == assignmentTitle)
                {
                    indexOfProcessingAssignment = i;
                    break;
                }
            }
            if (indexOfProcessingAssignment == -1)
                return;
            webBrowserTask = WebBrowserTask.ReloadStudents;

            if (dctAssignmentItems.Count >= 1) // Load students into the main frame
            {
                dctStudentInfos.Clear();
                confidentLoad = true;
                webBrowser.Document.Window.Frames[1].Navigate(dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.Link);
            }
        }
示例#44
0
        /// <summary>
        /// Parse students from selected assignment
        /// </summary>
        /// <param name="assignment"></param>
        public void ParseStudents(String assignment)
        {
            indexOfProcessingAssignment = -1;
            String[] assignments = dctAssignmentItems.Keys.ToArray();
            for (int i = 0; i < assignments.Length; i++)
            {
                if (assignments[i] == assignment)
                {
                    indexOfProcessingAssignment = i;
                    break;
                }
            }
            webBrowserTask = WebBrowserTask.ReloadStudents;

            if (dctAssignmentItems.Count >= 1) // Load into the main frame students
            {
                dctStudentInfos.Clear();
                confidentLoad = true;
                webBrowser.Document.Window.Frames[1].Navigate(dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.Link);
            }
        }
示例#45
0
        /// <summary>
        /// Method works with html and gets all required information about students.
        /// Works with indexOfProcessingAssignment, it should be set.
        /// </summary>
        private StudentInfo[] ParseLoadingStudents(int assignmentIndex, bool gradecall)
        {
            HtmlElementCollection submissionTable = webBrowser.Document.Window.Frames[1].Document.Forms["listSubmissionsForm"].Document.GetElementsByTagName("table");

            foreach (HtmlElement table in submissionTable)
            {
                if (table.GetAttribute("className") == "listHier lines nolines")
                {
                    HtmlElementCollection trs = table.GetElementsByTagName("tr");
                    foreach (HtmlElement tr in trs)
                    {
                        HtmlElementCollection tds = tr.GetElementsByTagName("td");

                        string studentName = "";
                        string studentID = "";
                        string submitted = "";
                        string status = "";
                        string grade = "";
                        bool released = false;
                        bool attached = tr.InnerHtml.Contains("attachments.gif");
                        string gradeLink = "";

                        foreach (HtmlElement td in tds)
                        {
                            if (td.GetAttribute("headers") == "studentname")
                            {
                                string text = td.InnerText.Trim();
                                MatchCollection matches = Regex.Matches(text, @"\(([\w|\.|\s]*)\)"); // Gets student ID
                                studentID = matches[0].Groups[1].Value;
                                studentName = text.Substring(0, text.IndexOf(" ("));
                                gradeLink = td.GetElementsByTagName("a")[0].GetAttribute("href");
                            }
                            if (td.GetAttribute("headers") == "submitted")
                            {
                                submitted = td.InnerText;
                            }
                            if (td.GetAttribute("headers") == "status")
                            {
                                status = td.InnerText;
                            }
                            if (td.GetAttribute("headers") == "grade")
                            {
                                grade = td.InnerText;
                            }
                            if (td.GetAttribute("headers") == "gradereleased")
                            {
                                released = td.InnerHtml.Contains("checkon.gif");
                            }
                        }

                        if (gradecall)
                        {
                            if (studentID == gradeStudentID)
                            {
                                webBrowserTask = WebBrowserTask.GradeStudent;
                                confidentLoad = true;
                                webBrowser.Document.Window.Frames[1].Navigate(gradeLink);

                                break;
                            }
                        }
                        else
                        {
                            if (studentID != "" && studentName != "")
                            {
                                Dictionary<string, StudentInfo> sid = dctAssignmentItems.ElementAt(assignmentIndex).Value.StudentInfosDictionary;
                                StudentInfo si = new StudentInfo(studentName, studentID, submitted, status, grade, released, gradeLink, attached);
                                if (sid.ContainsKey(studentID))
                                {
                                    sid[studentID] = si;
                                }
                                else
                                {
                                    sid.Add(studentID, si);
                                }

                            }
                        }
                    }

                }
            }

            return gradecall? null: dctAssignmentItems.ElementAt(assignmentIndex).Value.StudentInfosDictionary.Values.ToArray();
        }
示例#46
0
 /// <summary>
 /// Selects the worksite name.
 /// The name should be existing.
 /// </summary>
 /// <param name="worksiteName">The name of the worksite</param>
 public void SelectWorksite(string worksiteName)
 {
     this.worksiteName = worksiteName;
     ResetFields();
     webBrowserTask = WebBrowserTask.ParseSelectedWorksite;
     webBrowser.Navigate(dctWorksites[worksiteName]);
 }
示例#47
0
        private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (!confidentLoad)
            {
                if (e == null) return;
                if (e.Url != webBrowser.Url) return; // If we have not reached destination URL
                if (String.IsNullOrWhiteSpace(webBrowser.DocumentTitle)) return; // Waiting for page
            }
            else // Web form has been reloaded, we know confidently
            {
                confidentLoad = false; // We don't want to be confident every time =)
            }

            switch (webBrowserTask)
            {
                case WebBrowserTask.Busy:
                    {
                        webBrowserTask = WebBrowserTask.Idle;
                        break;
                    }
                case WebBrowserTask.LogIn:
                    LogIn();
                    break;
                case WebBrowserTask.ParseWorksites:
                    HtmlElement worksiteTable = webBrowser.Document.Window.Frames[0].Document.GetElementById("currentSites");
                    HtmlElementCollection tableTDs = worksiteTable.GetElementsByTagName("td");
                    foreach (HtmlElement worksiteTD in tableTDs)
                    {
                        if (worksiteTD.GetAttribute("headers") == "worksite")
                        {
                            HtmlElement linkToWorksite = worksiteTD.GetElementsByTagName("a")[0];
                            string sLink = linkToWorksite.GetAttribute("href");
                            if (dctWorksites.ContainsKey(worksiteTD.InnerText))
                            {
                               //SPExceptionProvider(SPExceptions.WorksiteNameAlreadyExist);
                            }
                            else
                            {
                                dctWorksites.Add(worksiteTD.InnerText, sLink);
                            }
                        }
                    }
                    //Alternative implementation:
                    //HtmlElement worksiteTables = webBrowser.Document.Window.Frames[0].Document.GetElementById("currentSites");
                    //HtmlElementCollection curSites = worksiteTables.GetElementsByTagName("a");
                    //string sLink = "";
                    //foreach (HtmlElement workSiteName in curSites)
                    //{
                    //    if (workSiteName.GetAttribute("target") == "_top")
                    //    {
                    //        sLink = workSiteName.GetAttribute("href");
                    //        dctWorksites.Add(workSiteName.InnerText,sLink);
                    //    }
                    //}
                    // Worksites in dctWorksites
                    bool nextPageAvailable = false;
                    HtmlElementCollection buttonForms = webBrowser.Document.Window.Frames[0].Document.GetElementsByTagName("input");
                    foreach (HtmlElement worksiteTD in buttonForms)
                    {
                        if (worksiteTD.GetAttribute("name") == "eventSubmit_doList_next")
                        {
                            if (worksiteTD.GetAttribute("disabled") == "False")
                            {
                                nextPageAvailable = true;
                                break;
                            }
                        }
                    }
                    if (nextPageAvailable)
                    {
                        webBrowserTask = WebBrowserTask.ParseWorksites;
                        webBrowser.Navigate("javascript:window.frames[0].document.forms[4].elements[0].click()");
                        Task asyncTask = new Task(() =>
                        {
                            Thread.Sleep(500);
                        });

                        asyncTask.ContinueWith((a) =>
                        {
                            webBrowser.Navigate(webBrowser.Url);
                        }, TaskScheduler.FromCurrentSynchronizationContext());

                        asyncTask.Start();
                    }
                    else
                    {
                        webBrowserTask = WebBrowserTask.Idle;
                        WorksitesReadyProvider();
                    }
                    break;
                case WebBrowserTask.GetMembershipLink:

                    HtmlElementCollection linksCollection = webBrowser.Document.GetElementsByTagName("a");
                    foreach (HtmlElement link in linksCollection)
                        if (link.GetAttribute("className") == "icon-sakai-membership")
                            linkToMembership = link.GetAttribute("href");
                    if (linkToMembership == "")
                    {
                        SPExceptionProvider(SPExceptions.UnableToFindMembership);
                    }
                    webBrowserTask = WebBrowserTask.ParseWorksites;
                    dctWorksites.Clear();
                    webBrowser.Navigate(linkToMembership);
                    break;
                case WebBrowserTask.ParseSelectedWorksite:
                    // Now we are at HOME link, maybe
                    // Now we are at Home of the WorkSite
                    linkToAssignments = "";
                    linkToSiteEditor = "";
                    linkToTestsAndQuizzes = "";
                    HtmlElementCollection links = webBrowser.Document.GetElementsByTagName("a");
                    foreach (HtmlElement link in links)
                    {
                        if (link.GetAttribute("className") == "icon-sakai-assignment-grades")
                        {
                            linkToAssignments = link.GetAttribute("href");
                        }
                        else if (link.GetAttribute("className") == "icon-sakai-siteinfo")
                        {
                            // Parsing site editor link.
                            linkToSiteEditor = link.GetAttribute("href");
                        }
                        else if (link.GetAttribute("className") == "icon-sakai-samigo")
                        {
                            linkToTestsAndQuizzes = link.GetAttribute("href");
                        }
                    }
                    if (linkToAssignments == "") throw new Exception("Unable to find Assignments link");

                    // if (linkToSiteEditor == "") throw new Exception("Unable to find SiteEditor link");

                    // If it is okay, we have linkToSiteEditor

                    webBrowserTask = WebBrowserTask.Idle;
                    WorksiteSelectedProvider();
                    break;
                case WebBrowserTask.GoToAssignments:
                    //////////////////////////////////////////////////////////////////////////////////
                    /*webBrowserTask = WebBrowserTask.ParseAssignments;
                    webBrowser.Navigate(linkToAssignments);*/
                    //////////////////////////////////////////////////////////////////////////////////

                    break;
                case WebBrowserTask.ParseAssignments:
                    // To fix
                    HtmlElementCollection assignmentsTable = webBrowser.Document.Window.Frames[1].Document.Forms["listAssignmentsForm"].Document.GetElementsByTagName("table");
                    foreach (HtmlElement table in assignmentsTable)
                    {
                        if (table.GetAttribute("className") == "listHier lines nolines")
                        {
                            HtmlElementCollection trs = table.GetElementsByTagName("tr");
                            foreach (HtmlElement tr in trs)
                            {
                                HtmlElementCollection tds = tr.GetElementsByTagName("td");

                                string title = "";
                                string status = "";
                                string open = "";
                                string url = "";
                                string due = "";
                                string innew = "";
                                string scale = "";

                                foreach (HtmlElement td in tds)
                                {
                                    if (td.GetAttribute("headers") == "title")
                                    {
                                        HtmlElement link = td.GetElementsByTagName("a")[0];
                                        title = link.InnerText.Trim();
                                    }
                                    if (td.GetAttribute("headers") == "status")
                                    {
                                        status = td.InnerText;
                                    }
                                    if (td.GetAttribute("headers") == "openDate")
                                    {
                                        open = td.InnerText;
                                    }
                                    if (td.GetAttribute("headers") == "dueDate")
                                    {
                                        due = td.InnerText;
                                    }
                                    if (td.GetAttribute("headers") == "num_submissions")
                                    {
                                        HtmlElementCollection linksCount = td.GetElementsByTagName("a");
                                        if (linksCount.Count > 0)
                                        {
                                            HtmlElement link = linksCount[0];
                                            string outerHtml = link.OuterHtml;
                                            MatchCollection mathes = Regex.Matches(outerHtml,
                                                "window.location\\s*=\\s*('|\")(.*?)('|\")", RegexOptions.IgnoreCase);
                                            url = mathes[0].Groups[2].Value;

                                            innew = td.InnerText;
                                        }
                                    }
                                    if (td.GetAttribute("headers") == "maxgrade")
                                    {
                                        scale = td.InnerText;
                                    }
                                }
                                if (title != "" && status != "" && open != "" && url != "" && due != "" && innew != "" && scale != "")
                                    dctAssignmentItems.Add(title, new Assignment(title, url, status, open, due, innew, scale));
                            }
                        }
                    }
                    // Assignments are supposed to be parsed
                    assignmentsParsed = true;
                    webBrowserTask = WebBrowserTask.Idle;
                    AssignmentItemsReadyProvider();
                    break;
                // We have all assignments. Go to LoadStudents
                case WebBrowserTask.AddAssignmentItems:
                    webBrowserTask = WebBrowserTask.Waiting;
                    HtmlElementCollection AssignmentMenuLinks = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("a");
                    foreach (HtmlElement AssignmentMenuLink in AssignmentMenuLinks)
                    {
                        if (AssignmentMenuLink.GetAttribute("title") == "Add")
                        {
                            AssignmentMenuLink.InvokeMember("CLICK");
                        }
                    }
                    Task asyncTask1 = new Task(() =>
                        {
                            Thread.Sleep(1000);
                        });

                        asyncTask1.ContinueWith((a) =>
                        {
                            webBrowserTask = WebBrowserTask.CountinueAddAssignmentItems;
                            confidentLoad = true;
                            webBrowser_DocumentCompleted(webBrowser, null);

                        }, TaskScheduler.FromCurrentSynchronizationContext());

                        asyncTask1.Start();
                    break;
                case WebBrowserTask.CountinueAddAssignmentItems:
                    webBrowserTask = WebBrowserTask.Waiting;
                    HtmlElementCollection asAreas = webBrowser.Document.Window.Frames[1].Document.Window.Frames[0].Document.Window.Frames[0].Document.GetElementsByTagName("body");
                    foreach(HtmlElement asArea in asAreas)
                    {
                            asArea.InnerHtml = AssignmentItemDecription;
                    }
                    HtmlElementCollection asSelects = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("select");
                    foreach (HtmlElement asSelect in asSelects)
                    {
                        if (asSelect.Id == "new_assignment_openmonth")
                        {
                            HtmlElementCollection openmonths = asSelect.Children;
                            foreach (HtmlElement openmonth in openmonths)
                            {
                                if (openmonth.GetAttribute("value") == (AssignmentItemOpenMonth).ToString())
                                {
                                    openmonth.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_openday")
                        {
                            HtmlElementCollection opendays = asSelect.Children;
                            foreach (HtmlElement openday in opendays)
                            {
                                if (openday.GetAttribute("value") == (AssignmentItemOpenDay).ToString())
                                {
                                    openday.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_openyear")
                        {
                            HtmlElementCollection openyears = asSelect.Children;
                            foreach (HtmlElement openyear in openyears)
                            {
                                if (openyear.GetAttribute("value") == (AssignmentItemOpenYear).ToString())
                                {
                                    openyear.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_duemonth")
                        {
                            HtmlElementCollection duemonths = asSelect.Children;
                            foreach (HtmlElement duemonth in duemonths)
                            {
                                if (duemonth.GetAttribute("value") == (AssignmentItemDueMonth).ToString())
                                {
                                    duemonth.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_closemonth")
                        {
                            HtmlElementCollection closemonths = asSelect.Children;
                            foreach (HtmlElement closemonth in closemonths)
                            {
                                if (closemonth.GetAttribute("value") == (AssignmentItemDueMonth).ToString())
                                {
                                    closemonth.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_dueday")
                        {
                            HtmlElementCollection opendays = asSelect.Children;
                            foreach (HtmlElement openday in opendays)
                            {
                                if (openday.GetAttribute("value") == (AssignmentItemDueYear).ToString())
                                {
                                    openday.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_closeday")
                        {
                            HtmlElementCollection closedays = asSelect.Children;
                            foreach (HtmlElement closeday in closedays)
                            {
                                if (closeday.GetAttribute("value") == (AssignmentItemDueYear).ToString())
                                {
                                    closeday.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_dueyear")
                        {
                            HtmlElementCollection dueyears = asSelect.Children;
                            foreach (HtmlElement dueyear in dueyears)
                            {
                                if (dueyear.GetAttribute("value") == (AssignmentItemDueYear).ToString())
                                {
                                    dueyear.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_closeyear")
                        {
                            HtmlElementCollection closeyears = asSelect.Children;
                            foreach (HtmlElement closeyear in closeyears)
                            {
                                if (closeyear.GetAttribute("value") == (AssignmentItemDueYear).ToString())
                                {
                                    closeyear.SetAttribute("selected", "selected");
                                }
                            }
                        }
                        if (asSelect.Id == "new_assignment_grade_type")
                        {
                            HtmlElementCollection gradeTypes = asSelect.Children;
                            foreach (HtmlElement gradeType in gradeTypes)
                            {
                                if (gradeType.GetAttribute("value") == "3")
                                {
                                    gradeType.SetAttribute("selected", "selected");
                                }
                            }
                            asSelect.InvokeMember("onchange");
                        }
                        HtmlElementCollection txts = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("input");
                        foreach (HtmlElement asName in txts)
                        {
                            if (asName.GetAttribute("id") == "new_assignment_title")
                            {
                                asName.SetAttribute("value", AssignmentItemTitle);
                            }
                            if (asName.Id == "new_assignment_grade_points")
                            {
                                asName.SetAttribute("value", AssignmentItemGrade);
                            }
                        }
                    }
                    Task asyncTask2 = new Task(() =>
                        {
                            Thread.Sleep(1000);
                        });

                        asyncTask2.ContinueWith((a) =>
                        {
                            InvokeAssignmentItemPost();

                        }, TaskScheduler.FromCurrentSynchronizationContext());

                        asyncTask2.Start();
                    break;
                case WebBrowserTask.AddAssignmentItemsResultMessage:
                    webBrowserTask = WebBrowserTask.Waiting;
                    Task asyncTask4 = new Task(() =>
                        {
                            Thread.Sleep(2000);
                        });

                        asyncTask4.ContinueWith((a) =>
                        {

                            GetAssignmentItemMessage();

                        }, TaskScheduler.FromCurrentSynchronizationContext());

                        asyncTask4.Start();
                        webBrowserTask = WebBrowserTask.AddAssignmentItemsResultMessage;
                    break;
                case WebBrowserTask.ParseTestsAndQuizzes:
                    int ii = 0;
                    HtmlElement form = webBrowser.Document.Window.Frames[1].Document.GetElementById("authorIndexForm");
                    HtmlElementCollection testsName = form.Document.GetElementsByTagName("td");
                    foreach (HtmlElement testName in testsName)
                    {
                        if (testName.GetAttribute("className") == "titlePub")
                        {
                            dctTestAndQuizzesItems.Add(ii.ToString(),new TestsAndQuizzes(testName.InnerText));
                            ii++;
                        }
                    }

                    webBrowserTask = WebBrowserTask.Idle;
                    TestsAndQuizzesReadyProvider();
                    break;
                case WebBrowserTask.OpenTestAndQuizzesSettings:
                    Regex reginactive = new Regex("inactivePublishedSelectAction");
                    Regex regactive = new Regex("publishedSelectAction");
                    Regex reg1 = new Regex("inactivePublishedSelectAction[0-9]+");
                    Regex reg2 = new Regex("publishedSelectAction[0-9]+");
                    int numLink = 0;
                    HtmlElement testAndQuizzesItem;
                    HtmlElementCollection testAndQuizzesLinks = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("a");
                    //HtmlElementCollection testAndQuizzesSelect;
                    HtmlElementCollection testAndQuizzesOptions;
                    String testAndQuizzesStr = "";
                    HtmlElement testAndQuizessForm = webBrowser.Document.Window.Frames[1].Document.GetElementById("authorIndexForm");
                    HtmlElementCollection testAndQuizzesItems = testAndQuizessForm.Document.GetElementsByTagName("td");
                    foreach (HtmlElement item in testAndQuizzesItems)
                    {
                        if (item.GetAttribute("className") == "titlePub")
                        {
                            if (item.InnerText == currentTestName)
                            {
                                testAndQuizzesItem = item.Parent;
                                testAndQuizzesItem = testAndQuizzesItem.FirstChild;
                                testAndQuizzesItem = testAndQuizzesItem.FirstChild;
                                testAndQuizzesOptions = testAndQuizzesItem.Children;
                                foreach (HtmlElement option in testAndQuizzesOptions)
                                {
                                    if (option.GetAttribute("value").ToString() == "settings_published")
                                    {
                                        option.SetAttribute("selected", "selected");
                                        if (reginactive.IsMatch(testAndQuizzesItem.Id))
                                        {
                                            testAndQuizzesStr = reg1.Replace(testAndQuizzesItem.Id, "inactivePublishedHiddenlink");
                                        }
                                        else
                                        {
                                            testAndQuizzesStr = reg2.Replace(testAndQuizzesItem.Id, "publishedHiddenlink");
                                        }
                                        foreach (HtmlElement link in testAndQuizzesLinks)
                                        {
                                            if (link.Id == testAndQuizzesStr)
                                            {
                                                webBrowser.Navigate("javascript:window.frames[1].document.links[" + numLink + "].click()");
                                            }
                                            else
                                            {
                                                numLink++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    webBrowserTask = WebBrowserTask.SetTestAndQuizzesDueDate;
                    confidentLoad = true;
                    break;
                case WebBrowserTask.SetTestAndQuizzesDueDate:
                    var culture = new CultureInfo("en-US");
                    DateTime localDate = DateTime.Now;
                    DateTime newdate = DateTime.Now;
                    TimeSpan timer = new TimeSpan(0, (int)currentTestDelay, 0);
                    newdate = newdate.Add(timer);
                    HtmlElementCollection dates = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("input");
                    foreach (HtmlElement date in dates)
                    {
                        if (date.GetAttribute("id") == "assessmentSettingsAction:startDate")
                        {
                            date.SetAttribute("value",localDate.ToString(culture));
                        }
                        if (date.GetAttribute("id") == "assessmentSettingsAction:endDate")
                        {
                            date.SetAttribute("value", newdate.ToString(culture));
                        }
                    }
                    HtmlElement testSettings = webBrowser.Document.Window.Frames[1].Document.GetElementById("assessmentSettingsAction");
                    HtmlElementCollection testSettingsElems = testSettings.All;
                    foreach (HtmlElement elem in testSettingsElems)
                    {
                        if (elem.GetAttribute("value") == "Save Settings")
                        {
                            elem.InvokeMember("CLICK");
                        }
                    }
                    webBrowserTask = WebBrowserTask.Idle;
                    DelayOfTestAssignedProvider();
                    break;
                case WebBrowserTask.ReloadStudents:

                    ParseLoadingStudents(indexOfProcessingAssignment, false);
                    webBrowserTask = WebBrowserTask.Idle;
                    StudentsInformationReadyProvider();
                    break;
                case WebBrowserTask.LoadStudents:

                    // Finding students
                    ParseLoadingStudents(indexOfProcessingAssignment, false);

                    confidentLoad = true; // We are not women :)
                    indexOfProcessingAssignment++;
                    if (indexOfProcessingAssignment >= dctAssignmentItems.Count)
                    {
                        // We have all in data base
                        // We can start to download students attachments
                        // We will process each assignment and each submission of processing assignment
                        webBrowserTask = WebBrowserTask.LoadStudentAttachments;
                        indexOfProcessingAssignment = 0; // Reset indexers
                        indexOfProcessingStudent = 0; // Reset indexers
                        // Only student with attachments will ne processed
                        confidentLoad = true; // Here we also men

                        attachmentPresent = dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.ElementAt(indexOfProcessingStudent).Value.FilesAttached;
                        if (attachmentPresent)
                            webBrowser.Document.Window.Frames[1].Navigate(dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.ElementAt(indexOfProcessingStudent).Value.GradeLink); // If you see it you are hero
                        else webBrowser_DocumentCompleted(webBrowser, null);
                        // Than the programe will be in LoadStudentAttachments switch case
                    }
                    else webBrowser.Document.Window.Frames[1].Navigate(dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.Link);
                    break;
                case WebBrowserTask.LoadStudentAttachments:
                    // Indexers should be initialized before this case reached

                    if (attachmentPresent)
                    {
                        // We are here if student has attachment. The page with it is loaded
                        HtmlElementCollection uls = webBrowser.Document.Window.Frames[1].Document.Forms["gradeForm"].Document.GetElementsByTagName("ul");
                        foreach (HtmlElement ul in uls)
                        {
                            if (ul.GetAttribute("className") == "attachList indnt1")
                            {
                                HtmlElementCollection alinks = ul.GetElementsByTagName("a");
                                foreach (HtmlElement alink in alinks)
                                {
                                    string slink = alink.GetAttribute("href");
                                    string fileName = alink.InnerText;

                                    if (dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.ElementAt(indexOfProcessingStudent).Value.SubmittedFiles == null)
                                    {
                                        dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.ElementAt(indexOfProcessingStudent).Value.SubmittedFiles = new List<SubmittedFile>();
                                    }

                                    SubmittedFile file = new SubmittedFile();
                                    file.Link = slink;
                                    file.Name = fileName;
                                    dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.ElementAt(indexOfProcessingStudent).Value.SubmittedFiles.Add(file);
                                }
                            }
                        }
                    }

                    indexOfProcessingStudent++;
                    if (indexOfProcessingStudent >= dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.Count)
                    {
                        indexOfProcessingAssignment++;
                        indexOfProcessingStudent = 0;
                        if (indexOfProcessingAssignment >= dctAssignmentItems.Count)
                        {
                            webBrowserTask = WebBrowserTask.Idle; // We are done with attachments loading. Lets have a rest
                            break;
                        }
                    }

                    attachmentPresent = dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.ElementAt(indexOfProcessingStudent).Value.FilesAttached;
                    if (attachmentPresent == true)
                    {
                        // If the student attached files
                        confidentLoad = true; // I'm a man! too dooo do do
                        webBrowser.Document.Window.Frames[1].Navigate(dctAssignmentItems.ElementAt(indexOfProcessingAssignment).Value.StudentInfosDictionary.ElementAt(indexOfProcessingStudent).Value.GradeLink);
                    }
                    else
                        if (attachmentPresent == false)
                        {
                            confidentLoad = true; // Bypass call. Don't know whether it is necessary, but let it be
                            webBrowser_DocumentCompleted(webBrowser, e);
                        }

                    break;
                case WebBrowserTask.OpenManageGroupsSection:
                    // Todo: find link to Manage Groups section.

                    linkToManageGroupsSection = "";
                    HtmlElementCollection lisElementCollection = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("li");
                    foreach (HtmlElement element in lisElementCollection)
                    {
                        if (element.GetAttribute("role") == "menuitem" && element.InnerHtml.Contains("doManageGroupHelper"))
                        {
                            MatchCollection matchCollection = Regex.Matches(element.InnerHtml,
                                @"(onclick)\s*=\s*""\s*(location)\s*=\s*'(?<link>.*)'\s*;");
                            linkToManageGroupsSection = matchCollection[0].Groups["link"].Value;
                        }
                    }

                    // linkToManageGroupsSection contains link to Manage Groups section. 
                    // We can navigate it right now.

                    webBrowser.Document.Window.Frames[1].Navigate(linkToManageGroupsSection);


                    //webBrowser.Navigate(linkToManageGroupsSection);
                    // LoadGroupsEditor is a page where we set name of group and add participants.
                    webBrowserTask = WebBrowserTask.LoadGroupsEditor;

                    confidentLoad = true; // The Frame URL of doesn't match Browser URL, beacuse Browser URL has nothing to do with frame.
                    //webBrowser_DocumentCompleted(webBrowser, e);

                    break;
                case WebBrowserTask.LoadGroupsEditor:
                    // Here we find the link to Create New Group section

                    switch (groupSectionTask)
                    {
                        case GroupEditorSectionTask.CreateNewGroup:
                            {
                                linkToCreateNewGroupSection = "";

                                HtmlElementCollection liElementCollection =
                                    webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("li");
                                foreach (
                                    HtmlElement htmlElement in
                                        liElementCollection.Cast<HtmlElement>()
                                            .Where(
                                                htmlElement => htmlElement.GetAttribute("className") == "firstToolBarItem"))
                                {
                                    if (htmlElement.InnerHtml.Contains("GroupEdit") &&
                                        htmlElement.InnerHtml.Contains("item_control"))
                                    {
                                        MatchCollection matchCollection = Regex.Matches(htmlElement.InnerHtml,
                                            "<[a|A].*href\\s*=\\s*[\"|'](?<link>.*)[\"|']\\s*>");
                                        linkToCreateNewGroupSection = matchCollection[0].Groups["link"].Value;
                                    }
                                }

                                if (linkToCreateNewGroupSection == "")
                                    throw new Exception("Link to Create New Group is not found.");

                                confidentLoad = true;
                                // The Frame URL of doesn't match Browser URL, beacuse Browser URL has nothing to do with frame.
                                webBrowser.Document.Window.Frames[1].Navigate(linkToCreateNewGroupSection);

                                // Browser is navigated to linkToCreateNewGroupSection
                                // Now lets add new group. 

                                webBrowserTask = WebBrowserTask.AddNewGroup;

                                break;
                            }
                        case GroupEditorSectionTask.DeleteExistingGroup:
                            {

                                webBrowserTask = WebBrowserTask.Idle;

                                HtmlElementCollection tablesCollection = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("table");
                                foreach (HtmlElement element in tablesCollection)
                                {
                                    if (element.GetAttribute("className").Contains("listHier") ||
                                        element.GetAttribute("className").Contains("lines") ||
                                        element.GetAttribute("className").Contains("nolines") ||
                                        element.GetAttribute("className").Contains("centerLines"))
                                    {
                                        HtmlElementCollection trsCollection = element.GetElementsByTagName("tr");
                                        foreach (HtmlElement trElement in trsCollection)
                                        {
                                            if (trElement.InnerText.Contains(deletingGroupName))
                                            {
                                                if (trElement.GetElementsByTagName("span")[0].InnerText == deletingGroupName)
                                                {
                                                    HtmlElement inputToCheck = trElement.GetElementsByTagName("input")[0];
                                                    inputToCheck.InvokeMember("CLICK");
                                                }
                                            }
                                        }
                                    }
                                }

                                HtmlElement deleteButtonInputElement = webBrowser.Document.Window.Frames[1].Document.GetElementById("delete-groups");
                                deleteButtonInputElement.InvokeMember("CLICK");

                                new Thread(() =>
                                {
                                    Thread.Sleep(1000);
                                    Application.OpenForms["Form1"].Invoke(confirmDeletingVoid);
                                }).Start();

                                break;
                            }
                        case GroupEditorSectionTask.GetGroupList:
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }


                    break;
                case WebBrowserTask.AddNewGroup:

                    // Description adding is not implemented yet.

                    HtmlWindow addGroupFrame = webBrowser.Document.Window.Frames[1];

                    addGroupFrame.Document.GetElementById("group_title").SetAttribute("value", addingGroupName);

                    HtmlElement selectOprionsElement = addGroupFrame.Document.GetElementById("siteMembers-selection");
                    HtmlElementCollection options = selectOprionsElement.Document.GetElementsByTagName("option");

                    Dictionary<string, int> dctSelectionOptions = new Dictionary<string, int>();

                    for (int i = 0; i < options.Count; i++)
                    {
                        MatchCollection matches = Regex.Matches(options[i].OuterHtml, ">.*\\((?<id>.*)\\)\\s*<");
                        dctSelectionOptions.Add(
                            matches.Count != 0 ? matches[0].Groups["id"].Value : options[i].InnerText, i);
                    }

                    foreach (string id in addingStudentIDs)
                    {
                        addGroupFrame.Document.GetElementsByTagName("option")[dctSelectionOptions[id]].SetAttribute("selected", "selected");
                        addingStudentsCount++;
                    }

                    if (addingStudentIDs.Length != 0)
                        addGroupFrame.Document.GetElementById("siteMembers-selection").InvokeMember("ondblclick");

                    addGroupFrame.Document.GetElementById("save").InvokeMember("click");
                    //addGroupFrame.Document.GetElementById("pw").SetAttribute("value", Password);
                    //addGroupFrame.Navigate("javascript:document.forms[0].submit()");
                    //webBrowserTask = WebBrowserTask.GetMembershipLink;

                    webBrowserTask = WebBrowserTask.Idle;

                    break;
                case WebBrowserTask.SelectStudentToGrade:
                    // Current page contains the list of students.
                    // Let's find the link width "Grade" title

                    ParseLoadingStudents(0, true);

                    break;

                case WebBrowserTask.GradeStudent:
                    webBrowser.Document.Window.Frames[1].Document.GetElementById("grade").SetAttribute("value", studentmark);
                    HtmlElementCollection processBtn = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("input");
                    foreach (HtmlElement element in processBtn)
                    {
                        if (element.GetAttribute("name") == "return")
                        {
                            element.InvokeMember("CLICK");
                            confidentLoad = true;
                            break;
                        }
                    }
                    webBrowserTask = WebBrowserTask.GradeResultMessage;
                    break;
                case WebBrowserTask.GradeResultMessage:
                    {
                        bool success = false;
                        String releaseMessage = "";
                        HtmlElementCollection bRelease = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("div");
                        if (bRelease.Count != 0)
                        {
                            foreach (HtmlElement divs in bRelease)
                            {
                                if (divs.GetAttribute("className") == "success")
                                {
                                    success = true;
                                    releaseMessage = divs.InnerText;
                                    break;
                                }
                                else if (divs.GetAttribute("className") == "alertMessage")
                                {
                                    success = false;
                                    releaseMessage = divs.InnerText;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            SPExceptionProvider(SPExceptions.GradeFrameWasntFound);
                        }
                        webBrowserTask = WebBrowserTask.Idle;
                        if (releaseMessage == String.Empty)
                        {
                            SPExceptionProvider(SPExceptions.GradeMessageWasntFound);
                        }
                        else
                        {
                            StudentGradedProvider(success, releaseMessage);
                        }
                        break;
                    }
                case WebBrowserTask.GoToAdministrationWorkspaceUsersTab:
                    {
                        HtmlElementCollection hec = webBrowser.Document.GetElementsByTagName("a");
                        //foreach(String str in from HtmlElement he in hec where he.InnerText.Contains("Users") select he.GetAttribute("href"))
                        String str = "";
                        foreach (HtmlElement elem in hec)
                        {
                            if (elem.InnerText != null)
                            {
                                if (elem.InnerText.Contains("Users"))
                                {
                                    str = elem.GetAttribute("href");
                                    break;
                                }
                            }
                        }
                        if (!String.IsNullOrEmpty(str))
                        {
                            webBrowserTask = WebBrowserTask.Busy;
                            webBrowser.Navigate(str);
                        }
                        else
                        {
                            SPExceptionProvider(SPExceptions.UnableToFindLinkToUsersTab);
                            return;
                        }
                        break;
                    }
                case WebBrowserTask.RenameStudent:
                    {
                        HtmlElement inputSearch = webBrowser.Document.Window.Frames[1].Document.GetElementById("search");

                        if (inputSearch == null) throw new NullReferenceException("Input field is NULL.");

                        inputSearch.Document.GetElementById("search").SetAttribute("value", renamingStudentID);

                        HtmlElementCollection framesAs = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("a");

                        foreach (HtmlElement a in framesAs)
                        {
                            if (a.GetAttribute("title").Contains("Search"))
                            {
                                a.InvokeMember("CLICK");
                                break;
                            }
                        }

                        Task asyncTask = new Task(() =>
                        {
                            Thread.Sleep(500);
                        });

                        asyncTask.ContinueWith((a) =>
                        {
                            webBrowserTask = WebBrowserTask.ContinueStudentRenaming;
                            confidentLoad = true;
                            webBrowser_DocumentCompleted(webBrowser, null);

                        }, TaskScheduler.FromCurrentSynchronizationContext());

                        asyncTask.Start();

                        break;
                    }
                case WebBrowserTask.ContinueStudentRenaming:
                    {
                        HtmlElementCollection tds = webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("td");

                        foreach (HtmlElement td in tds)
                        {
                            if (td.GetAttribute("headers").Contains("Eid") && td.InnerText.Contains(renamingStudentID))
                            {
                                HtmlElementCollection tdAs = td.GetElementsByTagName("a");

                                foreach (HtmlElement a in tdAs)
                                {
                                    string innerText = a.InnerText.Trim();
                                    if (innerText.Equals(renamingStudentID))
                                    {
                                        string href = a.GetAttribute("href");

                                        confidentLoad = true;
                                        webBrowserTask = WebBrowserTask.SetNewFirstNameAndLastName;
                                        webBrowser.Document.Window.Frames[1].Navigate(href);
                                    }
                                }


                            }
                        }

                        break;
                    }
                case WebBrowserTask.SetNewFirstNameAndLastName:
                    {
                        HtmlElementCollection inputCollection =
                            webBrowser.Document.Window.Frames[1].Document.GetElementsByTagName("input");

                        HtmlElement firstNameInput = webBrowser.Document.Window.Frames[1].Document.GetElementById("first-name");
                        HtmlElement lastNameInput = webBrowser.Document.Window.Frames[1].Document.GetElementById("last-name");

                        firstNameInput.SetAttribute("value", renamingStudentName);
                        lastNameInput.SetAttribute("value", renamingStudentLastname);

                        foreach (HtmlElement elem in from HtmlElement he in inputCollection where he.GetAttribute("name").Contains("eventSubmit_doSave") select he)
                        {
                            elem.InvokeMember("CLICK");
                        }

                        webBrowserTask = WebBrowserTask.Idle;
                        break;
                    }
                case WebBrowserTask.Idle:
                    break;
                case WebBrowserTask.Waiting:
                    break;
                default:
                    break;
            }
        }
示例#48
0
 /// <summary>
 /// Starts asynchronous assignment items parsing process
 /// </summary>
 public void ParseAssignmentItems()
 {
     if (linkToAssignments != String.Empty)
     {
         webBrowserTask = WebBrowserTask.ParseAssignments;
         webBrowser.Navigate(linkToAssignments);
     }
 }
示例#49
0
 /// <summary>
 /// Starts asynchronous assignment items parsing process
 /// </summary>
 public void ParseTestsAndQuizzesItems()
 {
     if (linkToTestsAndQuizzes != String.Empty)
     {
         webBrowserTask = WebBrowserTask.ParseTestsAndQuizzes;
         webBrowser.Navigate(linkToTestsAndQuizzes);
     }
 }
示例#50
0
        /// <summary>
        /// Creates a new group with specified GroupName, Description, students IDs
        /// The method is Private, because Description adding is not implemented
        /// </summary>
        /// <param name="groupName">The name of creating group</param>
        /// <param name="groupDescription">The description of creating group</param>
        /// <param name="studentIDs">The student IDs to add in a new group</param>
        /// <returns>The count of added students. Not implemented yet</returns>
        private int CreateNewGroup(string groupName, string groupDescription, string[] studentIDs)
        {
            addingStudentsCount = 0;

            if (linkToSiteEditor == "") throw new Exception("Link to SiteEditor is empty. Can't create new group.");

            addingGroupName = groupName;
            addingGroupDescription = groupDescription;
            addingStudentIDs = studentIDs;

            groupSectionTask = GroupEditorSectionTask.CreateNewGroup;
            webBrowserTask = WebBrowserTask.OpenManageGroupsSection;
            webBrowser.Navigate(linkToSiteEditor);

            return addingStudentsCount;
        }