Esempio n. 1
0
 public void Delete(Model.Exam entity)
 {
     entity.IsActive = false;
     _examDAL.Update(entity);
 }
Esempio n. 2
0
 public void Add(Model.Exam entity)
 {
     _examDAL.Add(entity);
 }
Esempio n. 3
0
 public void Update(Model.Exam entity)
 {
     _examDAL.Update(entity);
 }
Esempio n. 4
0
        public void FormExam(int ID, int PaperCount, int QuestionsCount, string Teacher, string Cafedral, int course, int semester, string path)
        {
            string Subject = unit.SubjectRepository.Get(ID).Name;

            Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application();
            winword.ShowAnimation = false;
            winword.Visible       = false;
            object missing = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
            for (int i = 0; i < PaperCount; i++)
            {
                var exam = new Model.Exam();
                exam.Title = "Билет №" + (i + 1).ToString();

                var papers = exam.BuildQuestionList(GetQuestions(ID), QuestionsCount);

                //Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);

                //document.Content.SetRange(0, 0);

                var wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 12;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Font.Bold = 1;
                wp.Range.Text      = "МИНОБРНАУКИ РОССИИ";
                wp.Range.ParagraphFormat.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceSingle;
                wp.Range.ParagraphFormat.SpaceAfter      = 0;
                wp.Range.ParagraphFormat.Alignment       = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 12;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = "Федеральное государственное бюджетное \r\n образовательное учреждение высшего образования";
                wp.Range.ParagraphFormat.SpaceAfter      = 0;
                wp.Range.ParagraphFormat.LineSpacingRule = Microsoft.Office.Interop.Word.WdLineSpacing.wdLineSpaceSingle;
                wp.Range.ParagraphFormat.Alignment       = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Font.Bold = 1;
                wp.Range.Text      = "«Ухтинский государственный технический университет» \r\n (УГТУ)";
                wp.Range.ParagraphFormat.SpaceAfter = 12;
                wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = "Кафедра вычислительной техники, информационных систем и технологий";
                wp.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = "Дисциплина " + "«" + Subject + "»";
                wp.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = "Направление подготовки 09.03.02";
                wp.Range.ParagraphFormat.SpaceAfter = 0;
                wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                var    dt  = DateTime.Now;
                string str = "";
                if (dt.Month <= 6)
                {
                    str = $"{dt.Year - 1} - {dt.Year} учебный год";
                }
                else
                {
                    str = $"{dt.Year} - {dt.Year + 1} учебный год";
                }
                wp.Range.Text = str;
                wp.Range.ParagraphFormat.SpaceAfter = 0;
                wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = "Форма обучения дневная";
                wp.Range.ParagraphFormat.SpaceAfter = 0;
                wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = "Курс " + course;
                wp.Range.ParagraphFormat.SpaceAfter = 0;
                wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = "Семестр " + semester;
                wp.Range.ParagraphFormat.SpaceAfter = 12;
                wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                wp.Range.InsertParagraphAfter();


                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Font.Bold = 1;
                wp.Range.Text      = exam.Title;
                wp.Range.ParagraphFormat.SpaceAfter = 24;
                wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                for (int j = 0; j < QuestionsCount; j++)
                {
                    wp.Range.Font.Size = 14;
                    wp.Range.Font.Name = "Times New Roman";
                    wp.Range.ParagraphFormat.Alignment  = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                    wp.Range.ParagraphFormat.SpaceAfter = 0;
                    wp.Range.ParagraphFormat.Space15();
                    wp.Range.InsertBefore($"{j + 1}. {papers[j]} \r\n");
                }

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = $"Экзаменатор _____________ " + Teacher;
                wp.Range.ParagraphFormat.Alignment   = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.ParagraphFormat.SpaceBefore = 24;
                wp.Range.ParagraphFormat.SpaceAfter  = 0;
                wp.Range.ParagraphFormat.Space15();
                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = $"Зав. кафедрой _____________ " + Cafedral;
                wp.Range.ParagraphFormat.Alignment   = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.ParagraphFormat.SpaceBefore = 0;
                wp.Range.ParagraphFormat.SpaceAfter  = 0;
                wp.Range.ParagraphFormat.Space15();

                wp.Range.InsertParagraphAfter();

                wp = document.Paragraphs.Add(Type.Missing);
                wp.Range.Font.Size = 14;
                wp.Range.Font.Name = "Times New Roman";
                wp.Range.Text      = $"Утверждено на заседании кафедры протокол № ___ от ___________г";
                wp.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                wp.Range.ParagraphFormat.Space15();
                wp.Range.ParagraphFormat.SpaceBefore = 0;
                wp.Range.ParagraphFormat.SpaceAfter  = 0;
                wp.Range.InsertParagraphAfter();
                if (i != PaperCount - 1)
                {
                    wp.Range.InsertBreak();
                }
            }

            object filename = $"{path}\\{Subject} {DateTime.Now.Day}.{DateTime.Now.Month}.{DateTime.Now.Year}.docx";

            document.SaveAs2(ref filename);
            document.Close(ref missing, ref missing, ref missing);
            document = null;
            winword.Quit(ref missing, ref missing, ref missing);
            winword = null;
            MessageBox.Show("Экзамен успешно создан!");
        }