Esempio n. 1
0
        /// <summary>
        /// 验证用户
        /// </summary>
        private bool CheckUser()
        {
            ClientServer _client = new ClientServer();

            _client.StartConn();

            MessageHead head = new MessageHead((int)KeywordMessageType.User, 0, 1);

            byte[]     bodyBytes = Service.GetBodyBytes(password, Service.DictVersion, Service.ComputerMac);
            MessageBag bag       = new MessageBag(head, bodyBytes);

            _client.SendMessage(bag);

            MessageBag recBag = _client.ReceiveMessage();

            if (recBag == null)
            {
                Debug.Fail("有错");
            }

            string returnVal = _client.AnalyzeResponeMessage(recBag);

            _client.CloseConn();

            if (string.Compare(returnVal, "true") != 0)
            {
                errorInfo = returnVal;
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新词库
        /// </summary>
        public void UpdateWord()
        {
            ClientServer _client = new ClientServer();

            _client.StartConn();

            MessageHead head = new MessageHead((int)KeywordMessageType.Upload, 0, 1);

            byte[]     bodyBytes = Service.GetBodyBytes(Service.SessionId, Service.DictVersion, Service.ComputerMac);
            MessageBag bag       = new MessageBag(head, bodyBytes);

            _client.SendMessage(bag);

            MessageBag recBag = _client.ReceiveMessage();

            string returnVal = _client.AnalyzeResponeMessage(recBag);

            if (string.Compare(returnVal, "versionSameOfSuccess") == 0)
            {
                //验证成功,版本一样,可上传
                MessageHead head2     = new MessageHead((int)KeywordMessageType.Upload, 0, 2);
                string      updateCmd = WordsManager.GetUpdateCmd();
                byte[]      bytes     = Encoding.UTF8.GetBytes(updateCmd);
                MessageBag  bag2      = new MessageBag(head2, bytes);

                _client.SendMessage(bag2);

                MessageBag recBag2 = _client.ReceiveMessage();

                string recVal = _client.AnalyzeResponeMessage(recBag2);


                if (string.Compare(recVal, "true") != 0)
                {
                    Debug.Fail("更新失败!");
                }
                else
                {
                    MessageBox.Show("更新成功!");
                    KeywordClear();
                }
            }
            else if (string.Compare(returnVal, "versionDifferentOfSuccess") == 0)
            {
                //验证成功,版本不一样,不可上传  需更新本地词库并显示
                WordsManager man = new WordsManager(this);
                man.ShowNewWordsForm();
            }
            else
            {
                if (!string.IsNullOrEmpty(returnVal))
                {
                    MessageBox.Show(returnVal);
                }
            }

            _client.CloseConn();
        }
Esempio n. 3
0
        /// <summary>
        /// 更新本地词库
        /// </summary>
        private void UpdateLocalWord()
        {
            ClientServer _client = new ClientServer();

            _client.StartConn();

            MessageHead head = new MessageHead((int)KeywordMessageType.Update, 0, 1);

            byte[]     bodyBytes = Service.GetBodyBytes(Service.SessionId, Service.DictVersion, Service.ComputerMac);
            MessageBag bag       = new MessageBag(head, bodyBytes);

            _client.SendMessage(bag);

            MessageBag recBag = _client.ReceiveMessage();

            string returnVal = _client.AnalyzeResponeMessage(recBag);

            _client.CloseConn();

            WordsManager.UpdateLocalWord();
        }