コード例 #1
0
    public static string ChangePwd(UserObject user, string oldpwd, string newpwd)
    {
        if (user.Password != SecurityFactory.GetSecurity().Encrypt(oldpwd))
        {
            return("旧密码输入错误!");
        }
        bool result = DataAccessFactory.GetDataAccess().ExecuteSql("update table_users set c_pwd='" + SecurityFactory.GetSecurity().Encrypt(newpwd) + "' where id=" + user.Id);

        if (result)
        {
            BusLog log = new BusLog();
            log.BusType = "修改密码";
            log.Content = user.FullName + "修改自己的密码";
            BusLogOperator.InitByLoginUser(log);
            //log.Operator=
            return(string.Empty);
        }
        else
        {
            return("修改密码失败!");
        }
    }
コード例 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     this.textBox2.Text = SecurityFactory.GetSecurity().Decrypt(this.textBox1.Text);
 }
コード例 #3
0
        // Process the client connection.
        public void ReceiveEnd(IAsyncResult ar)
        {
            this.Log("客户端开始接收服务器消息");
            Socket socket = (Socket)ar.AsyncState;

            try
            {
                int real = socket.EndReceive(ar);
                if (real == 0)
                {
                    //this.Log("客户端接收到消息长度为0,开始关闭连接!");
                    //this.Stop();
                }
                else
                {
                    this.Log("客户端接收到消息的长度为:" + real);
                    string      xml  = System.Text.Encoding.UTF8.GetString(this.buffers, 0, real);
                    MessageInfo info = (MessageInfo)SerializeHelper.DeserializeFromXml(typeof(MessageInfo),
                                                                                       SecurityFactory.GetSecurity().Decrypt(xml));
                    //msgHandle.BeginInvoke(Info, null, null);
                    if (info.Type == MessageType.String && info.Data == TcpComand.Bye)
                    {
                        this.Stop();
                    }
                    else
                    {
                        IntPtr formhandle = FT.Commons.Win32.SystemDefine.GetForegroundWindow();
                        Parent.Invoke(MsgHandle, new object[] { info });
                        socket.BeginReceive(this.buffers, 0, bufferSize, SocketFlags.None, new AsyncCallback(ReceiveEnd), socket);
                    }
                }
            }
            catch (Exception ex)
            {
                this.Log("客户端接收异常->" + ex.Message);
                this.IsStarted = false;
                log.Info(ex);
            }
        }
コード例 #4
0
        // Process the client connection.
        public void ReceiveEnd(IAsyncResult ar)
        {
            this.Log("服务器开始接收客户端消息");
            Socket socket = (Socket)ar.AsyncState;

            try
            {
                int real = socket.EndReceive(ar);
                if (real == 0)
                {
                    this.Log("服务器接收到消息长度为0,开始关闭连接!");
                    this.CloseClient((Customer)this.clients[(int)socket.Handle]);
                    this.Log("服务器现有的客户端个数:" + this.clients.Count);
                }
                else
                {
                    this.Log("服务器接收到消息的长度为:" + real);
                    string      xml  = System.Text.Encoding.UTF8.GetString(this.buffers, 0, real);
                    MessageInfo info = (MessageInfo)SerializeHelper.DeserializeFromXml(typeof(MessageInfo), SecurityFactory.GetSecurity().Decrypt(xml));
                    //msgHandle.BeginInvoke(Info, null, null);
                    if (info.Type == MessageType.String && info.Data == TcpComand.Login)
                    {
                        Customer customer = this.CopyFromMessageInfo(info);
                        customer.Client = socket;
                        this.Log("服务器开始添加客户端" + (int)socket.Handle);
                        this.clients.Add((int)socket.Handle, customer);
                        this.ClientConnWrapper(customer);
                        this.Log("服务器现有的客户端个数:" + this.clients.Count);
                        socket.BeginReceive(this.buffers, 0, bufferSize, SocketFlags.None, new AsyncCallback(ReceiveEnd), socket);
                    }
                    else if (info.Type == MessageType.String && info.Data == TcpComand.Bye)
                    {
                        this.Log("服务器开始移除客户端" + (int)socket.Handle);
                        Customer customer = this.clients[(int)socket.Handle] as Customer;
                        this.CloseClient(customer);
                        this.Log("服务器现有的客户端个数:" + this.clients.Count);
                    }
                    else
                    {
                        Parent.Invoke(MsgHandle, new object[] { info });
                        socket.BeginReceive(this.buffers, 0, bufferSize, SocketFlags.None, new AsyncCallback(ReceiveEnd), socket);
                    }
                }
            }
            catch (SocketException ex)
            {
                //客户端退出
                if (10054 == ex.ErrorCode)
                {
                    this.Log("服务器有客户端断开连接,现有的客户端个数:" + this.clients.Count);
                    this.CloseClient((Customer)this.clients[(int)socket.Handle]);
                }
            }
            catch (ObjectDisposedException ex)
            {
                //log.Info(ex);
            }
        }
コード例 #5
0
ファイル: RegisterHelper.cs プロジェクト: marcellus/fivemen
        /// <summary>
        /// 判断是否有效注册码
        /// </summary>
        /// <param name="keycode">注册码</param>
        /// <returns>如果有效返回true</returns>
        public static bool ValidateKeyCode(string keycode)
        {
            string need = md5.Encrypt(SecurityFactory.GetSecurity().Encrypt(HardwareManager.GetMachineCode()));

            return(need == keycode);
        }
コード例 #6
0
 public MockUser()
 {
     this.Pwd = SecurityFactory.GetSecurity().Encrypt("123456");
 }
コード例 #7
0
ファイル: UserInfoOperator.cs プロジェクト: radtek/fivemen
        public static bool ResetPwd(int id, string newpwd)
        {
            bool result = DataAccessFactory.GetDataAccess().ExecuteSql("update table_user_info set c_pwd='" + SecurityFactory.GetSecurity().Encrypt(newpwd) + "' where id=" + id);

            if (result)
            {
                LogInfoOperator.LogSystem("密码复位", "复位ID为" + id + "的密码");

                //log.Operator=
            }
            return(result);
        }
コード例 #8
0
ファイル: UserInfoOperator.cs プロジェクト: radtek/fivemen
        public static string ChangePwd(UserInfo user, string oldpwd, string newpwd)
        {
            if (user.Password != SecurityFactory.GetSecurity().Encrypt(oldpwd))
            {
                return("旧密码输入错误!");
            }
            bool result = DataAccessFactory.GetDataAccess().ExecuteSql("update table_user_info set c_pwd='" + SecurityFactory.GetSecurity().Encrypt(newpwd) + "' where id=" + user.Id);

            if (result)
            {
                LogInfoOperator.LogSystem("修改密码", user.FullName + "修改自己的密码");
                return(string.Empty);
            }
            else
            {
                return("修改密码失败!");
            }
        }