Exemplo n.º 1
0
        public override void Execute(Protocol.Clients.PosStoreClient posStoreClient, Protocol.RequestInfos.PosStorePackageInfo package)
        {
            var datas = package.Read <MachineInformation>();

            if (datas != null)
            {
                var cache = new OnlineCache();
                var key   = KeyFactory.MachineKeyFactory(datas.CompanyToken, datas.StoreId, datas.MachineSn, datas.DeviceSn);
                cache.Set(key, datas);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 验证用户登录
        /// </summary>
        /// <param name="userParams">登录参数</param>
        /// <returns></returns>
        public static LoginResult Login(LoginParams userParams, string deviceSn, bool inTestMode = false, bool isLock = false)
        {
            var dataAdapter = DataAdapterFactory.Factory(MachinesSettings.Mode, userParams.StoreId, userParams.MachineSn, userParams.CompanyId, deviceSn);
            var userInfo    = dataAdapter.GetUser(userParams.Account);

            if (userInfo == null)
            {
                throw new LoginExecption("401", "账号错误!");
            }
            if (userInfo.LoginPwd != MD5.MD5Encrypt(userParams.Password))
            {
                throw new LoginExecption("401", "密码错误!");
            }
            //本店角色(1:店长、2:营业员、3:收银员、4:数据维护),格式:门店ID,角色ID|门店ID,角色ID
            if (!inTestMode && !(VerfyOperateAuth(userInfo, dataAdapter.StoreId, StoreOperateAuth.Cashier) || VerfyOperateAuth(userInfo, dataAdapter.StoreId, StoreOperateAuth.DataManager)))
            {
                throw new LoginExecption("402", "非销售员或数据维护员不允许登录销售!");
            }
            var key         = KeyFactory.MachineKeyFactory(userParams.CompanyId, userParams.StoreId, userParams.MachineSn, deviceSn);
            var machineInfo = new MachineInformation()
            {
                CashierName        = userInfo.FullName,
                CashierOperateAuth = userInfo.OperateAuth,
                CashierUid         = userInfo.UID,
                CashierUserCode    = userInfo.UserCode,
                StoreName          = userInfo.StoreName,
                StoreId            = userParams.StoreId,
                MachineSn          = userParams.MachineSn,
                CompanyId          = userParams.CompanyId,
                InTestMode         = inTestMode,
                DeviceSn           = deviceSn
            };

            onlineCache.Set(key, machineInfo);
#if (Local != true)
            RedisManager.Publish("SyncOnlineCache", JsonConvert.SerializeObject(machineInfo));
#endif
#if (Local)
            StoreManager.PubEvent("SyncOnlineCache", JsonConvert.SerializeObject(machineInfo));
#endif
            if (!isLock)
            {
                ShoppingCartFactory.Factory(userParams.StoreId, userParams.MachineSn, userParams.CompanyId, deviceSn, true);
            }
            return(new LoginResult()
            {
                FullName = userInfo.FullName,
                OperateAuth = userInfo.OperateAuth,
                UserCode = userInfo.UserCode,
                StoreName = userInfo.StoreName
            });
        }
Exemplo n.º 3
0
 public override void Excute(PosStoreServer server, PosStoreSession session, PosStoreRequestInfo requestInfo)
 {
     try
     {
         var datas = requestInfo.Read <MachineInformation>();
         if (datas != null)
         {
             var cache = new OnlineCache();
             var key   = KeyFactory.MachineKeyFactory(datas.CompanyId, datas.StoreId, datas.MachineSn, datas.DeviceSn);
             cache.Set(key, datas);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 4
0
        public static void Sub()
        {
            new EventAggregator().Subscribe <SyncMemberNoEvent>("SyncMemberNoEventForServer", (o) =>
            {
                MemberNo memberNo = new MemberNo(o.CompanyId, o.StoreId);
                if (memberNo.GetNumber() < o.Number)
                {
                    memberNo.Reset(o.Number);
                }
            });

            new EventAggregator().Subscribe <SyncOnlineEvent>("SyncOnlineEventForServer", (o) =>
            {
                var cache = new OnlineCache();
                var key   = KeyFactory.MachineKeyFactory(o.CompanyToken, o.StoreId, o.MachineSn, o.DeviceSn);
                cache.Set(key, new MachineInformation()
                {
                    CashierName        = o.CashierName,
                    CashierOperateAuth = o.CashierOperateAuth,
                    CashierUid         = o.CashierUid,
                    CashierUserCode    = o.CashierUserCode,
                    CompanyToken       = o.CompanyToken,
                    DeviceSn           = o.DeviceSn,
                    InTestMode         = o.InTestMode,
                    MachineSn          = o.MachineSn,
                    StoreId            = o.StoreId,
                    StoreName          = o.StoreName
                });
            });

            new EventAggregator().Subscribe <SyncSerialNumberEvent>("SyncSerialNumberEventForServer", (o) =>
            {
                PaySn customOrderSn = new PaySn(o.CompanyToken, o.StoreId, o.MachineSn);
                if (customOrderSn.GetNumber() < o.Number)
                {
                    customOrderSn.ResetSerialNumber(o.Number);
                }
            });
        }