Ejemplo n.º 1
0
        /// <summary>
        /// ボタン押下でPost
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnPost_Click(object sender, EventArgs e)
        {
            string anspath = _answerDirectoryPath + "ans" + _problemNum + ".txt";

            if (postConfirm())
            {
                await Poster.Post(_submitUrl, anspath);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 問題DL, 解答, 提出をすべて実行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnAllRun_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                //HttpServer.Run(_localServerAddress, _score);
                // 問題DL
                updateServerSettings();
                this._localServerAddress = "http://" + txtLocalServerAddress.Text + "/";  // ローカルサーバアドレス設定

                _workingDirectoryPath = createWorkingDirectory();

                String problemPath = downloadProblem();

                if (problemPath == null)
                {
                    updateLogStatus("問題取得に失敗しました");
                    return;
                }
                else
                {
                    updateLogStatus("問題ファイルのダウンロード完了");
                }


                // sataticクラスの初期化
                Poster.Init(_localServerAddress, _token);

                // Solver
                _answerDirectoryPath = createAnswerDirectory();

                updateLogStatus("Solve開始");

                string args = _workingDirectoryPath + "quest" + _problemNum + ".txt " + _answerDirectoryPath + "ans" + _problemNum + ".txt " + _solverParams;

                string res = await runSolver(_solverPath, args);

                updateLogStatus("Solve終了. スコア : " + int.Parse(res) % 257);
                _score = int.Parse(res.ToString());

                string anspath = _answerDirectoryPath + "ans" + _problemNum + ".txt";

                // Post
                HttpServer.PostScore(_score);

                await Poster.Post(_localServerAddress, anspath);
            }
            else
            {
                updateServerSettings();

                _workingDirectoryPath = createWorkingDirectory();

                String problemPath = downloadProblem();

                if (problemPath == null)
                {
                    updateLogStatus("問題取得に失敗しました");
                    return;
                }
                else
                {
                    updateLogStatus("問題ファイルのダウンロード完了");
                }

                // staticクラスの初期化
                Poster.Init(_submitUrl, _token);

                _answerDirectoryPath = createAnswerDirectory();

                string args = _workingDirectoryPath + "quest" + _problemNum + ".txt " + _answerDirectoryPath + "ans" + _problemNum + ".txt " + _solverParams;
                string res  = await runSolver(_solverPath, args);

                _score = int.Parse(res);  // score(だいたい4桁のやつ)をintに

                if (_maxScore > _score)
                {
                    _maxScore     = _score;
                    txtScore.Text = res;
                }

                updateLogStatus("Solve終了. スコア : " + (int.Parse(res) / 257));

                updateLogStatus("[Core : サーバ不使用] " + res.ToString());

                string anspath = _answerDirectoryPath + "ans" + _problemNum + ".txt";

                if (postConfirm())
                {
                    await Poster.Post(_submitUrl, anspath);
                }
            }
        }