예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Utility u = new Utility();

                Guid               g1     = u.GetPersonIdfromRequest(Request);
                MessageList        ml1    = new MessageList();
                MessageGroupList   mgl1   = new MessageGroupList();
                Group              group1 = new Group();
                PupilDetails       pupil1 = new PupilDetails();
                MessageStudentList msl1   = new MessageStudentList();
                PersonDetails      p2     = new PersonDetails(g1.ToString());
                ml1.LoadList_Person(g1, 20);
                bool   first = true;
                string s     = "<h4>Last 20 messages sent from " + p2.m_GivenName + " " + p2.m_Surname + "</h4>";
                s += "<br><table  border  class=\"EventsTable\"  >";
                s += "<tr><th>Valid From</th><th>Message</th><th>To</th><th>Delivered</th></tr>";
                foreach (Message m1 in ml1.m_list)
                {
                    first = true;
                    s    += "<tr><td>" + m1.ValidFrom.ToShortDateString() + "</td><td>" + m1.Msg + "</td>";
                    //fi nd groups
                    mgl1.LoadList_Message(m1.Id);
                    foreach (MessageGroup mg1 in mgl1.m_list)
                    {
                        group1.Load(mg1.GroupId);
                        if (!first)
                        {
                            s += "<tr><td></td><td></td>";
                        }
                        s += "<td>" + group1._GroupCode + "</td>";
                        if (mg1.Delivered)
                        {
                            s += "<td>" + mg1.DateDelivered + "</td>";
                        }
                        s    += "</tr>";
                        first = false;
                    }
                    msl1.LoadList_Message(m1.Id);
                    foreach (MessageStudent ms1 in msl1.m_list)
                    {
                        pupil1.Load(ms1.StudentId.ToString());
                        if (!first)
                        {
                            s += "<tr><td></td><td></td>";
                        }
                        s += "<td>" + pupil1.m_GivenName + " " + pupil1.m_Surname + "</td>";
                        if (ms1.Delivered)
                        {
                            s += "<td>" + ms1.DateDelivered.ToString() + "</td>";
                        }
                        s    += "</tr>";
                        first = false;
                    }
                }
                s += "</table>";
                content0.InnerHtml = s;
            }
        }
예제 #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            // going to run through db and add any missing uci where we have an exam no...

            SimpleStudentList sl1    = new SimpleStudentList(SimpleStudentList.LIST_TYPE.NOFORM_ONROLE);
            PupilDetails      pupil1 = new PupilDetails();
            string            s      = "";

            ExamFiles ef = new ExamFiles();
            Encode    en = new Encode();
            int       n = 0; int n1 = 0;

            foreach (SimplePupil p in sl1._studentlist)
            {
                pupil1.m_UCI = "";
                pupil1.Load(p.m_StudentId.ToString());
                string year = DateTime.Now.Year.ToString();
                if ((pupil1.m_UCI == "") && (pupil1.m_examNo > 0))
                {
                    pupil1.m_UCI = ef.Calculate_UCI_Checksum("52205", "0", year, pupil1.m_examNo.ToString());
                    s            = "UPDATE dbo.tbl_Core_Students SET StudentUCI='" + pupil1.m_UCI + "' ";
                    s           += "WHERE StudentId = '" + p.m_StudentId.ToString() + "' ";
                    en.ExecuteSQL(s);
                    n++;
                }
                if (pupil1.m_examNo == 0)
                {
                    n1++;
                }
            }
            Label1.Text = "Created " + n.ToString() + " new UCIs.  There were " + n1.ToString() + " students found with no Exam Number!";
        }
예제 #3
0
        private bool ProcessFile(Exam_Board exb1, string series, ref string Errors)
        {
            //so are we able to do E file or A file...
            string s               = "";
            string line            = "";
            Cerval_Configuration c = new Cerval_Configuration("StaffIntranet_Exams_CentreNumber");
            string centre_number   = "";

            if (c.valid)
            {
                centre_number = c.Value;
            }
            else
            {
                Errors = "Centre Number not found in cerval..." + centre_number; return(false);
            }



            //check that if we are asked for an E file we dont already have one...
            //could just check no entries have been sent for this series...
            ExamEntries_List exl0 = new ExamEntries_List();

            exl0.LoadAllSeries(Year.ToString(), series, true, exb1.m_ExamBoardId.ToString());
            char type = exl0.m_list.Count > 0 ? 'A' : 'E';

            int          n1    = 0;
            Encode       en    = new Encode();
            PupilDetails p1    = new PupilDetails();
            DateTime     date1 = new DateTime();

            date1 = DateTime.Now;


            if (centre_number.Length != 5)
            {
                Errors = "Centre Number wrong!" + centre_number; return(false);
            }

            Exam_File    ef1 = new Exam_File();
            StreamWriter fs  = OpenFile(exb1, type, ref ef1, 194, series, centre_number, "14");

            if (fs == null)
            {
                Errors = "Error opening file"; return(false);
            }
            if (type == 'A')
            {
                //going to find any not yet sent and for these students clear the sent dates...
                exl0.m_list.Clear();



                exl0.LoadAllSeries(Year.ToString(), series, false, exb1.m_ExamBoardId.ToString());


                //now for each student in this list we need to re-send entries....
                foreach (Exam_Entry ex in exl0.m_list)
                {
                    ExamOption exo0 = new ExamOption();
                    exo0.Load(ex.m_OptionID);
                    ExamEntries_List exl2 = new ExamEntries_List();
                    exl2.Load(ex.m_StudentID, Year.ToString(), series, true, exb1.m_ExamBoardId.ToString());
                    foreach (Exam_Entry ex0 in exl2.m_list)
                    {
                        s  = "UPDATE tbl_Exams_Entries SET EntryFileID = NULL , DateEntered = NULL WHERE (ExamEntryID ='" + ex0.m_ExamEntryID.ToString() + "')";
                        n1 = en.Execute_count_SQL(s);
                    }
                }
            }

            ExamEntries_List exl1 = new ExamEntries_List();

            exl1.LoadAllSeries(Year.ToString(), series, false, exb1.m_ExamBoardId.ToString());
            int  n         = 0;
            int  n_record  = -1;//don't write first one
            int  n_records = 0;
            Guid std1      = Guid.Empty;

            foreach (Exam_Entry ex1 in exl1.m_list)
            {
                if (ex1.m_StudentID != std1)
                {
                    //have a new student
                    while (line.Length < 192)
                    {
                        line += " ";
                    }
                    if (n_record >= 0)
                    {
                        fs.WriteLine(line); n_records++;
                    }
                    std1     = ex1.m_StudentID;
                    p1.m_UCI = "";
                    p1.Load(std1.ToString());
                    n_record = 0;
                    line     = "";
                }
                if (n_record == 12)
                {
                    while (line.Length < 192)
                    {
                        line += " ";
                    }
                    fs.WriteLine(line); n_records++;
                    line = ""; n_record = 0;
                }
                n++;
                if (line == "")
                {
                    line = type + "5";
                    if (p1.m_IsOnRole)
                    {
                        line += "C";
                    }
                    else
                    {
                        line += "P";
                    }
                    line += centre_number;
                    s     = p1.m_examNo.ToString();
                    while (s.Length < 4)
                    {
                        s = "0" + s;
                    }
                    line += s;
                    //going to strip , from middle names to space...
                    s = p1.m_Surname + ":" + p1.m_GivenName + " " + p1.m_MiddleName.Replace(",", " ");
                    while (s.Length < 40)
                    {
                        s += " ";
                    }
                    if (s.Length > 40)
                    {
                        s.Substring(0, 40);
                    }
                    line += s;
                    if (p1.m_Gender == "F")
                    {
                        line += "F";
                    }
                    else
                    {
                        line += "M";
                    }
                    if (p1.m_dob == null)
                    {
                        s = "000000";
                    }
                    else
                    {
                        s = p1.m_dob.ToString("ddMMyy");
                    }
                    if (s == "010101")
                    {
                        s = "000000";               //010101  appears to the the defauult date if date in NULL in db
                    }
                    line += s;
                    if ((p1.m_UCI.Length != 13) || (p1.m_examNo == 0))
                    {
                        // todo  .. need to hanlde this error
                        /// clean up or offer UCI generation....
                        Errors  = "No UCI for " + p1.m_GivenName + " " + p1.m_Surname + "(" + p1.m_adno.ToString() + ")";
                        Errors += "Please create UCI for student and re-run";
                        //first mark any entries made for this file as not made........
                        s  = "UPDATE dbo.tbl_Exams_Entries SET EntryFileID = NULL , DateEntered = NULL ";
                        s += " WHERE (EntryFileID ='" + ef1.m_EntryFileId.ToString() + "' )";
                        Encode en1 = new Encode();
                        n1 = en1.Execute_count_SQL(s);
                        fs.Close();
                        return(false);
                    }
                    s     = p1.m_UCI;
                    line += s;
                    line += p1.m_upn.Trim();

                    //TODO....
                    line += p1.m_uln.Trim();
                    //line += "          ";//uln
                    //now the guest flag..... hmm...
                    //ought to do this really for cand from collaboration...

                    line += "             ";// up to byte 108 in jcq mess...
                }
                ExamOption exo1 = new ExamOption();
                exo1.Load(ex1.m_OptionID);
                if (exo1.m_ExamBoardID == exb1.m_ExamBoardId)
                {
                    //add it to the file unless withdrawn
                    if (!ex1.m_withdrawn)
                    {
                        s     = exo1.m_OptionCode + "      "; s = s.Substring(0, 6);
                        line += s + " "; n_record++;
                    }
                    //now update the Exam Entry record...
                    s  = "UPDATE tbl_Exams_Entries SET EntryFileID ='" + ef1.m_EntryFileId.ToString() + "' ";
                    s += " , DateEntered =CONVERT(DATETIME, '" + ef1.m_DateCreated.ToString("yyyy-MM-dd HH:mm:ss") + "', 102)  ";
                    s += " , EntryStatus = '4' ";
                    s += " WHERE (ExamEntryID = '" + ex1.m_ExamEntryID.ToString() + "' )";
                    en.ExecuteSQL(s);
                }
            }
            while (line.Length < 192)
            {
                line += " ";
            }
            if (n_record >= 0)
            {
                fs.WriteLine(line); n_records++;
            }
            EndFile(type, n_records, date1, fs, 194, ef1);
            return(true);
        }