コード例 #1
0
        private void btnRemove_Click(object sender, System.EventArgs e)
        {
            //Confirm
            string       text   = AMResources.GetLocalizedString("ConfirmRemoveCourse");
            DialogResult result = MessageBox.Show(text, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                int         nCount      = deleteCourseList.Items.Count;
                ClientTools clientTools = new ClientTools(m_applicationObject);
                for (int i = 0; i < nCount; i++)
                {
                    if (deleteCourseList.GetSelected(i))
                    {
                        string courseGuid = courseGuids[i];
                        if (courseGuid != null && courseGuid != String.Empty)
                        {
                            clientTools.UnregisterAssignmentManagerCourse(courseGuid);
                        }
                    }
                }
                this.Close();
            }
        }
コード例 #2
0
        private void populateDeleteCourseList()
        {
            deleteCourseList.CheckOnClick = true;
            deleteCourseList.Items.Clear();
            ClientTools clientTools = new ClientTools(m_applicationObject);
            XmlDocument xmlDoc      = clientTools.LocalCoursesFile;
            XmlNodeList xmlCourses  = xmlDoc.SelectNodes("/studentcourses/course");

            courseGuids = new string[xmlCourses.Count];
            for (int i = 0; i < xmlCourses.Count; i++)
            {
                XmlNode parentNode = xmlCourses.Item(i);
                XmlNode node       = parentNode.SelectSingleNode("name");
                string  courseName = node.InnerText;
                deleteCourseList.Items.Add(courseName, CheckState.Unchecked);

                // save Guid for delete
                XmlNode guid = parentNode.SelectSingleNode("assnmgr/guid");
                if (guid != null)
                {
                    courseGuids[i] = guid.InnerText;
                }
            }
        }
コード例 #3
0
 public FacultyTools(EnvDTE._DTE dte)
 {
     m_applicationObject = dte;
     m_studentTools      = new StudentClient.ClientTools(dte);
 }
コード例 #4
0
        private void AddCourse()
        {
            if ((this.txtCourseURL.Text == String.Empty) || (this.txtCourseURL.Text == "http://"))
            {
                //User hasn't entered the information, so display error dialog
                MessageBox.Show(AMResources.GetLocalizedString("AMStudentAddCourse_ErrorBlankField"),
                                this.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            ClientTools clientTools = new ClientTools(m_applicationObject);
            string      courseGuid  = Guid.NewGuid().ToString();
            string      url         = txtCourseURL.Text;

            string versionURL = "";

            try
            {
                string strServer;
                if (url.StartsWith("http://"))
                {
                    versionURL = "http://";
                    strServer  = url.Substring(7);
                }
                else if (url.StartsWith("https://"))
                {
                    versionURL = "https://";
                    strServer  = url.Substring(8);
                }
                else
                {
                    versionURL = "http://";
                    strServer  = url;
                }

                int nIndex = strServer.IndexOf("/");
                if (nIndex == -1)
                {
                    throw new System.ArgumentException();
                }

                //find the second one
                nIndex = strServer.IndexOf("/", nIndex + 1);

                strServer   = strServer.Substring(0, nIndex);
                versionURL += strServer + "/amversion.xml";
            }
            catch
            {
                versionURL = "";
            }

            if (versionURL == "")
            {
                string message = AssignmentManager.ClientUI.AMResources.GetLocalizedString("AddCourse_ErrorWrongServerName");
                string caption = AssignmentManager.ClientUI.AMResources.GetLocalizedString("AddCourse_ErrorWrongServerNameCaption");
                message = message.Replace("%1", url);
                System.Windows.Forms.MessageBox.Show(message, caption, System.Windows.Forms.MessageBoxButtons.OK,
                                                     System.Windows.Forms.MessageBoxIcon.Warning);
                return;
            }
            else if (!clientTools.CheckVersion(versionURL))
            {
                return;
            }

            XmlDocument xmlCourseDoc = clientTools.GetCourseFile(url);

            if (xmlCourseDoc == null)
            {
                //Not a valid course file
                string text = AMResources.GetLocalizedString("AddCourseFail");
                MessageBox.Show(text, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                XmlNode node          = xmlCourseDoc.SelectSingleNode("/course/assnmgr");
                string  strCourseName = xmlCourseDoc.SelectSingleNode("/course/name").InnerText;
                string  strUrl        = node.SelectSingleNode("amurl").InnerText;
                string  strGUID       = node.SelectSingleNode("guid").InnerText;
                clientTools.RegisterAssignmentManagerCourse(strCourseName, strUrl, strGUID, url);

                strUrl += "/Student/AddCourse.aspx?CourseID=" + strGUID;
                try
                {
                    m_applicationObject.ItemOperations.Navigate(strUrl, vsNavigateOptions.vsNavigateOptionsNewWindow);
                }
                catch
                {
                }
                this.Close();
            }
        }