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();
        }
Beispiel #2
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();
            }
        }