コード例 #1
0
        public void Apply()
        {
            var worksetLog = new TransactionLog(@"Workset Creation/Modifications");

            if (WorksharingIsEnabled)
            {
                ModelSetupWizardUtilities.ApplyWorksetModifications(doc, Worksets.ToList(), ref worksetLog);
            }
            var projectInfoLog = new TransactionLog(@"Project Information Modifications");

            ModelSetupWizardUtilities.ApplyProjectInfoModifications(doc, ProjectInformation.ToList(), ref projectInfoLog);

            var iniFile = IniIO.GetIniFile(doc);

            if (iniFile.Length > 0)
            {
                IniIO.WriteColours(iniFile, Colours.ToList());
            }
            else
            {
                SCaddinsApp.WindowManager.ShowMessageBox(iniFile + " does not exist");
            }

            string msg = "Summary" + System.Environment.NewLine +
                         System.Environment.NewLine +
                         worksetLog + System.Environment.NewLine +
                         projectInfoLog;

            SCaddinsApp.WindowManager.ShowMessageBox("Model Setup Wizard - Summary", msg);
            TryClose(true);
        }
コード例 #2
0
 public void RemoveWorksets()
 {
     if (SelectedWorksets != null && SelectedWorksets.Count > 0)
     {
         Worksets.RemoveRange(SelectedWorksets);
     }
 }
コード例 #3
0
 public void Reset()
 {
     Worksets.Clear();
     ProjectInformationReplacements.Clear();
     NominatedArchitects.Clear();
     Init();
 }
コード例 #4
0
        public IActionResult Assign(CreateSetViewModel model)
        {
            Worksets sets = new Worksets()
            {
                GroupID        = model.GroupID,
                WorksetName    = model.WorksetName,
                SetBy          = UserHelper.GetUserId(HttpContext.Session),
                Time_Allowed   = model.TimeAllowed,
                Date_Set       = DateTime.Now.Date,
                SetType        = model.SetType,
                Date_Due       = model.Date_Due,
                ExamStyle      = model.SelectFromList,
                RandomOrdering = model.RandomQuestions
            };

            return(RedirectToAction("Set"));
        }
コード例 #5
0
        /// <summary>
        /// Checks to see if the workset owner and the person trying to access
        /// the workset are in the same organisation. This is important for admins
        /// who may be trying to check all worksets in their organisation.
        /// </summary>
        /// <param name="uid">The id of the user trying to gain access</param>
        /// <param name="worksetID">the Id of the workset being checked</param>
        /// <returns></returns>
        public static bool InSameOrganisation(int uid, int worksetID)
        {
            Worksets workset = DatabaseConnector.GetWorkset(worksetID);

            if (workset == null)
            {
                return(false);
            }
            var setBy = GetUser(workset.SetBy);
            var user  = GetUser(uid);

            if (user == null)
            {
                return(false);
            }
            return(user.OrganisationID == setBy.OrganisationID);
        }
コード例 #6
0
        public IActionResult Create(CreateSetViewModel model)
        {
            // Checks that valid model has been returned
            if (!ModelState.IsValid)
            {
                model.Groups = UserHelper.GetGroups(UserHelper.GetUserId(HttpContext.Session));
                return(View(model));
            }

            // Creates the workset from the given information
            Worksets sets = new Worksets()
            {
                GroupID        = model.GroupID,
                WorksetName    = model.WorksetName,
                SetBy          = UserHelper.GetUserId(HttpContext.Session),
                Time_Allowed   = model.TimeAllowed,
                Date_Set       = DateTime.Now.Date,
                SetType        = model.SetType,
                Date_Due       = model.Date_Due,
                ExamStyle      = model.SelectFromList,
                RandomOrdering = model.RandomQuestions
            };

            // Checks if the workset should have no group because it was saved for later
            if (sets.GroupID == -2)
            {
                sets.GroupID = null;
            }

            // Adds the workset to the database and gets its ID
            sets.WorksetID = DatabaseConnector.AddWorkset(sets);

            // Creates the model that nit used to build the workset
            var Model = new BuildViewModel()
            {
                WorkSetID   = sets.WorksetID,
                createdWork = new CreatedWork()
                {
                    SelectFromList = sets.ExamStyle,
                    CatagoryTypes  = GetAllQuestions()
                }
            };

            return(View("Build", Model));
        }
コード例 #7
0
        private void AddDefaultWorksets()
        {
            var newWorksets = ModelSetupWizardSettings.Default.DefaultWorksets;

            foreach (var newWorksetDef in newWorksets)
            {
                var segs = newWorksetDef.Split(';');
                var b    = false;
                bool.TryParse(segs[1].Trim(), out b);
                if (!string.IsNullOrEmpty(segs[0]))
                {
                    if (segs.Length > 2 && !string.IsNullOrEmpty(segs[2]))
                    {
                        WorksetParameter wp = new WorksetParameter(segs[0], b, segs[2]);
                        Worksets.Add(wp);
                    }
                    else
                    {
                        WorksetParameter wp = new WorksetParameter(segs[0], b, -1);
                        Worksets.Add(wp);
                    }
                }
            }
        }
コード例 #8
0
        public static string ToPDF(this Worksets set)
        {
            var time = DateTime.Now.ToString("dd-hh-mm hh-MM-ss");
            var path = AppContext.BaseDirectory + "/prints/";

            if (!File.Exists(path + set.WorksetName + "-" + time + ".pdf"))
            {
                Directory.CreateDirectory(path);
                File.Create(path + set.WorksetName + "-" + time + ".pdf").Close();
            }
            writer   = new PdfWriter(path + set.WorksetName + "-" + time + ".pdf");
            pdf      = new PdfDocument(writer);
            document = new Document(pdf, Page);


            Paragraph p = new Paragraph().Add(new Text(set.WorksetName + "\n\n").SetBold().SetUnderline().SetFontSize(22f)).SetTextAlignment(TextAlignment.CENTER);

            document.Add(p);

            Table tbl = new Table(1);

            tbl.SetWidth(UnitValue.CreatePercentValue(100));

            var interpreter = new PythonInterpreter();
            var work        = DatabaseConnector.GetWhere <Work>($"WorksetID={set.WorksetID}");

            for (int i = 0; i < work.Length; i++)
            {
                var   question = interpreter.GenerateQuestion(AppContext.BaseDirectory + @"wwwroot\lib\Python\" + DatabaseConnector.Get <QuestionTypes>().SingleOrDefault(x => x.TypeID == work[i].QuestionType).Class, work[i].Seed);
                Table qTbl     = new Table(1);
                qTbl.SetKeepTogether(true);
                qTbl.SetWidth(UnitValue.CreatePercentValue(100));

                var qCell = new Cell().Add(new Paragraph("Question " + i + ":").SetBold()).SetTextAlignment(TextAlignment.CENTER).SetBorderLeft(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER);
                var AskQ  = new Cell().Add(new Paragraph(question.GetQuestion() as string)).SetTextAlignment(TextAlignment.LEFT).SetVerticalAlignment(VerticalAlignment.TOP).SetBorder(Border.NO_BORDER);
                var ans   = question.Answer("");
                qTbl.AddCell(qCell).AddCell(AskQ);
                if (ans.Contains(","))
                {
                    var answerTitles = question.Boxes().Split(',');
                    var workcell     = new Cell().Add(new Paragraph("   ").SetTextAlignment(TextAlignment.RIGHT).SetVerticalAlignment(VerticalAlignment.BOTTOM)).SetVerticalAlignment(VerticalAlignment.BOTTOM).SetHeight(60f).SetBorder(Border.NO_BORDER);
                    qTbl.AddCell(workcell);
                    for (int q = 0; q < answerTitles.Length; q++)
                    {
                        try
                        {
                            var AnsCell = new Cell().Add(new Paragraph(answerTitles[q] + ": ___________________.").SetTextAlignment(TextAlignment.RIGHT).SetVerticalAlignment(VerticalAlignment.BOTTOM)).SetVerticalAlignment(VerticalAlignment.BOTTOM).SetHeight(70f).SetBorder(Border.NO_BORDER);
                            qTbl.AddCell(AnsCell);
                        }
                        catch (IndexOutOfRangeException)
                        {
                            var AnsCell = new Cell().Add(new Paragraph("Answer" + q + ": ___________________.").SetTextAlignment(TextAlignment.RIGHT).SetVerticalAlignment(VerticalAlignment.BOTTOM)).SetVerticalAlignment(VerticalAlignment.BOTTOM).SetHeight(70f).SetBorder(Border.NO_BORDER);
                            qTbl.AddCell(AnsCell);
                        }
                    }
                }
                else
                {
                    var AnsCell = new Cell().Add(new Paragraph("Answer: ___________________.").SetTextAlignment(TextAlignment.RIGHT).SetVerticalAlignment(VerticalAlignment.BOTTOM)).SetVerticalAlignment(VerticalAlignment.BOTTOM).SetHeight(70f).SetBorder(Border.NO_BORDER);
                    qTbl.AddCell(AnsCell);
                }

                var cell = new Cell();
                cell.Add(qTbl);
                tbl.AddCell(cell);
            }


            document.Add(tbl);

            document.Close();
            return(path + set.WorksetName + "-" + time + ".pdf");
        }
コード例 #9
0
 public void AddWorkset()
 {
     Worksets.Add(new WorksetParameter(string.Empty, false, -1));
 }
コード例 #10
0
 public void AddWorkset()
 {
     Worksets.Add(new WorksetParameter());
 }