Esempio n. 1
0
        public static void insertUserDataToWorkBean(UserBean bean)//读卡器读到卡号
        {
            /***
             * 接收到一个用户刷卡信息
             * 1、查看卡号是否存在用户表中(可不做要求cjc)
             * 2、查看关联表中,是否存在读卡器IP
             * 3、记录
             *
             * 一个IP对应一个读卡器,
             * 查看workMap中是否有
             */

            // TODO 从用户表中通过卡号查找用户信息在给到bean

            WorkBean work = tryGetWorkBeanValue(bean.Ip);

            if (work != null)
            {
                if (!work.Card.Equals(bean.Card))//判断存在卡号是否与当前刷的卡号一致  不一致则移除后新增
                {
                    workMap.Remove(bean.Ip);
                    workMap.Add(bean.Ip, insertUserToMap(bean));
                }
            }
            else
            {
                workMap.Add(bean.Ip, insertUserToMap(bean));
            }
        }
Esempio n. 2
0
        public void ChangePassword(UserBean userbean)
        {
            try
            {
                User user = _userRepo.GetUserByUserName(userbean.UserName);
                if (user == null)
                {
                    throw new Exception("User Name not exist");
                }

                string decode = PasswordHelper.EncodePassword(userbean.OldPassword, user.Vcode);
                if (decode != user.Password)
                {
                    throw new Exception("Old Password not match");
                }

                string vcode   = PasswordHelper.GeneratePassword(PasswordHelper.DEFAULT_PASSWORD_LENGTH);
                string newPass = PasswordHelper.EncodePassword(userbean.Password, vcode);
                user.Password = newPass;
                user.Vcode    = vcode;
                _userRepo.Update(user);
            } catch (Exception e)
            {
                throw new Exception("Change password has failed: " + e.Message);
            }
        }
            public void Rename_Test()
            {
                //Arrange
                string expected = Guid.NewGuid().ToString("n");
                string actual   = String.Empty;

                //Arrange
                //load the user
                UserBean user = _bundledocsApi.Users.Me();

                //choose a brief
                Brief brief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault();

                //load the brief
                BriefBean loadedBrief = _bundledocsApi.Bundles.Get(brief.PartitionKey, brief.RowKey);

                //load the brief documents
                BriefDocument sectionToRename = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey).Where(k => k.Type == "HEADER").FirstOrDefault();

                //Act
                //rename the section
                BriefDocument renamedSection = _bundledocsApi.Sections.Rename(sectionToRename.PartitionKey, sectionToRename.RowKey, expected);

                actual = renamedSection.Description;

                //Assert
                Assert.AreEqual(expected, actual);
            }
Esempio n. 4
0
        public void LoadUser(int id)
        {
            UserBean user = mUserModel.Load(id);

            mUserView.SetFirstName(user.mFirstName); // 通过调用IUserView的方法来更新显示
            mUserView.SetLastName(user.mLastName);
        }
            public void Download_Test()
            {
                //Arange
                //load the user
                UserBean user = _bundledocsApi.Users.Me();

                //find a brief to load
                Brief briefToLoad = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault();

                //load the brief
                BriefBean loadedBrief = _bundledocsApi.Bundles.Get(briefToLoad.PartitionKey, briefToLoad.RowKey);

                //Act
                //Download the bundle
                Stream myStream = _bundledocsApi.Bundles.Download(loadedBrief.PartitionKey, loadedBrief.RowKey);

                //write the downloaded bundle to disk
                byte[] myFile      = myStream.ReadToEnd();
                string newFilePath = $@"{App.Default.TempFolder}{Guid.NewGuid().ToString("n")}.pdf";

                File.WriteAllBytes(newFilePath, myFile);

                //Assert
                Assert.IsTrue(File.Exists(newFilePath));

                //open the downloaded bundle
                Process.Start(newFilePath);
            }
Esempio n. 6
0
        public UserBean Login(UserBean userbean)
        {
            UserBean result = null;

            try
            {
                User user = _userRepo.GetUserByUserName(userbean.UserName);
                if (user == null)
                {
                    throw new Exception("User Name not exist");
                }

                string decode = PasswordHelper.EncodePassword(userbean.Password, user.Vcode);
                if (decode != user.Password)
                {
                    throw new Exception("Password not match");
                }

                result = new UserBean()
                {
                    Id       = user.Id,
                    UserName = user.UserName
                };
            } catch (Exception e)
            {
                throw new Exception("Login fail: " + e.Message);
            }

            return(result);
        }
            public void Rename_Test()
            {
                //Arrange
                string expected = Guid.NewGuid().ToString("n");

                //Arrange
                //load the user
                UserBean user = _bundledocsApi.Users.Me();

                //choose a brief
                Brief brief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault();

                //load the brief
                BriefBean loadedBrief = _bundledocsApi.Bundles.Get(brief.PartitionKey, brief.RowKey);

                //load the brief documents
                BriefDocument documentToRename = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey).Where(k => k.Type == "HEADER").FirstOrDefault().Children.Where(k => k.Type == "DOCUMENT").FirstOrDefault();

                //Act
                //rename the section
                BriefDocument renamedDocument = _bundledocsApi.Documents.Rename(documentToRename.PartitionKey, documentToRename.RowKey, expected);

                //Assert
                Assert.AreEqual(expected, renamedDocument.Description);
            }
            public void Download_Test()
            {
                //Arrange
                //load the user
                UserBean user = _bundledocsApi.Users.Me();

                //find a brief to load
                Brief parentBrief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault();

                //load the brief
                BriefBean loadedBrief = _bundledocsApi.Bundles.Get(parentBrief.PartitionKey, parentBrief.RowKey);

                //load the brief receipts
                IList <BriefReceipt> briefReceipts = _bundledocsApi.Bundles.Receipts(loadedBrief.PartitionKey, loadedBrief.RowKey);

                //load the latest brief receipt
                BriefReceipt briefReceiptToDownload = briefReceipts.FirstOrDefault();

                //download the brief receipt
                Stream briefReceiptStream = _bundledocsApi.Receipts.Download(briefReceiptToDownload.PartitionKey, briefReceiptToDownload.RowKey);

                //write the downloaded stream to disk
                byte[] myFile      = briefReceiptStream.ReadToEnd();
                string newFilePath = $@"{App.Default.TempFolder}{Guid.NewGuid().ToString("n")}.pdf";

                File.WriteAllBytes(newFilePath, myFile);

                //Assert
                Assert.IsTrue(File.Exists(newFilePath));

                //open the downloaded bundle
                Process.Start(newFilePath);
            }
            public void Download_Test()
            {
                //Arrange
                //load the user
                UserBean user = _bundledocsApi.Users.Me();

                //find a brief to load
                Brief parentBrief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault();

                //load the brief
                BriefBean loadedBrief = _bundledocsApi.Bundles.Get(parentBrief.PartitionKey, parentBrief.RowKey);

                //load the brief documents
                BriefDocument documentToDownload = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey).Where(k => k.Type == "HEADER").FirstOrDefault().Children.Where(k => k.Type == "DOCUMENT").FirstOrDefault();

                //Act
                //download the document
                Stream myStream = _bundledocsApi.Documents.Download(documentToDownload.PartitionKey, documentToDownload.RowKey);

                //write the downloaded bundle to disk
                byte[] myFile      = myStream.ReadToEnd();
                string newFilePath = $@"{App.Default.TempFolder}{Guid.NewGuid().ToString("n")}.pdf";

                File.WriteAllBytes(newFilePath, myFile);

                //Assert
                Assert.IsTrue(File.Exists(newFilePath));

                //open the downloaded bundle
                Process.Start(newFilePath);
            }
            public void Create_Test()
            {
                //Arrange
                bool expected = true;
                bool actual   = false;

                //load the user
                UserBean user = _bundledocsApi.Users.Me();

                //find a brief to load
                Brief briefToLoad = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault();

                //load the brief
                BriefBean loadedBrief = _bundledocsApi.Bundles.Get(briefToLoad.PartitionKey, briefToLoad.RowKey);

                //load the brief documents
                IList <BriefDocument> briefDocuments = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey);

                //find a section to upload a document into
                BriefDocument uploadLocation = briefDocuments.Where(k => k.Type == "HEADER").FirstOrDefault();

                //Act
                bool isSuccess = _bundledocsApi.Documents.Create(uploadLocation, App.Default.UploadFileLocation);

                //listen to the events back from the server to verify the document is uploaded and processed successfully
                actual = _bundledocsApi.Events.WaitForUploadToComplete(uploadLocation.ForeignKey);

                //Assert
                Assert.AreEqual(expected, actual);
            }
Esempio n. 11
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            string name = textEditName.Text;
            string pwd  = textEditPassword.Text;

            UserBean u = new UserBean();

            u.Name            = name;
            Program.loginUser = u;

            if (name == "admin")
            {
                DialogResult = DialogResult.OK;
                u.Role.Id    = 1;
            }
            else if (name == "xs")
            {
                u.Role.Id    = 2;
                DialogResult = DialogResult.OK;
            }
            else
            {
                return;
            }
        }
Esempio n. 12
0
        private void Save_Edit(object sender, RoutedEventArgs e)
        {
            ComboBoxItem status = (ComboBoxItem)this.status.SelectedItem;
            UserBean     bean   = new UserBean();
            QueryUser    query  = new QueryUser();

            query.Account  = UserManagerBean.AddUser.queryAccount.Text;
            query.UserName = UserManagerBean.AddUser.queryName.Text;
            bean.Id        = int.Parse(this.userId.Content.ToString());
            bean.UserName  = this.userName.Text;
            bean.Phone     = this.userPhone.Text;
            bean.Status    = int.Parse(status.Tag.ToString());
            bean.Type      = this.userType.SelectedIndex;
            Users user  = new Users();
            int   state = user.saveUserEdit(bean);

            if (state == BaseRequest.SUCCESS)
            {
                JXMessageBox.Show(Window.GetWindow(this), "编辑用信息保存成功!", MsgImage.Success);
                this.Close();
                UserManagerBean.AddUser.page.ShowPages(UserManagerBean.AddUser.userData, user.getUsersList(query), BaseRequest.PAGE_SIZE);
            }
            else if (state == BaseRequest.SYSTEM_EXCEPTION)
            {
                JXMessageBox.Show(Window.GetWindow(this), "系统异常,请联系管理员!", MsgImage.Error);
            }
            else
            {
                JXMessageBox.Show(Window.GetWindow(this), "未知错误", MsgImage.Error);
            }
        }
Esempio n. 13
0
        protected override void OnOpen(object arg)
        {
            base.OnOpen(arg);
            UserBean ub = AppConfig.Value.mainUserData;

            inputName.text = ub.name;
            inputId.text   = ub.id.ToString();
        }
Esempio n. 14
0
        void f2_accept(object sender, EventArgs e)
        {
            //事件的接收者通过一个简单的类型转换得到Form2的引用
            Form2 f2 = (Form2)sender;

            //接收到Form2的textBox1.Text
            this.u = f2.uu;
        }
            public void Me_Test()
            {
                //Arrange
                //Act
                UserBean user = _bundledocsApi.Users.Me();

                //Assert
                Assert.IsNotNull(user);
            }
Esempio n. 16
0
        private void Submit_AddUser(object sender, RoutedEventArgs e)
        {
            if (ValidateUtil.CheckFolderName(this.account.Text) == false)
            {
                JXMessageBox.Show(Window.GetWindow(this), "请填写帐号!", MsgImage.Error);
                return;
            }
            if (ValidateUtil.CheckFolderName(this.userName.Text) == false)
            {
                JXMessageBox.Show(Window.GetWindow(this), "请填写用户姓名!", MsgImage.Error);
                return;
            }
            if (ValidateUtil.CheckPasswordStrength(this.password.Password) == false)
            {
                JXMessageBox.Show(Window.GetWindow(this), "请输入6位以上的密码长度!", MsgImage.Error);
                return;
            }

            if (!this.password.Password.Equals(this.password2.Password))
            {
                JXMessageBox.Show(Window.GetWindow(this), "输入密码不一致,请重新输入!", MsgImage.Error);
                return;
            }
            Users     u     = new Users();
            UserBean  bean  = new UserBean();
            QueryUser query = new QueryUser();

            query.Account   = UserManagerBean.AddUser.queryAccount.Text;
            query.UserName  = UserManagerBean.AddUser.queryName.Text;
            bean.Account    = this.account.Text;
            bean.UserName   = this.userName.Text;
            bean.Password   = this.password.Password;
            bean.Status     = 0;
            bean.CreateId   = Session.UserId;
            bean.CreateTime = Convert.ToDateTime(DateTime.Now);
            bean.Phone      = this.phone.Text;
            ComboBoxItem type = (ComboBoxItem)this.userType.SelectedItem;

            bean.Type = int.Parse(type.Tag.ToString());
            int    state = u.registUser(bean);
            Window targe = Window.GetWindow(this);

            if (state == BaseRequest.HAS)
            {
                JXMessageBox.Show(Window.GetWindow(this), "该账号已被使用!", MsgImage.Error);
            }
            else if (state == BaseRequest.SUCCESS)
            {
                JXMessageBox.Show(Window.GetWindow(this), "新增用户成功!", MsgImage.Error);
                UserManagerBean.AddUser.page.ShowPages(UserManagerBean.AddUser.userData, u.getUsersList(query), BaseRequest.PAGE_SIZE);
                this.Close();
            }
            else
            {
                JXMessageBox.Show(Window.GetWindow(this), "系统异常,请联系管理员!", MsgImage.Error);
            }
        }
Esempio n. 17
0
        private void SaveUser(UserBean loginUser)
        {
            var userList = LoadUserList().Where(user => user.id != loginUser.id).ToList();

            userList.Insert(0, loginUser);

            string json = JsonConvert.SerializeObject(userList);

            FileHelper.WriteStringToFile(USERFILE, json);
        }
Esempio n. 18
0
 public ActionResult ChangePassword([FromBody] UserBean userbean)
 {
     return(new ActionResult(() =>
     {
         string username = HttpContext.Current.Session[Contents.LOGIN_KEY].ToString();
         userbean.UserName = username;
         _userService.ChangePassword(userbean);
         return null;
     }));
 }
Esempio n. 19
0
        private void InitializeApi(string accessToken)
        {
            BundledocsApi bundledocsApi = BundledocsApi.New(accessToken);
            UserBean      user          = bundledocsApi.Users.Me();

            this.Invoke((Action) delegate
            {
                txtApiMe.Text = JsonConvert.SerializeObject(new { PartitionKey = user.PartitionKey, RowKey = user.RowKey, Email = user.Email }, Formatting.Indented);
            });
        }
Esempio n. 20
0
        private static WorkBean insertUserToMap(UserBean bean)
        {
            WorkBean workBean = new WorkBean();

            workBean.UserIp = bean.Ip;
            workBean.UserId = bean.Num;
            workBean.Name   = bean.Name;
            workBean.Card   = bean.Card;

            return(workBean);
        }
Esempio n. 21
0
 public IHttpActionResult Post([FromBody] UserBean user, [FromUri] string apiKey)
 {
     try
     {
         return(Ok(userService.AddUser(user.email, user.password, user.auth_name, apiKey)));
     }
     catch (ValidationException exception)
     {
         return(Content(HttpStatusCode.BadRequest, exception.Message));
     }
 }
Esempio n. 22
0
        /// <summary>
        /// 用户登录接口--转换
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static UserBean convertUser(UserEntity entity)
        {
            UserBean bean = new UserBean();

            if (entity != null)
            {
                bean.UserID   = entity.UserID;
                bean.UserName = entity.UserName;
                bean.NickName = entity.NickName;
            }
            return(bean);
        }
Esempio n. 23
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (username.Text != "" && passwd.Text != "")
     {
         uu = new UserBean(username.Text, passwd.Text);
         if (accept != null)
         {
             accept(this, EventArgs.Empty); //当窗体触发事件,传递自身引用
         }
         this.Close();
     }
 }
Esempio n. 24
0
        public bool save(string context, UserBean u)
        {
            filehelper f    = new filehelper();
            code       c    = new code(u.Password, DateTime.Now.ToString("yyyyMMdd"));
            string     name = f.writefile(c.encodefile(context), u);

            Console.WriteLine(name);
            if (f.filesize(name) != 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 25
0
        private void OnLoginSuccess(UserBean ub)
        {
            UserManager.Instance.UpdateMainUserData(ub);

            AppConfig.Value.mainUserData = UserManager.Instance.MainUserData;
            AppConfig.Save();

            //broadcast login event
            GlobalEvent.onLogin.Invoke(true);

            //enter the main page of app
            UIManager.Instance.EnterMainPage();
        }
Esempio n. 26
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        public void Login(uint id, string name, string pwd)
        {
            //simply the logic coz we dont implement the server side
            //pretend that we have received success response from server
            UserBean ub = new UserBean();

            ub.id             = id;
            ub.name           = name;
            ub.defaultSnakeId = 1;

            //operations after getting successful response from server
            OnLoginSuccess(ub);
        }
Esempio n. 27
0
        private void clientAccept(Object socketServer)
        {
            Socket client = socketServer as Socket;

            while (true)
            {
                //获取客户端的IP和端口号
                IPAddress clientIP   = (client.RemoteEndPoint as IPEndPoint).Address;
                int       clientPort = (client.RemoteEndPoint as IPEndPoint).Port;
                LogUtil.instance.Log("读卡器客户端连入  " + clientIP + " : " + clientPort);//CJC应提示或列出报警器是否可用正常
                //---------------------------------------
                byte[] clientData = new byte[1024];
                //try
                //{
                int revLen = client.Receive(clientData);
                //对数据进行判断
                if (revLen == 8)//先8字节判断  && clientData[revLen-1] == 13
                {
                    byte[] data = new byte[revLen];
                    Array.Copy(clientData, data, revLen);//转存另一个数组
                    //在这里把数据整理
                    DZCBean bean = new DZCBean();
                    bean.Ip     = clientIP.ToString();
                    bean.Weight = DataUtil.byteWeightDataToDouble(data);      //重量数据
                    bean.Data   = DataUtil.byteWeightDataToStringSplit(data); //byte[]转string,用逗号分隔

                    LogUtil.instance.Log("读卡器 " + clientIP + " 当前重量: " + bean.Weight);
                    //--------------------------------------

                    UserBean user = new UserBean();

                    control.receiveData(null, user);//回传数据
                }
                else
                {
                    LogUtil.instance.Log("数据不是读卡器重量数据,不发送");
                }

                string recMessage = Encoding.ASCII.GetString(clientData, 0, revLen);
                for (int i = 0; i < revLen; i++)
                {
                    Console.Write(clientData[i] + " ");
                }
                Console.WriteLine("读卡器收到信息:" + recMessage);
                //}
                //catch (SocketException e)
                //{
                //     LogUtil.Log("读卡器远程主机强迫关闭了一个现有的连接");
                // }
            }
        }
Esempio n. 28
0
        public ActionResult PostLogin([FromBody] UserBean userbean)
        {
            return(new ActionResult(() =>
            {
                UserBean user = _userService.Login(userbean);
                if (user == null)
                {
                    throw new Exception("Login failed check user name and password");
                }

                var session = HttpContext.Current.Session;
                session[Contents.LOGIN_KEY] = user.UserName;

                return user;
            }));
        }
Esempio n. 29
0
 public bool checkuser(UserBean u)
 {
     if (!u.isempty())
     {
         return(false);
     }
     if (DBhelper.queryuserinfo(u))
     {
         MessageBox.Show("检查通过!");
         return(true);
     }
     else
     {
         MessageBox.Show("检查有问题!");
         return(false);
     }
 }
Esempio n. 30
0
        //--------------------------------------------------

        /// <summary>
        /// Start Game
        /// </summary>
        /// <param name="param"></param>
        public void Start(PVPStartParam param)
        {
            MyLogger.Log(LOG_TAG, "StartGame() param:{0}", param.ToString());


            UserBean mainUserData = UserManager.Instance.MainUserData;

            playerDataList = param.players;
            for (int i = 0; i < playerDataList.Count; i++)
            {
                if (playerDataList[i].userId == mainUserData.id)
                {
                    mainPlayerId             = playerDataList[i].id;
                    GameCamera.FocusPlayerId = mainPlayerId;
                }

                //register player data, this can provide player data for FSP
                //coz FSP is too easy to have player data
                GameManager.Instance.RegPlayerData(playerDataList[i]);
            }

            //start game
            GameManager.Instance.CreateGame(param.gameParam);
            GameManager.Instance.onPlayerDie += OnPlayerDie;//player died
            m_context = GameManager.Instance.Context;

            //start FSP
            mgrFSP = new FSPManager();
            mgrFSP.Start(param.fspParam, mainPlayerId);
            mgrFSP.SetFrameListener(OnEnterFrame);
            mgrFSP.onGameBegin += OnGameBegin; //game start
            mgrFSP.onGameExit  += OnGameExit;  //player exit
            mgrFSP.onRoundEnd  += OnRoundEnd;  //player exit
            mgrFSP.onGameEnd   += OnGameEnd;   //game over


            //initial game input
            GameInput.Create();
            GameInput.OnVkey += OnVKey;

            //listen on EnterFrame
            MonoHelper.AddFixedUpdateListener(FixedUpdate);

            GameBegin();
        }