예제 #1
0
        public override void Login(string username, string password)
        {
            List <SYSUSEREntity> users = _db.SelectList(new SYSUSEREntity()
            {
                USERCODE = username
            });

            if (users.IsEmpty())
            {
                throw new Exception("找不到用户");
            }
            else if (users.Where(a => a.USER_FLAG.ToInt() == (int)用户标记.正常).IsEmpty())
            {
                throw new Exception($"用户已{users.First().USER_FLAG.ToEnum<用户标记>() }");
            }
            else
            {
                SYSUSEREntity user = users.First();
                if (Verify(user, password))
                {
                    Employee e = GetUser(user.USERID);
                    ApplicationContextBase.GetContext().SetData(LoginKey + e.Id, users);
                    ApplicationContextBase.GetContext().principal = new GenericPrincipal(new GenericIdentity(e.Id), null);
                    FormsAuthentication.SetAuthCookie(e.Id, true);
                }
                else
                {
                    throw new Exception("密码错误");
                }
            }
        }
        public void Initialize(ApplicationContextBase context)
        {
            var namings = context.ServiceFactory.Default.ResolveAll <IDataAccessNaming>();

            if (namings != null)
            {
                foreach (var naming in namings)
                {
                    if (naming != null)
                    {
                        this.Map(naming);
                    }
                }
            }

            var dataAccesses = context.ServiceFactory.Default.ResolveAll <IDataAccess>();

            if (dataAccesses != null)
            {
                foreach (var dataAccess in dataAccesses)
                {
                    if (dataAccess != null && dataAccess.Naming != null)
                    {
                        this.Map(dataAccess.Naming);
                    }
                }
            }
        }
예제 #3
0
        public override T GetUser <T>(bool throwError = true)
        {
            string key = ApplicationContextBase.GetContext()?.principal?.Identity.Name;
            T      e   = ApplicationContextBase.GetContext().GetData <T>(LoginKey + key);

            if (!key.IsEmpty() && e == null && ApplicationContextBase.GetContext().principal != null)
            {
                SYSUSEREntity user = _db.Select(new SYSUSEREntity(key));
                if (user == null)
                {
                    throw new NoLoginException();
                }
                return(GetUser(user.USERID) as T);
            }
            if (e == null)
            {
                if (ConfigExtension.TestModel)//测试模式
                {
                    var teste = new Employee()
                    {
                        Id         = ConfigExtension.TestModel_User,
                        Name       = $"测试模式:{ConfigExtension.TestModel_User}",
                        PlatformId = ""
                    } as T;
                    return(teste);
                }
                if (throwError)
                {
                    throw new NoLoginException();
                }
            }
            return(e);
        }
예제 #4
0
 public override void LogOut()
 {
     if (HasLogin)
     {
         ApplicationContextBase.GetContext().RemoveData(LoginKey + GetUser <User>().Id);
     }
 }
예제 #5
0
        public override T GetUser <T>(bool throwError = true)
        {
            if (ConfigExtension.TestModel)//测试模式
            {
                ServiceUser teste = new ServiceUser()
                {
                    Id         = ConfigExtension.TestModel_User,
                    Name       = $"测试模式:{ConfigExtension.TestModel_User}",
                    PlatformId = "-1"
                };
                return(teste as T);
            }
            string key  = ApplicationContextBase.GetContext()?.principal?.Identity.Name;
            T      user = GetUserByKey <T>(key);

            if (user == null)
            {
                if (throwError)
                {
                    throw new NoLoginException();
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(user);
            }
        }
예제 #6
0
 public override void Login(string username, string password)
 {
     Model.User user = service.GetUserByCode(username, password).ToObj(a => new User()
     {
         Id = a.Id, Name = a.Name
     });
     ApplicationContextBase.GetContext().SetData(LoginKey + user.Id, user);
     ApplicationContextBase.GetContext().principal = new GenericPrincipal(new GenericIdentity(user.Id), null);
 }
예제 #7
0
 public override int Logins(string username, string password)
 {
     Model.User user = service.GetUserByCode(username, password).ToObj(a => new User()
     {
         Id = a.Id, Name = a.Name
     });
     ApplicationContextBase.GetContext().SetData(LoginKey + user.Id, user);
     ApplicationContextBase.GetContext().principal = new GenericPrincipal(new GenericIdentity(user.Id), null);
     FormsAuthentication.SetAuthCookie(user.Id, true);
     return(0);
 }
예제 #8
0
파일: Game.cs 프로젝트: Pedlar/PacmanOgre
        public Game(ApplicationContextBase applicationContextBase)
        {
            _applicationContextBase = applicationContextBase;
            _disposables            = new List <IDisposable>();
            _keyListener            = new KeyListener(applicationContextBase);
            _inputManager           = new InputManager(this);
            _tickManager            = new TickManager();
            _sceneManager           = new Scene.SceneManager(this);

            _disposables
            .Append(_inputManager)
            .Append(_keyListener)
            .Append(_tickManager)
            .Append(_sceneManager);
        }
예제 #9
0
 public override void Login(string username, string password)
 {
     if (username.IsEmpty())
     {
         if (ConfigExtension.TestModel)//测试模式
         {
             return;
         }
         throw new NoLoginException();
     }
     //------------这里接入验证登陆和权限配置
     if (GetUserByKey <ServiceUser>(username) != null)
     {
         ApplicationContextBase.GetContext().principal = new GenericPrincipal(new GenericIdentity(username), null);
     }
     else
     {
         throw new NoLoginException();
     }
 }
예제 #10
0
        public override T GetUser <T>(bool throwError = true)
        {
            if (ConfigExtension.TestModel)//测试模式
            {
                Employee teste = new Employee()
                {
                    Id         = ConfigExtension.TestModel_User,
                    Name       = $"测试模式:{ConfigExtension.TestModel_User}",
                    PlatformId = ""
                };
                teste.PermissionHandle = HasPermission;
                return(teste as T);
            }
            string key = ApplicationContextBase.GetContext()?.principal?.Identity.Name;
            T      e   = ApplicationContextBase.GetContext().GetData <T>(LoginKey + key);

            if (!key.IsEmpty() && e == null && ApplicationContextBase.GetContext().principal != null)
            {
                User user = service.GetUserById(key)?.ToObj(a => new User()
                {
                    Id = a.Id, Name = a.Name
                });
                if (user == null)
                {
                    throw new NoLoginException();
                }
                Employee emp = new Employee()
                {
                    Id         = user.Id,
                    Name       = user.Name,
                    PlatformId = ""
                };
                emp.PermissionHandle = HasPermission;
                return(emp as T);
            }
            if (e == null && throwError)
            {
                throw new NoLoginException();
            }
            return(e);
        }
        void run()
        {
            NativeWindowType nwt = new NativeWindowType();
            {
                MyApplicationContextSDL a = new MyApplicationContextSDL();

                if (ApplicationContextBase.call_setWindowGrab(a, nwt, true) != 100)
                {
                    throw new Exception("failed");
                }

                if (ApplicationContextSDL.call_setWindowGrab(a, nwt, true) != 100)
                {
                    throw new Exception("failed");
                }
            }

            {
                MyACSDL a = new MyACSDL();

                if (ACB.call_setWindowGrab(a, nwt, true) != 100)
                {
                    throw new Exception("failed");
                }
                if (ACB.call_setWindowGrab(a, "hi", 0) != 200)
                {
                    throw new Exception("failed");
                }

                if (ACSDL.call_setWindowGrab(a, nwt, true) != 100)
                {
                    throw new Exception("failed");
                }
                if (ACSDL.call_setWindowGrab(a, "hi", 0) != 200)
                {
                    throw new Exception("failed");
                }
            }
        }
예제 #12
0
 public ApplicationEventArgs(ApplicationContextBase applicationContext, string[] args)
 {
     _applicationContext = applicationContext;
     _args = args ?? new string[0];
 }
예제 #13
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ApplicationContextBase obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
예제 #14
0
파일: Game.cs 프로젝트: Pedlar/PacmanOgre
 public KeyListener(ApplicationContextBase ctx)
 {
     this.ctx = ctx;
 }