void Set_CookieVisitor() { //注册获取cookie回调事件 CookieVisitor visitor = new CookieVisitor(); visitor.SendCookie += (Cookie obj) => { switch (obj.Name) { case "user_n": //userName main.Dispatcher.Invoke(() => { userName.Text = obj.Value; quitButton.Visibility = Visibility.Visible; }); break; case TokenKey: Token.TokenCode = obj.Value; Domain = obj.Domain; ShowLeftBar(); StartFistPage(); //mIsEndCheck = true; if (!String.IsNullOrEmpty(Token.TokenCode)) { Thread getDialPhoneManagerThread = new Thread(() => { while (!this.isExit && !String.IsNullOrEmpty(Token.TokenCode)) { try { String retString = HttpControl.GetHttpResponseList(HttpControl.GetNeedCallPhoneCmd, 50000, Token.TokenCode); List <DialPhoneInfo> infos = (List <DialPhoneInfo>)HttpControl.JSONStringToList <DialPhoneInfo>(retString); DialPhoneInfo[] dialInfos = new DialPhoneInfo[infos.Count]; int i = 0; foreach (DialPhoneInfo info in infos) { dialInfos[i] = info; i++; } if (dialInfos.Length > 0) { phoneControl.startDialPstn(dialInfos, this.Token.TokenCode); } Thread.Sleep(ThreadSleepTime); } catch (Exception ex) { } } }); getDialPhoneManagerThread.Start(); } break; default: break; } };; mCookieManager.VisitAllCookies(visitor); }
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); } }
void Set_CookieVisitor() { //注册获取cookie回调事件 CookieVisitor visitor = new CookieVisitor(); visitor.SendCookie += (Cookie obj) => { if (obj.Name != "auth_t") { return; } Token.token = obj.Value; //mIsEndCheck = true; if (!String.IsNullOrEmpty(Token.token)) { Thread getDialPhoneManagerThread = new Thread(() => { while (!this.isExit) { Thread.Sleep(ThreadSleepTime); try { String retString = HttpControl.GetHttpResponseList(HttpControl.GetNeedCallPhoneCmd, 50000, Token.token); List <DialPhoneInfo> infos = (List <DialPhoneInfo>)HttpControl.JSONStringToList <DialPhoneInfo>(retString); DialPhoneInfo[] dialInfos = new DialPhoneInfo[infos.Count]; int i = 0; foreach (DialPhoneInfo info in infos) { dialInfos[i] = info; i++; } phoneControl.startDialPstn(dialInfos, this.Token.token); } catch (Exception ex) { } } }); getDialPhoneManagerThread.Start(); } };; mCookieManager.VisitAllCookies(visitor); }
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); } }