コード例 #1
0
        private void UpdateLoginTime(object user)
        {
            if (user == null)
            {
                return;
            }
            if (!(user is UserInfo))
            {
                return;
            }

            string   strError = string.Empty;
            UserInfo _user    = user as UserInfo;

            Login_Func.UpdateLoginTime(ref _user, ref strError);
        }
コード例 #2
0
ファイル: FrmChangePwd.cs プロジェクト: saiganmei/xcxl
        private bool SaveData()
        {
            bsMain.EndEdit();

            if (_user.Password != _back.Password)
            {
                _user.Password   = Basic_Func.JiaMi(_user.Password);
                _user.RePassword = Basic_Func.JiaMi(_user.RePassword);
            }
            else
            {
                Common.Common_Func.ErrorMessage("密码未做任何修改!", "保存失败");
                return(false);
            }

            if (!CheckInput())
            {
                return(false);
            }

            string strErr = string.Empty;

            if (Login_Func.ChangeUserPassword(_user, ref strErr))
            {
                if (_user.ID == Common.Common_Var.CurrentUser.ID)
                {
                    Common.Common_Func.ErrorMessage("密码修改成功,请重新登陆!", "保存成功");
                    Application.Exit();
                }
                else
                {
                    Common.Common_Func.ErrorMessage("数据保存成功!", "保存成功");
                    InitForm();
                }
                return(true);
            }
            else
            {
                Common.Common_Func.ErrorMessage(strErr, "保存失败");
                return(false);
            }
        }
コード例 #3
0
        private void UserLogin()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (!CheckInput())
                {
                    return;
                }

                string MacAddress = IPHelper.GetMacByWMI();

                string   strError = string.Empty;
                UserInfo user     = new UserInfo();
                user.UserNo   = txtAccount.Text.Trim();
                user.Password = Basic.Basic_Func.JiaMi(txtPassword.Text.Trim());
                //UFSoft.U8.Framework.Login.UI.clsLogin netLogin = new UFSoft.U8.Framework.Login.UI.clsLogin();
                //user.Password = txtPassword.Text.Trim();// netLogin.EnPassWord(txtPassword.Text.Trim());

                user.LoginIP     = string.Format("PC:{0}", MacAddress);
                user.LoginDevice = IPHelper.GetUserName();

                //string strUserJson;
                //user.Password = (txtPassword.Text.Trim());
                //strUserJson = Login_Func.ObjectToJson<UserInfo>(user);
                //strUserJson = Login_Func.UserLoginForAndroid(strUserJson);

                ////string strUpdTime = Login_Func.UpdateLoginTimeForAndroid(strUserJson);
                ////string strClrTime = Login_Func.ClearLoginTimeForAndroid(strUserJson);
                ////string strChangePwd = Login_Func.ChangeUserPasswordForAndroid(strUserJson);

                ////string strTaskJson = Login_Func.GetTaskInfo(strUserJson, "");
                //return;

                if (Login_Func.UserLogin(ref user, ref strError))
                {
                    Common.Common_Var.CurrentUser = user;
                    if (user.Password == Basic.Basic_Func.JiaMi(Common_Var.DefaultPwd))
                    {
                        MessageBox.Show(string.Format("您当前使用默认密码【{0}】登陆,请先修改密码!", Common_Var.DefaultPwd), "登陆提示");
                        FrmChangePwd frm = new FrmChangePwd();
                        DialogResult dr  = frm.ShowDialog();
                        Application.Exit();
                    }
                }
                else
                {
                    MessageBox.Show(strError, "登陆提示");
                    if (strError.IndexOf("用户") >= 0)
                    {
                        Focus_txtAccount();
                    }
                    else
                    {
                        Focus_txtPassword();
                    }
                    return;
                }


                this.Opacity = 0;
                this.Hide();
                Application.DoEvents();

                Login_Var.lstMenu = user.lstMenu;
                //五分钟后每十分钟更新一次登录时间
                Login_Var.tLoginTime = new System.Threading.Timer(new System.Threading.TimerCallback(UpdateLoginTime), Common.Common_Var.CurrentUser, 300000, 600000);

                FrmMainTab frmMain = new FrmMainTab();
                frmMain.Show();
            }
            catch (Exception ex)
            {
                Common.Common_Func.ErrorMessage(ex.Message, "程序异常");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #4
0
        private void UpdateApplication()
        {
            try
            {
                AppVersionInfo appVersion = new AppVersionInfo();

                Cursor               = Cursors.WaitCursor;
                txtAccount.Enabled   = false;
                txtPassword.Enabled  = false;
                btnLogin.Enabled     = false;
                this.lblMessage.Text = "正在验证版本......";
                this.lblMessage.Refresh();
                Application.DoEvents();

                appVersion.LocalVersion = Common_Var.AppVersion;
                if (string.IsNullOrEmpty(appVersion.LocalVersion))
                {
                    this.lblMessage.Text = "版本获取错误";
                    this.lblMessage.Refresh();
                    MessageBox.Show(lblMessage.Text, "提示");
                    return;
                }

                appVersion.AppName = Login_Func.GetValue("AppName");
                if (string.IsNullOrEmpty(appVersion.AppName))
                {
                    this.lblMessage.Text = "程序文件名读取失败,请检查Config.xml文件配置";
                    this.lblMessage.Refresh();
                    MessageBox.Show(lblMessage.Text, "提示");
                    return;
                }
                appVersion.FileName = appVersion.AppName;

                AssemblyName an = Assembly.GetExecutingAssembly().GetName();
                appVersion.UpdateAppPath = Path.GetDirectoryName(an.CodeBase.Replace("file:///", "")).ToString() + "\\" + appUpdate;
                if (!File.Exists(appVersion.UpdateAppPath))
                {
                    this.lblMessage.Text = "更新程序不存在,程序将无法自动更新";
                    this.lblMessage.Refresh();
                    MessageBox.Show(lblMessage.Text, "提示");
                    return;
                }

                string filePath = Login_Func.GetValue("UpdateUrl").Trim('/');
                if (string.IsNullOrEmpty(filePath))
                {
                    this.lblMessage.Text = "更新地址读取失败,请检查Config.xml文件配置";
                    this.lblMessage.Refresh();
                    MessageBox.Show(lblMessage.Text, "提示");
                    return;
                }

                int index = filePath.LastIndexOf('/');
                if (index < 0)
                {
                    this.lblMessage.Text = "服务器更新路径格式错误,请检查Config.xml文件配置";
                    this.lblMessage.Refresh();
                    MessageBox.Show(lblMessage.Text, "提示");
                    return;
                }

                appVersion.UpdateUrl = filePath.Substring(index + 1, filePath.Length - index - 1);
                if (string.IsNullOrEmpty(appVersion.UpdateUrl))
                {
                    this.lblMessage.Text = "服务器更新目录获取失败,请检查Config.xml文件配置";
                    this.lblMessage.Refresh();
                    MessageBox.Show(lblMessage.Text, "提示");
                    return;
                }

                string strError = string.Empty;
                if (Login_Func.VerifyAppVersion(ref appVersion, ref strError))
                {
                    if (string.IsNullOrEmpty(appVersion.VersionDesc))
                    {
                        MessageBox.Show(string.Format("程序发现新的版本【{0}】,请确定后更新!", appVersion.AppVersion), "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        System.Diagnostics.Process.Start(appVersion.UpdateAppPath, null);
                    }
                    else
                    {
                        if (MessageBox.Show(string.Format("程序发现新的版本【{0}】,是否查看版本说明?", appVersion.AppVersion), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            using (FrmVersionInfo frm = new FrmVersionInfo(appVersion))
                            {
                                frm.ShowDialog();
                            }
                        }
                        else
                        {
                            System.Diagnostics.Process.Start(appVersion.UpdateAppPath, null);
                        }
                    }

                    Application.Exit();

                    System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess();
                    proc.Kill();
                    return;
                }
                else
                {
                    if (!string.IsNullOrEmpty(strError))
                    {
                        this.lblMessage.Text = strError;
                        this.lblMessage.Refresh();
                        MessageBox.Show(lblMessage.Text, "提示");
                    }
                }

                Application.DoEvents();
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
                this.lblMessage.Refresh();
                //MessageBox.Show(lblMessage.Text, "错误");
                return;
            }
            finally
            {
                Cursor               = Cursors.Default;
                txtAccount.Enabled   = true;
                txtPassword.Enabled  = true;
                btnLogin.Enabled     = true;
                this.lblMessage.Text = "";
                txtAccount.Focus();
                txtPassword.SelectAll();
                Application.DoEvents();
            }
        }