private ResultWorkflows GetWorkflows(Token token) { //Token tempToken = new Token(); //tempToken.token = "208dbf9f968a432815a2b726ed49de0a669b5f27";//"a08074ead1a8f3b4ffa42895b28d02938f3aacbf"; GetWorkflowData data = new GetWorkflowData(); data.token = token.token; var param = HttpControl.ObjectToJson(data); var getResult = HttpControl.PostMoths(HttpControl.GetWorkflowCmd, param, Token); return((ResultWorkflows)getResult); }
private void TestButton_Click(object sender, EventArgs e) { String strPhone1 = this.mPhoneOneTextBox.Text; String strPhone2 = this.mPhoneTowTextBox.Text; String workflowName = this.mWorkflowComboBox.Text; if (String.IsNullOrEmpty(strPhone1) || strPhone1.Length < 6) { MessageBox.Show("请输入正确的电话号码1!"); return; } if (!String.IsNullOrEmpty(strPhone2)) { if (strPhone2.Length < 6) { MessageBox.Show("请输入正确的电话号码2!"); return; } } if (String.IsNullOrEmpty(workflowName)) { MessageBox.Show("请选择工作流程!"); return; } String workflowId = _dict[workflowName]; if (!String.IsNullOrEmpty(workflowId)) { TestWorkflow flow = new TestWorkflow(); flow.flow_id = workflowId; flow.numbers = strPhone1; if (!String.IsNullOrEmpty(strPhone2)) { flow.numbers += "," + strPhone2; } string param = HttpControl.ObjectToJson(flow); string cmd = HttpControl.TestWorkflowCmd + "?" + "flow_id=" + flow.flow_id + "&numbers=" + flow.numbers; String strResult = HttpControl.GetHttpResponseList(cmd, 5000, this.Token.token); TestWorkflowResult result = (TestWorkflowResult)HttpControl.JsonToObject <TestWorkflowResult>(strResult); if (result == null) { MessageBox.Show("网络连接失败!"); return; } if (result.status == 0) { MessageBox.Show("测试发送成功。"); } phoneControl.startDialPstn(result.result, this.Token.token); } }
private void TestButton_Click(object sender, RoutedEventArgs e) { String strPhone1 = this.PhoneEdit.Text; String workflowName = this.WorkflowCombo.Text; if (String.IsNullOrEmpty(strPhone1) || strPhone1.Length < 6) { MessageBox.Show("请输入正确的电话号码1!"); return; } if (String.IsNullOrEmpty(workflowName)) { MessageBox.Show("请选择工作流程!"); return; } String workflowId = PageCommon.Dict[workflowName]; if (!String.IsNullOrEmpty(workflowId)) { TestWorkflow flow = new TestWorkflow(); flow.flow_id = workflowId; flow.numbers = strPhone1; string param = HttpControl.ObjectToJson(flow); string cmd = HttpControl.TestWorkflowCmd + "?" + "flow_id=" + flow.flow_id + "&numbers=" + flow.numbers; String strResult = HttpControl.GetHttpResponseList(cmd, 5000, MainWindow.main.Token.TokenCode); TestWorkflowResult result = (TestWorkflowResult)HttpControl.JsonToObject <TestWorkflowResult>(strResult); if (result == null) { MessageBox.Show("网络连接失败!"); return; } if (result.status == 0) { MessageBox.Show("测试发送成功。"); } else { TestResultError ret = (TestResultError)HttpControl.JsonToObject <TestResultError>(strResult); if (ret != null) { MessageBox.Show(ret.error); } else { MessageBox.Show("服务器连接错误"); } return; } phoneControl.startDialPstn(result.result, MainWindow.main.Token.TokenCode); } }
private void DownloadControlButton_Click(object sender, EventArgs e) { try { String workflowName = this.FlowComboBox.Text; if (String.IsNullOrEmpty(workflowName)) { MessageBox.Show("请选择工作流程!"); return; } String workflowId = PageCommon.Dict[workflowName]; if (!String.IsNullOrEmpty(workflowId)) { TestWorkflow flow = new TestWorkflow(); flow.flow_id = workflowId; string param = HttpControl.ObjectToJson(flow); string cmd = HttpControl.GeUrlInfoCmd + flow.flow_id + "/bot/"; String strResult = HttpControl.GetHttpResponseList(cmd, 500, this.Token.TokenCode); if (strResult == null) { MessageBox.Show("该流程没有录音文件"); return; } ResultFtpInfo ret = (ResultFtpInfo)HttpControl.JsonToObject <ResultFtpInfo>(strResult); if (strResult == null) { MessageBox.Show("网络连接失败!"); return; } if (ret.message != "成功") { MessageBox.Show("网络连接失败!"); return; } if (isNewDownload) { this.downloadIndex = 0; } var filePath = CPlayVoicePathManager.GetVoicePath(flow.flow_id); var objFullFileName = filePath + flow.flow_id.ToString() + ".zip"; Thread thread = new Thread(() => { try { long downSize = 0; long fileSize = 0; HttpManager.HttpDownloadFile(ret.data.url, objFullFileName, new UZipProgressDelegate((count, total) => { this.BeginInvoke(new InvokeDelegate(() => { downSize = total; fileSize = count; DownloadInfoTextBox.Text = "正在下载文件:" + count.ToString() + "/" + total.ToString(); })); })); if (downSize <= fileSize) { Console.WriteLine("文件下载异常的长度"); } ZipHelper.UnZip2(objFullFileName, filePath, new UZipProgressDelegate((total, count) => { this.BeginInvoke(new InvokeDelegate(() => { DownloadInfoTextBox.Text = "解压文件进度" + total.ToString() + "/" + count.ToString(); })); })); MessageBox.Show("下载完成!"); if (_isTaskCreate) { CloseButton.Text = "关闭窗口"; } } catch (Exception ex) { Console.WriteLine(ex.Message); } }); thread.Start(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }