コード例 #1
0
        public bool rankking()
        {
            SqlConnection con = DbConnect.GetConnection();

            con.Open();
            SqlCommand comm  = new SqlCommand("SELECT COUNT(*) FROM Student WHERE takecareStatus=0", con);
            Int32      count = (Int32)comm.ExecuteScalar();
            string     sql   = "SELECT studentID FROM Student WHERE takecareStatus=0";
            SqlCommand cmd   = new SqlCommand(sql, con);

            Entity.Rate   rt = getRate();
            SqlDataReader dr = cmd.ExecuteReader();

            var tasks = new Task[count];
            int i     = 0;

            while (dr.Read())
            {
                string studentID = dr["studentID"].ToString();
                tasks[i++] = Task.Factory.StartNew(() =>
                {
                    calRank(studentID, rt);
                });
            }
            Task.WaitAll(tasks);
            return(true);
        }
コード例 #2
0
        public Entity.Rate getRate()
        {
            Entity.Rate   rt  = new Entity.Rate();
            SqlConnection con = DbConnect.GetConnection();

            try
            {
                con.Open();
                string        sql = "SELECT markRate,behRate,failCout,attentRate FROM Rate ";
                SqlCommand    cmd = new SqlCommand(sql, con);
                SqlDataReader dr  = cmd.ExecuteReader();


                if (dr.Read())
                {
                    rt.markRate   = (int)dr["markRate"];
                    rt.behRate    = (int)dr["behRate"];
                    rt.failCout   = (int)dr["failCout"];
                    rt.attentRate = (int)dr["attentRate"];
                }
            }
            finally
            {
                con.Close();
            }
            return(rt);
        }
コード例 #3
0
        public Entity.Rate updatePercent(Entity.Rate rt)
        {
            SqlConnection con = DbConnect.GetConnection();

            con.Open();
            string     sql = "Update Rate SET markRate=@markRate , behRate=@behRate,failCout=@failCout,attentRate=@attentRate Where id = 1";
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add("markRate", SqlDbType.Int);
            cmd.Parameters.Add("behRate", SqlDbType.Int);
            cmd.Parameters.Add("failCout", SqlDbType.Int);
            cmd.Parameters.Add("attentRate", SqlDbType.Int);
            cmd.Parameters["markRate"].Value   = rt.markRate;
            cmd.Parameters["behRate"].Value    = rt.behRate;
            cmd.Parameters["failCout"].Value   = rt.failCout;
            cmd.Parameters["attentRate"].Value = rt.attentRate;
            cmd.ExecuteNonQuery();
            return(rt);
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
        }