public void callWordList() { HttpWorker httpWorker = new HttpWorker(HttpWorker.wordList, httpResponse); JSONObject form = new JSONObject(); httpWorker.setData(form); httpWorker.httpWorker(); }
private void background_Finish(object sender, RunWorkerCompletedEventArgs e) { JSONObject values = new JSONObject(reponse); JSONObject data = values.getJSONObject("data"); if (aCb != null) aCb(data); stopWorker(); }
/*GET*/ public JSONObject getJSONObject(string key) { string dataDiry = resource[key].ToString(); Dictionary<string, object> data = JsonConvert.DeserializeObject<Dictionary<string, object>>(dataDiry); JSONObject result = new JSONObject(data); return result; }
private void httpResponse(JSONObject response) { WaitDialog.close(); int error_code = response.getInt("error_code"); if (error_code == 0) { FloderUtils folder = new FloderUtils(outPath); JSONObject value = response.getJSONObject("value"); string file_path = folder.createDeviceFolder(value.getString("deviceAddress"), orderID); BrainChart brainCharts = new BrainChart(file_path,true,false); //brainCharts.Location = new Point(350, 45); //brainCharts.TopLevel = false; //this.Controls.Add(brainCharts); brainCharts.Show(); brainCharts.Location = new Point(0, 0); resultList.Clear(); JSONArray list = response.getJSONArray("list"); for (int i = 0; i < list.Count; i++) { JSONObject item = list.getJSONObject(i); resultList.Add(item); } reloadList(); setValue(value); } else { string message = response.getString("message"); MessageBox.Show(message); } }
public WordManager(JSONObject word_item) { this.wordItem = word_item; this.definitionList = wordItem.getJSONArray("definitionList"); this.translateList = wordItem.getJSONArray("translateList"); this.exampleList = wordItem.getJSONArray("exampleList"); this.enWord = wordItem.getString("enWord"); this.Count = this.definitionList.Count; }
private void httpResponse(JSONObject response) { JSONArray list = response.getJSONArray("wordList"); for (int i = 0; i < list.Count; i++) { JSONObject item = list.getJSONObject(i); Console.WriteLine(item.toString()); WordManager manager = new WordManager(item); } }
private void getOrderView() { HttpWorker httpWorker = new HttpWorker(HttpWorker.orderView, httpResponse); JSONObject form = new JSONObject(); form.setString("orderID", orderID); form.setString("showTranslate", "true"); httpWorker.setData(form); httpWorker.httpWorker(); WaitDialog.show(); }
private void finishBtn_Click(object sender, EventArgs e) { DialogResult myResult = MessageBox.Show("確定答題完成", "正要交卷,確定已經上傳答案了嗎??", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if ( myResult == DialogResult.Yes) { HttpWorker httpWorker = new HttpWorker(HttpWorker.orderFinish, httpResponse); JSONObject form = new JSONObject(); form.setString("orderID", configManager.getOrderID()); httpWorker.setData(form); httpWorker.httpWorker(); WaitDialog.show(); } }
private void httpResponse(JSONObject response) { WaitDialog.close(); int error_code = response.getInt("error_code"); if (error_code == 0) { ChromeUtils.closeChrome(); this.Close(); OrderView view = new OrderView(configManager.getOrderID(),configManager.getPath()); view.Show(); } else { string message = response.getString("message"); MessageBox.Show(message); } }
private void getOrderList() { if (isClient) { FloderUtils floder = new FloderUtils(this.outPath); ArrayList pathes = floder.listAllOrder(); resultList = pathes; reloadList(); } else { HttpWorker httpWorker = new HttpWorker(HttpWorker.orderList, httpResponse); JSONObject form = new JSONObject(); form.setString("status", "4"); httpWorker.setData(form); httpWorker.httpWorker(); WaitDialog.show(); } }
private void stopTimer() { stopWorker(); time = 0; brainReceiver.stop(); if (!configManager.getIsTest()) { ChromeUtils.closeChrome(); this.Close(); ShowExDialog.show("第三步、測試單字", Properties.Resources.test); DoTest doTest = new DoTest(configManager); doTest.Show(); doTest.Location = new Point(0, 0); ChromeUtils.openChrome(ChromeUtils.testURL + configManager.getOrderID()); } else { WindowsMediaPlayer newMedia = new WindowsMediaPlayer(); newMedia.URL = @"sound.mp3"; newMedia.controls.play(); if (configManager.getIsClient()) { WriteFile writeFile = new WriteFile(this.runPath); writeFile.clientSave(configManager); this.Close(); BrainChart view = new BrainChart(this.runPath,false,true); view.Show(); } else { HttpWorker httpWorker = new HttpWorker(HttpWorker.orderFinish, httpResponse); JSONObject form = new JSONObject(); form.setString("orderID", configManager.getOrderID()); httpWorker.setData(form); httpWorker.httpWorker(); WaitDialog.show(); } } }
private void btnCheck_Click(object sender, EventArgs e) { if (outputText.Text.Length == 0) { FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); outputText.Text = path.SelectedPath; } if (outputText.Text.Length == 0) { MessageBox.Show("尚未選擇輸出路徑!"); return; } if (textTestTime.Text.Length == 0 || textUserName.Text.Length == 0 || textUserYearOld.Text.Length == 0 || textWordNum.Text.Length == 0) { MessageBox.Show("欄位都為必填!"); return; } ArrayList list = bluetooth_list.getResult(); if (list.Count == 0) { MessageBox.Show("尚未選擇Device!"); return; } ChromeUtils.closeChrome(); Boolean isclient = checkBoxClient.Checked; if (isclient) { BluetoothDeviceManager manager = (BluetoothDeviceManager)list[0]; string order_id = DateTime.Now.ToString("yyyyMMddHHmmss"); ConfigManager config_manager = new ConfigManager(order_id, outputText.Text, int.Parse(textTestTime.Text), manager, true, isclient, textUserName.Text, textUserYearOld.Text); MessageBox.Show("準備好了?確定後開始測試"); ArrayList formList = new ArrayList(); formList.Add(this); formList.Add(bluetooth_list); new Memory(config_manager,formList); } else { BluetoothDeviceManager manager = (BluetoothDeviceManager)list[0]; HttpWorker httpWorker = new HttpWorker(HttpWorker.orderCreate, httpResponse); JSONObject form = new JSONObject(); form.setString("deviceAddress", manager.getDeviceAddress()); form.setString("userName", textUserName.Text); form.setString("userYearOld", textUserYearOld.Text); form.setString("wordNum", textWordNum.Text); form.setString("testTime", textTestTime.Text); httpWorker.setData(form); httpWorker.httpWorker(); WaitDialog.show(); } }
private void setValue(JSONObject value) { textCreateTime.Text = value.getString("create_time"); textUserName.Text = value.getString("userName"); textUserYearOld.Text = value.getString("userYearOld"); textTestTime.Text = value.getString("testTime"); textWordNum.Text = value.getString("wordNum"); labelScore.Text = "共獲得:"+value.getString("testResult")+"分"; }
public void setData(JSONObject form) { this.requestForm = form; }
public JSONObject readClient() { JSONObject item = new JSONObject(); item.setString("path", runPath); string path = runPath + Client; if (File.Exists(path)) { StreamReader fSR = new StreamReader(path); string fLine; int index = 0; while ((fLine = fSR.ReadLine()) != null)/*讓使用者選擇第幾筆到第幾筆(1:512)*/ { if (index == 0) { item.setString("orderID", fLine); } else if (index == 1) { item.setString("userName", fLine); } else if (index == 2) { item.setString("userYearOld", fLine); } else if (index == 3) { item.setString("testTime", fLine); } else if (index == 4) { item.setString("deviceAddress", fLine); } index++; } fSR.Close(); } return item; }
private void httpResponse(JSONObject response) { WaitDialog.close(); int error_code = response.getInt("error_code"); if (error_code == 0) { resultList.Clear(); FloderUtils floder = new FloderUtils(this.outPath); ArrayList pathes = floder.listAllOrder(); resultList = pathes; JSONArray list = response.getJSONArray("list"); for (int i = 0; i < list.Count; i++) { JSONObject item = list.getJSONObject(i); resultList.Add(item); } reloadList(); } else { string message = response.getString("message"); MessageBox.Show(message); } }
private void httpResponse(JSONObject response) { WaitDialog.close(); int error_code = response.getInt("error_code"); if (error_code == 0) { Boolean isTest = radioTest.Checked; Boolean isclient = checkBoxClient.Checked; ArrayList list = bluetooth_list.getResult(); BluetoothDeviceManager manager = (BluetoothDeviceManager)list[0]; string order_id = response.getString("orderID"); ConfigManager config_manager = new ConfigManager(order_id, outputText.Text, int.Parse(textTestTime.Text), manager, isTest, isclient, textUserName.Text, textUserYearOld.Text); if (!config_manager.getIsTest()) { ShowExDialog.show("第一步、選擇單字", Properties.Resources.choose); string chooseUrl = ChromeUtils.chooseURL + order_id; ChromeUtils.openChrome(chooseUrl); Choose choose = new Choose(config_manager); choose.Show(); choose.Location = new Point(0, 0); this.WindowState = FormWindowState.Minimized; } else { MessageBox.Show("準備好了?確定後開始測試"); ArrayList formList = new ArrayList(); formList.Add(this); formList.Add(bluetooth_list); new Memory(config_manager, formList); } } else { string message = response.getString("message"); MessageBox.Show(message); } }