Exemplo n.º 1
0
        private bool LogIn(Cashier cashier)
        {
            Logger.Log(LoggingLevel.Info, string.Format("Login Cashier: [{0}]", cashier != null ? cashier.LoginName : ""));
            _cashier = cashier;
            using (var ctx = new RMSModel())
            {
                CashierLog log =
                    ctx.CashierLogs
                    .OrderByDescending(x => x.LoginTime)
                    .FirstOrDefault(x => x.PersonId == cashier.Id && x.MachineName == Environment.MachineName);
                if (log != null)
                {
                    LogOut(cashier);
                }
                SalesRegion.SalesVM.Instance.CashierEx = cashier;

                log = new CashierLog()
                {
                    MachineName   = Environment.MachineName,
                    LoginTime     = DateTime.Now,
                    Status        = "LogIn",
                    PersonId      = cashier.Id,
                    TrackingState = TrackingState.Added
                };


                ctx.CashierLogs.Add(log);

                ctx.SaveChanges();
            }
            //  db.Dispose();
            return(true);
        }
Exemplo n.º 2
0
        private bool LogOut(Cashier cashier)
        {
            if (cashier == null)
            {
                return(false);
            }

            _cashier = cashier;
            using (var ctx = new RMSModel())
            {
                CashierLog log = ctx.CashierLogs.OrderByDescending(x => x.LoginTime).FirstOrDefault(x => x.PersonId == cashier.Id && x.MachineName == Environment.MachineName);

                if (log != null && log.Status == "LogIn")
                {
                    log.MachineName = Environment.MachineName;
                    log.LogoutTime  = DateTime.Now;
                    log.Status      = "LogOut";
                    log.PersonId    = cashier.Id;
                    //log.Cashier = cashier;

                    ctx.CashierLogs.AddOrUpdate(log);
                    ctx.SaveChanges();
                }
                //db.Dispose();
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        //public App()
        //{
        //    this.ShutdownMode = ShutdownMode.OnMainWindowClose;
        //    Bootstrapper bootstrapper = new Bootstrapper();
        //    bootstrapper.Run();
        //}

        private bool Authenticate(string user, string pass)
        {
            RMSModel db      = new RMSModel();
            var      cashier = (from c in db.Persons.OfType <Cashier>()
                                where c.LoginName == user
                                select c).FirstOrDefault();

            if (cashier != null && cashier.SPassword == pass)
            {
                CashierLog log = db.CreateObject <CashierLog>();
                log.PersonId    = cashier.Id;
                log.MachineName = Environment.MachineName;
                log.LoginTime   = DateTime.Now;
                log.Status      = "LogIn";
                //db = null;
                db.CashierLogs.AddObject(log);
                db.SaveChanges();
                db.Dispose();
                return(true);
            }
            else
            {
                return(false);
            }
        }