예제 #1
0
        private async void tmr_rquest_Tick(object sender, EventArgs e)
        {
            // request取得先URL
            string get_url = request;
            // response登録先URL
            string  post_url = resultbox;
            bool    status   = false;
            dynamic json_obj = "";
            string  error    = "";
            // add_user取得
            string request_string = http_Request_CTRL.http_get(get_url, out status);

            // 処理ステータス確認
            if (!status)
            {
                return;
            }
            // 取得情報チェックと処理結果生成
            json_obj = Json_request_action.request_motion(request_string, out status, out error);

            if (status)
            {
                if (json_obj != null)
                {
                    // 処理結果登録
                    await http_Request_CTRL.http_post(json_obj.ToString(), post_url);
                }
            }
        }
예제 #2
0
        private void btn_readFile_Click(object sender, EventArgs e)
        {
            // ファイル読み込み
            string readed_file = File_CTRL.file_Read(txt_readFile.Text);
            // 各種初期化
            dynamic json_obj          = "";
            bool    status            = false;
            string  error             = "";
            string  out_put_file_name = "";

            if (readed_file.Length > 0)
            {
                if (rdo_add_user.Checked)
                {
                    json_obj          = Json_add_user_action.add_user_motion(readed_file, out status, out error);
                    out_put_file_name = "end_init.json";
                }

                if (rdo_request.Checked)
                {
                    json_obj          = Json_request_action.request_motion(readed_file, out status, out error);
                    out_put_file_name = "Response.json";
                }

                if (json_obj != null)
                {
                    string file_path = System.IO.Path.GetDirectoryName(txt_readFile.Text) + "\\" + out_put_file_name;

                    File_CTRL.file_OverWrite(json_obj.ToString(), file_path);
                    //MessageBox.Show("結果ファイル出力完了!");
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 監視用タイマーのタイマーイベントです。
        /// キューイングされているjsonから処理上に付加されたタグを除去してリクエスト時の状態に戻します。
        /// その上でリクエストの受信時の動作を呼び出して、再実行します。
        /// 戻りのPOSTリクエストをコメントにしてるのでasyncが警告となっています。
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private async void OnTimerEvent(object source, ElapsedEventArgs e)
        {
            int get_cnt = Program.queue_list.Count;

            if (get_cnt > 0)
            {
                dynamic retry_obj = null;
                retry_obj = Json_Util.reParse(Program.queue_list);
                Program.queue_list.RemoveRange(0, get_cnt);

                foreach (dynamic retry in (object[])retry_obj)
                {
                    bool   status = false;
                    string error  = "";
                    // response登録先URL
                    string post_url = "https://systrade-cloud.com/server/resultbox.php";

                    //キューに入っている内容をリクエスト時の状態に再整形
                    if (Json_Util.get_Value(retry, "Check_Status") != "")
                    {
                        retry.Delete("Check_Status");
                    }
                    if (Json_Util.get_Value(retry, "EA_Status") != "")
                    {
                        retry.Delete("EA_Status");
                    }

                    dynamic json_obj = Json_request_action.request_motion("[" + retry.ToString() + "]", out status, out error);

                    if (status)
                    {
                        if (json_obj != null)
                        {
                            // 処理結果登録
                            await http_Request_CTRL.http_post(json_obj.ToString(), post_url);

                            // debug用
                            //string file_path = "C:\\Users\\f464\\Desktop\\Response.json";
                            //File_CTRL.file_OverWrite(json_obj.ToString(), file_path);
                        }
                    }
                }
            }
        }
예제 #4
0
        private void btn_http_get_Click(object sender, EventArgs e)
        {
            if (!System.IO.Directory.Exists(txt_out_put.Text))
            {
                MessageBox.Show("指定されたフォルダが見当たりません!デスクトップの所定フォルダに強制設定します!");
                // パスをend_initとend_ea_add用のフォルダにします
                string output_path = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                if (rdo_url_add_user.Checked)
                {
                    // ユーザー追加
                    output_path += @"\end_init";
                }
                else if (rdo_url_add_EA.Checked)
                {
                    // EA追加
                    output_path += @"\end_ea_add";
                }

                txt_out_put.Text = output_path;
            }
            // URL用文字列
            string request_machine = "";
            string order_url       = "";
            string add_user        = "";
            string add_EA          = "";

            if (txt_get_url.Text == "")
            {
                add_user        = add_user_url;
                request_machine = request;
                add_EA          = add_EA_url;
            }
            else
            {
                add_user        = txt_get_url.Text;
                request_machine = txt_get_url.Text;
                add_EA          = txt_get_url.Text;
            }

            // ラジオボタンはadd_userだけだが取り敢えずrequest_machineも分岐してみる
            if (rdo_url_add_user.Checked)
            {
                // ユーザー追加
                order_url = add_user;
            }
            else if (rdo_url_request.Checked)
            {
                // 操作リクエスト
                order_url = request_machine;
            }
            else if (rdo_url_add_EA.Checked)
            {
                // EA追加
                order_url = add_EA;
            }

            dynamic json_obj = "";

            bool   status = false;
            string error  = "";

            string result = http_Request_CTRL.http_get(order_url, out status);

            if (status)
            {
                string out_put_file_name = "";

                if (rdo_url_add_user.Checked || rdo_url_add_EA.Checked)
                {
                    add_mt4_folder(result);

                    /*
                     * json_obj = Json_add_user_action.add_user_motion(result, out status, out error);
                     *
                     * if (json_obj == null)
                     * {
                     *  MessageBox.Show("対象データが取得できませんでした!con_setting.txtの記載順でreal_server_urlが2行目ですか?");
                     *  return;
                     * }
                     * /*
                     * //jsonを1レコード単位に分解してファイル出力する
                     * foreach (dynamic read_user in (object[])json_obj)
                     * {
                     *   string created_user = read_user.Stc_ID + "_"
                     + read_user.MT4_Server + "_"
                     + read_user.MT4_ID + "_"
                     + read_user.Ccy + "_"
                     + read_user.Time_Period + "_"
                     + read_user.EA_ID;
                     +
                     +  System.Console.WriteLine(created_user);
                     +
                     +  if (rdo_url_add_user.Checked)
                     +  {
                     +      // ユーザー追加
                     +      out_put_file_name = "ei_" + created_user + ".json";
                     +  }
                     +  else if (rdo_url_add_EA.Checked)
                     +  {
                     +      // EA追加
                     +      out_put_file_name = "ea_" + created_user + ".json";
                     +  }
                     +
                     +  if (read_user != null)
                     +  {
                     +      File_CTRL.file_OverWrite("[" + read_user.ToString() + "]", txt_out_put.Text + "\\" + out_put_file_name);
                     +
                     +  }
                     +
                     + }
                     */
                    /*
                     * // 登録結果としてインストールフォルダのログを出力して保管
                     * File_CTRL.get_folders();
                     *
                     * MessageBox.Show("結果ファイル出力完了!");
                     *
                     */
                }
                else
                {
                    json_obj          = Json_request_action.request_motion(result, out status, out error);
                    out_put_file_name = "Response.json";

                    if (json_obj != null)
                    {
                        File_CTRL.file_OverWrite(json_obj.ToString(), txt_out_put.Text + "\\" + out_put_file_name);
                        MessageBox.Show("結果ファイル出力完了!");
                    }
                }
            }
            else
            {
                MessageBox.Show(result);
            }
        }
예제 #5
0
        private async void btn_http_post_Click(object sender, EventArgs e)
        {
            //if (txt_word.Text != "")
            //{
            //    if (!System.IO.File.Exists(txt_word.Text))
            //    {
            //        MessageBox.Show("ファイルが見つかりません!", "ファイル存在チェック", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //        return;
            //    }
            //}


            string request_string = "";
            bool   status         = false;

            if (txt_word.Text != "")
            {
                // ファイル読み込み
                request_string = File_CTRL.file_Read(txt_word.Text);
            }
            else
            {
                string get_url = "";

                if (rdo_get_url_add_user.Checked)
                {
                    get_url = add_user_url;
                }
                else
                {
                    get_url = request;
                }

                request_string = http_Request_CTRL.http_get(get_url, out status);
                if (!status)
                {
                    MessageBox.Show(request_string);
                    return;
                }
            }

            string post_url = "";

            if (rdo_stc.Checked)
            {
                if (rdo_get_url_add_user.Checked)
                {
                    post_url = upload;
                }
                else
                {
                    post_url = resultbox;
                }
            }
            if (rdo_kakuninn.Checked)
            {
                post_url = "http://www.kojikoji.net/";
            }
            if (rdo_set_post_url.Checked)
            {
                post_url = txt_post_url.Text;
            }

            if (post_url == "")
            {
                MessageBox.Show("post url が未指定です!", "post対象チェック", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // 各種初期化
            dynamic json_obj = "";
            //bool status = false;
            string error = "";

            if (rdo_get_url_add_user.Checked)
            {
                json_obj = Json_add_user_action.add_user_motion(request_string, out status, out error);
            }
            else
            {
                json_obj = Json_request_action.request_motion(request_string, out status, out error);
            }

            if (status)
            {
                if (json_obj != null)
                {
                    //Console.WriteLine("呼出し:" + MT4_CTLR.operation(json_obj));

                    MessageBox.Show("Http Post開始!");
                    string result = await http_Request_CTRL.http_post(json_obj.ToString(), post_url);

                    string file_path = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\結果.html";
                    File_CTRL.file_OverWrite(result, file_path);
                    MessageBox.Show("Http Post終了!結果.htmlが生成されました");
                }
                else
                {
                    MessageBox.Show("postするべきデータが作れませんでした");
                }
            }
        }