Пример #1
0
        public void DoExams()
        {
            PreferencesRow p = inter.IBS.CurrentPreference;

            inter.IBS.Working = true;

            updatePreferenceAndClone(ref p);

            inter.IBS.Working = false;

            inter.IBS.LogPref.Position = inter.IBS.LogPref.Find(inter.IdB.Preferences.PIDColumn.ColumnName, p.PID);

            inter.IBS.Working = true;


            inter.Status = "Empezando...";

            FillClassDataBase(p.Class);

            // inter.IBS.LogPref.MoveFirst(); //select item to clone Application.DoEvents();

            inter.ProgressHandler?.Invoke(p.Models, EventArgs.Empty);

            int mod = 0; //models

            for (mod = 0; mod < p.Models; mod++)
            {
                inter.IdB.Exams.Clear();

                inter.ProgressHandler?.Invoke(0, EventArgs.Empty);

                ExamsListRow ls = doOneExam(ref p);
                if (ls == null)
                {
                    continue;
                }

                inter.ProgressHandler?.Invoke(0, EventArgs.Empty);

                Generator.FindFactor(ref p, ref ls);


                ////ENCRIPTAMIENTOOOOOOO
                inter.Status = "Procesando examen...";

                IList <string[]> questionAnswer;
                doOneEncriptExam(ref p, ref ls, out questionAnswer, inter.Password);
                //SAVE COPY OF TABLE in EXAMLIST

                Generator.MakeTableBytes(ref ls, examsPath);

                DB.TAM.ExamsListTableAdapter.Update(inter.IdB.ExamsList);

                inter.ProgressHandler?.Invoke(0, EventArgs.Empty);
                inter.Status = Resources.Creando + "el examen " + ls.GUID;

                doOneDocExam(ref p, ref ls, ref questionAnswer);

                inter.Status = "Examen generado";
                inter.ProgressHandler?.Invoke(0, EventArgs.Empty);
            }

            Generator.MakeTableBytes(ref p, examsPath);

            int count = p.GetExamsListRows().Count();

            if (count != 0)
            {
                inter.Status = count + " Modelos generados";
            }

            DB.TAM.PreferencesTableAdapter.Update(p);


            inter.IdB.Exams.Clear();

            inter.IBS.Working = false;
        }
Пример #2
0
        private static void MakeTableBytes <T>(ref T l, string examPath)
        {
            Type tipo = l.GetType();

            byte[] arr2 = null;
            // string afile = string.Empty;

            if (tipo.Equals(typeof(ExamsListRow)))
            {
                ExamsListRow ls = l as ExamsListRow;

                IEnumerable <ExamsRow> rows = ls.GetExamsRows();

                ExamsDataTable exdt = new ExamsDataTable();
                foreach (var item in rows)
                {
                    exdt.ImportRow(item);
                }

                // afile = ExasmPath + ls.EID.ToString();

                arr2     = Tables.MakeDTBytes(ref exdt, examPath);
                ls.EData = arr2;
            }
            else if (tipo.Equals(typeof(ExamsRow)))
            {
                //SAVE COPY OF TABLE

                ExamsRow     ex = l as ExamsRow;
                QuestionsRow q  = ex.QuestionsRow;
                // afile = ExasmPath + ex.QID.ToString(); IEnumerable<DB.QuestionsRow> shortQlist =
                // new List<DB.QuestionsRow>(); ((IList<DB.QuestionsRow>)shortQlist).Add(ex.QuestionsRow);
                QuestionsDataTable qdt = new QuestionsDataTable();
                qdt.ImportRow(q);
                byte[] qarray = Tables.MakeDTBytes(ref qdt, examPath);
                ex.QData = qarray;
                Dumb.FD(ref qdt);

                AnswersDataTable         adt  = new AnswersDataTable();
                IEnumerable <AnswersRow> answ = q.GetAnswersRows();
                foreach (var item in answ)
                {
                    adt.ImportRow(item);
                }
                // afile = ExasmPath + ex.QueToString() + ".xml";
                arr2     = Tables.MakeDTBytes(ref adt, examPath);
                ex.AData = arr2;
                Dumb.FD(ref adt);
            }
            else if (tipo.Equals(typeof(PreferencesRow)))
            {
                PreferencesRow p = l as PreferencesRow;              //SAVE A COPY OF EXAMS LISTS
                IEnumerable <DB.ExamsListRow> rows = p.GetExamsListRows();

                ExamsListDataTable dt = new ExamsListDataTable();
                foreach (var item in rows)
                {
                    dt.ImportRow(item);
                }

                // afile = ExasmPath + p.PID.ToString() + ".xml";
                arr2     = Tables.MakeDTBytes(ref dt, examPath);
                p.ELData = arr2;

                Dumb.FD(ref dt);
            }
        }