private void AddCourse()
        {
            string strPath       = txtServer.Text;
            string strCourseName = txtCourseName.Text;
            string strGuid       = System.Guid.NewGuid().ToString();

            if ((strCourseName == "") || (strPath == "") || (strPath == "http://"))
            {
                //User hasn't entered the information, so display error dialog
                MessageBox.Show(AMResources.GetLocalizedString("AddCourse_ErrorBlankField"),
                                this.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            FacultyTools fac = new FacultyTools(m_applicationObject);

            if (!fac.CheckVersion(strPath + "/amversion.xml"))
            {
                //Error message has already been displayed
                return;
            }

            Utilities.RegisterAssignmentManagerCourse(m_applicationObject, strCourseName, strPath, strGuid);
            fac.RegenerateUserCustomTab(false);
            strPath += "/Faculty/AddCourse.aspx?CourseID=" + strGuid + "&CourseName=" + System.Web.HttpUtility.UrlEncode(strCourseName);
            m_applicationObject.ItemOperations.Navigate(strPath, vsNavigateOptions.vsNavigateOptionsDefault);
            this.Close();
        }
        private void btnDeleteSelected_Click(object sender, System.EventArgs e)
        {
            int nCount = deleteCourseList.Items.Count;

            for (int i = 0; i < nCount; i++)
            {
                if (deleteCourseList.GetItemChecked(i))
                {
                    string courseGuid = courseGuids[i];
                    if (courseGuid != null && courseGuid != String.Empty)
                    {
                        FacultyTools fac = new FacultyTools(m_applicationObject);
                        fac.UnregisterAssignmentManagerCourse(courseGuid);

                        try
                        {
                            //Get AM Server
                            XmlNode xmlCourse  = xmlDoc.SelectSingleNode("/managedcourses/course/assnmgr[guid='" + courseGuid + "']");
                            XmlNode xmlServer  = xmlCourse.SelectSingleNode("amurl");
                            string  deletePath = xmlServer.InnerText;
                            if (deletePath != String.Empty)
                            {
                                deletePath += "/Faculty/DeleteCourse.aspx?CourseID=" + courseGuid;
                                m_applicationObject.ItemOperations.Navigate(deletePath, vsNavigateOptions.vsNavigateOptionsNewWindow);
                            }
                        }
                        catch
                        {
                            //ignore the error.  If something fails then we can't delete from the server but still removed from local machine.
                        }
                    }
                }
            }
            this.Close();
        }
Beispiel #3
0
        private void AddCourse()
        {
            if (this.txtServer.Text == String.Empty || this.txtServer.Text == "http://")
            {
                //User hasn't entered the information, so display error dialog
                MessageBox.Show(AMResources.GetLocalizedString("AddExistingCourse_ErrorBlankField"),
                                this.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            FacultyTools fac        = new FacultyTools(m_applicationObject);
            string       url        = txtServer.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 == "" || !fac.CheckVersion(versionURL))
            {
                return;
            }

            string courseUrl = fac.RegisterCourseFromUrl(url);

            if (courseUrl == null)
            {
                string errorMessage = AMResources.GetLocalizedString("AddExisting_Error_UnableToRegisterExistingCourse");
                if (errorMessage != String.Empty)
                {
                    MessageBox.Show(errorMessage, "Add Existing Course", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                m_applicationObject.ItemOperations.Navigate(courseUrl, vsNavigateOptions.vsNavigateOptionsDefault);
                this.Close();
            }
        }