예제 #1
0
        static async Task Main(string[] args)
        {
            var host = CreateHost();

            using (var serviceScope = host.Services.CreateScope())
            {
                var services = serviceScope.ServiceProvider;
                try
                {
                    var studentsSource = services.GetRequiredService <IStudentsSource>();
                    var studentDtos    = await studentsSource.GetStudentsAsync();

                    var students = studentDtos.Select(x => x.ToEntity()).ToList();
                    var report   = StudentsReport.Create("Maksym Voloshyn", "*****@*****.**", students);

                    var outputReportService = services.GetRequiredService <IOutputReportService>();
                    var outputReportTask    = outputReportService.OutputAsync(report);

                    var publishService = services.GetRequiredService <IStudentsReportPublishService>();
                    var publishTask    = publishService.PublishAsync(report);

                    await Task.WhenAll(outputReportTask, publishTask);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            Console.ReadLine();
        }
예제 #2
0
        private void All_Person_Button_Click_1(object sender, EventArgs e)
        {
            this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False";
            this.sqlcon          = new SqlConnection(connetionString);
            try
            {
                SqlCommand cmd = new SqlCommand("select Email, Password, Permission from person", sqlcon);
                StudentsReport.Visible = true;
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();

                //Paint headers
                StudentsReport.EnableHeadersVisualStyles = false;
                StudentsReport.GridColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                StudentsReport.AutoResizeColumns();
                StudentsReport.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;



                bsource.DataSource        = dbdataset;
                StudentsReport.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "StudentId,CirruculumId,FirstExam,SecondExam,Ready,Absent")] StudentsReport studentsReport)
        {
            if (ModelState.IsValid)
            {
                //Eper Öğrenciye Ders atanmışsa tekrarı engelle
                int reportCount = db.StudentsReports.Where
                                  (
                    i => i.StudentId == studentsReport.StudentId && i.CirruculumId == studentsReport.CirruculumId
                                  ).Count();
                if (reportCount == 0)
                {
                    db.StudentsReports.Add(studentsReport);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = "Student Report Already Exist";
                    return(RedirectToAction("Create"));
                }
            }

            ViewBag.CirruculumId = new SelectList(db.Curricula, "Id", "Id", studentsReport.CirruculumId);
            ViewBag.StudentId    = new SelectList(db.Students, "Id", "UserId", studentsReport.StudentId);
            return(View(studentsReport));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "LessonId,TeacherId,TermId")] Curriculum curriculum)
        {
            if (ModelState.IsValid)
            {
                //Eğer ders ve yıl daha önce varsa ders müfredata eklenmiş demektir
                int recordExist = db.Curricula.Where(i => i.LessonId == curriculum.LessonId && i.TermId == curriculum.TermId).Count();
                if (!(recordExist > 0))
                {
                    db.Curricula.Add(curriculum);
                    //Curriculum oluşturunca otomatik olarak o sınıfa ait olan öğrencileri derse ata
                    var students = db.Students.Where(i => i.TermId == curriculum.TermId);
                    foreach (Student x in students)
                    {
                        StudentsReport report = new StudentsReport();
                        var            rnd    = new Random(DateTime.Now.Millisecond);
                        report.id           = rnd.Next(0, 3000);
                        report.Absent       = 0;
                        report.CirruculumId = curriculum.Id;
                        report.StudentId    = x.Id;
                        report.Ready        = false;
                        db.StudentsReports.Add(report);
                    }
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.LessonId  = new SelectList(db.Lessons, "Id", "Name", curriculum.LessonId);
            ViewBag.TeacherId = new SelectList(db.Teachers, "Id", "UserId", curriculum.TeacherId);
            ViewBag.TermId    = new SelectList(db.Terms, "Id", "Term1", curriculum.TermId);
            return(View(curriculum));
        }
예제 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            StudentsReport studentsReport = db.StudentsReports.Find(id);

            db.StudentsReports.Remove(studentsReport);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "id,StudentId,CirruculumId,FirstExam,SecondExam,Ready,Absent")] StudentsReport studentsReport)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentsReport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CirruculumId = new SelectList(db.Curricula, "Id", "Id", studentsReport.CirruculumId);
     ViewBag.StudentId    = new SelectList(db.Students, "Id", "UserId", studentsReport.StudentId);
     return(View(studentsReport));
 }
예제 #7
0
        public void printDSSVLop(string Lop, string khoa, List <DTO.Student> data)
        {
            StudentsReport studentsReport = new StudentsReport();

            foreach (DevExpress.XtraReports.Parameters.Parameter p in studentsReport.Parameters)
            {
                p.Visible = true;
            }
            studentsReport.initData(Lop, khoa, data);
            documentViewer1.DocumentSource = studentsReport;
            studentsReport.CreateDocument();
        }
예제 #8
0
        public async Task PublishAsync(StudentsReport report)
        {
            var client = _httpClientFactory.CreateClient();

            var content  = new StringContent(JsonSerializer.Serialize(report), Encoding.UTF8, "application/json");
            var response = await client.PutAsync($"{PublishTargetUrl}{StudentsReportEndpoint}", content);

            if (!response.IsSuccessStatusCode)
            {
                //TODO: logging
                throw new PublishReportException($"Failed to publish students report - {response.ReasonPhrase}");
            }
        }
예제 #9
0
        // GET: StudentsReports/Details/5
        public ActionResult Details(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentsReport studentsReport = db.StudentsReports.Find(id);

            if (studentsReport == null)
            {
                return(HttpNotFound());
            }
            return(View(studentsReport));
        }
 public Task OutputAsync(StudentsReport report)
 {
     return(Task.Run(() =>
     {
         Console.WriteLine("====================================");
         Console.WriteLine($"YourName                      - {report.YourName}");
         Console.WriteLine($"YourEmail                     - {report.YourEmail}");
         Console.WriteLine($"YearWithHighestAttendance     - {report.YearWithHighestAttendance}");
         Console.WriteLine($"YearWithHighestOverallGPA     - {report.YearWithHighestOverallGPA}");
         Console.WriteLine($"Top10StudentIdsWithHighestGPA - {string.Join(',', report.Top10StudentIdsWithHighestGPA)}");
         Console.WriteLine($"StudentIdMostInconsistent     - {report.StudentIdMostInconsistent}");
         Console.WriteLine("====================================");
     }));
 }
예제 #11
0
        public ActionResult StudentsReport(StudentsReport model)
        {
            var sManager = new StudentManager();
            var student  = sManager.GetAllStudentsByCollge(model.CollegeName);

            if (student == null)
            {
                return(View("Error"));
            }

            var ListofStudents = student.Students.ToList().OrderByDescending(z => z.StudentDob);

            return(View("_StudentReportsView", ListofStudents));
        }
예제 #12
0
        // GET: StudentsReports/Edit/5
        public ActionResult Edit(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentsReport studentsReport = db.StudentsReports.Find(id);

            if (studentsReport == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CirruculumId = new SelectList(db.Curricula, "Id", "Id", studentsReport.CirruculumId);
            ViewBag.StudentId    = new SelectList(db.Students, "Id", "UserId", studentsReport.StudentId);
            return(View(studentsReport));
        }
예제 #13
0
        public void Should_CreateStudentsReport()
        {
            //Arrange
            const string name  = "MyName";
            const string email = "MyEmail";

            //Act
            var orderedStudents = StudentsReport.Create(name, email, _fixture.Students);

            //Assert
            Assert.Equal(name, orderedStudents.YourName);
            Assert.Equal(email, orderedStudents.YourEmail);
            Assert.Equal(2013, orderedStudents.YearWithHighestAttendance);
            //TODO: Setup bigger test fixture to test TOP10 property
            Assert.Equal(2016, orderedStudents.YearWithHighestOverallGPA);
            Assert.Equal(3, orderedStudents.StudentIdMostInconsistent);
        }
예제 #14
0
        private void Load_table_Click_1(object sender, EventArgs e)
        {
            this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False";
            this.sqlcon          = new SqlConnection(connetionString);

            SqlCommand cmd = new SqlCommand("declare @results varchar(50) select @results = convert(varchar(50),Course_id) from Teaching_Stuff  WHERE Teaching_Stuff.ID = '" + Utility.User.ID + "' SELECT Person.F_name,Person.L_name,Teaching_Stuff.ID,Teaching_Stuff.Course_id,Teaching_Stuff.office,Person.Email FROM Teaching_Stuff JOIN Person on Person.ID=Teaching_Stuff.ID WHERE Course_id  = @results AND Teaching_Stuff.ID  != '" + Utility.User.ID + "'", sqlcon);

            try
            {
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();


                //Paint headers
                StudentsReport.EnableHeadersVisualStyles = false;
                StudentsReport.GridColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                StudentsReport.AutoResizeColumns();
                StudentsReport.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;


                bsource.DataSource        = dbdataset;
                StudentsReport.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
                Reports form2 = new Reports();
                form2.StartPosition = FormStartPosition.Manual;
                form2.SetDesktopBounds(218, 46, 1520, 820);
                form2.ShowDialog();
            }
            this.sqlcon.Close();
            //this.Close();
        }
예제 #15
0
        private void Failing_Students_Click(object sender, EventArgs e)
        {
            this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False";
            this.sqlcon          = new SqlConnection(connetionString);
            try
            {
                SqlCommand cmd = new SqlCommand("select stud_Id, final_grade from Student_Courses where final_grade <= 56 and course_id='" + CourseID.Text + "'", sqlcon);
                StudentsReport.Visible = true;
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();

                //Paint headers
                StudentsReport.EnableHeadersVisualStyles = false;
                StudentsReport.GridColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                StudentsReport.AutoResizeColumns();
                StudentsReport.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;



                bsource.DataSource        = dbdataset;
                StudentsReport.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (SqlException ex)
            {
                //this.Close();
                CourseID.Text = "";
                MessageBox.Show("Error selecting course id, try again!\n" + ex.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #16
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            this.connetionString   = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False; MultipleActiveResultSets=true";
            this.sqlcon            = new SqlConnection(connetionString);
            StudentsReport.Visible = true;

            try
            {
                SqlCommand     cmd = new SqlCommand("select Student_Courses.stud_Id,Student_Courses.course_id FROM Student_Courses LEFT join Teaching_Stuff on Student_Courses.course_id=Teaching_Stuff.Course_ID where ID='" + Utility.User.ID + "' and Type = 1", sqlcon);
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();


                //Paint headers
                StudentsReport.EnableHeadersVisualStyles = false;
                StudentsReport.GridColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                StudentsReport.AutoResizeColumns();
                StudentsReport.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;


                bsource.DataSource        = dbdataset;
                StudentsReport.DataSource = bsource;
                sda.Update(dbdataset);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
                Reports form2 = new Reports();
                form2.StartPosition = FormStartPosition.Manual;
                form2.SetDesktopBounds(218, 46, 1520, 820);
                form2.ShowDialog();
            }
        }
예제 #17
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            string str = null;


            try
            {
                this.connetionString = "Data Source = whitesnow.database.windows.net; Initial Catalog = Mazal; Integrated Security = False; User ID = Grimm; Password = #!7Dwarfs; Connect Timeout = 15; Encrypt = False; TrustServerCertificate = True; ApplicationIntent = ReadWrite; MultiSubnetFailover = False";
                this.sqlcon          = new SqlConnection(connetionString);
                SqlCommand cmd = new SqlCommand("select * from Classes_SM1 where date='" + "1990-01-01" + "'", sqlcon);
                if (toolStripComboBox3.Text.Equals("") && !toolStripComboBox4.Text.Equals(""))

                {
                    str = toolStripComboBox4.Text;
                    //MessageBox.Show(str);
                    cmd = new SqlCommand("select * from Classes_SM1 where date='" + str + "'", sqlcon);
                    StudentsReport.Visible = true;
                }
                else if (toolStripComboBox4.Text.Equals("") && !toolStripComboBox3.Text.Equals(""))
                {
                    str = toolStripComboBox3.Text;
                    //MessageBox.Show(str);
                    cmd = new SqlCommand("select * from Classes_SM2 where date='" + str + "'", sqlcon);
                    StudentsReport.Visible = true;
                }
                else
                {
                    throw new ArgumentException("Error selecting dates,try again!");
                }

                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataTable dbdataset = new DataTable();
                sda.Fill(dbdataset);
                BindingSource bsource = new BindingSource();

                //Paint headers
                StudentsReport.EnableHeadersVisualStyles = false;
                StudentsReport.GridColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.BackColor = Utility.HeaderBackColor;
                StudentsReport.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                StudentsReport.AutoResizeColumns();
                StudentsReport.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                StudentsReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;


                bsource.DataSource        = dbdataset;
                StudentsReport.DataSource = bsource;
                sda.Update(dbdataset);

                int i = 0;
                for (int j = 0; j <= 9; j++)
                {
                    paintCells2(i);
                    i++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                toolStripComboBox3.Text = "";
                toolStripComboBox4.Text = "";
            }
            Print.Visible = true;
            Application.DoEvents();
        }