Пример #1
0
        /// <summary>
        /// writes a modulhandbook and its subjects and modules to a pdf and opens the pdf
        /// </summary>
        /// <param name="modulhandbook">should not me null</param>
        /// <param name="server">http server</param>
        public void WriteModulhandbookToPdf(Modulhandbook modulhandbook, HttpServerUtility server)
        {
            var output   = new FileStream(server.MapPath(pdfpath + modulhandbook.Name + ".pdf"), FileMode.Create);
            var document = new Document(PageSize.A4, 50, 50, 25, 25);
            var writer   = PdfWriter.GetInstance(document, output);

            document.Open();

            try
            {
                createTitlePage(modulhandbook, server, document);
                createIndex(modulhandbook, server, document);
                writeSubjectsToDoc(modulhandbook, document);
            }
            catch (Exception e)
            {
                throw new Exception("Das erstellen des Modulhandbuchs hat nicht geklappt mit folgender Fehlermelung: " + e.Message);
            }
            finally
            {
                document.Close();
            }

            openPdf(server.MapPath(pdfpath + modulhandbook.Name + ".pdf"));
        }
Пример #2
0
        private void writeSubjectsToDoc(Modulhandbook modulhandbook, Document document)
        {
            int subNo = 1;

            foreach (Subject s in modulhandbook.Subjects)
            {
                writeSubjectToDoc(document, subNo, s);
                subNo++;
            }
        }
Пример #3
0
        /// <summary>
        /// returns all subjects from a modulhandbook which is specified by the name
        /// </summary>
        /// <param name="name">the name from the modulhandbook</param>
        /// <returns>null if no modulhandbook with the name is found</returns>
        public List <Subject> getAllSubjectsFromModulhandbook(String name)
        {
            name = name.ToLower();
            Modulhandbook mhb = getModulhandbookByName(name);

            if (mhb == null)
            {
                return(null);
            }
            return(getAllSubjectsFromModulhandbook(mhb.ModulhandbookID));
        }
Пример #4
0
        private void addTitle(Modulhandbook modulhandbook, Document document)
        {
            Paragraph p = new Paragraph(modulhandbook.Abschluss, titleFont);

            p.Alignment = 1;
            document.Add(p);
            p           = new Paragraph(modulhandbook.Name, titleFont);
            p.Alignment = 1;
            document.Add(p);
            p           = new Paragraph("(FSPO " + modulhandbook.FspoYear + ")", titleFont);
            p.Alignment = 1;
            document.Add(p);
        }
Пример #5
0
        private void createTitlePage(Modulhandbook modulhandbook, HttpServerUtility server, Document document)
        {
            addLogos(server, document);
            addEmptyParagraphs(document, 8);
            document.Add(new Paragraph("_________________________________________________________________________"));
            addEmptyParagraphs(document, 5);
            Paragraph p = new Paragraph("Modulhandbuch", subTitleFont);

            p.Alignment = 1;
            document.Add(p);
            addEmptyParagraphs(document, 5);
            addTitle(modulhandbook, document);
            addEmptyParagraphs(document, 5);
            document.NewPage();
        }
Пример #6
0
        /// <summary>
        /// creates and opens a pdf document for the clicked element. Only for Modulhandbooks and Modules
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ModulhandbookTreeView_SelectedNodeChanged(object sender, EventArgs e)
        {
            Modulhandbook mhb    = logic.getModulhandbookByNameAndSemester(ModulhandbookTreeView.SelectedNode.Text.ToLower(), getSemesterNodeText(ModulhandbookTreeView.SelectedNode));
            Modul         module = logic.getModuleByName(ModulhandbookTreeView.SelectedNode.Text.ToLower());
            Subject       subj   = logic.getSubjectByName(ModulhandbookTreeView.SelectedNode.Text.ToLower());

            if (mhb != null)
            {
                pdf.WriteModulhandbookToPdf(mhb, Server);
            }
            else if (module != null)
            {
                pdf.CreatePDF(module, Server);
            }
            else if (subj != null)
            {
                pdf.CreateAndOpenSoubjectPdf(subj, Server);
            }
        }
Пример #7
0
        /// <summary>
        /// creates and opens a pdf document if the user clicked on a search result in the search result list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void searchResultList_Click(object sender, BulletedListEventArgs e)
        {
            String objName = searchResultList.Items[e.Index].Text;

            objName = objName.Remove(objName.LastIndexOf('-') - 1).ToLower();

            Modulhandbook mhb    = logic.getModulhandbookByName(objName);
            Modul         module = logic.getModuleByNameAttendVersion(objName);
            Subject       subj   = logic.getSubjectByName(objName);

            if (mhb != null)
            {
                pdf.WriteModulhandbookToPdf(mhb, Server);
            }
            else if (module != null)
            {
                pdf.CreatePDF(module, Server);
            }
            else if (subj != null)
            {
                pdf.CreateAndOpenSoubjectPdf(subj, Server);
            }
        }
Пример #8
0
        private void DrawHeader()
        {
            ArchiveLogic         al  = new ArchiveLogic();
            ModulhandbookContext mhc = new ModulhandbookContext();

            if (Request.QueryString["ModulhandbookID"] != null)
            {
                int MId = Int32.Parse(Request.QueryString["ModulhandbookID"]);
                List <Modulhandbook> books = mhc.Modulhandbooks.Where(m => m.ModulhandbookID == MId).ToList <Modulhandbook>();
                Modulhandbook        book  = books.First();
                ChosenModulhandbook.Text = "Modulhandbuch: " + book.Name + " FSPOYear: " + book.FspoYear + " Abschluss: " + book.Abschluss + " ValidSemester: " + book.ValidSemester;

                if (Request.QueryString["SubjectID"] != null)
                {
                    int            SId      = Int32.Parse(Request.QueryString["SubjectID"]);
                    List <Subject> subjects = mhc.Subjects.Where(s => s.SubjectID == SId).ToList <Subject>();
                    ChosenSubject.Text = "Subject: " + subjects.First().Name;
                }
                else
                {
                    ChosenModulhandbook.Text = "Modulhandbuch: " + book.Name + " FSPOYear: " + book.FspoYear + " Abschluss: " + book.Abschluss + " ValidSemester: " + book.ValidSemester;
                }
            }
        }
        /// <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);
        }
Пример #10
0
 private void createIndex(Modulhandbook modulhandbook, HttpServerUtility server, Document document)
 {
     // need to create Index
 }