예제 #1
0
        /// <summary>
        /// Creates a Xml-File that is the datasource for the treeview. It contains          all Modulhandbooks, Subjects and Modules
        /// </summary>
        private void createDataSourceXmlFile()
        {
            XmlDocument doc = new XmlDocument();
            XmlNode     semester, modulhandbook, subject, myRoot = null;
            XmlElement  el;

            List <Subject> subjects = null;
            List <Modul>   moduls   = null;

            // füge einen root knoten hinzu
            myRoot = doc.CreateElement("Modulhandbücher");
            doc.AppendChild(myRoot);

            foreach (Semester sem in logic.getAllSemester())
            {
                el = doc.CreateElement("Semester");
                el.SetAttribute("Heading", sem.Name);
                semester = myRoot.AppendChild(el);

                // füge alle modulhandbücher hinzu
                List <Modulhandbook> handbookList = logic.getAllModulhandbooksFromSemester(sem.SemesterID);
                foreach (Modulhandbook mhb in handbookList)
                {
                    el = doc.CreateElement("Modulhandbuch");
                    el.SetAttribute("Heading", mhb.Name);
                    modulhandbook = semester.AppendChild(el);
                    //füge alle Fächer von einem Modulhandbuch hinzu
                    subjects = logic.getAllSubjectsFromModulhandbook(mhb.ModulhandbookID);
                    foreach (Subject s in subjects)
                    {
                        el = doc.CreateElement("Fach");
                        el.SetAttribute("Heading", s.Name);
                        subject = modulhandbook.AppendChild(el);
                        //füge alle module von einem fach hinzu
                        moduls = logic.getAllModulesFromSubject(s.SubjectID);
                        foreach (Modul m in moduls)
                        {
                            if (m.State.Equals(ModulState.archiviert))
                            {
                                // finde den namen des moduls in der desctription
                                foreach (ModulPartDescription d in m.Descriptions)
                                {
                                    if (d.Name == GlobalNames.getModulNameText())
                                    {
                                        el = doc.CreateElement("Modul");
                                        el.SetAttribute("Heading", d.Description);
                                        subject.AppendChild(el);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // hier muss der pfad zur \Modulhandbook.xml eingetragen werden. die datei liegt im root verzeichnis von den projekten
            doc.Save(Server.MapPath("/Modulhandbook.xml"));
            needToLoadXmlTree = false;
            //ModulhandbookTreeView.Parent.Visible = false;
        }
        /// <summary>
        /// Creates a Pdf of the Current Modul and open it with a valid pdf viewer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PdfBtn_Click(object sender, EventArgs e)
        {
            jumpToDescription(0);
            Core.PDFOperations.PDFHandler pdf  = new Core.PDFOperations.PDFHandler();
            List <ModulPartDescription>   list = GetModulpartDescriptions();
            String title = "";

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].Name.Equals(GlobalNames.getModulNameText()))
                {
                    title = list[i].Description;
                    i     = list.Count;
                }
            }
            Modul newModule = new Modul()
            {
                Descriptions = list,
            };

            pdf.CreatePDF(newModule, title, Server);
        }
        /// <summary>
        /// Checks the User input
        /// </summary>
        /// <returns>Returns true, if everything is fine</returns>
        public bool CheckDescriptions()
        {
            List <ModulPartDescription> descriptions = GetModulpartDescriptions();

            for (int i = 0; i < descriptions.Count; i++)
            {
                //Check for undone mandatory fields
                if (descriptions[i].IsNeeded)
                {
                    if (descriptions[i].Description.Equals(defaultMPDs[i].Description))
                    {
                        Session["Message"] = true;
                        CheckforMessage("Ein Pflichtfeld muss noch bearbeitet werden");
                        jumpToDescription(i);
                        return(false);
                    }
                }

                //Check double Modules
                if (descriptions[i].Name.Equals(GlobalNames.getModulNameText()))
                {
                    ModulhandbookContext mhc  = new ModulhandbookContext();
                    ArchiveLogic         al   = new ArchiveLogic();
                    List <Modul>         list = mhc.Modules.ToList <Modul>();

                    foreach (Modul m in list)
                    {
                        if (descriptions[i].Description == al.getNameFromModule(m))
                        {
                            Session["Message"] = true;
                            CheckforMessage("Ein Modul mit diesem Namen existiert schon!");
                            jumpToDescription(i);
                            return(false);
                        }
                    }
                }

                //Check for invalide Types
                if (descriptions[i].Name.Equals(GlobalNames.getModulNameECTS()) ||
                    descriptions[i].Name.Equals(GlobalNames.getModulNameWeekHours()) ||
                    descriptions[i].Name.Equals(GlobalNames.getModulNameEffort()))
                {
                    double Num;
                    bool   isNum = double.TryParse(descriptions[i].Description, out Num);

                    if (!isNum)
                    {
                        Session["Message"] = true;
                        CheckforMessage("Der Modulpunkt muss eine Zahl enthalten");
                        jumpToDescription(i);
                        return(false);
                    }
                }
            }
            //Check the Subjects
            List <Subject> subjects = GetSubjects();

            //At least one Subject must be chosen
            if (subjects.Count < 1)
            {
                Session["Message"] = true;
                CheckforMessage("Sie wüssen mindestens ein Fach für das Modul festlegen!");
                return(false);
            }

            //A Module cannot exist more then once inside a Modulhandbook
            if (subjects.Count >= 2)
            {
                for (int i = 0; i < subjects.Count; i++)
                {
                    Modulhandbook m = subjects[i].Modulhandbook;
                    for (int j = 1 + 1; j < subjects.Count; j++)
                    {
                        if (m == subjects[j].Modulhandbook)
                        {
                            Session["Message"] = true;
                            CheckforMessage("Ein Modul kann nicht zweimal im gleichen Modulhandbuch auftreten!");
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
예제 #4
0
 public static List <ModulPartDescription> getDefaultDescriptions()
 {
     return(new List <ModulPartDescription>()
     {
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameNum(), Description = GlobalNames.getModulNameNumDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameText(), Description = GlobalNames.getModulNameTextDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameECTS(), Description = GlobalNames.getModulNameECTSDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameWeekHours(), Description = GlobalNames.getModulNameWeekHoursDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameLanguage(), Description = GlobalNames.getModulNameLanguageDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameTurnus(), Description = GlobalNames.getModulNameTurnusDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameLecturer(), Description = GlobalNames.getModulNameLecturerDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameFitsInStudy(), Description = GlobalNames.getModulNameFitsInStudyDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameReqContent(), Description = GlobalNames.getModulNameReqContentDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameEducation(), Description = GlobalNames.getModulNameEducationDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameContent(), Description = GlobalNames.getModulNameContentDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameLiterature(), Description = GlobalNames.getModulNameLiteratureDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameTeaching(), Description = GlobalNames.getModulNameTeachingDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameEffort(), Description = GlobalNames.getModulNameEffortDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameMark(), Description = GlobalNames.getModulNameMarkDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameReqFormal(), Description = GlobalNames.getModulNameReqFormalDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameGrade(), Description = GlobalNames.getModulNameGradeDesc(), IsNeeded = true
         }
     });
 }