/// <summary>
 /// Saves the new Modul if the input was valid
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void AdoptBtn_Click(object sender, EventArgs e)
 {
     if (CheckDescriptions())
     {
         int indexOfCurrentModulpunkt     = GetCurrentIndex();
         List <ModulPartDescription> list = GetModulpartDescriptions();
         list[indexOfCurrentModulpunkt].Name        = NameTextBox.Text;
         list[indexOfCurrentModulpunkt].Description = DescriptionTextBox.Text;
         var            mu        = System.Web.Security.Membership.GetUser();
         Guid           owner     = (Guid)mu.ProviderUserKey;
         ArchiveLogic   al        = new ArchiveLogic();
         JobLogic       jl        = new JobLogic();
         List <Subject> subjects  = GetSubjects();
         Modul          newModule = al.CreateModul(list, ModulState.created, owner, owner, DateTime.Now, subjects, 1);
         Session["Message"] = true;
         if (newModule != null)
         {
             CheckforMessage("Neues Modul erstellt!");
             jl.CreateNewJob(ModulState.created, list, newModule, owner);
         }
         else
         {
             CheckforMessage("Ein Fehler ist aufgetreten. Es wurde kein Modul erstellt!");
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Adds the specified archive to the lists.
        /// </summary>
        public void AddArchive(Archive archiveEntity, ArchiveLogic archiveLogic)
        {
            if (archiveEntity == null)
            {
                throw new ArgumentNullException(nameof(archiveEntity));
            }
            if (archiveLogic == null)
            {
                throw new ArgumentNullException(nameof(archiveLogic));
            }

            // add archive to the corresponding list
            allArchives.Add(archiveLogic);

            if (archiveLogic is CurrentArchiveLogic currentArchiveLogic)
            {
                currentArchives.Add(currentArchiveLogic);
            }
            else if (archiveLogic is HistoricalArchiveLogic historicalArchiveLogic)
            {
                historicalArchives.Add(historicalArchiveLogic);
            }
            else if (archiveLogic is EventArchiveLogic eventArchiveLogic)
            {
                eventArchives.Add(eventArchiveLogic);

                if (archiveEntity.IsDefault)
                {
                    defaultEventArchives.Add(eventArchiveLogic);
                }
            }

            // add archive to array by bit number
            int archiveBit = archiveEntity.Bit;

            if (0 <= archiveBit && archiveBit < ServerUtils.MaxArchiveCount)
            {
                arcByBit[archiveBit] = archiveLogic;
            }
            else
            {
                throw new ScadaException("Archive bit is out of range.");
            }

            // build default archive mask
            if (archiveEntity.IsDefault)
            {
                DefaultArchiveMask = DefaultArchiveMask.SetBit(archiveEntity.Bit, true);
            }

            // calculate maximum title length
            if (maxArcTitleLength < archiveLogic.Title.Length)
            {
                maxArcTitleLength = archiveLogic.Title.Length;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor initialized fonts and logic
 /// </summary>
 public PDFHandler()
 {
     bfTimes               = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
     subjectTitleFont      = new Font(bfTimes, 15, Font.ITALIC);
     moduleTitleFont       = new Font(bfTimes, 13, Font.ITALIC);
     moduleDescriptionFont = new Font(bfTimes, 10, Font.ITALIC);
     subTitleFont          = new Font(bfTimes, 14, Font.ITALIC);
     titleFont             = new Font(bfTimes, 20, Font.ITALIC);
     logic = new ArchiveLogic();
 }
Esempio n. 4
0
 /// <summary>
 /// Calls the Unlock method of the specified archive.
 /// </summary>
 public void Unlock(ArchiveLogic archiveLogic)
 {
     try
     {
         archiveLogic.Unlock();
     }
     catch (Exception ex)
     {
         log.WriteException(ex, ServerPhrases.ErrorInArchive, nameof(Unlock), archiveLogic.Code);
     }
 }
 private Modul GetModulByQuerystring()
 {
     if (Request.QueryString["ModulId"] == null)
     {
         Response.Redirect("Default.aspx");
         return(null);
     }
     else
     {
         ArchiveLogic al = new ArchiveLogic();
         return(al.getModulById(Int32.Parse(Request.QueryString["ModulId"])));
     }
 }
 private List <Subject> GetSubjects()
 {
     if (Session["Subjects"] == null)
     {
         ArchiveLogic al    = new ArchiveLogic();
         Modul        modul = al.getModulById(Int32.Parse(Request.QueryString["ModulID"]));
         return(modul.Subjects.ToList <Subject>());
     }
     else
     {
         return((List <Subject>)Session["Subjects"]);
     }
 }
        /// <summary>
        /// Saves the Modul with the given Modulstate und version number 1+n where n is the number, of the latest version
        /// </summary>
        /// <param name="state"></param>
        private void SaveChanges(ModulState state)
        {
            if (CheckDescriptions())
            {
                int indexOfCurrentModulpunkt = GetCurrentIndex();
                List <ModulPartDescription> modulpartdescriptions = GetModulpartDescriptions();
                List <Subject> subjects = GetSubjects();
                modulpartdescriptions[indexOfCurrentModulpunkt].Name        = NameTextBox.Text;
                modulpartdescriptions[indexOfCurrentModulpunkt].Description = DescriptionTextBox.Text;
                if (!CommentTextBox.Text.Trim().Equals(""))
                {
                    modulpartdescriptions[indexOfCurrentModulpunkt].Comment = CommentTextBox.Text;
                }



                var          mu    = System.Web.Security.Membership.GetUser();
                Guid         user  = (Guid)mu.ProviderUserKey;
                Modul        modul = GetModulByQuerystring();
                ArchiveLogic al    = new ArchiveLogic();
                JobLogic     jl    = new JobLogic();

                //create the new Modulpartdescriptions
                List <ModulPartDescription> mpdList = new List <ModulPartDescription>();
                foreach (ModulPartDescription m in modulpartdescriptions)
                {
                    ModulPartDescription toAdd = new ModulPartDescription()
                    {
                        IsNeeded    = m.IsNeeded,
                        Description = m.Description,
                        Comment     = m.Comment,
                        Name        = m.Name
                    };
                    mpdList.Add(toAdd);
                }

                Modul newModule = al.CreateModul(mpdList, state, modul.Owner, user, DateTime.Now, subjects, modul.Version + 1);

                Session["Message"] = true;
                if (newModule != null)
                {
                    CheckforMessage("Neue Version Erstellt!");
                    jl.CreateNewJob(state, mpdList, newModule, user);
                }
                else
                {
                    CheckforMessage("Ein Fehler ist aufgetreten. Es wurde kein Modul erstellt!");
                }
            }
        }
        /// <summary>
        /// Delete the current Modul
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DeleteModulBtn_Click(object sender, EventArgs e)
        {
            Modul                modul  = GetModulByQuerystring();
            ArchiveLogic         al     = new ArchiveLogic();
            ModulhandbookContext mhc    = new ModulhandbookContext();
            List <Modul>         moduls = mhc.Modules.ToList <Modul>();

            foreach (Modul m in moduls)
            {
                if (al.getNameFromModule(m) == al.getNameFromModule(modul))
                {
                    mhc.Modules.Remove(m);
                }
            }
            mhc.SaveChanges();
            Response.Redirect("Default.aspx");
        }
Esempio n. 9
0
        private void DrawModulhandbooks()
        {
            ArchiveLogic         al             = new ArchiveLogic();
            List <Modulhandbook> modulhandbooks = al.GetModulhandbooksKooFrei(HttpContext.Current);

            foreach (Modulhandbook m in modulhandbooks)
            {
                TableCell  tc   = new TableCell();
                LinkButton link = new LinkButton();
                link.Text   = m.Name + " FSPOYear: " + m.FspoYear + " Abschluss: " + m.Abschluss + " ValidSemester: " + m.ValidSemester;
                link.ID     = m.ModulhandbookID.ToString();
                link.Click += Modulhandbook_Click;
                tc.Controls.Add(link);
                TableRow tr = new TableRow();
                tr.Cells.Add(tc);
                ModulhandbookTable.Rows.Add(tr);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// debug function to display modules only
        /// </summary>
        private void debugDraw()
        {
            ArchiveLogic al     = new ArchiveLogic();
            List <Modul> moduls = al.GetModulsKooFrei(HttpContext.Current);

            foreach (Modul m in moduls)
            {
                TableCell  tc   = new TableCell();
                LinkButton link = new LinkButton();
                link.Text   = al.getNameFromModule(m) + " ModulStatus: " + m.State + " Version: " + m.Version + " Jahr" + m.Year;
                link.ID     = "" + m.ModulID;
                link.Click += Modul_Click;
                tc.Controls.Add(link);
                TableRow tr = new TableRow();
                tr.Cells.Add(tc);
                ModulTable.Rows.Add(tr);
            }
        }
Esempio n. 11
0
        private void DrawSubjects()
        {
            ArchiveLogic   al       = new ArchiveLogic();
            List <Subject> subjects = al.GetSubjectsKooFrei(HttpContext.Current, Int32.Parse(Request.QueryString["ModulhandbookID"]));

            foreach (Subject s in subjects)
            {
                TableCell  tc   = new TableCell();
                LinkButton link = new LinkButton();
                link.Text   = s.Name;
                link.ID     = "" + s.SubjectID;
                link.Click += Subject_Click;
                tc.Controls.Add(link);
                TableRow tr = new TableRow();
                tr.Cells.Add(tc);
                SubjectTable.Rows.Add(tr);
            }
        }
Esempio n. 12
0
        private void DrawModuls()
        {
            ArchiveLogic al     = new ArchiveLogic();
            var          mu     = System.Web.Security.Membership.GetUser();
            Guid         owner  = (Guid)mu.ProviderUserKey;
            List <Modul> moduls = al.GetModulsModulverantwortlicher(HttpContext.Current, owner);

            foreach (Modul m in moduls)
            {
                TableCell  tc   = new TableCell();
                LinkButton link = new LinkButton();
                link.Text   = al.getNameFromModule(m) + " ModulStatus: " + m.State + " Version: " + m.Version + " Jahr" + m.Year;
                link.ID     = "" + m.ModulID;
                link.Click += Modul_Click;
                tc.Controls.Add(link);
                TableRow tr = new TableRow();
                tr.Cells.Add(tc);
                ModulTable.Rows.Add(tr);
            }
        }
Esempio n. 13
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);
        }
        protected ICollection <Modulhandbook> GetModulhandbooks()
        {
            ArchiveLogic al = new ArchiveLogic();

            return(al.getEditableModulhandbooks());
        }
        private List <Subject> GetSubjectsToDisplay()
        {
            ArchiveLogic al = new ArchiveLogic();

            return(al.getSubjectstoDisplay(DropDownList.SelectedValue.Trim()));
        }
Esempio n. 17
0
        private bool nothingToDo()
        {
            ArchiveLogic al = new ArchiveLogic();

            return(al.GetModulsKooFrei(HttpContext.Current).Count == 0);
        }