示例#1
0
        private void добавитьЭкзаменToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var add = new AddExam();

            add.DisciplinesCB.DataSource    = db.Disciplines.Local.ToBindingList(); // дисциплины
            add.DisciplinesCB.DisplayMember = "Name";
            if (add.ShowDialog() == DialogResult.OK)
            {
                ExamSheet examSheet = new ExamSheet();
                examSheet.Examiner   = add.ExaminerTB.Text;
                examSheet.Comment    = add.CommentTB.Text;
                examSheet.Score      = Convert.ToInt32(add.ScoreNumericUpDown.Value);
                examSheet.EnrolleeId = currentEnrolleeId;
                examSheet.discipline = (Discipline)add.DisciplinesCB.SelectedItem;
                db.ExamSheets.Add(examSheet); // добавление абитуриента
                db.SaveChanges();
                //ExamsDataGV.DataSource = db.ExamSheets.Where(idenrollee => idenrollee.EnrolleeId == currentEnrolleeId).ToList();
                ExamsDataGV.DataSource = new BindingSource
                {
                    DataSource = db.ExamSheets.Where(idenrollee => idenrollee.EnrolleeId == currentEnrolleeId).ToList().Select(b =>
                                                                                                                               new { b.Id, b.EnrolleeId, b.Examiner, b.discipline.Name, b.Score, b.Comment }
                                                                                                                               )
                };
                ExamsDataGV.Columns[0].HeaderText = "id";
                ExamsDataGV.Columns[1].HeaderText = "id абитуриента";
                ExamsDataGV.Columns[2].HeaderText = "Экзаменатор";
                ExamsDataGV.Columns[3].HeaderText = "Название дисциплины";
                ExamsDataGV.Columns[4].HeaderText = "Количество набранных баллов";
                ExamsDataGV.Columns[5].HeaderText = "Комментарий";
                ExamsDataGV.Refresh();
            }
        }
示例#2
0
 public void UpdateSheet(ExamSheet sheet)
 {
     using (var db = new LiteDatabase(localdb))
     {
         var col = db.GetCollection <ExamSheet>("examsheet");
         col.Update(sheet._id, sheet);
     }
 }
示例#3
0
        private void удалитьИнформациюToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ExamsDataGV.SelectedRows.Count > 0)
            {
                try
                {
                    foreach (DataGridViewRow i in ExamsDataGV.SelectedRows)
                    {
                        bool converted = Int32.TryParse(ExamsDataGV[0, i.Index].Value.ToString(), out int id);
                        if (converted == false)
                        {
                            return;
                        }

                        ExamSheet examSheet = db.ExamSheets.Find(id);
                        db.ExamSheets.Remove(examSheet);
                        db.SaveChanges();
                    }
                    //ExamsDataGV.DataSource = db.ExamSheets.Where(idenrollee => idenrollee.EnrolleeId == currentEnrolleeId).ToList();
                    ExamsDataGV.DataSource = new BindingSource
                    {
                        DataSource = db.ExamSheets.Where(idenrollee => idenrollee.EnrolleeId == currentEnrolleeId).ToList().Select(b =>
                                                                                                                                   new { b.Id, b.EnrolleeId, b.Examiner, b.discipline.Name, b.Score, b.Comment }
                                                                                                                                   )
                    };
                    ExamsDataGV.Columns[0].HeaderText = "id";
                    ExamsDataGV.Columns[1].HeaderText = "id абитуриента";
                    ExamsDataGV.Columns[2].HeaderText = "Экзаменатор";
                    ExamsDataGV.Columns[3].HeaderText = "Название дисциплины";
                    ExamsDataGV.Columns[4].HeaderText = "Количество набранных баллов";
                    ExamsDataGV.Columns[5].HeaderText = "Комментарий";
                    ExamsDataGV.Refresh();

                    MessageBox.Show("Удаление прошло успешно!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#4
0
        private void изменитьИнформациюToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ExamsDataGV.SelectedRows.Count > 0)
            {
                foreach (DataGridViewRow i in ExamsDataGV.SelectedRows)
                {
                    try
                    {
                        bool converted = Int32.TryParse(ExamsDataGV[0, i.Index].Value.ToString(), out int id);
                        if (converted == false)
                        {
                            return;
                        }

                        ExamSheet examSheet = db.ExamSheets.Find(id);
                        var       add       = new AddExam(examSheet.Examiner, examSheet.Comment, examSheet.Score);
                        add.DisciplinesCB.DataSource    = db.Disciplines.Local.ToBindingList(); // дисциплины
                        add.DisciplinesCB.DisplayMember = "Name";
                        if (add.ShowDialog(this) == DialogResult.OK)
                        {
                            try
                            {
                                examSheet.Examiner   = add.ExaminerTB.Text;
                                examSheet.Comment    = add.CommentTB.Text;
                                examSheet.Score      = Convert.ToInt32(add.ScoreNumericUpDown.Value);
                                examSheet.discipline = (Discipline)add.DisciplinesCB.SelectedItem;
                                db.SaveChanges();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                        else
                        {
                            add.Close(); // если нажали кнопку отмены
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                //dataGridView1.DataSource = new BindingSource { DataSource = list.Select(b => new { b.prop1, p2 = b.prop2.prop1, b.prop2.prop2 }) };
                //ExamsDataGV.DataSource = db.ExamSheets.Where(idenrollee => idenrollee.EnrolleeId == currentEnrolleeId).ToList();

                ExamsDataGV.DataSource = new BindingSource
                {
                    DataSource = db.ExamSheets.Where(idenrollee => idenrollee.EnrolleeId == currentEnrolleeId).ToList().Select(b =>
                                                                                                                               new { b.Id, b.EnrolleeId, b.Examiner, b.discipline.Name, b.Score, b.Comment }
                                                                                                                               )
                };  // АХТУНГ
                ExamsDataGV.Columns[0].HeaderText = "id";
                ExamsDataGV.Columns[1].HeaderText = "id абитуриента";
                ExamsDataGV.Columns[2].HeaderText = "Экзаменатор";
                ExamsDataGV.Columns[3].HeaderText = "Название дисциплины";
                ExamsDataGV.Columns[4].HeaderText = "Количество набранных баллов";
                ExamsDataGV.Columns[5].HeaderText = "Комментарий";
                ExamsDataGV.Refresh();
                MessageBox.Show("Информация успешно обновлена!");
            }
        }
示例#5
0
        public ExamSheetRespone GetSheet(string pid, string subjectCode, string clientid)
        {
            var regis = repoOnSite.GetTestRegisInfo(pid, subjectCode);

            if (regis.MaxCount <= regis.LatestCount)
            {
                return(null);
            }

            ExamSheet sheet = new ExamSheet();

            //Get available exam sheet if haven't availble return null
            if (repoOnSite.GetSheetBySubjectCodeForMap(subjectCode, regis.ExamLanguage) == null)
            {
                return(new ExamSheetRespone {
                    Message = new ViewModels.MessageRespone {
                        Code = "1", Message = string.Format(getsheet1, subjectCode, regis.ExamLanguage).ToString()
                    }
                });
            }

            var oldsheet = repoOnSite.GetSheetByPIDAndSubjectCode(pid, subjectCode, regis.ExamLanguage);

            if (oldsheet.ClientId == null)
            {
                sheet = repoOnSite.GetSheetBySubjectCodeForMap(subjectCode, regis.ExamLanguage);
                sheet.RandomQuestions = new List <Question>(GetQuestion(sheet.RandomQuestions));
            }
            else
            {
                if (oldsheet.LatestStatus == "FAIL")
                {
                    sheet = repoOnSite.GetSheetBySubjectCodeForMap(subjectCode, regis.ExamLanguage);
                }
                else if (oldsheet.LatestStatus == "RESUME")
                {
                    sheet = oldsheet;
                }
                else if (oldsheet.LatestStatus != "RESUME")
                {
                    return(new ExamSheetRespone {
                        Message = new ViewModels.MessageRespone {
                            Code = "2", Message = getsheet2
                        }
                    });
                }
                else if (oldsheet.LatestStatus == "PASS")
                {
                    return(new ExamSheetRespone {
                        Message = new ViewModels.MessageRespone {
                            Code = "3", Message = getsheet3
                        }
                    });
                }
            }

            if (sheet.LatestStatus != "RESUME")
            {
                int testCount = regis.LatestCount + 1;

                sheet.TestCount   = testCount;
                regis.LatestCount = testCount;
            }

            sheet.TestRegisID = regis._id;
            sheet.PID         = regis.PID;

            var newStatus = new StatusExtension
            {
                _id            = Guid.NewGuid().ToString(),
                ClientId       = clientid,
                CreateDateTime = DateTime.Now,
                Status         = "Ready",
            };

            if (sheet.StatusExtensions == null)
            {
                sheet.StatusExtensions = new List <StatusExtension>();
                sheet.StatusExtensions.Add(newStatus);
            }
            else
            {
                sheet.StatusExtensions.Add(newStatus);
            }

            sheet.ClientId     = clientid;
            sheet.LatestStatus = "Ready";

            repoOnSite.UpdateSheet(sheet);
            repoOnSite.UpdateTestRegis(regis);

            var activeInfo = repoOnSite.GetLastActive();

            var result = new ExamSheetRespone
            {
                _id                = sheet._id,
                Title              = regis.Title,
                FirstName          = regis.FirstName,
                LastName           = regis.LastName,
                PID                = regis.PID,
                ExamNumber         = regis.ExamNumber,
                SubjectCode        = sheet.Subject.SubjectCode,
                SubjectName        = sheet.Subject.SubjectName,
                IsEReadiness       = sheet.Subject.IsEReadiness,
                ContentLanguage    = sheet.Subject.ContentLanguage,
                TestCount          = sheet.TestCount,
                LastedStatus       = sheet.LatestStatus,
                PassScore          = sheet.Subject.PassScore,
                CorrectScore       = 0,
                InCorrectScore     = 0,
                ExamDuration       = sheet.Subject.ExamDuration,
                ReviewDuration     = sheet.ReviewDuration,
                ActiveThruDateTime = activeInfo.ActiveThruDateTime,
                ClientId           = clientid,
                Questions          = sheet.RandomQuestions.Select(q => new Question
                {
                    _id                 = q._id,
                    QuestionNumber      = q.QuestionNumber,
                    IsAllowRandomChoice = q.IsAllowRandomChoice,
                    Detail              = q.Detail,
                    GroupId             = q.GroupId,
                    //UserAnswer = q.UserAnswer == null ? new Choice() :
                    //new Choice
                    //{
                    //    _id = q.UserAnswer._id,
                    //    Detail = q.UserAnswer.Detail,
                    //    IsCorrect = q.UserAnswer.IsCorrect.Value,
                    //},
                    UserAnswer = q.UserAnswer == null ? null :
                                 new Choice
                    {
                        _id       = q.UserAnswer._id,
                        Detail    = q.UserAnswer.Detail,
                        IsCorrect = q.UserAnswer.IsCorrect.Value,
                    },

                    Choices = q.Choices.Select(c => new Choice
                    {
                        _id       = c._id,
                        Detail    = c.Detail,
                        IsCorrect = null,
                    }).ToList(),
                }).ToList(),
                Message = new MessageRespone {
                    Code = "0", Message = getsheet0
                }
            };

            return(result);
        }
示例#6
0
        private void SyncExam(ExamSheet mysheet)
        {
            //var mysheet = repoOnSite.GetSheetBySheetId(sheetid);
            var myregis = repoOnSite.GetTestRegisById(mysheet.TestRegisID);

            if (mysheet.LatestStatus == "PASS")
            {
                mysheet.IsSync = true;
                myregis.IsSync = true;
            }

            List <ExamSheet> sheetList = new List <ExamSheet>();

            sheetList.Add(mysheet);

            List <ExamSheetOnline> sheetForOnline = new List <ExamSheetOnline>();

            var listReg = repoOnSite.GetTestRegisByIds(sheetList.Select(x => x.TestRegisID).ToList());

            foreach (var item in sheetList)
            {
                var regis = listReg.Where(x => x._id == item.TestRegisID).FirstOrDefault();

                var regisOnline = new TestRegistrationOnline
                {
                    _id           = regis._id,
                    Title         = regis.Title,
                    FirstName     = regis.FirstName,
                    LastName      = regis.LastName,
                    SubjectCode   = regis.SubjectCode,
                    SubjectName   = regis.SubjectName,
                    ExamLanguage  = regis.ExamLanguage,
                    VoiceLanguage = regis.VoiceLanguage,
                    RegDate       = regis.RegDate,
                    RegDateString = regis.RegDateString,
                    ExpriedDate   = regis.ExpriedDate,
                    SiteId        = regis.SiteId,
                    CenterId      = regis.CenterId,
                    ForTestSystem = regis.ForTestSystem,
                    ForPractice   = regis.ForPractice,
                    Status        = regis.Status,
                    ExamStatus    = regis.ExamStatus,
                    PID           = regis.PID,
                    ExamNumber    = regis.ExamNumber,
                    ExamPeriod    = regis.ExamPeriod,
                    AppointDate   = regis.AppointDate,
                    Email         = regis.Email,
                    Mobile        = regis.Mobile,
                    Address       = regis.Address,
                    MaxCount      = regis.MaxCount,
                    CertData      = regis.CertData,
                    LatestCount   = regis.LatestCount,
                };


                var sheet = new ExamSheetOnline
                {
                    _id              = item._id,
                    Subject          = item.Subject,
                    TestReg          = regisOnline,
                    TestCount        = item.TestCount,
                    LatestStatus     = item.LatestStatus,
                    ExamDateTime     = item.ExamDateTime,
                    StatusExtensions = item.StatusExtensions,
                    RandomQuestion   = item.RandomQuestions,
                    CenterId         = item.CenterId,
                    CorrectScore     = item.CorrectScore,
                    InCorrectScore   = item.InCorrectScore,
                    ReviewDuration   = item.ReviewDuration,
                    CreateDate       = item.CreateDate,
                    ClientId         = item.ClientId
                };

                sheetForOnline.Add(sheet);
            }

            CloseExamRequest request = new CloseExamRequest()
            {
                ResultSheet = sheetForOnline,
            };

            using (var client = new WebClient())
            {
                try
                {
                    var json     = Newtonsoft.Json.JsonConvert.SerializeObject(request);
                    var dataByte = System.Text.Encoding.UTF8.GetBytes(json);
                    client.Headers[HttpRequestHeader.ContentType] = "application/json";
                    //dataByte = client.UploadData("http://localhost:10585/api/ExamSheet/UpdateExamSheetFromOnSite/", "POST", dataByte);
                    dataByte = client.UploadData("http://eexamthaiex.azurewebsites.net/api/ExamSheet/UpdateExamSheetFromOnSite/", "POST", dataByte);

                    //update sheet
                    repoOnSite.UpdateSheet(mysheet);
                    //update Regis
                    repoOnSite.UpdateTestRegis(myregis);
                }
                catch (Exception e)
                {
                    throw new Exception(e.ToString());
                }
            }
        }