Ejemplo n.º 1
0
        private async void tmr_add_user_Tick(object sender, EventArgs e)
        {
            // add_user取得先URL
            string get_url = add_user_url;
            // end_init登録先URL
            string  post_url = upload;
            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_add_user_action.add_user_motion(request_string, out status, out error);

            if (status)
            {
                if (json_obj != null)
                {
                    // 処理結果登録
                    await http_Request_CTRL.http_post(json_obj.ToString(), post_url);
                }
            }
        }
Ejemplo n.º 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("結果ファイル出力完了!");
                }
            }
        }
Ejemplo n.º 3
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するべきデータが作れませんでした");
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 指定されたユーザー追加若しくはEA追加データを使ってインストールフォルダの準備を行う
        /// </summary>
        /// <param name="add_target">インストールフォルダ生成情報文字列add_user/add_EA</param>
        /// <returns></returns>
        private bool add_mt4_folder(string add_target)
        {
            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;
            string out_put_file_name = "";


            if (rdo_url_add_user.Checked || rdo_url_add_EA.Checked)
            {
                dynamic json_obj = "";
                bool    status   = false;
                string  error    = "";

                json_obj = Json_add_user_action.add_user_motion(add_target, out status, out error);

                if (json_obj == null)
                {
                    MessageBox.Show("対象データが取得できませんでした!\n\r対象を選択していますか?\n\rcon_setting.txtの記載順でreal_server_urlが2行目ですか?");
                    return(false);
                }
                //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("結果ファイル出力完了!");
            }

            return(true);
        }