Пример #1
0
        private void insertStudentData()
        {
            Persistence p = new PersistenceImpl();

            var conf = new MyConfiguration();

            conf.currentBatch  = "2012-16";
            conf.currentDegree = "B.TECH";

            string[] branch = new string[5] {
                "Software", "COMPUTER SCIENCE", "MECHANICAL", "ECE", "CIVIL"
            };
            string[] gender = new string[2] {
                "MALE", "FEMALE"
            };
            int  studentId = 1704;
            long scoreID   = 247;
            var  mylist    = new List <Object>();
            var  scoreList = new List <Object>();

            for (int i = 200; i < 2201; i++)
            {
                var student = new Entity_Student();
                student.branch      = branch[i % branch.Length];
                student.collegeId   = studentId.ToString();
                student.email       = "*****@*****.**";
                student.gender      = gender[i % gender.Length];
                student.myConfigObj = conf;
                student.phone       = "111111111";
                student.studentName = "Student" + i;

                mylist.Add(student);
                studentId++;

                var score = new Entity_StudentScore();
                score.arrears   = 0;
                score.cgpa      = 7.6;
                score.X         = 85;
                score.XII       = 78;
                score.studentId = scoreID;
                scoreList.Add(score);

                scoreID++;
            }

            if (p.bulkInsert(mylist))
            {
                p.bulkInsert(scoreList);
            }
        }
Пример #2
0
        private IList<object> getStudentData(Excel.Range xlRange)
        {
            if (xlRange != null)
            {
                if (xlRange.Columns.Count == Constant.DB_INSERT_STUDENT_DATA)
                {
                    int rowCount = xlRange.Rows.Count;
                    int colCount = xlRange.Columns.Count;

                    var studentList = new List<Object>();
                    var scoreList = new List<Object>();
                    var clusteredList = new List<Object>();

                    Entity_Student studentObj;
                    Entity_StudentScore scoreObj;
                    MyConfiguration myconfObj;

                    for (int currRow = 3; currRow <= rowCount; currRow++)
                    {
                        studentObj = new Entity_Student();
                        scoreObj = new Entity_StudentScore();
                        myconfObj = new MyConfiguration();

                        for (int currCol = 1; currCol <= colCount; currCol++)
                        {
                            if (xlRange.Cells[currRow, currCol] != null &&
                                xlRange.Cells[currRow, currCol].Value2 != null &&
                                xlRange.Cells[currRow, currCol].Value2.ToString() != string.Empty)
                            {
                                string currValue = xlRange.Cells[currRow, currCol].Value2.ToString();

                                switch (currCol)
                                {
                                    case 1:
                                        studentObj.collegeId = currValue;
                                        scoreObj.collegeId = studentObj.collegeId;
                                        break;
                                    case 2:
                                        studentObj.studentName = currValue;
                                        break;
                                    case 3:
                                        studentObj.gender = currValue;
                                        break;
                                    case 4:
                                        studentObj.branch = currValue;
                                        break;
                                    case 5:
                                        myconfObj.currentDegree = currValue;
                                        break;
                                    case 6:
                                        myconfObj.currentBatch = currValue;
                                        break;
                                    case 7:
                                        studentObj.phone = currValue;
                                        break;
                                    case 8:
                                        studentObj.email = currValue;
                                        break;
                                    case 9:
                                        scoreObj.X = Convert.ToDouble(currValue);
                                        break;
                                    case 10:
                                        scoreObj.XII = Convert.ToDouble(currValue);
                                        break;
                                    case 11:
                                        scoreObj.cgpa = Convert.ToDouble(currValue);
                                        break;
                                    case 12:
                                        scoreObj.diploma = Convert.ToDouble(currValue);
                                        break;
                                    case 13:
                                        scoreObj.arrears = Convert.ToInt16(currValue);
                                        break;
                                }
                            }
                        }
                        studentObj.myConfigObj = myconfObj;
                        studentList.Add(studentObj);
                        scoreList.Add(scoreObj);
                        studentObj = null;
                        scoreObj = null;
                        myconfObj = null;
                    }

                    clusteredList.Add(studentList);
                    clusteredList.Add(scoreList);
                    return clusteredList;
                }
                return null;
            }
            return null;
        }