Example #1
0
        public Dictionary<int, UserInfo> GetAllUserInfo(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            Dictionary<int, UserInfo> list = new Dictionary<int, UserInfo>();
            try
            {

                DataSet ds = UserDataAccess.GetAllUserInfo(db);

                UserInfo userInfo;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    userInfo = new UserInfo(ds.Tables[0].Rows[i]);
                    list.Add(userInfo.UserId, userInfo);
                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
Example #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string errMessage = "";
            if (!dxValidationProvider1.Validate())
            {
                return;
            }
            var ui = new UserInfo
                         {
                             UserName = textEditUserName.Text,
                             Password = textEditPassword.Text,
                             CreateDateTime = DateTime.Now,
                             UserTypeName = comboBoxEditUserType.Text,
                             UserTypeId = comboBoxEditUserType.Text == "管理员" ? 1 : 2
                         };
            switch (userMode)
            {
                case UserMode.Add:
                    UserBusiness.Instance.Insert(ref errMessage, ui);
                    ui = UserBusiness.Instance.GetUserInfo(ref errMessage, ui.UserName);
                    OperateLog ol = new OperateLog
                                        {
                                            HappenTime = DateTime.Now,
                                            OperateTypeId = (int)(OperateLogTypeId.UserAdd),
                                            OperateTypeName = OperateLogTypeName.UserAdd,
                                            Content = ui.ToString(),
                                            OperateUserName = MainForm.CurrentUser.UserName,
                                            ClientUserName = MainForm.CurrentUser.UserName,
                                            ClientUserId = MainForm.CurrentUser.UserId
                                        };
                    OperateLogBusiness.Instance.Insert(ref errMessage, ol);
                    break;

                case UserMode.UPDATE:
                    UserBusiness.Instance.UpdatePassword(ref errMessage, userInfo.UserId, textEditPassword.Text);
                    OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog
                                       {
                                           HappenTime = DateTime.Now,
                                           OperateTypeId = (int)(OperateLogTypeId.UserUpdate),
                                           OperateTypeName = OperateLogTypeName.SynGroupUpdate,
                                           Content = ui.ToString(),
                                           OperateUserName = MainForm.CurrentUser.UserName,
                                           ClientUserName = MainForm.CurrentUser.UserName,
                                           ClientUserId = MainForm.CurrentUser.UserId
                                       });

                    break;
                default:
                    break;

            }
            Close();
            Dispose();
        }
Example #3
0
 public FrmUser(UserInfo ui)
 {
     userInfo = ui;
     userMode = UserMode.UPDATE;
     InitializeComponent();
     this.Text = "重置密码";
     textEditUserName.Text = ui.UserName;
     comboBoxEditUserType.Visible = false;
     labelControl4.Visible = false;
     textEditUserName.Enabled = false;
     InitValidationRules();
 }
Example #4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            InputUsername = txtUserID.Text;
            InputPassword = txtPassword.Text;
            string errMessage = "";
            isLoginOK = UserBusiness.Instance.IsUserValid(ref errMessage, InputUsername, InputPassword);
            if (isLoginOK)
            {
                //登录成功日志
                currentUser = UserBusiness.Instance.GetUserInfo(ref errMessage, InputUsername);
                SystemLogBusiness.Instance.Insert(ref errMessage,new SystemLog
                                                                     {
                                                                         HappenTime =DateTime.Now,
                                                                         SystemTypeId = 1,
                                                                         SystemTypeName ="用户登录成功",
                                                                         Content = "用户登录成功",
                                                                         SyeUserName = currentUser.UserName,
                                                                         ClientUserId=currentUser.UserId,
                                                                         ClientUserName = currentUser.UserName

                                                                     });
            }
            else
            {
               //登录失败日志
                currentUser = UserBusiness.Instance.GetUserInfo(ref errMessage, InputUsername);
                int userid = currentUser == null ? -1 : currentUser.UserId;
                SystemLogBusiness.Instance.Insert(ref errMessage, new SystemLog
                {
                    HappenTime = DateTime.Now,
                    SystemTypeId = 2,
                    SystemTypeName = "用户登录失败",
                    Content = "用户登录失败",
                    SyeUserName = InputUsername,
                    ClientUserId = userid,
                    ClientUserName = InputUsername

                });

            }
        }
Example #5
0
        public int Insert(ref string errMessage, UserInfo userInfo)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return UserDataAccess.Insert(db, userInfo);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
Example #6
0
 private bool Login(string iu, string ip, string pi)
 {
     FormLogin lf = new FormLogin(iu, ip, pi);
     if (lf.ShowDialog(this) == DialogResult.OK)
     {
         _inputUsername = lf.InputUsername;
         _inputPassword = lf.InputPassword;
         if (lf.isLoginOK == true)
         {
             CurrentUser = lf.currentUser;
             return true;
         }
         return false;
     }
     System.Diagnostics.Process.GetCurrentProcess().Kill();
     return false;
 }
Example #7
0
        public MainForm()
        {
            #if !DEBUG
            while (Login(_inputUsername, _inputPassword, PromoteInfo) != true)
            {
                PromoteInfo = "��������ȷ���û���������!";
            }
            #else
            CurrentUser = new UserInfo { UserId = 1, UserName = "******", UserTypeId = 1, UserTypeName = "����Ա" };
            #endif
            Splash.Splash.Show();
            this.Visible = false;
            Splash.Splash.Status = "���.Net Remoting...";
            BeginRemotingService();
            Splash.Splash.Status = "�����ý�����...";
            BeginStreamMediaService();

            InitializeComponent();

            _getTransPacket = new GetTransPacket();
            _getTransPacket.LiveDecoderPacketHandle.DataChange += LiveDecoderPacketHandleDataChange;

            //start tcp server
            var thread = new Thread(StartServerForDecoder) { IsBackground = true };
            thread.Start();

            var threadForRecognizer = new Thread(StartServerForRecognizer) { IsBackground = true };
            threadForRecognizer.Start();
        }
        public static int Insert(Database db, UserInfo userInfo)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  [UserInfo](");
            sbValue.Append("values (");
            sbField.Append("[username]");
            sbValue.AppendFormat("'{0}'", userInfo.UserName);
            sbField.Append(",[password]");
            sbValue.AppendFormat(",'{0}'", userInfo.Password);
            sbField.Append(",[createdatetime]");
            sbValue.AppendFormat(",'{0}'", userInfo.CreateDateTime);
            sbField.Append(",[usertypeid]");
            sbValue.AppendFormat(",{0}", userInfo.UserTypeId);
            sbField.Append(",[usertypename])");
            sbValue.AppendFormat(",'{0}')", userInfo.UserTypeName);

            string cmdText = sbField.ToString() + " " + sbValue.ToString();

            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }