Exemple #1
0
        public bool WsSignPk(string oldPass, string newPass, XmlReader reader)
        {
            string code = null;
            if (reader.Name == "Code" || reader.ReadToFollowing("Code"))
            {
                code = reader.ReadElementContentAsString();
            }
            if (!CharUtil.IsValidateCode(code))
            {
                return false;
            }

            string data = null;
            if (reader.Name == "Data" || reader.ReadToFollowing("Data"))
            {
                data = reader.ReadElementContentAsString();
            }
            if (!Regex.IsMatch(data, "^[A-Za-z0-9+/=]{256,}$"))
            {
                return false;
            }

            string info = null;
            if (reader.Name == "Info" || reader.ReadToFollowing("Info"))
            {
                info = reader.ReadElementContentAsString();
            }
            if (!Regex.IsMatch(info, "^[A-Za-z0-9+/=]{44}$"))
            {
                return false;
            }

            string main = null;
            if (reader.Name == "Main" || reader.ReadToFollowing("Main"))
            {
                main = reader.ReadElementContentAsString();
            }
            if (!Regex.IsMatch(main, "^[A-Za-z0-9+/=]{108}$"))
            {
                return false;
            }

            string safe = null;
            if (reader.Name == "Safe" || reader.ReadToFollowing("Safe"))
            {
                safe = reader.ReadElementContentAsString();
            }

            _Data = Convert.FromBase64String(data);
            if (info != Digest(oldPass, newPass))
            {
                return false;
            }

            if (!Decrypt(oldPass, code, newPass, main))
            {
                return false;
            }

            DFEngine prop = new DFEngine();
            prop.Load(Path.Combine(this.DatHome, CApp.AMON_CFG));
            prop.Set(CApp.AMON_CFG_NAME, oldPass);
            prop.Set(CApp.AMON_CFG_CODE, code);
            prop.Set(CApp.AMON_CFG_DATA, data);
            prop.Set(CApp.AMON_CFG_INFO, info);
            prop.Set(CApp.AMON_CFG_LOCK, _Lock);
            prop.Set(CApp.AMON_CFG_MAIN, main);
            prop.Set(CApp.AMON_CFG_SAFE, safe);
            prop.Save(Path.Combine(this.DatHome, CApp.AMON_CFG));

            return true;
        }
Exemple #2
0
        /// <summary>
        /// 布局存储
        /// </summary>
        public void LoadLayout()
        {
            #region Look
               _LookPath = Path.Combine(_UserModel.ResHome, "Skin", "Look", _UserModel.Look);
               _LookProp = new DFEngine();
               _LookProp.Load(Path.Combine(_LookPath, CApp.FILE_LOOK));
               #endregion

               #region Feel
               _FeelPath = Path.Combine(_UserModel.ResHome, "Skin", "Feel", _UserModel.Feel);
               _FeelProp = new DFEngine();
               _FeelProp.Load(Path.Combine(_FeelPath, CApp.FILE_FEEL));

               if (_Imgs == null)
               {
               _Imgs = new Dictionary<string, Image>();
               }
               else
               {
               _Imgs.Clear();
               }
               #endregion
        }
Exemple #3
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <returns></returns>
        public bool CaSignUp(string root, string code, string name, string pass)
        {
            byte[] k = GenK(name, code, pass);
            byte[] v = GenV(name, code, pass);

            Random r = new Random();
            _Salt = new byte[16];
            r.NextBytes(_Salt);
            _Keys = new byte[32];
            r.NextBytes(_Keys);
            _Mask = GenChar();

            byte[] t = new byte[72];
            byte[] a = Encoding.UTF8.GetBytes(code);
            int i = 0;
            Array.Copy(a, 0, t, i, a.Length);
            i += a.Length;
            Array.Copy(_Salt, 0, t, i, _Salt.Length);
            i += _Salt.Length;
            Array.Copy(_Keys, 0, t, i, _Keys.Length);
            i += _Keys.Length;
            a = Encoding.UTF8.GetBytes(_Mask);
            Array.Copy(a, 0, t, i, a.Length);

            #region AES 加密
            AesManaged aes = new AesManaged();
            using (MemoryStream mStream = new MemoryStream())
            {
                using (CryptoStream cStream = new CryptoStream(mStream, aes.CreateEncryptor(k, v), CryptoStreamMode.Write))
                {
                    cStream.Write(t, 0, t.Length);
                    cStream.FlushFinalBlock();
                    t = mStream.ToArray();
                }
            }
            aes.Clear();
            #endregion
            string main = Convert.ToBase64String(t);

            _Data = new byte[256];
            r.NextBytes(_Data);
            string info = Digest(name, pass);

            this.DatHome = Path.Combine(root, code);
            if (!Directory.Exists(this.DatHome))
            {
                Directory.CreateDirectory(this.DatHome);
            }
            DFEngine prop = new DFEngine();
            prop.Set(CApp.AMON_CFG_NAME, name);
            prop.Set(CApp.AMON_CFG_CODE, code);
            prop.Set(CApp.AMON_CFG_DATA, Convert.ToBase64String(_Data));
            prop.Set(CApp.AMON_CFG_INFO, info);
            prop.Set(CApp.AMON_CFG_LOCK, info);
            prop.Set(CApp.AMON_CFG_MAIN, main);
            prop.Set(CApp.AMON_CFG_SAFE, "");
            prop.Save(Path.Combine(this.DatHome, CApp.AMON_CFG));

            this.Name = name;
            this.Code = code;
            _Info = info;
            _Lock = info;
            Look = "Default";
            Feel = "Default";
            return true;
        }
Exemple #4
0
        /// <summary>
        /// 网络登录
        /// </summary>
        /// <returns></returns>
        public bool WsSignIn(string home, string code, string name, string pass, XmlReader reader)
        {
            string data = null;
            if (reader.Name == "Data" || reader.ReadToFollowing("Data"))
            {
                data = reader.ReadElementContentAsString();
            }
            if (!Regex.IsMatch(data, "^[A-Za-z0-9+/=]{256,}$"))
            {
                return false;
            }

            string info = null;
            if (reader.Name == "Info" || reader.ReadToFollowing("Info"))
            {
                info = reader.ReadElementContentAsString();
            }
            if (!Regex.IsMatch(info, "^[A-Za-z0-9+/=]{44}$"))
            {
                return false;
            }

            string main = null;
            if (reader.Name == "Main" || reader.ReadToFollowing("Main"))
            {
                main = reader.ReadElementContentAsString();
            }
            if (!Regex.IsMatch(main, "^[A-Za-z0-9+/=]{108}$"))
            {
                return false;
            }

            string safe = null;
            if (reader.Name == "Safe" || reader.ReadToFollowing("Safe"))
            {
                safe = reader.ReadElementContentAsString();
            }

            _Data = Convert.FromBase64String(data);
            if (info != Digest(name, pass))
            {
                return false;
            }

            if (!Decrypt(name, code, pass, main))
            {
                return false;
            }

            this.DatHome = home;
            DFEngine prop = new DFEngine();
            prop.Set(CApp.AMON_CFG_NAME, name);
            prop.Set(CApp.AMON_CFG_CODE, code);
            prop.Set(CApp.AMON_CFG_DATA, data);
            prop.Set(CApp.AMON_CFG_INFO, info);
            prop.Set(CApp.AMON_CFG_LOCK, info);
            prop.Set(CApp.AMON_CFG_MAIN, main);
            prop.Set(CApp.AMON_CFG_SAFE, safe);
            prop.Save(Path.Combine(this.DatHome, CApp.AMON_CFG));

            this.Name = name;
            this.Code = code;
            _Info = info;
            _Lock = info;
            Look = "Default";
            Feel = "Default";
            return true;
        }
Exemple #5
0
        /// <summary>
        /// 设定安全口令
        /// </summary>
        /// <param name="oldPass"></param>
        /// <param name="secPass"></param>
        /// <returns></returns>
        public bool CaAuthSk(string oldPass, string secPass)
        {
            DFEngine prop = new DFEngine();
            prop.Load(Path.Combine(this.DatHome, CApp.AMON_CFG));

            // 已有口令校验
            string info = Digest(Name, oldPass);
            if (info != prop.Get(CApp.AMON_CFG_INFO))
            {
                return false;
            }

            // 生成加密密钥及字符空间
            byte[] t = new byte[72];
            byte[] a = Encoding.UTF8.GetBytes(Code);
            int i = 0;
            Array.Copy(a, 0, t, i, a.Length);
            i += a.Length;
            Array.Copy(_Salt, 0, t, i, _Salt.Length);
            i += _Salt.Length;
            Array.Copy(_Keys, 0, t, i, _Keys.Length);
            i += _Keys.Length;
            a = Encoding.UTF8.GetBytes(_Mask);
            Array.Copy(a, 0, t, i, a.Length);

            // 口令
            byte[] k = GenK(Name, Code, secPass);
            // 向量
            byte[] v = GenV(Name, Code, secPass);

            #region AES 加密
            AesManaged aes = new AesManaged();
            using (MemoryStream mStream = new MemoryStream())
            {
                using (CryptoStream cStream = new CryptoStream(mStream, aes.CreateEncryptor(k, v), CryptoStreamMode.Write))
                {
                    cStream.Write(t, 0, t.Length);
                    cStream.FlushFinalBlock();
                    t = mStream.ToArray();
                }
            }
            aes.Clear();
            #endregion

            prop.Set(CApp.AMON_CFG_SAFE, Convert.ToBase64String(t));
            prop.Save(Path.Combine(this.DatHome, CApp.AMON_CFG));
            return true;
        }
Exemple #6
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        public bool CaSignIn(string home, string code, string name, string pass)
        {
            string file = Path.Combine(home, CApp.AMON_CFG);
            if (!File.Exists(file))
            {
                return false;
            }

            DFEngine prop = new DFEngine();
            prop.Load(file);

            string data = prop.Get(CApp.AMON_CFG_DATA);
            if (!CharUtil.IsValidate(data, 344))
            {
                return false;
            }
            _Data = Convert.FromBase64String(data);

            string info = Digest(name, pass);
            if (info != prop.Get(CApp.AMON_CFG_INFO))
            {
                return false;
            }

            string main = prop.Get(CApp.AMON_CFG_MAIN);
            if (!Decrypt(name, code, pass, main))
            {
                return false;
            }

            _Lock = prop.Get(CApp.AMON_CFG_LOCK);

            this.Name = name;
            this.Code = code;
            this.DatHome = home;
            _Info = info;
            Look = "Default";
            Feel = "Default";
            return true;
        }
Exemple #7
0
        /// <summary>
        /// 打开(&O)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MiOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog fdOpen = Main.OpenFileDialog;
            fdOpen.Filter = "阿木密码箱配置文件|*.cfg";
            fdOpen.FileName = CApp.AMON_CFG;
            fdOpen.InitialDirectory = _UserModel.SysHome;
            fdOpen.Multiselect = false;
            if (DialogResult.OK != fdOpen.ShowDialog(_Main))
            {
                return;
            }

            string path = fdOpen.FileName;
            if (!File.Exists(path))
            {
                Main.ShowAlert("无法访问您选择的文件!");
                return;
            }

            string file = (Path.GetFileName(path) ?? "").ToLower();
            if (CApp.AMON_CFG.ToLower() != file)
            {
                Main.ShowAlert(string.Format("请确认您选择的文件名是否为:{0}!", CApp.AMON_CFG));
                return;
            }

            DFEngine prop = new DFEngine();
            prop.Load(path);
            string name = prop.Get(CApp.AMON_CFG_NAME);
            string code = prop.Get(CApp.AMON_CFG_CODE);
            if (!CharUtil.IsValidateCode(code) || !CharUtil.IsValidate(name))
            {
                Main.ShowAlert("请确认您选择的数据路径是否正确!");
                return;
            }

            prop.Clear();
            string sysFile = Path.Combine(_UserModel.SysHome, CApp.AMON_SYS);
            prop.Load(sysFile);
            prop.Set(string.Format(CApp.AMON_SYS_CODE, name), code);
            path = Path.GetDirectoryName(path);
            if (path.StartsWith(Application.StartupPath))
            {
                path = path.Substring(Application.StartupPath.Length + 1);
            }
            prop.Set(string.Format(CApp.AMON_SYS_HOME, name), path);
            prop.Save(sysFile);
        }
Exemple #8
0
        /// <summary>
        /// 设定锁屏口令
        /// </summary>
        /// <returns></returns>
        public bool CaAuthLk(string oldPass, string newPass)
        {
            if (_Lock != Digest(this.Name, oldPass))
            {
                return false;
            }

            _Lock = Digest(Name, newPass);

            DFEngine prop = new DFEngine();
            prop.Load(Path.Combine(this.DatHome, CApp.AMON_CFG));
            prop.Set(CApp.AMON_CFG_LOCK, _Lock);
            prop.Save(Path.Combine(this.DatHome, CApp.AMON_CFG));
            return true;
        }
Exemple #9
0
        public void DoSignAc()
        {
            #region 用户判断
            string name = TbName.Text;
            if (string.IsNullOrEmpty(name))
            {
                Main.ShowAlert("请输入【登录用户】!");
                TbName.Focus();
                return;
            }
            #endregion

            #region 登录口令
            string pass = TbPass.Text;
            if (string.IsNullOrEmpty(pass))
            {
                Main.ShowAlert("请输入【登录口令】!");
                TbPass.Focus();
                return;
            }
            if (pass.Length < 4)
            {
                Main.ShowAlert("【登录口令】不能少于 4 个字符!");
                TbPass.Focus();
                return;
            }
            #endregion

            #region 路径判断
            string path = TbPath.Text;
            if (string.IsNullOrEmpty(path))
            {
                path = CApp.DIR_DATA;
            }
            if (!Directory.Exists(path))
            {
                Main.ShowAlert("无法访问路径!");
                BtPath.Focus();
                return;
            }
            #endregion

            #region 认证信息
            string text = TbText.Text;
            if (string.IsNullOrEmpty(text))
            {
                Main.ShowAlert("请输入认证数据!");
                TbPath.Focus();
                return;
            }
            #endregion

            try
            {
                using (XmlReader reader = XmlReader.Create(new StringReader(text)))
                {
                    if (text.IndexOf("<Error>") > 0)
                    {
                        _SignAc.HideWaiting();
                        reader.ReadToFollowing("Error");
                        Main.ShowAlert(reader.ReadElementContentAsString());
                        return;
                    }

                    string code = null;
                    if (reader.Name == "Code" || reader.ReadToFollowing("Code"))
                    {
                        code = reader.ReadElementContentAsString();
                    }
                    if (!CharUtil.IsValidateCode(code))
                    {
                        _SignAc.HideWaiting();
                        Main.ShowAlert("注册用户失败,请稍后重试!");
                        return;
                    }
                    path = Path.Combine(path, code);
                    if (Directory.Exists(path))
                    {
                        _SignAc.HideWaiting();
                        Main.ShowAlert(string.Format("指定路径下已存在名为 {0} 的目录!", code));
                        return;
                    }
                    Directory.CreateDirectory(path);

                    if (!_UserModel.WsSignIn(path, code, name, pass, reader))
                    {
                        Main.ShowAlert("请确认您输入的令牌数据是否有效!");
                        TbPath.Focus();
                        return;
                    }
                }

                string sysFile = Path.Combine(_UserModel.SysHome, CApp.AMON_SYS);
                DFEngine prop = new DFEngine();
                prop.Load(sysFile);
                prop.Set(string.Format(CApp.AMON_SYS_CODE, name), _UserModel.Code);
                path = _UserModel.DatHome;
                if (path.StartsWith(Application.StartupPath))
                {
                    path = path.Substring(Application.StartupPath.Length + 1);
                }
                prop.Set(string.Format(CApp.AMON_SYS_HOME, name), _UserModel.DatHome);
                prop.Save(sysFile);

                InitDat();
            }
            catch (Exception exp)
            {
                _SignAc.HideWaiting();
                Main.ShowAlert(exp.Message);
                TbPath.Focus();
                return;
            }
        }
Exemple #10
0
        public void DoSignAc()
        {
            #region 用户判断
            _Name = TbName.Text;
            if (string.IsNullOrEmpty(_Name))
            {
                Main.ShowAlert("请输入【登录用户】!");
                TbName.Focus();
                return;
            }
            if (!CharUtil.IsValidateName(_Name))
            {
                Main.ShowAlert("【登录用户】应在 4 到 32 个字符之间,且仅能为大小写字母、下划线及英文点号!");
                TbName.Focus();
                return;
            }
            #endregion

            #region 口令判断
            _Pass = TbPass.Text;
            TbPass.Text = "";
            if (string.IsNullOrEmpty(_Pass))
            {
                Main.ShowAlert("请输入【登录口令】!");
                TbPass.Focus();
                return;
            }

            if (_Pass.Length < 4)
            {
                Main.ShowAlert("【登录口令】不能少于 4 个字符!");
                TbPass.Focus();
                return;
            }
            #endregion

            _SignAc.ShowWaiting();

            _Prop = new DFEngine();
            _Prop.Load(Path.Combine(_UserModel.SysHome, CApp.AMON_SYS));

            _Name = _Name.ToLower();
            string code = _Prop.Get(string.Format(CApp.AMON_SYS_CODE, _Name));
            _Home = _Prop.Get(string.Format(CApp.AMON_SYS_HOME, _Name));

            #region 已有用户首次登录
            if (!CharUtil.IsValidateCode(code))
            {
                //_Home = CApp.DIR_DATA;

                //WebClient client = new WebClient();
                //client.Credentials = CredentialCache.DefaultCredentials;
                //client.Headers["Content-type"] = "application/x-www-form-urlencoded";
                //client.Encoding = Encoding.UTF8;
                //client.UploadStringCompleted += new UploadStringCompletedEventHandler(SignIn_UploadStringCompleted);
                //client.UploadStringAsync(new Uri(CApp.SERVER_PATH), "POST", "&o=sin&d=" + _Name);

                _SignAc.HideWaiting();
                Main.ShowAlert("身份验证错误,请确认您的用户及口令输入是否正确!");
                TbName.Focus();
                return;
            }
            #endregion

            #region 已有用户正常登录
            if (!_Home.StartsWith(_UserModel.SysHome))
            {
                _Home = Path.Combine(_UserModel.SysHome, _Home);
            }
            if (!_UserModel.CaSignIn(_Home, code, _Name, _Pass))
            {
                _SignAc.HideWaiting();
                Main.ShowAlert("身份验证错误,请确认您的用户及口令输入是否正确!");
                TbPass.Focus();
                return;
            }

            _UserModel.Load();
            _SignAc.CallBack(CApp.IAPP_NONE);
            #endregion
        }
Exemple #11
0
        private void SignIn_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                _SignAc.HideWaiting();
                Main.ShowAlert(e.Error.Message);
                return;
            }

            string xml = e.Result;

            using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
            {
                if (xml.IndexOf("<Error>") > 0)
                {
                    _SignAc.HideWaiting();
                    reader.ReadToFollowing("Error");
                    Main.ShowAlert(reader.ReadElementContentAsString());
                    return;
                }

                string code = null;
                if (reader.Name == "Code" || reader.ReadToFollowing("Code"))
                {
                    code = reader.ReadElementContentAsString();
                }
                if (!CharUtil.IsValidateCode(code))
                {
                    _SignAc.HideWaiting();
                    Main.ShowAlert("注册用户失败,请稍后重试!");
                    return;
                }
                _Home = Path.Combine(_Home, code);
                if (!Directory.Exists(_Home))
                {
                    Directory.CreateDirectory(_Home);
                }

                if (!_UserModel.WsSignIn(_Home, code, _Name, _Pass, reader))
                {
                    _SignAc.HideWaiting();
                    Main.ShowAlert("请确认您输入的登录用户及登录口令是否正确!");
                    TbName.Focus();
                }
                else
                {
                    string sysFile = Path.Combine(_UserModel.SysHome, CApp.AMON_SYS);
                    DFEngine prop = new DFEngine();
                    prop.Load(sysFile);
                    prop.Set(string.Format(CApp.AMON_SYS_HOME, _Name), _Home);
                    prop.Set(string.Format(CApp.AMON_SYS_CODE, _Name), code);
                    prop.Save(sysFile);

                    InitDat();
                }
            }

            _Pass = null;
        }
Exemple #12
0
        public void DoSignAc()
        {
            #region 用户判断
            _Name = TbName.Text;
            if (string.IsNullOrEmpty(_Name))
            {
                Main.ShowAlert("请输入【登录用户】!");
                TbName.Focus();
                return;
            }
            if (!CharUtil.IsValidateName(_Name))
            {
                Main.ShowAlert("【登录用户】应在 4 到 32 个字符之间,且仅能为大小写字母、下划线及英文点号!");
                TbName.Focus();
                return;
            }
            #endregion

            #region 用户邮件
            _Mail = TbMail.Text;
            if (string.IsNullOrEmpty(_Mail))
            {
                Main.ShowAlert("请输入【电子邮件】!");
                TbMail.Focus();
                return;
            }
            if (!CharUtil.IsValidateMail(_Mail))
            {
                Main.ShowAlert("请输入一个有效的【电子邮件】!");
                TbMail.Focus();
                return;
            }
            #endregion

            #region 口令判断
            _Pass = TbPass1.Text;
            TbPass1.Text = "";
            if (string.IsNullOrEmpty(_Pass))
            {
                Main.ShowAlert("请输入【登录口令】!");
                TbPass1.Focus();
                return;
            }

            if (_Pass.Length < 4)
            {
                Main.ShowAlert("【登录口令】不能少于 4 个字符!");
                TbPass1.Text = "";
                TbPass2.Text = "";
                TbPass1.Focus();
                return;
            }

            if (_Pass != TbPass2.Text)
            {
                TbPass2.Text = "";
                Main.ShowAlert("您两次输入的口令不一致!");
                TbPass1.Focus();
                return;
            }
            TbPass2.Text = "";
            #endregion

            #region 路径判断
            _Root = TbPath.Text;
            if (string.IsNullOrEmpty(_Root))
            {
                _Root = CApp.DIR_DATA;
            }
            #endregion

            _SignAc.ShowWaiting();

            #region 本地用户判断
            _Name = _Name.ToLower();
            _Prop = new DFEngine();
            _Prop.Load(Path.Combine(_UserModel.SysHome, CApp.AMON_SYS));
            string home = _Prop.Get(string.Format(CApp.AMON_SYS_HOME, _Name));
            if (!string.IsNullOrEmpty(home))
            {
                _SignAc.HideWaiting();
                Main.ShowAlert(string.Format("已存在名为 {0} 的用户,请尝试其它用户名!", _Name));
                TbName.Focus();
                return;
            }
            #endregion

            // 在线注册
            WebClient client = new WebClient();
            client.Headers["Content-type"] = "application/x-www-form-urlencoded";
            client.Encoding = Encoding.UTF8;
            client.UploadStringCompleted += new UploadStringCompletedEventHandler(SignUpV_UploadStringCompleted);
            client.UploadStringAsync(new Uri(CApp.SERVER_PATH), "POST", "&o=rsa&m=0");
        }
Exemple #13
0
        public void DoSignAc()
        {
            #region 用户判断
            string name = TbName.Text;
            if (string.IsNullOrEmpty(name))
            {
                Main.ShowAlert("请输入用户名!");
                TbName.Focus();
                return;
            }

            if (name.Length < 5)
            {
                Main.ShowAlert("用户名不能少于5个字符!");
                TbName.Focus();
                return;
            }

            if (!Regex.IsMatch(name, "^\\w{5,}$"))
            {
                Main.ShowAlert("用户名中含有非法字符!");
                TbName.Focus();
                return;
            }

            name = name.ToLower();
            string sysFile = Path.Combine(_UserModel.SysHome, CApp.AMON_SYS);
            _Prop = new DFEngine();
            _Prop.Load(sysFile);
            string home = _Prop.Get(string.Format(CApp.AMON_SYS_HOME, name));
            if (!string.IsNullOrEmpty(home))
            {
                Main.ShowAlert(string.Format("已存在名为 {0} 的用户,请尝试其它用户名!", name));
                return;
            }
            #endregion

            #region 口令判断
            string pass = TbPass1.Text;
            TbPass1.Text = "";
            if (string.IsNullOrEmpty(pass))
            {
                Main.ShowAlert("请输入登录口令!");
                TbPass1.Focus();
                return;
            }

            if (pass.Length < 4)
            {
                Main.ShowAlert("登录口令不能少于4个字符!");
                TbPass1.Text = "";
                TbPass2.Text = "";
                TbPass1.Focus();
                return;
            }

            if (pass != TbPass2.Text)
            {
                TbPass2.Text = "";
                Main.ShowAlert("您两次输入的口令不一致!");
                TbPass1.Focus();
                return;
            }
            TbPass2.Text = "";
            #endregion

            #region 路径判断
            home = TbPath.Text;
            if (string.IsNullOrEmpty(home))
            {
                Main.ShowAlert("请选择您的数据存放目录!");
                BtPath.Focus();
                return;
            }
            #endregion

            #region 代码
            string code = CApp.USER_AMON;
            if (Directory.Exists(Path.Combine(home, code)))
            {
                Main.ShowAlert(string.Format("指定路径下已存在名为 {0} 的目录!", code));
                return;
            }
            #endregion

            _SignAc.ShowWaiting();

            try
            {
                // 本地注册
                if (!_UserModel.CaSignUp(home, code, name, pass))
                {
                    pass = null;
                    _SignAc.HideWaiting();
                    Main.ShowAlert("系统异常,请稍后重试!");
                    return;
                }

                _Prop.Set(string.Format(CApp.AMON_SYS_CODE, name), _UserModel.Code);
                home = _UserModel.DatHome;
                if (home.StartsWith(Application.StartupPath))
                {
                    home = home.Substring(Application.StartupPath.Length + 1);
                }
                _Prop.Set(string.Format(CApp.AMON_SYS_HOME, name), home);
                _Prop.Save(sysFile);

                InitDat();
            }
            catch (Exception exp)
            {
                _SignAc.HideWaiting();
                Main.ShowAlert(exp.Message);
                return;
            }
        }