示例#1
0
        private void OnDownloadUpdatedFired(object sender, DownloadItem e)
        {
            //DownloadHandler downloadHandler = (DownloadHandler)sender;
            IBrowser browser = (IBrowser)sender;

            //this.UpdateDownloadAction("OnDownloadUpdated", e);

            //
            //TODO: 显示下载进度...
            //

            if (e.IsCancelled || e.IsComplete)
            {
                if (e.IsComplete)
                {
                    string[] fileNames = e.FullPath.Split('\\');
                    string   fileName  = fileNames.Length > 0 ? fileNames[fileNames.Length - 1] : "";
                    string   message   = string.Format(ResourceCulture.GetString("Cefsharp_DownloadComplete"), fileName);
                    MessageBox.Show(message, ResourceCulture.GetString("GeneralTitle_Prompt"));
                }
                if (browser.IsPopup)
                {
                    browser.CloseBrowser(true);
                }
            }
        }
 private void pbBtnClose_Click(object sender, EventArgs e)
 {
     try
     {
         //DialogResult result = MessageBox.Show("请问您确定退出“立信安全客户端”程序吗?", "退出系统", MessageBoxButtons.OKCancel);
         DialogResult result = MessageBox.Show(ResourceCulture.GetString("GeneralMsg_ExitApp"), ResourceCulture.GetString("GeneralTitle_ExitApp"), MessageBoxButtons.OKCancel);
         if (result == DialogResult.OK)//如果点击“确定”按钮
         {
             //Cef.RunMessageLoop();
             Cef.Shutdown();
             Program.Run.Close();
             this.Hide();
             Thread.Sleep(2000);
             //Application.Exit();
             Environment.Exit(0);
         }
         else//如果点击“取消”按钮
         {
             //DoNothing
         }
     }
     catch (Exception ex)
     {
         string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
         if (Program.ReleaseType == "DEBUG")
         {
             exMessage = ex.Message + ex.StackTrace;
         }
         MessageBox.Show(exMessage, ResourceCulture.GetString("LoginMsg_Title"));
     }
 }
 /// <summary>
 /// 关闭窗体,退出应用程序
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnClose_Click(object sender, EventArgs e)
 {
     try
     {
         //DialogResult result = MessageBox.Show("请问您确定退出“立信安全客户端”程序吗?", "退出系统", MessageBoxButtons.OKCancel);
         DialogResult result = MessageBox.Show(ResourceCulture.GetString("GeneralMsg_ExitApp"), ResourceCulture.GetString("GeneralTitle_ExitApp"), MessageBoxButtons.OKCancel);
         if (result == DialogResult.OK)//如果点击“确定”按钮
         {
             ApplicationExit();
         }
         else//如果点击“取消”按钮
         {
             //DoNothing
         }
     }
     catch (Exception ex)
     {
         string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
         if (Program.ReleaseType == "DEBUG")
         {
             exMessage = ex.Message + ex.StackTrace;
         }
         MessageBox.Show(exMessage, ResourceCulture.GetString("GeneralTitle_Prompt"));
     }
 }
        public DomainAccount(string userName = "")
        {
            InitializeComponent();

            #region 国际化

            labelBindStep1.Text = ResourceCulture.GetString("BindStep1");
            btnNextStep.Text    = ResourceCulture.GetString("NextStep");

            #endregion

            txtUser.Text = !string.IsNullOrEmpty(userName) ? userName : "";
        }
        public ShowSLKeyCode(List <string> slCodeList)
        {
            InitializeComponent();

            labelKeyCode.Text = ResourceCulture.GetString("SLKeyCode");
            foreach (var slCode in slCodeList)
            {
                int iCode = slCodeList.IndexOf(slCode);
                if (iCode <= 4)
                {
                    TextBox txtSLCode = this.Controls.Find("txtSLCode" + iCode.ToString(), true)[0] as TextBox;
                    txtSLCode.Text = slCodeList[iCode];
                }
            }
        }
        private void btnNextStep_Click(object sender, EventArgs e)
        {
            string userName = txtUser.Text.Trim();
            string password = txtPassword.Text.Trim();

            if (string.IsNullOrWhiteSpace(userName))
            {
                //MessageBox.Show("请输入用户名。", "提示信息");
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyUser"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            else if (string.IsNullOrWhiteSpace(password))
            {
                //MessageBox.Show("请输入密码信息。", "提示信息");
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyPwd"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }

            try
            {
                //UserBLL userBll = new UserBLL();
                BDOSecurityPortalModel.UserProfile userProfile = new BDOSecurityPortalModel.UserProfile();
                string loginUserId  = string.Empty;
                string loginMessage = string.Empty;
                bool   loginResult  = EoopService.LoginVerify(userName, password, out loginUserId, out loginMessage);
                if (!loginResult)
                {
                    MessageBox.Show(loginMessage, ResourceCulture.GetString("LoginMsg_Title"));
                    return;
                }

                this.Hide();
                PersonalAssets bindStep2Form = new PersonalAssets(loginUserId, userName, password);
                bindStep2Form.ShowDialog();
                this.Close();
            }
            catch (Exception ex)
            {
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, ResourceCulture.GetString("LoginMsg_Title"));
            }
        }
        private void btnNext_Click(object sender, EventArgs e)
        {
            try
            {
                Property selectedProperty = null;
                foreach (Property property in PropertyList)
                {
                    if (property.ComboDisplay == cbxAsset.Text)
                    {
                        selectedProperty = property;
                        break;
                    }
                }

                if (selectedProperty == null)
                {
                    MessageBox.Show(ResourceCulture.GetString("BindMsg_EmptyAsset"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }

                if (selectedProperty.tinyintfield1 == "1")
                {
                    MessageBox.Show(ResourceCulture.GetString("BindMsg_AssetBound"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }

                this.Hide();

                AuthorizationNO bindStep3Form = new AuthorizationNO(UserID, UserName, Password, selectedProperty);
                bindStep3Form.ShowDialog();

                this.Close();
            }
            catch (Exception ex)
            {
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, ResourceCulture.GetString("GeneralTitle_Prompt"));
            }
        }
        /// <summary>
        /// MessageBox 按钮国际化
        /// </summary>
        private void MessageBoxInternationalization()
        {
            #region MessageBox 按钮国际化

            MessageBoxEx.UnRegister();

            //Set button text from resources
            MessageBoxEx.OK     = ResourceCulture.GetString("MsgBox_OK");       // LocalResource.OK;
            MessageBoxEx.Cancel = ResourceCulture.GetString("MsgBox_Cancel");   // LocalResource.Cancel;
            MessageBoxEx.Retry  = ResourceCulture.GetString("MsgBox_Retry");    // LocalResource.Retry;
            MessageBoxEx.Ignore = ResourceCulture.GetString("MsgBox_Ignore");   // LocalResource.Ignore;
            MessageBoxEx.Abort  = ResourceCulture.GetString("MsgBox_Abort");    // LocalResource.Abort;
            MessageBoxEx.Yes    = ResourceCulture.GetString("MsgBox_Yes");      // LocalResource.Yes;
            MessageBoxEx.No     = ResourceCulture.GetString("MsgBox_No");       // LocalResource.No;

            //Register manager
            MessageBoxEx.Register();

            #endregion
        }
        public AuthorizationNO(string userId, string userName, string password, Property bindAsset)
        {
            InitializeComponent();

            showMaskPanel.Visible = false;
            this.Refresh();

            #region 国际化

            labelBindStep3.Text = ResourceCulture.GetString("BindStep3");
            btnLastStep.Text    = ResourceCulture.GetString("LastStep");
            btnComplete.Text    = ResourceCulture.GetString("Complete");

            #endregion

            UserID    = userId;
            UserName  = userName;
            Password  = password;
            BindAsset = bindAsset;
        }
        /// <summary>
        /// 页面国际化
        /// </summary>
        private void Internationalization(string language)
        {
            //国际化
            this.Text = ResourceCulture.GetString("AppName");
            labelResetPassword.Text = ResourceCulture.GetString("ResetPwd_Title");
            labelUserName.Location  = language == "en-US" ? new Point(146, 64) : new Point(160, 64);

            labelUserName.Text     = ResourceCulture.GetString("ResetPwd_UserName");
            labelUserName.Location = language == "en-US" ? new Point(6, 105) : new Point(40, 105);

            labelOldPwd.Text     = ResourceCulture.GetString("ResetPwd_OldPwd");
            labelOldPwd.Location = language == "en-US" ? new Point(16, 155) : new Point(40, 155);

            labelNewPwd.Text     = ResourceCulture.GetString("ResetPwd_NewPwd");
            labelNewPwd.Location = language == "en-US" ? new Point(16, 205) : new Point(40, 205);

            labelConfirmPwd.Text     = ResourceCulture.GetString("ResetPwd_ConfirmPwd");
            labelConfirmPwd.Location = language == "en-US" ? new Point(26, 255) : new Point(21, 255);

            btnChangePassword.Text = ResourceCulture.GetString("ResetPwd_Submit");
            btnCancel.Text         = ResourceCulture.GetString("ResetPwd_Cancel");
        }
        /// <summary>
        /// 页面国际化
        /// </summary>
        private void Internationalization(string language)
        {
            //国际化
            DefaultLanguage = !string.IsNullOrWhiteSpace(language) ? language : "zh-CN";
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
            ResourceCulture.SetCurrentCulture(language);

            lblAppName.Text = ResourceCulture.GetString("AppName");
            //lblAppName.Location = language == "zh-CN" ? new Point(413, 155) : new Point(360, 155);

            this.langChineseTool.ForeColor = DefaultLanguage == "en-US" ? Color.White : Color.FromArgb(192, 192, 255);
            this.langEnglishTool.ForeColor = DefaultLanguage == "en-US" ? Color.FromArgb(192, 192, 255) : Color.White;

            btnLogin.Text = ResourceCulture.GetString("Login");
            chxUser.Text  = ResourceCulture.GetString("RememberUser");

            chxPassword.Text = ResourceCulture.GetString("RememberPassword");
            //chxPassword.Location = language == "zh-CN" ? new Point(440, 485) : new Point(460, 485);

            lblBtnChangePwd.Text = ResourceCulture.GetString("ChangePassword");
            lblCopyRight.Text    = ResourceCulture.GetString("CopyRight");
        }
        public PersonalAssets(string userId, string userName, string password, Property bindAsset = null)
        {
            try
            {
                InitializeComponent();

                #region 国际化

                labelBindStep2.Text = ResourceCulture.GetString("BindStep2");
                btnLastStep.Text    = ResourceCulture.GetString("LastStep");
                btnNext.Text        = ResourceCulture.GetString("NextStep");

                #endregion

                UserID   = userId;
                UserName = userName;
                Password = password;

                PropertyList = EoopService.GetUserAssetList(userName);
                foreach (Property property in PropertyList)
                {
                    cbxAsset.Items.Add(property.ComboDisplay);
                }
                if (bindAsset != null)
                {
                    cbxAsset.SelectedText = bindAsset.ComboDisplay;
                }
            }
            catch (Exception ex)
            {
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, ResourceCulture.GetString("GeneralTitle_Prompt"));
            }
        }
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                //DPI 适配
                //SetProcessDPIAware();

                ReleaseType = ConfigurationManager.AppSettings["RELEASE_TYPE"].Trim().ToUpper();

                #region MessageBox 按钮国际化

                string language = ConfigurationManager.AppSettings["DEFAULT_LANGUAGE"].Trim();
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
                ResourceCulture.SetCurrentCulture(language);

                //Set button text from resources
                MessageBoxEx.OK     = ResourceCulture.GetString("MsgBox_OK");       // LocalResource.OK;
                MessageBoxEx.Cancel = ResourceCulture.GetString("MsgBox_Cancel");   // LocalResource.Cancel;
                MessageBoxEx.Retry  = ResourceCulture.GetString("MsgBox_Retry");    // LocalResource.Retry;
                MessageBoxEx.Ignore = ResourceCulture.GetString("MsgBox_Ignore");   // LocalResource.Ignore;
                MessageBoxEx.Abort  = ResourceCulture.GetString("MsgBox_Abort");    // LocalResource.Abort;
                MessageBoxEx.Yes    = ResourceCulture.GetString("MsgBox_Yes");      // LocalResource.Yes;
                MessageBoxEx.No     = ResourceCulture.GetString("MsgBox_No");       // LocalResource.No;

                //Register manager
                MessageBoxEx.Register();

                #endregion

                #region 保证同时只有一个客户端在运行

                bool noRun = false;
                Run = new System.Threading.Mutex(true, "BDOSecurityPortal", out noRun);
                if (!noRun)
                {
                    Process instance = RunningInstance();

                    string productName = ResourceCulture.GetString("AppName");  //Application.ProductName
                    string exMsg       = string.Format(ResourceCulture.GetString("GeneralMsg_AppAlreadyRun"), productName);
                    MessageBox.Show(exMsg, productName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    HandleRunningInstance(instance);
                    return;
                }

                #endregion

                #region 检测软锁(hasplms)服务
                ServiceController[] localServices = ServiceController.GetServices();
                var hasplmsServices = localServices.SingleOrDefault(s => s.ServiceName == "hasplms");
                if (hasplmsServices == null)//软锁服务未安装成功
                {
                    MessageBox.Show(ResourceCulture.GetString("GeneralMsg_HasplmsNotExist"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                    Application.Exit();
                    return;
                }
                if (hasplmsServices.Status != ServiceControllerStatus.Running)
                {
                    hasplmsServices.Start();
                }
                #endregion

                #region 检测网络连接是否正常

                if (!CommonService.IsConnectInternet())
                {
                    string productName = ResourceCulture.GetString("AppName");  //Application.ProductName
                    string exMsg       = string.Format(ResourceCulture.GetString("GeneralMsg_NetworkOffline"), Application.ProductName);
                    MessageBox.Show(exMsg, productName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                #endregion

                #region  序升级
                string localVersion = string.Empty, serverVersion = string.Empty;
                var    shouldUpdateApp = ShouldUpdateApp(out localVersion, out serverVersion);
                if (shouldUpdateApp)
                {
                    Process.Start(Application.StartupPath + @"\AutoUpdate.exe");
                    //Application.Exit();
                    Environment.Exit(0);
                    return;
                }
                #endregion

                //SetProcessDPIAware(); // 不兼容XP
                //IntPtr hUser32 = GetModuleHandle("user32.dll");
                //IntPtr addrSetProcessDPIAware = GetProcAddress(hUser32, "SetProcessDPIAware");
                //if (addrSetProcessDPIAware != IntPtr.Zero)
                //{
                //    FarProc SetProcessDPIAware = (FarProc)Marshal.GetDelegateForFunctionPointer(addrSetProcessDPIAware, typeof(FarProc));
                //    SetProcessDPIAware();
                //}
                //// C#的原有代码
                //Application.EnableVisualStyles();
                //Application.SetCompatibleTextRenderingDefault(false);

                Application.Run(new Login());
            }
            catch (Exception ex)
            {
                string exMsg = ResourceCulture.GetString("GeneralMsg_AppException");
                if (ReleaseType == "DEBUG")
                {
                    exMsg = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMsg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Application.Exit();
                Environment.Exit(0);
            }
        }
        /// <summary>
        /// 窗体初始化
        /// </summary>
        public Login()
        {
            try
            {
                InitializeComponent();

                //初始化窗体信息
                InitializeFormInfo();

                #region 验证:锁号 & 资产 & 资产绑定

                List <string> slCodeList = new List <string>();

                #region 获取资产软锁锁号信息

                try
                {
                    slCodeList = (new safeNetBiz()).getSlCode();
                }
                catch
                {
                }

                #endregion

#if DEBUG
                //slCodeList.Clear();
                //slCodeList.Add("256451793977733503");
#endif

                if (slCodeList.Count == 0)//未生成锁号,需进入资产绑定授权界面
                {
                    GotoBindAsset();
                    return;
                }

                List <UserSLCodes> userSlCodeList = new List <UserSLCodes>();
                foreach (var slcode in slCodeList)
                {
                    UserSLCodes userSLCodes = EoopService.GetUserSLCodes(slcode);
                    if (userSLCodes != null)
                    {
                        userSlCodeList.Add(userSLCodes);
                    }
                }

                //已生成锁号,未绑定资产(锁号未启用,请联系技术部)
                if (userSlCodeList.Count == 0)
                {
                    MessageBox.Show(ResourceCulture.GetString("LoginMsg_Disable"), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    FormDisabled();
                    return;
                }

                //检测到软锁已绑定多台资产,请联系信息技术部。
                if (userSlCodeList.Where(u => u.propertyId == userSlCodeList[0].propertyId).Count() != userSlCodeList.Count)
                {
                    MessageBox.Show(ResourceCulture.GetString("LoginMsg_MultipleAsset"), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    FormDisabled();
                    return;
                }

                string propertyId = userSlCodeList[0].propertyId;
                string slCode     = userSlCodeList[0].slCode;

                Property currentAsset = EoopService.GetUserAsset(propertyId);
                if (currentAsset == null)
                {
                    //锁号未启用,请联系信息技术部。
                    MessageBox.Show(ResourceCulture.GetString("LoginMsg_Disable"), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    FormDisabled();
                    return;
                }

                #endregion

                CurrentSLCodeList = slCodeList;
                CurrentAsset      = currentAsset;
                CurrentSLCode     = slCodeList[0];

                string             loginId      = CurrentAsset != null ? CurrentAsset.loginid : "";
                List <HrmResource> thisHrmUsers = EoopService.GetHrmResource(loginId);
                if (thisHrmUsers.Count != 1)//AD 人事系统登录用户不存在/不唯一
                {
                    string showMsg = thisHrmUsers.Count == 0 ? ResourceCulture.GetString("LoginMsg_NotExistAssetUser")
                                                             : ResourceCulture.GetString("LoginMsg_NotUniqueAssetUser");
                    MessageBox.Show(showMsg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ApplicationExit();
                    return;
                }

                CurrentAssetHrmUser = thisHrmUsers.Count > 0 ? thisHrmUsers[0] : new HrmResource();

                #region 读取配置文件: 绑定记住的用户名和密码

                if (cbxUserName.Items.Count > 0)
                {
                    cbxUserName.Items.Clear();
                }

                //数据序列化异常,更换存储方式 neo 2017年4月19日9:55:43

                /*using (FileStream fStream = new FileStream(Application.StartupPath + @"\data.bin", FileMode.OpenOrCreate))
                 * {
                 *  if (fStream.Length > 0)
                 *  {
                 *      BinaryFormatter bf = new BinaryFormatter();
                 *      List<LogUser> users = bf.Deserialize(fStream) as List<LogUser>;
                 *
                 #region 下拉框 - 记住密码
                 *
                 *      //foreach (LogUser user in users)
                 *      //{
                 *      //    this.cbxUserName.Items.Add(user.Username);
                 *      //}
                 *      //if (!string.IsNullOrWhiteSpace(cbxUserName.Text))
                 *      //{
                 *      //    var user = users.Where(u => u.Username == cbxUserName.Text).SingleOrDefault();
                 *      //    if (user != null)
                 *      //    {
                 *      //        this.txtPassword.Text = user.Password;
                 *      //        this.chxUser.Checked = true;
                 *      //        this.chxPassword.Checked = !string.IsNullOrEmpty(user.Password);
                 *      //    }
                 *      //}
                 *
                 #endregion
                 *
                 #region 输入框 - 记住密码
                 *
                 *      foreach (LogUser user in users)
                 *      {
                 *          this.txtUserName.Text = !string.IsNullOrWhiteSpace(user.Username) ? user.Username : string.Empty;
                 *          this.txtPassword.Text = !string.IsNullOrEmpty(user.Password) ? user.Password : string.Empty;
                 *          this.chxUser.Checked = !string.IsNullOrWhiteSpace(user.Username);
                 *          this.chxPassword.Checked = !string.IsNullOrEmpty(user.Password);
                 *      }
                 *
                 #endregion
                 *  }
                 * }*/


                string username = Properties.Settings.Default.UserName;
                string password = Properties.Settings.Default.Password;
                this.txtUserName.Text    = !string.IsNullOrWhiteSpace(username) ? username : string.Empty;
                this.txtPassword.Text    = !string.IsNullOrEmpty(password) ? password : string.Empty;
                this.chxUser.Checked     = !string.IsNullOrWhiteSpace(username);
                this.chxPassword.Checked = !string.IsNullOrEmpty(password);

                #region 设置默认(第一个)登录用户

                //if (this.cbxUserName.Items.Count > 0)
                //{
                //    this.cbxUserName.SelectedIndex = this.cbxUserName.Items.Count - 1;
                //}

                #endregion

                #endregion
            }
            catch (Exception ex)
            {
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);

                FormDisabled();
            }
        }
        /// <summary>
        /// 登录按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            #region 检测网络连接是否正常

            if (!CommonService.IsConnectInternet())
            {
                string productName = ResourceCulture.GetString("AppName");  //Application.ProductName
                string exMsg       = string.Format(ResourceCulture.GetString("GeneralMsg_NetworkOffline"), Application.ProductName);
                MessageBox.Show(exMsg, productName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            #endregion

            //string userName = this.cbxUserName.Text.Trim();
            string userName = this.txtUserName.Text.Trim();
            string password = this.txtPassword.Text.Trim();

            if (string.IsNullOrWhiteSpace(userName))
            {
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyUser"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            else if (string.IsNullOrWhiteSpace(password))
            {
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyPwd"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }

            bool   loginResult  = false;        //登录结果
            string loginUserId  = string.Empty; //登录用户对应 OA 系统用户 id
            string loginMessage = string.Empty; //登录结果提示信息

            try
            {
                #region LDAP 登录&OA验证&初始密码验证

                loginResult = EoopService.LoginVerify(userName, password, out loginUserId, out loginMessage);

                if (!loginResult)
                {
                    MessageBox.Show(loginMessage, ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }

                if (loginResult && !string.IsNullOrEmpty(loginMessage) && loginMessage.Trim() == "1")//默认密码登录,强制更新密码
                {
                    this.Hide();
                    ChangePassword changePwdForm = new ChangePassword(DefaultLanguage, userName, password, true);
                    changePwdForm.ShowDialog();
                    return;
                }

                #endregion

                #region OA 系统验证登录用户信息

                List <HrmResource> loginHrmUsers = EoopService.GetHrmResource(userName);
                if (loginHrmUsers.Count != 1)//"AD 人事系统登录用户({userName}不存在/不唯一";
                {
                    string showMsg = loginHrmUsers.Count == 0 ? string.Format(ResourceCulture.GetString("LoginMsg_NotExistUser"), userName)
                                                              : string.Format(ResourceCulture.GetString("LoginMsg_NotUniqueUser"), userName);
                    MessageBox.Show(showMsg, ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }
                LoginHrmUser = loginHrmUsers[0];

                #endregion

                #region OA 系统验证资产用户信息

                //string loginId = CurrentAsset != null ? CurrentAsset.loginid : "";
                //List<HrmResource> thisHrmUsers = EoopService.GetHrmResource(loginId);
                //if (thisHrmUsers.Count != 1)//"AD 人事系统登录用户({userName}不存在/不唯一";
                //{
                //    string showMsg = thisHrmUsers.Count == 0 ? string.Format(ResourceCulture.GetString("LoginMsg_NotExistAssetUser"), userName) : string.Format(ResourceCulture.GetString("LoginMsg_NotUniqueAssetUser"), userName);
                //    MessageBox.Show(showMsg, ResourceCulture.GetString("GeneralTitle_Prompt"));
                //    return;
                //}
                //CurrentAssetHrmUser = thisHrmUsers.Count > 0 ? thisHrmUsers[0] : new HrmResource();

                #endregion

                #region 判断用户是否可使用该资产登录

                if (CurrentAsset.tinyintfield2.Trim() != "1")//非公共资产
                {
                    List <Property> loginUserPropertyList = EoopService.GetUserAssetList(userName);
                    if (loginUserPropertyList == null || loginUserPropertyList.Where(p => p.id == CurrentAsset.id).Count() == 0)//非为资产本人登录
                    {
                        //同一用户组判断
                        var groupMembers = EoopService.GetGroupMembers(CurrentAssetHrmUser.userId, LoginHrmUser.loginid);
                        var departRoles  = EoopService.GetDepartRoleMapping(LoginHrmUser.departmentid);
                        if (groupMembers.Count == 0 && departRoles.Count == 0)//非资产所属用户组用户登录
                        {
                            MessageBox.Show(ResourceCulture.GetString("LoginMsg_NotSameGroup"), ResourceCulture.GetString("LoginMsg_Title"));
                            return;
                        }
                    }
                }

                #endregion

                #region 记住用户 & 记住密码

                #region 注释代码:记住多个用户

                //List<LogUser> userList = new List<LogUser>();

                //using (FileStream fStream = new FileStream("data.bin", FileMode.OpenOrCreate, FileAccess.ReadWrite))
                //{
                //    BinaryFormatter bFormat = new BinaryFormatter();
                //    List<LogUser> users = fStream.Length > 0 ? bFormat.Deserialize(fStream) as List<LogUser> : new List<LogUser>();
                //    if (chxUser.Checked)
                //    {
                //        LogUser user = new LogUser();
                //        user.Username = userName;
                //        user.Password = chxPassword.Checked ? password : "";        //如果单击了记住密码的功能则在文件中保存密码,否则不在文件中保存密码
                //        var containsUsers = users.Where(u => u.Username == userName);
                //        if (containsUsers != null && containsUsers.Count() > 0)   //选在集合中是否存在用户名
                //        {
                //            int index = users.IndexOf(containsUsers.SingleOrDefault());
                //            users.RemoveAt(index);
                //        }
                //        users.Add(user);
                //    }
                //    else
                //    {
                //        var containsUsers = users.Where(u => u.Username == userName);
                //        if (containsUsers != null && containsUsers.Count() > 0)          //选在集合中是否存在用户名
                //        {
                //            int index = users.IndexOf(containsUsers.SingleOrDefault());
                //            users.RemoveAt(index);
                //        }
                //    }
                //    userList = users;
                //}

                //using (FileStream fStream = new FileStream("data.bin", FileMode.Open, FileAccess.ReadWrite))
                //{
                //    BinaryFormatter bFormat = new BinaryFormatter();
                //    bFormat.Serialize(fStream, userList);               //要先将User类先设为可以序列化(即在类的前面加[Serializable])
                //}

                #endregion

                #region 记录最近一次登录用户

                /*using (FileStream fStream = new FileStream(Application.StartupPath + @"\data.bin", FileMode.Create))
                 * {
                 *  BinaryFormatter bFormat = new BinaryFormatter();
                 *  List<LogUser> users = fStream.Length > 0 ? bFormat.Deserialize(fStream) as List<LogUser> : new List<LogUser>();
                 *  if (chxUser.Checked)
                 *  {
                 *      LogUser user = new LogUser();
                 *      user.Username = userName;
                 *      user.Password = chxPassword.Checked ? password : "";        //如果单击了记住密码的功能则在文件中保存密码,否则不在文件中保存密码
                 *      var containsUsers = users.Where(u => u.Username == userName);
                 *      if (containsUsers != null && containsUsers.Count() > 0)   //选在集合中是否存在用户名
                 *      {
                 *          int index = users.IndexOf(containsUsers.SingleOrDefault());
                 *          users.RemoveAt(index);
                 *      }
                 *      users.Add(user);
                 *  }
                 *  else
                 *  {
                 *      var containsUsers = users.Where(u => u.Username == userName);
                 *      if (containsUsers != null && containsUsers.Count() > 0)          //选在集合中是否存在用户名
                 *      {
                 *          int index = users.IndexOf(containsUsers.SingleOrDefault());
                 *          users.RemoveAt(index);
                 *      }
                 *  }
                 *
                 *  bFormat.Serialize(fStream, users);               //要先将User类先设为可以序列化(即在类的前面加[Serializable])
                 * }*/

                if (chxUser.Checked)
                {
                    Properties.Settings.Default.UserName = userName;
                    Properties.Settings.Default.Password = password;
                }
                else
                {
                    Properties.Settings.Default.UserName = "";
                    Properties.Settings.Default.Password = "";
                }
                Properties.Settings.Default.Save();

                #endregion

                #endregion

                #region 登录,进入程序主界面 MainForm

                //if (!Cef.IsInitialized)
                //{
                //    Cef.RunMessageLoop();
                //    Cef.Shutdown();
                //}

                MainForm mainForm = new MainForm(loginUserId, userName, password, DefaultLanguage, CurrentSLCode, CurrentSLCodeList, CurrentAsset, LoginHrmUser);
                this.Hide();
                mainForm.WindowState = FormWindowState.Maximized;
                mainForm.Show();

                //初始化 CefSharp 浏览器内核组件
                InitializeCefSharp(DefaultLanguage);

                txtPassword.Text    = string.Empty;
                chxUser.Checked     = false;
                chxPassword.Checked = false;

                #endregion
            }
            catch (Exception ex)
            {
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, ResourceCulture.GetString("LoginMsg_Title"));
            }
        }
        private void btnChangePassword_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUserName.Text.Trim()))
            {
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyUser"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            if (string.IsNullOrEmpty(txtOldPwd.Text.Trim()))
            {
                MessageBox.Show(ResourceCulture.GetString("GeneralMsg_EmptyPwd"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            if (string.IsNullOrEmpty(txtNewPwd.Text.Trim()))
            {
                MessageBox.Show(ResourceCulture.GetString("ResetPwd_EmptyNewPwd"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            if (string.IsNullOrEmpty(txtConfirmPwd.Text.Trim()))
            {
                MessageBox.Show(ResourceCulture.GetString("ResetPwd_EmptyConfirm"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            if (!string.IsNullOrEmpty(Password) && txtOldPwd.Text != Password)
            {
                MessageBox.Show(ResourceCulture.GetString("ResetPwd_PwdNotMatch"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            if (txtNewPwd.Text != txtConfirmPwd.Text)
            {
                MessageBox.Show(ResourceCulture.GetString("ResetPwd_PwdNotMatch"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }
            string userName    = txtUserName.Text;
            string oldPassword = txtOldPwd.Text;
            string newPassword = txtConfirmPwd.Text;
            string message     = string.Empty;

            try
            {
                bool result = EoopService.ResetPassword(userName, oldPassword, newPassword, out message);
                if (!result)
                {
                    MessageBox.Show(message, ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }
                MessageBox.Show(ResourceCulture.GetString("ResetPwd_ResetSuccess"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                this.Close();
                foreach (Form openForm in Application.OpenForms)
                {
                    if (openForm.Name == "Login")
                    {
                        openForm.WindowState = FormWindowState.Normal;
                        openForm.Show();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, ResourceCulture.GetString("GeneralTitle_Prompt"));
            }
        }
        private void btnComplete_Click(object sender, EventArgs e)
        {
            string authorNO = txtAuthorNO.Text.Trim();

            if (string.IsNullOrWhiteSpace(authorNO))
            {
                MessageBox.Show(ResourceCulture.GetString("BindMsg_EmptAuthorNO"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                return;
            }

            try
            {
                #region 显示 Loading 等待

                showMaskPanel.Visible = true;
                this.Refresh();

                #endregion

                string slKeyId   = string.Empty;
                string slKeyCode = string.Empty;
                string message   = string.Empty;

                safeNetTool.safeNetBiz safetBiz = new safeNetTool.safeNetBiz();
                bool installSafeNetResult       = safetBiz.installSafeNet(authorNO, out slKeyId, out message);
                if (!installSafeNetResult)
                {
                    showMaskPanel.Visible = false;
                    this.Refresh();

                    MessageBox.Show(message, ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }
                //获取密锁锁号
                List <string> slKeyCodes = (new safeNetTool.safeNetBiz()).getSlCode();
                slKeyCode = slKeyCodes.Count > 0 ? slKeyCodes[0] : string.Empty;
                bool bindResult = EoopService.BindUserAsset(slKeyCode, BindAsset.id, 1);
                if (!bindResult)
                {
                    showMaskPanel.Visible = false;
                    this.Refresh();
                    //MessageBox.Show("资产绑定失败,请重新绑定。", "提示信息");
                    MessageBox.Show(ResourceCulture.GetString("BindMsg_BindFailed"), ResourceCulture.GetString("GeneralTitle_Prompt"));
                    return;
                }
                MainForm mainForm = new MainForm(UserID, UserName, Password, Language, slKeyCode);
                foreach (Form openForm in Application.OpenForms)
                {
                    openForm.Hide();
                }
                mainForm.WindowState = FormWindowState.Maximized;
                mainForm.ShowDialog();
                this.Close();
            }
            catch (Exception ex)
            {
                showMaskPanel.Hide();
                string exMessage = ResourceCulture.GetString("GeneralMsg_AppException");
                if (Program.ReleaseType == "DEBUG")
                {
                    exMessage = ex.Message + ex.StackTrace;
                }
                MessageBox.Show(exMessage, ResourceCulture.GetString("GeneralTitle_Prompt"));
            }
        }