private void MakeRegistFileClick(object sender, EventArgs e) { string localFileName = string.Concat( RegistFileHelper.ApplicationDataPath, RegistFileHelper.ComputerInfofile); WinForm.FolderBrowserDialog dialog = new WinForm.FolderBrowserDialog(); if (dialog.ShowDialog() == WinForm.DialogResult.OK) { string fileName = dialog.SelectedPath + System.IO.Path.DirectorySeparatorChar + RegistFileHelper.ComputerInfofile; computer_info_file.Text = fileName; string computerInfo = ComputerInfo.GetComputerInfo(); string encryptComputer = new EncryptionHelper().EncryptString(computerInfo); RegistFileHelper.WriteComputerInfoFile(encryptComputer); if (fileName != localFileName) { if (File.Exists(fileName) == false) { File.Create(fileName).Close(); } ; File.Copy(localFileName, fileName, true); } } else { return; } }
public LoginWindow() { InitializeComponent(); string versionValue = string.Empty; try { XmlDocument doc = new XmlDocument(); String CurrPath = Directory.GetCurrentDirectory().Trim(); if (CurrPath.EndsWith("upgrade")) { doc.Load(@"config.xml"); } else { doc.Load(@"upgrade\config.xml"); } XmlElement root = doc.DocumentElement; foreach (XmlElement item in root.ChildNodes) { string codeTxt = string.Empty; string nameTxt = string.Empty; if (item.Name == "CurrVersion") { versionValue = item.ChildNodes[0].Value; break; } } } catch (Exception err) { LogHelper.WriteWarnLog("Get version failed:" + err.Message); versionValue = Properties.Settings.Default.app_version; } competent_organization.Content = Properties.Settings.Default.competent_organization; province.Content = Properties.Settings.Default.province; app_type.Content = Properties.Settings.Default.app_type; app_name.Content = Properties.Settings.Default.app_name + "V" + versionValue; support_company.Content = Properties.Settings.Default.support_company; support_tel.Content = Properties.Settings.Default.support_tel; RESTClient.REST_HOST = Properties.Settings.Default.rest_host; if (!Directory.Exists(CommDef.ApplicationDataPath)) { Directory.CreateDirectory(CommDef.ApplicationDataPath); } string computerInfo = ComputerInfo.GetComputerInfo(); string encryptComputer = new EncryptionHelper().EncryptString(computerInfo); EncryptionHelper help = new EncryptionHelper(EncryptionKeyEnum.KeyB); string md5String = help.GetMD5String(encryptComputer); string registInfo = help.EncryptString(md5String); //判断是否已经运行 Process selfProcess = Process.GetCurrentProcess(); Process[] allProcess = Process.GetProcessesByName("SignInApp"); foreach (Process item in allProcess) { if (item.Id != selfProcess.Id) { item.Kill(); } } if (RegistFileHelper.ExistRegistInfofile() == true) { string inputRegist = RegistFileHelper.ReadRegistFile(); if (registInfo == inputRegist) { if (File.Exists(CONF_FILE_NAME) == false) { FileStream fs = new FileStream(CONF_FILE_NAME, FileMode.CreateNew); if (fs != null) { fs.Close(); } return; } string userName = ""; string password = ""; string isRemember = ""; bool ret = GetConfInfo(ref userName, ref password, ref isRemember); if (ret) { if (userName != "") { account.Text = userName; this.account.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0x00, 0x00, 0x00)); } if (isRemember == "true") { this.password.Password = password; this.remainFlag.IsChecked = true; } } return; } } RegistWindow RegistWindowPage = new RegistWindow(); RegistWindowPage.Show(); this.Close(); }