Пример #1
0
        public Entity.Rank loadRank(string studentID, string semesterID)
        {
            SqlConnection con = DbConnect.GetConnection();

            con.Open();
            string     sql = "select rankName from Rank where studentID=@studentID AND semesterID=@semesterID";
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add("studentID", SqlDbType.NVarChar);
            cmd.Parameters.Add("semesterID", SqlDbType.NVarChar);
            cmd.Parameters["studentID"].Value  = studentID;
            cmd.Parameters["semesterID"].Value = semesterID;
            SqlDataReader dr = cmd.ExecuteReader();

            Entity.Rank r = null;
            if (dr.Read())
            {
                r      = new Entity.Rank();
                r.rank = dr["rankName"].ToString();
            }
            dr.Close();
            con.Close();
            return(r);
        }
Пример #2
0
        public void calRank(string studentID, Entity.Rate rt)
        {
            ServiceReference1.WebService1SoapClient ws  = new ServiceReference1.WebService1SoapClient();
            ServiceReference2.SAPISoapClient        fap = new ServiceReference2.SAPISoapClient();
            Entity.Rank r = new Entity.Rank();
            r.studentID = studentID;
            string             currentSemester = "Spring2018";
            string             fail            = fap.getFailCourse(r.studentID);
            string             pass            = fap.getPassCourse(r.studentID);
            List <Curricurlum> listPass        = new List <Curricurlum>();
            List <Curricurlum> listFail        = new List <Curricurlum>();

            if (!pass.Equals("Data not found"))
            {
                listPass = JsonConvert.DeserializeObject <List <Curricurlum> >(pass);
            }
            if (!fail.Equals("Data not found"))
            {
                listFail = JsonConvert.DeserializeObject <List <Curricurlum> >(fail);
            }
            List <Gpa> gpaList = new List <Gpa>();
            string     t2      = fap.getGPA(r.studentID, currentSemester);

            if (!t2.Equals("Data not found"))
            {
                gpaList = JsonConvert.DeserializeObject <List <Gpa> >(t2);
            }
            int    totalCredit = 0;
            double avg         = 0;

            for (int j = 0; j < gpaList.Count; j++)
            {
                double temp = 0;
                if (gpaList[j].averageMark != null)
                {
                    temp = gpaList[j].credits * (double)gpaList[j].averageMark;
                }
                if (temp > 0)
                {
                    totalCredit += gpaList[j].credits;
                    avg         += temp;
                }
            }
            double gpa = ((double)avg) / ((double)totalCredit);
            double failcourse;

            if (listFail.Count != 0 && listPass.Count != 0)
            {
                failcourse = ((1 - ((double)listFail.Count) / ((double)listPass.Count + (double)listFail.Count))) * 10;
            }
            failcourse = 0;
            double             behavior  = ws.getBehaviorMark(r.studentID, currentSemester).behaviorMark;
            List <Curricurlum> attenList = new List <Curricurlum>();
            string             t         = fap.getAttendanceMark(r.studentID, currentSemester);

            if (!t.Equals("Data not found"))
            {
                attenList = JsonConvert.DeserializeObject <List <Curricurlum> >(t);
            }
            int totalAbsent = 0;

            for (int i = 0; i < attenList.Count; i++)
            {
                totalAbsent += attenList[i].absentTotal;
            }
            double atten = Math.Round(((double)(attenList.Count * 30) - totalAbsent) / ((double)attenList.Count * 30), 2) * 10;

            r.rank = Caculate(gpa, behavior, failcourse, atten, rt.markRate, rt.behRate, rt.failCout, rt.attentRate);
            if (checkExistRank(r.studentID, currentSemester))
            {
                isInsertRank(r.studentID, r.rank, currentSemester);
            }
            else
            {
                isUpdateRank2(r.studentID, r.rank, currentSemester);
            }
        }
Пример #3
0
        public Entity.Rank changeRankByCoefficient()
        {
            ServiceReference1.WebService1SoapClient ws = new ServiceReference1.WebService1SoapClient();
            //FreedomeF.ServiceReference1.ListStudentID[] list = ws.getStudentID();
            ServiceReference2.SAPISoapClient fap = new ServiceReference2.SAPISoapClient();

            Entity.Rank   r   = null;
            SqlConnection con = DbConnect.GetConnection();

            con.Open();
            string        sql = "SELECT studentID FROM Student WHERE takecareStatus=0";
            SqlCommand    cmd = new SqlCommand(sql, con);
            RankDAL       rdl = new RankDAL();
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                r           = new Entity.Rank();
                r.studentID = dr["studentID"].ToString();
                string currentSemester = "Spring2018";

                List <Curricurlum> listFail = new List <Curricurlum>();
                string             fail     = fap.getFailCourse(r.studentID);
                string             pass     = fap.getPassCourse(r.studentID);
                List <Curricurlum> listPass = new List <Curricurlum>();
                if (!pass.Equals("Data not found"))
                {
                    listPass = JsonConvert.DeserializeObject <List <Curricurlum> >(pass);
                }
                if (!fail.Equals("Data not found"))
                {
                    listFail = JsonConvert.DeserializeObject <List <Curricurlum> >(fail);
                }
                List <Gpa> gpaList = new List <Gpa>();
                string     t2      = fap.getGPA(r.studentID, currentSemester);

                if (!t2.Equals("Data not found"))
                {
                    gpaList = JsonConvert.DeserializeObject <List <Gpa> >(t2);
                }

                int    totalCredit = 0;
                double avg         = 0;

                for (int j = 0; j < gpaList.Count; j++)
                {
                    double temp = 0;
                    if (gpaList[j].averageMark != null)
                    {
                        temp = gpaList[j].credits * (double)gpaList[j].averageMark;
                    }
                    if (temp > 0)
                    {
                        totalCredit += gpaList[j].credits;
                        avg         += temp;
                    }
                }

                double gpa        = ((double)avg) / ((double)totalCredit);
                double failcourse = ((1 - ((double)listFail.Count) / ((double)listPass.Count + (double)listFail.Count))) * 10;

                double behavior = ws.getBehaviorMark(r.studentID, currentSemester).behaviorMark;

                List <Curricurlum> attenList = new List <Curricurlum>();

                string t = fap.getAttendanceMark(r.studentID, currentSemester);
                if (!t.Equals("Data not found"))
                {
                    attenList = JsonConvert.DeserializeObject <List <Curricurlum> >(t);
                }


                int totalAbsent = 0;
                for (int i = 0; i < attenList.Count; i++)
                {
                    totalAbsent += attenList[i].absentTotal;
                }


                double      atten = Math.Round(((double)(attenList.Count * 30) - totalAbsent) / ((double)attenList.Count * 30), 2) * 10;
                Entity.Rate rt    = new Entity.Rate();
                rt               = getRate();
                r.rank           = Caculate(gpa, behavior, failcourse, atten, rt.markRate, rt.behRate, rt.failCout, rt.attentRate);
                r                = new Entity.Rank();
                r.studymark      = gpa;
                r.failcourseNumb = failcourse;
                r.behaviorMark   = behavior;
                r.attendance     = atten;
                r.rank           = Caculate(gpa, behavior, failcourse, atten, rt.markRate, rt.behRate, rt.failCout, rt.attentRate);
                isUpdateRank2(r.studentID.ToString(), r.rank, currentSemester);
            }
            return(r);
        }