Exemple #1
0
        public JsonResult doLogin(string name, string pas, string sec)
        {
            int    ret       = 0;
            string nextsec   = "";
            string thetype   = "";
            string staffname = "";

            if (ses.loginFailCount > 3)
            {
                if (sec != ses.securityCode)
                {
                    ret = 1;
                }
                //login
            }
            STAFF_BUS bus    = new STAFF_BUS();
            STAFF_OBJ obj    = new STAFF_OBJ();
            STAFF_OBJ objGot = new STAFF_OBJ();

            if (ret == 0)
            {
                if (bus.OpenConnection() != 0)
                {
                    ret = -2 - 10;
                }
            }
            List <STAFFPRIORITY> lipermission = new List <STAFFPRIORITY>();

            if (ret >= 0)
            {
                obj.USERNAME     = name;
                obj.USERPASSWORD = pas;
                obj.CODEVIEW     = name;
                ret = bus.login(obj, out objGot, out lipermission);
                if (ret < 0)
                {
                    ret = -13;
                }
            }
            bus.CloseConnection();
            if (ret >= 0)
            {
                thetype = "LECTURER";
                STAFF_INFO inf = new STAFF_INFO(objGot.UNIVERSITYCODE, objGot.CODE, objGot.CODEVIEW, objGot.NAME, objGot.DEPARTMENTCODE, objGot.DEGREECODE, objGot.LEVELTITLECODE, objGot.ACADEMICTITLECODE, objGot.ARMYRANKCODE, objGot.PARTYLEVELTITLECODE, objGot.CHANGEPASS, DateTime.Now, thetype, objGot.PHOTO, objGot._DEPARTMENTCODE.NAME); // objGot._RESEARCHDEPARTMENTCODE.NAME);
                //login as lecturer or management
                //ses.login(objGot.CODE, objGot.CODEVIEW, objGot.NAME, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"), lipermission, objGot.DEPARTMENTCODE, obj.RESEARCHDEPARTMENTCODE, objGot.LEVELTITLECODE);
                ses.login(inf, lipermission);
                ses.clearLoginFail();
                getPersonalParameter(objGot.CODE);
                getGlobalParameter();
                staffname = inf.NAME;
                //logme
                COMMONTOOL comt = new COMMONTOOL();
                //                System.Web.UI.Page pgCallingPage = (System.Web.UI.Page)HttpContext.CurrentHandler;
                comt.logLogin(Request, "Login to admin");
                //end logme
            }
            //Kiểm tra đăng nhập cho sinh viên
            if (ret != 0)
            {
                STUDENT_BUS bus_student = new STUDENT_BUS();
                STUDENT_OBJ obj_student = new STUDENT_OBJ();
                STUDENT_OBJ obj_out     = new STUDENT_OBJ();
                string      functions   = "";
                obj_student.CODEVIEW     = obj.CODEVIEW;
                obj_student.USERPASSWORD = obj.USERPASSWORD;
                ret = bus_student.login(obj_student, out obj_out, out lipermission);
                if (ret < 0)
                {
                    ret = ret + -100;
                }
                bus_student.CloseConnection();
                if (ret == 0)
                {
                    thetype = "STUDENT";
                    STAFF_INFO inf = new STAFF_INFO(obj_out.UNIVERSITYCODE, obj_out.CODE, obj_out.CODEVIEW, obj_out.NAME, obj_out.CLASSCODE, "", "", "", "", "", obj_out.CHANGEPASS, DateTime.Now, thetype, obj_out.PHOTO, obj_out._CLASSCODE.NAME);
                    ses.login(inf, lipermission);
                    ses.clearLoginFail();
                    getStudentParameter(obj_out.CODE);
                    getGlobalParameter();
                    COMMONTOOL comt = new COMMONTOOL();
                    comt.logLogin(Request, "Student login");
                }
            }
            if (ret != 0)
            {
                if (ses.loginFail() >= 3)
                {
                    // nextsec = genNextQuestion();
                }
                ses.loginFail();
            }


            //some thing like that
            return(Json(new { ret = ret, logintype = thetype, NAME = staffname, COUNT = ses.loginFailCount }, JsonRequestBehavior.AllowGet));
        }