// 负责与服务器的具体连接
        private void CommunicateWithServer()
        {
            try
            {
                SyncClient.SendBytes(FileHelper.getBytesOfString(GenerateSearchString()));

                _response = SyncClient.ReceiveString();
            }
            catch (Exception)
            {
                _popupWindow = new PopupWindow("无法连接到管理服务器", 1000);
                _popupWindow.Show();

                // TODO 怎么在这里关闭MainWindow 回到LoginWindow呢
                // MainWindow.ReturnToLogin();
                return;
            }

            try
            {
                // 从服务器得到数据并存储到_historyList
                ParseRepsonseFromServer(_response);
            }
            catch (Exception)
            {
                _popupWindow = new PopupWindow("从管理服务器获取数据错误", 1000);
                _popupWindow.Show();

                // TODO 怎么在这里关闭MainWindow 回到LoginWindow呢
                // MainWindow.ReturnToLogin();
                return;
            }
        }
        private void Login_click(object sender, RoutedEventArgs e)
        {
            //获取用户名密码
            string user    = NameTextBox.Text;
            string pass    = FileHelper.CalcStringMD5(PasswordBox.Password);
            string userMsg = "user/username:"******"&password:"******"failure")
                {
                    popupWindow = new PopupWindow("用户名密码不正确", 1000);
                    popupWindow.Show();
                    return;
                }
                else if (response != "" && response != "success")
                {
                    MainWindow mainWindow = new MainWindow(response);
                    mainWindow.Show();
                    Close();
                }
            }
            catch (Exception)
            {
                popupWindow = new PopupWindow("无法连接到管理服务器", 1000);
                popupWindow.Show();

                LoginWindow loginWindow = new LoginWindow();
                loginWindow.Show();
                Close();
            }
        }
        // 连接服务器 发送公钥
        private void init()
        {
            // 从配置文件里读取管理服务器的地址和端口号
            // TODO 之后应该是先连接归属服务器 在连接管理服务器
            serverAddr = FileHelper.GetValueFromConf("client.conf", "homeserveraddr");
            serverPort = int.Parse(FileHelper.GetValueFromConf("client.conf", "homeserverport"));

            try
            {
                SyncClient.StartClient(serverAddr, serverPort);
            }
            catch (Exception)
            {
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    popupWindow = new PopupWindow("无法连接到管理服务器", 1000);
                    popupWindow.Show();
                }));
            }

            //生成key pair
            // keyPair = RSAHelper.GetRASKey();
        }
        // 上传文件按钮点击事件
        private void Upload_Click(object sender, RoutedEventArgs e)
        {
            // 收集填写的数据
            string person = PersonBox.Text;
            string type   = TypeBox.Text;

            string version = VersionBox.Text;

            Console.WriteLine(version);

            string desc      = DescBox.Text;
            string file1Name = File1NameBox.Text;
            string file1Size = file1ByteSize.ToString();
            string file2Size = file2ByteSize.ToString();
            string file1Hash = File1HashBox.Text;
            string file2Name = File2NameBox.Text;
            string file2Hash = File2HashBox.Text;

            // 校验数据填写是否完整
            if (person == "" || type == "" || version == "" || desc == "" || file1Name == "" || file1Size == "" || file1Hash == "" || file2Name == "" || file2Size == "" || file2Hash == "")
            {
                popupWindow = new PopupWindow("请填写完整数据", 1000);
                popupWindow.Show();
                return;
            }

            // 发送文件信息-----------------------------------------------------
            string fileInfoMsg = "fileInfo/person:" + person + "&type:" + type + "&version:" + version + "&desc:" + desc + "&file1Name:"
                                 + file1Name + "&file1Size:" + file1Size + "&file1Hash:" + file1Hash + "&file2Name:" + file2Name + "&file2Size:" + file2Size + "&file2Hash:" + file2Hash;

            try
            {
                SyncClient.SendBytes(FileHelper.getBytesOfString(fileInfoMsg));

                response = SyncClient.ReceiveString();
            }
            catch (Exception)
            {
                popupWindow = new PopupWindow("无法连接到管理服务器", 1000);
                popupWindow.Show();
                ReturnToLogin();
                return;
            }

            if (response == "exist")
            {
                popupWindow = new PopupWindow("数据版本已经存在", 1000);
                popupWindow.Show();
                return;
            }
            else if (response != "success")
            {
                popupWindow = new PopupWindow("文件信息上传失败", 1000);
                popupWindow.Show();
                return;
            }
            else
            {
                popupWindow = new PopupWindow("文件信息上传完毕", 1000);
                popupWindow.Show();
            }


            // 上传文件一-------------------------------------------------------
            try
            {
                SyncClient.SendBytes(FileHelper.getBytesOfStringAndFile("file1/content:", file1FullName));
                response = SyncClient.ReceiveString();
            }
            catch (Exception)
            {
                popupWindow = new PopupWindow("无法连接到管理服务器", 1000);
                popupWindow.Show();
                ReturnToLogin();
                return;
            }

            if (response != "success")
            {
                popupWindow = new PopupWindow("文件1上传失败", 1000);
                popupWindow.Show();
                return;
            }
            else
            {
                popupWindow = new PopupWindow("文件1上传完毕", 1000);
                popupWindow.Show();
            }

            // 上传文件二-------------------------------------------------------
            try
            {
                SyncClient.SendBytes(FileHelper.getBytesOfStringAndFile("file2/content:", file2FullName));
                response = SyncClient.ReceiveString();
            }
            catch (Exception)
            {
                popupWindow = new PopupWindow("无法连接到管理服务器", 1000);
                popupWindow.Show();
                ReturnToLogin();
                return;
            }

            if (response != "success")
            {
                popupWindow = new PopupWindow("文件2上传失败", 1000);
                popupWindow.Show();
                return;
            }
            else
            {
                popupWindow = new PopupWindow("文件2上传完毕", 1000);
                popupWindow.Show();
            }
        }