コード例 #1
0
        static void Main(string[] args)
        {
            main m1 = new main();
            main m2 = new main();

            session s1 = new session(m1, "127.0.0.1", 9252);
            session s2 = new session(m2, "127.0.0.1", 9252);

            // 1. lily login
            result r = s1.login("lily", "123456", 10000);

            if (!r.succ)
            {
                Console.WriteLine("ERROR: failed to login: {0}", r.info);
                return;
            }
            s1.quickplay(); // 2. lily want to play game

            // 3. test login
            r = s2.login("test", "t", 10000);
            if (!r.succ)
            {
                Console.WriteLine("ERROR: failed to login: {0}", r.info);
                s1.stop();
            }
            Thread.Sleep(2000);
            s2.quickplay(); // 4. test want to play

            // pause for a while, both logout
            Thread.Sleep(5000);
            s1.logout(5000);
            s2.logout(5000);
            s1.stop();
            s2.stop();
        }
コード例 #2
0
        public ActionResult dologin()
        {
            //Kiểm tra mật khâu cơ sở dữ liệu ở đây
            STAFF_INFO staff = new STAFF_INFO();

            staff.CODE    = "ABC";
            staff.NAME    = "Đã đăng nhập";
            staff.LOGTIME = DateTime.Now;
            ses.login(staff);

            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
        public ActionResult dologin(AccountVM account)
        {
            //Kiểm tra mật khâu cơ sở dữ liệu ở đây.
            USER_OBJ user_LogedIn = checkLogin(account);

            if (user_LogedIn != null)
            {
                STAFF_INFO staff = new STAFF_INFO();
                staff.CODE     = user_LogedIn.CODE;
                staff.USERMAME = user_LogedIn.Username;
                staff.LOGTIME  = DateTime.Now;
                List <MENU_OBJ> lidata = _serviceMenu.GetMenu();
                staff.MENUCHA = lidata.Where(x => x.MenuIdCha == null).OrderBy(x => x.Sort).ToList();
                staff.MENU    = lidata.Where(x => x.MenuIdCha != null).OrderBy(x => x.Sort).ToList();
                _serviceMenu.CloseConnection();
                ses.login(staff);
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Login", "Home"));
        }
コード例 #4
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));
        }