コード例 #1
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            DictionarySearchPublicRequest request = new DictionarySearchPublicRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");
            request.NameCondition   = textBoxCondition.Text.Trim();

            List <DictionarySearchPublicDto> dictionaries = _noodleTokenClient.DoPost(request);

            _dtDictionary = DataTableHelper.ToDataTable <DictionarySearchPublicDto>(dictionaries);

            dataGridViewDictionary.DataSource = _dtDictionary;
        }
コード例 #2
0
        private void RefreshData()
        {
            ReviewVocabularyListRequest request = new ReviewVocabularyListRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");
            request.PageNum         = 1;
            request.PageSize        = 50;
            List <ReviewVocabularyDto> ReviewVocabularys = _noodleTokenClient.DoPost(request);

            _dtVocabulary = DataTableHelper.ToDataTable <ReviewVocabularyDto>(ReviewVocabularys);

            dataGridViewVocabulary.DataSource = _dtVocabulary;

            textBoxNumber.Text = ReviewVocabularys.Count.ToString();
        }
コード例 #3
0
ファイル: FormLogin.cs プロジェクト: wanghy0411/recite-words
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            labelInfo.Text = "";

            NoodleTokenClient noodleTokenClient = new NoodleTokenClient(Config.Url, null, 0);

            UserPasswordCheckRequest userPasswordCheckRequest = new UserPasswordCheckRequest();

            userPasswordCheckRequest.ClientRequestNo = Guid.NewGuid().ToString("N");
            userPasswordCheckRequest.Nick            = textBoxUser.Text;
            userPasswordCheckRequest.Password        = textBoxPassword.Text;
            long userId = noodleTokenClient.DoPost(userPasswordCheckRequest);

            noodleTokenClient = new NoodleTokenClient(Config.Url, null, userId);
            UserInfoQueryRequest userInfoQueryRequest = new UserInfoQueryRequest();

            userInfoQueryRequest.ClientRequestNo = Guid.NewGuid().ToString("N");
            UserInfoQueryDto userInfoQueryDto = noodleTokenClient.DoPost(userInfoQueryRequest);

            //记录登录用户信息
            initUserInfo(userInfoQueryDto);

            //关闭登录窗口
            this.DialogResult = DialogResult.OK;
        }
コード例 #4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            //填充Dictionary对象
            Dictionary dictionary = new Dictionary();
            DataRow    dr;

            if (_currentDictionaryId == 0)
            {
                NoodleIdGeneratorRequest noodleIdGeneratorRequest = new NoodleIdGeneratorRequest();
                noodleIdGeneratorRequest.ClientRequestNo = Guid.NewGuid().ToString("N");
                List <long> ids = _noodleTokenClient.DoPost(noodleIdGeneratorRequest);
                _currentDictionaryId = ids[0];

                dr               = _dtDictionary.NewRow();
                dr["Id"]         = _currentDictionaryId;
                dr["PublicFlag"] = UserInfo.AdminFlag > 0 ? "Y" : "N";
            }
            else
            {
                DataRow[] drs = _dtDictionary.Select("Id = " + _currentDictionaryId);
                dr = drs[0];
            }

            dr["Name"]      = textBoxDictionary.Text;
            dr["Publisher"] = textBoxPublisher.Text;
            dr["ValidFlag"] = checkBoxValidFlag.Checked ? "Y" : "N";
            if (dr.RowState.Equals(DataRowState.Detached))
            {
                _dtDictionary.Rows.Add(dr);
            }
            _dtDictionary.AcceptChanges();

            dictionary.Id         = (long)dr["Id"];
            dictionary.Name       = textBoxDictionary.Text;
            dictionary.Publisher  = textBoxPublisher.Text;
            dictionary.ValidFlag  = (string)dr["ValidFlag"];
            dictionary.PublicFlag = (string)dr["PublicFlag"];

            DictionarySaveRequest request = new DictionarySaveRequest();

            request.Dictionary = dictionary;
            _noodleTokenClient.DoPost(request);
        }
コード例 #5
0
ファイル: FormWords.cs プロジェクト: wanghy0411/recite-words
        private void comboBoxDictionary_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxDictionary.SelectedIndex < 0)
            {
                return;
            }
            textBoxSpelling.Text      = "";
            textBoxPronunciation.Text = "";
            textBoxExplanation.Text   = "";

            DataRow dr = _dtDictionary.Rows[comboBoxDictionary.SelectedIndex];

            _currentDictionaryId = (long)dr["Id"];
            if (UserInfo.AdminFlag <= 0 && "Y".Equals(dr["PublicFlag"].ToString()))
            {
                textBoxSpelling.ReadOnly      = true;
                textBoxPronunciation.ReadOnly = true;
                textBoxExplanation.ReadOnly   = true;
            }
            else
            {
                textBoxSpelling.ReadOnly      = false;
                textBoxPronunciation.ReadOnly = false;
                textBoxExplanation.ReadOnly   = false;
            }

            WordsListRequest request = new WordsListRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");
            request.DictionaryId    = _currentDictionaryId;
            request.PageNum         = 1;
            request.PageSize        = pageSize;

            List <Words> wordsList = _noodleTokenClient.DoPost(request);

            wordsList.Sort((x, y) => x.Id.CompareTo(y.Id));
            _dtWords = DataTableHelper.ToDataTable <Words>(wordsList);

            dataGridViewWords.DataSource = _dtWords;
        }
コード例 #6
0
        private void FormVocabulary_Load(object sender, EventArgs e)
        {
            _noodleTokenClient = new NoodleTokenClient(Config.Url, UserInfo.Token, UserInfo.Id);

            DictionaryListRequest request = new DictionaryListRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");

            List <Dictionary> dictionaries = _noodleTokenClient.DoPost(request);

            _dtDictionary = DataTableHelper.ToDataTable <Dictionary>(dictionaries);

            dataGridViewDictionary.DataSource = _dtDictionary;
        }
コード例 #7
0
ファイル: FormRecite.cs プロジェクト: wanghy0411/recite-words
        private void refreshData()
        {
            ReciteListRequest request = new ReciteListRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");

            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);

            request.StartTimestamp = Convert.ToInt64(ts.TotalMilliseconds) - 60L * 24 * 60 * 60 * 1000;

            List <Recite> recites = _noodleTokenClient.DoPost(request);

            recites.Sort((x, y) => y.ReciteTime.CompareTo(x.ReciteTime));

            foreach (Recite recite in recites)
            {
                recite.ReciteDateTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(recite.ReciteTime);
            }
            _dtRecite = DataTableHelper.ToDataTable <Recite>(recites);


            dataGridViewRecite.DataSource = _dtRecite;
        }
コード例 #8
0
ファイル: FormWords.cs プロジェクト: wanghy0411/recite-words
        private void FormWords_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;

            _noodleTokenClient = new NoodleTokenClient(Config.Url, UserInfo.Token, UserInfo.Id);

            DictionaryListRequest request = new DictionaryListRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");

            List <Dictionary> dictionaries = _noodleTokenClient.DoPost(request);

            _dtDictionary = DataTableHelper.ToDataTable <Dictionary>(dictionaries);

            comboBoxDictionary.DataSource    = _dtDictionary;
            comboBoxDictionary.DisplayMember = "Name";
        }
コード例 #9
0
        private void FormExerciseScore_Load(object sender, EventArgs e)
        {
            _noodleTokenClient = new NoodleTokenClient(Config.Url, UserInfo.Token, UserInfo.Id);

            ExerciseWordsRequest request = new ExerciseWordsRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");
            request.ExerciseId      = _exerciseId;
            List <ExerciseWordsDto> exerciseWordsList = _noodleTokenClient.DoPost(request);

            foreach (ExerciseWordsDto exerciseWordsDto in exerciseWordsList)
            {
                exerciseWordsDto.Correct = 1;
            }
            _dtExerciseWords = DataTableHelper.ToDataTable <ExerciseWordsDto>(exerciseWordsList);

            dataGridViewWords.DataSource = _dtExerciseWords;
        }
コード例 #10
0
        private void buttonConfirm_Click(object sender, EventArgs e)
        {
            ExerciseScoreRequest request = new ExerciseScoreRequest();

            request.ClientRequestNo = Guid.NewGuid().ToString("N");
            request.Id = _exerciseId;

            List <ExerciseWords> exerciseWordsList = new List <ExerciseWords>();

            foreach (DataRow dr in _dtExerciseWords.Rows)
            {
                ExerciseWords exerciseWords = new ExerciseWords();
                exerciseWords.Id      = (long)dr["Id"];
                exerciseWords.Correct = (int)dr["Correct"];

                exerciseWordsList.Add(exerciseWords);
            }
            request.ExerciseWords = exerciseWordsList;
            _noodleTokenClient.DoPost(request);

            MessageBox.Show("保存成功!", "提示信息");

            Refresh();
        }
コード例 #11
0
        private void buttonConfirm_Click(object sender, EventArgs e)
        {
            if (textBoxMemoryLine.Text == null || textBoxMemoryLine.Text.Trim().Length == 0)
            {
                textBoxMemoryLine.Focus();
                throw new ArgumentException("请输入正确的记忆曲线节点信息");
            }
            if (textBoxNumber.Text == null || textBoxNumber.Text.Trim().Length == 0)
            {
                textBoxNumber.Focus();
                throw new ArgumentException("请输入正确的单词数量");
            }

            int wordsNumber = 0;

            if (!int.TryParse(textBoxNumber.Text.Trim(), out wordsNumber))
            {
                textBoxNumber.Focus();
                throw new ArgumentException("请输入正确的单词数量");
            }

            //解析记忆曲线
            string[] memoryLineArray = textBoxMemoryLine.Text.Trim().Split(',');
            if (memoryLineArray.Length < 4)
            {
                textBoxMemoryLine.Focus();
                throw new ArgumentException("请输入正确的记忆曲线节点信息");
            }

            int schedule1 = 0;

            if (!int.TryParse(memoryLineArray[0], out schedule1))
            {
                textBoxMemoryLine.Focus();
                throw new ArgumentException("请输入正确的记忆曲线节点信息");
            }

            int schedule2 = 0;

            if (!int.TryParse(memoryLineArray[1], out schedule2))
            {
                textBoxMemoryLine.Focus();
                throw new ArgumentException("请输入正确的记忆曲线节点信息");
            }

            int schedule3 = 0;

            if (!int.TryParse(memoryLineArray[2], out schedule3))
            {
                textBoxMemoryLine.Focus();
                throw new ArgumentException("请输入正确的记忆曲线节点信息");
            }

            int schedule4 = 0;

            if (!int.TryParse(memoryLineArray[3], out schedule4))
            {
                textBoxMemoryLine.Focus();
                throw new ArgumentException("请输入正确的记忆曲线节点信息");
            }

            //取唯一id
            NoodleIdGeneratorRequest noodleIdGeneratorRequest = new NoodleIdGeneratorRequest();

            noodleIdGeneratorRequest.ClientRequestNo = Guid.NewGuid().ToString("N");
            List <long> ids = _noodleTokenClient.DoPost(noodleIdGeneratorRequest);

            //生成背诵记录
            ReciteAddRequest reciteAddRequest = new ReciteAddRequest();

            reciteAddRequest.ClientRequestNo = Guid.NewGuid().ToString("N");
            reciteAddRequest.Id          = ids[0];
            reciteAddRequest.Comment     = textBoxComment.Text;
            reciteAddRequest.WordsNumber = wordsNumber;
            reciteAddRequest.Schedule1   = schedule1;
            reciteAddRequest.Schedule2   = schedule4;
            reciteAddRequest.Schedule3   = schedule3;
            reciteAddRequest.Schedule4   = schedule4;
            _noodleTokenClient.DoPost(reciteAddRequest);

            //查询生成的结果
            ReciteWordsRequest reciteWordsRequest = new ReciteWordsRequest();

            reciteWordsRequest.ClientRequestNo = Guid.NewGuid().ToString("N");
            reciteWordsRequest.ReciteId        = ids[0];
            List <ReciteWordsDto> reciteWordsDtos = _noodleTokenClient.DoPost(reciteWordsRequest);

            DataTable dtReciteWords = DataTableHelper.ToDataTable <ReciteWordsDto>(reciteWordsDtos);

            dataGridViewReciteWords.DataSource = dtReciteWords;
        }