Exemple #1
0
        private void Button_Click_20(object sender, RoutedEventArgs e)
        {
            AuthDAO authDAO = new AuthDAO();
            var     result  = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER);

            MessageBox.Show(JsonTools.Obj2JSONStrNew(result));
        }
Exemple #2
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            AuthDAO authDAO     = new AuthDAO();
            Auther  auther      = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_ADMIN);
            string  pingJsonStr = JsonTools.Obj2JSONStrNew(auther);

            MessageBox.Show(pingJsonStr);
        }
Exemple #3
0
        //得到当前状态的心跳
        public HttpHeartBeat GetHeartBeatByCurrent()
        {
            HttpHeartBeat sendHeartBeat = null;

            //不属于未注册状态
            SetterDAO setterDAO = new SetterDAO();
            Setter    setter    = setterDAO.getSetter();

            if (setterDAO.ListAll().Count != 1)
            {
                //设置表没有唯一标识,直接返回
                return(null);
            }

            //需要加入解密逻辑
            string mac = "";

            //获得当前主机的mac地址
            mac = SystemInfo.GetMacAddress().Replace(":", "-");
            AuthDAO authDAO = new AuthDAO();
            var     result  = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER);

            //注册用户设置mac与用户名
            //TODO设置mac地址不能从本地拿,必须实时获取


            sendHeartBeat = new HttpHeartBeat(result.Auth_UserName, mac);

            if (result.User_Status == Auther.USER_STATUS_FREEZE)
            {
                //是否为冻结状态的心跳,这里不能从数据库取,否则,云通知本地锁死,本地改状态后,会再次通知云锁死本机,陷入死循环
                sendHeartBeat.heartbeatType = 1;
                sendHeartBeat.authStatus    = 0;
            }
            else if (result.User_Status == Auther.USER_STATUS_FREE)

            {
                //是否完全离线
                sendHeartBeat.heartbeatType = 2;
                sendHeartBeat.authStatus    = 0;
            }
            else
            {
                //默认为正常心跳
                sendHeartBeat.heartbeatType = 0;
                sendHeartBeat.authStatus    = 0;
            }


            return(sendHeartBeat);
        }
Exemple #4
0
        /// <summary>
        /// 输入密码点击确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            result = "failed";
            var    queryResult = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER);
            string inputPass   = password.Password;

            if (!string.IsNullOrEmpty(inputPass) && !string.IsNullOrEmpty(queryResult.Auth_UserPass))
            {
                if (inputPass == queryResult.Auth_UserPass)
                {
                    result = "success";
                }
            }

            this.Close();
        }
        /// <summary>
        /// 获取当前心跳
        /// </summary>
        /// <returns></returns>
        public static HeartbeatRequest GetHeartBeatByCurrent()
        {
            HeartbeatRequest sendHeartBeat = new HeartbeatRequest();
            //不属于未注册状态
            SetterDAO setterDAO = new SetterDAO();
            Setter    setter    = setterDAO.getSetter();

            if (setterDAO.ListAll().Count != 1)
            {
                //设置表没有唯一标识,直接返回
                return(null);
            }
            AuthDAO authDAO = new AuthDAO();
            var     result  = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER);

            if (result == null)
            {
                return(null);
            }
            //机器码mac地址从本地拿
            sendHeartBeat.UniqueId = setter.Set_Unique_Id;
            //setting表装换成json,赋值
            sendHeartBeat.SettingJSON = JsonTools.Obj2JSONStrNew <Setter>(setter);
            //项目名 医疗康复赋值
            sendHeartBeat.ProductName = "医疗康复";
            //使用期限
            sendHeartBeat.UseDeadTime = result.Auth_OfflineTime.ToString().Replace("/", "-");
            //地理位置
            //sendHeartBeat.Address = setter.Set_Organizationaddress;
            //冻结
            if (result.User_Status == Auther.USER_STATUS_FREEZE)
            {
                //是否为冻结状态的心跳,这里不能从数据库取,否则,云通知本地锁死,本地改状态后,会再次通知云锁死本机,陷入死循环
                //状态 正常0和锁定1
                sendHeartBeat.Status = 1.ToString();
            }
            //正常
            else if (result.User_Status == Auther.USER_STATUS_GENERAL)
            {
                //状态 正常0和锁定1
                //默认为正常心跳
                sendHeartBeat.Status = 0.ToString();
            }
            return(sendHeartBeat);
        }
Exemple #6
0
        /// <summary>
        /// 根据web传来的心跳信息,做操作
        /// </summary>
        /// <param name="httpHeartBeat"></param>
        public void SolveHeartbeat(HttpHeartBeat httpHeartBeat)
        {
            AuthDAO authDAO = new AuthDAO();
            Auther  auther  = authDAO.GetByAuthLevel(Auther.AUTH_LEVEL_MANAGER);

            if (httpHeartBeat.authStatus == 0)
            {
                //0权限操作位  不作处理,属于正常心跳
                //解锁
                auther.User_Status = Auther.USER_STATUS_GENERAL;
            }
            else if (httpHeartBeat.authStatus == 1)
            {
                //锁定
                auther.User_Status = Auther.USER_STATUS_FREEZE;
            }
            else if (httpHeartBeat.authStatus == 2)
            {
                //解锁
                auther.User_Status = Auther.USER_STATUS_GENERAL;
            }
            else if (httpHeartBeat.authStatus == 3)
            {
                //永久离线至9999年
                auther.User_Status      = Auther.USER_STATUS_FREE;
                auther.Auth_OfflineTime = Auther.Auth_OFFLINETIMEFREE;
            }
            else if (httpHeartBeat.authStatus == 4)
            {
                //删除用户,做冻结处理
                auther.User_Status = Auther.USER_STATUS_FREEZE;
            }

            authDAO.UpdateByPrimaryKey(auther);
            //插入至上传表
            UploadManagementDAO uploadManagementDao = new UploadManagementDAO();

            uploadManagementDao.Insert(new UploadManagement(auther.Pk_Auth_Id, "bdl_auth", 1));
        }