/// <summary> /// 绑定产品和列表 /// </summary> public void BindProductList() { Task.Run((Action)(() => { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("condition", "true"); dic.Add("exchangeId", (string)this.exchangeId); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.hangqinglist, dic, header, "post"); Quotation resultmodel = JsonHelper.JsonToObj <Quotation>(result); objList = resultmodel.data; Dispatcher.Invoke(new Action(() => { if (this.listbox_product.Items.Count == 0) { for (int i = 0; i < resultmodel.data.Count; i++) { ListBoxItem listBoxItem = new ListBoxItem(); TextBlock txt = new TextBlock(); txt.Text = resultmodel.data[i].productName; txt.MouseLeftButtonDown += SecondToolBar_MouseLeftButtonDown; listBoxItem.Content = txt; if (i == 0) { listBoxItem.IsSelected = true; } this.listbox_product.Items.Add(listBoxItem); if (i == 0) { this.productId = resultmodel.data[i].productId; } } ReloadProduct(); } if (objList.Count > 0) { if (objDetailList != null && objDetailList.Count > 0) { QuotationChildren model = objList.Find(x => x.productId == this.productId); if (model != null) { objDetailList = model.contractDtoList; } } else { objDetailList = objList[0].contractDtoList; } this.grid_saffer.ItemsSource = objDetailList; Grid_saffer_SizeChanged(null, null); BindSocket(); } })); })); }
/// <summary> /// 添加条件 /// </summary> private void AddCondition() { try { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("direction", "BUY");//BUY,SELL Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance())); header.Add("Authorization", "Bearer " + Loginer.LoginerUser.Token); ResultModel result = JsonHelper.JsonToObj <ResultModel>(ApiHelper.SendPost(InterfacePath.Default.maimai, dic, header, "post")); if (result.code == 200) { MessageBox.Show("设置成功!"); } else { MessageBox.Show("设置失败!"); } } catch (Exception ex) { Log4Helper.Error(this.GetType(), "设置条件单:" + ex); } }
public MainPage() { #region 获取MQTT连接信息 try { Dictionary <string, string> dic = new Dictionary <string, string>(); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.mqttinfo, dic, header, "post"); ResultModel <MqttEntity> loginsession = JsonHelper.JsonToObj <ResultModel <MqttEntity> >(result); MqttEntity._instance = loginsession.data; MqttEntity._instance.clientId = SoftwareInformation.Instance().deviceId; #endregion #region 连接MQTT SubscribeClient subscribeClient = new SubscribeClient(MqttEntity._instance); #endregion } catch (Exception ex) { MessageBox.Show(ex.Message); } InitializeComponent(); }
/// <summary> /// 卖出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SellOut_Click(object sender, RoutedEventArgs e) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("direction", "SELL"); //BUY,SELL dic.Add("instrumentId", this.contractId); dic.Add("limitPrice", this.limitPrice.Text); //若选择市价,则 priceType=MARKET_PRICE,limitPrice为空, 若选择对手价,最新价,排队价,或者用户手动输入,则priceType=LIMIT_PRICE,limitPrice为对应的价格 if (this.rdo_kaicang.IsChecked == true) { dic.Add("offsetFlag", "OPEN");//开仓 } else { dic.Add("offsetFlag", "CLOSE");//平仓 } dic.Add("priceType", "LIMIT_PRICE"); dic.Add("volume", this.volume.Text); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.maimai, dic, header, "post"); ResultModel resultmodel = JsonHelper.JsonToObj <ResultModel>(result); if (resultmodel.code == 200) { MessageBox.Show("提交成功!"); } else if (resultmodel.code == 402) { ReloadLogin(); } }
private void Application_Exit(object sender, ExitEventArgs e) { if (!string.IsNullOrEmpty(BussinesLoginer.bussinesLoginer.sessionId)) { Dictionary <string, string> dic = new Dictionary <string, string>(); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.bussineloginout, dic, header, "post"); } }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="token"></param> /// <returns></returns> public ResultModel <UserInfoModel> GetUserInfo(string strUrl, string token) { //string strUrl = "http://front.future.alibaba.com/user/info"; Dictionary <string, string> param = new Dictionary <string, string>(); Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance())); header.Add("Authorization", "Bearer " + token); return(JsonHelper.JsonToObj <ResultModel <UserInfoModel> >(ApiHelper.SendPost(strUrl, param, header, "post"))); }
/// <summary> /// 短信验证码登录/注册 /// </summary> /// <param name="mobile">手机号</param> /// <param name="checkCode">验证码</param> /// <returns></returns> public ResultModel <Token> LoginOrRegisterByCode(string strUrl, string mobile, string checkCode) { //string strUrl = "http://front.future.alibaba.com/user/auth/login/sms"; Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("mobile", mobile); param.Add("checkCode", checkCode); Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance())); return(JsonHelper.JsonToObj <ResultModel <Token> >(ApiHelper.SendPost(strUrl, param, header, "post"))); }
public ResultModel CheckMessageCode(string strUrl, string checkCode, string checkCodeType, string mobile) { //string strUrl = "http://front.future.alibaba.com/user/auth/checkCode/verify"; Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("checkCode", checkCode); param.Add("checkCodeType", checkCodeType); param.Add("mobile", mobile); Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance())); return(JsonHelper.JsonToObj <ResultModel>(ApiHelper.SendPost(strUrl, param, header, "post"))); }
/// <summary> /// 发送短信验证码 /// </summary> /// <param name="mobile">手机号</param> /// <param name="checkCodeType"></param> public ResultModel SendMessage(string strUrl, string mobile, string checkCodeType) { Log4Helper.Info(this.GetType(), $"手机号;{mobile}发送短信一次!"); //string strUrl = "http://front.future.alibaba.com/user/auth/checkCode/send"; Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("checkCodeType", checkCodeType); param.Add("mobile", mobile); Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance())); return(JsonHelper.JsonToObj <ResultModel>(ApiHelper.SendPost(strUrl, param, header, "post"))); }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { int selectindex = this.tab_bussines.SelectedIndex; Dictionary <string, string> dic = new Dictionary <string, string>(); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); if (selectindex == 0)//持仓 { string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chicang, dic, header, "post"); //ResultModel<HoldModel> resultmodel = JsonHelper.JsonToObj<ResultModel<HoldModel>>(result); //if (resultmodel.code == 402) //{ // ReloadLogin(); //} //if (resultmodel.data != null) //{ // this.grid_hold.Dispatcher.Invoke(new Action(() => { this.grid_hold.ItemsSource = resultmodel.data.list; })); //} } if (selectindex == 2)//委托 { //string result = ApiHelper.SendPostByHeader(InterfacePath.Default.weituo, dic, header, "post"); //ResultModel<EntrustModel_List> resultmodel = JsonHelper.JsonToObj<ResultModel<EntrustModel_List>>(result); //if (resultmodel.code == 402) //{ // ReloadLogin(); //} ResultModel <EntrustModel_List> resultmodel = new ResultModel <EntrustModel_List>(); LoadList(resultmodel, 2); this.grid_entrust.Dispatcher.Invoke(new Action(() => { this.grid_entrust.ItemsSource = resultmodel.data.list; })); } if (selectindex == 3)//成交记录 { //string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chengjiaojilu, dic, header, "post"); //ResultModel<RecordModel> resultmodel = JsonHelper.JsonToObj<ResultModel<RecordModel>>(result); //if (resultmodel.code == 402) //{ // ReloadLogin(); //} ResultModel <RecordModel> resultmodel = new ResultModel <RecordModel>(); LoadList(resultmodel, 3); this.grid_record.Dispatcher.Invoke(new Action(() => { this.grid_record.ItemsSource = resultmodel.data.list; })); } }
/// <summary> /// 账户注册 /// </summary> /// <param name="checkCode">验证码</param> /// <param name="mobile">手机号</param> /// <param name="nickname">昵称</param> /// <param name="password">密码</param> /// <param name="profilePhoto">头像</param> /// <param name="qq">qq</param> /// <returns></returns> public ResultModel <Token> Register(string strUrl, string checkCode, string mobile, string nickname, string password, string profilePhoto, string qq) { //string strUrl = "http://front.future.alibaba.com/user/auth/register"; Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("mobile", mobile); param.Add("checkCode", checkCode); param.Add("nickname", nickname); param.Add("password", password); param.Add("profilePhoto", profilePhoto); param.Add("qq", qq); Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("GeneralParam", JsonHelper.ToJson(SoftwareInformation.Instance())); return(JsonHelper.JsonToObj <ResultModel <Token> >(ApiHelper.SendPost(strUrl, param, header, "post"))); }
/// <summary> /// 确定按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSure_Click(object sender, RoutedEventArgs e) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("instrumentId", ""); //合约编号 dic.Add("stopPrice", ""); //输入价格 dic.Add("volume", ""); //数量 //if (this.rdo_kaicang.IsChecked == true)//开平 //{ // dic.Add("offsetFlag", "OPEN");//开仓 //} //else //{ // dic.Add("offsetFlag", "CLOSE");//平仓 //} dic.Add("direction", "");//方向 BUY,SELL //价格->可选择市价,或者是手动输入价格。 若选择市价则 priceType=MARKET_PRICE, limitPrice为空 ,若不选择市价手动输入价格,则 priceType=LIMIT_PRICE,limitPrice=输入值 dic.Add("priceType", "MARKET_PRICE"); //dic.Add("priceType", "LIMIT_PRICE"); //dic.Add("limitPrice", this.limitPrice.Text); dic.Add("contingentCondition ", ""); //dic.Add("volume", this.volume.Text); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.maimai, dic, header, "post"); ResultModel resultmodel = JsonHelper.JsonToObj <ResultModel>(result); if (resultmodel.code == 200) { //刷新条件列表 } else if (resultmodel.code == 402) { MessageBox.Show("提交失败!"); } }
private void BussinesLogin_MouseDown(object sender, MouseButtonEventArgs e) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("user", "1297005"); dic.Add("password", "1297005"); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.bussinelogin, dic, header, "post"); ResultModel <BussinesLoginer> loginsession = JsonHelper.JsonToObj <ResultModel <BussinesLoginer> >(result); BussinesLoginer.bussinesLoginer.sessionId = loginsession.data.sessionId; MainPage mainPage = new MainPage(); mainPage.Show(); this.Close(); }
public void TiaoJianDanList() { int selectindex = this.tab_bussines.SelectedIndex; Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("condition", "true"); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.weituo, dic, header, "post"); ResultModel <EntrustModel_List> resultmodel = JsonHelper.JsonToObj <ResultModel <EntrustModel_List> >(result); if (resultmodel.code == 402) { ReloadLogin(); } this.grid_condition.Dispatcher.Invoke(new Action(() => { this.grid_condition.ItemsSource = resultmodel.data.list; })); }
/// <summary> /// 撤单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CheDan_Click(object sender, RoutedEventArgs e) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("exchangeId", ""); dic.Add("instrumentId", this.contractId); dic.Add("orderSysId", ""); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chedan, dic, header, "post"); ResultModel resultmodel = JsonHelper.JsonToObj <ResultModel>(result); if (resultmodel.code == 200) { MessageBox.Show("提交成功!"); } else if (resultmodel.code == 402) { ReloadLogin(); } }
public T LoadList <T>(T t, int selectindex) { Dictionary <string, string> dic = new Dictionary <string, string>(); Dictionary <string, string> header = new Dictionary <string, string>(); string GeneralParam = JsonHelper.ToJson(SoftwareInformation.Instance()); header.Add("GeneralParam", GeneralParam); header.Add("Authorization", BussinesLoginer.bussinesLoginer.sessionId); if (selectindex == 0)//持仓 { string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chicang, dic, header, "post"); //ResultModel<HoldModel> resultmodel = JsonHelper.JsonToObj<ResultModel<HoldModel>>(result); //if (resultmodel.code == 402) //{ // ReloadLogin(); //} //if (resultmodel.data != null) //{ // this.grid_hold.Dispatcher.Invoke(new Action(() => { this.grid_hold.ItemsSource = resultmodel.data.list; })); //} } if (selectindex == 2)//委托 { string result = ApiHelper.SendPostByHeader(InterfacePath.Default.weituo, dic, header, "post"); ResultModel <EntrustModel_List> resultmodel = JsonHelper.JsonToObj <ResultModel <EntrustModel_List> >(result); if (resultmodel.code == 402) { ReloadLogin(); } if ((t as ResultModel <EntrustModel_List>).data == null) { (t as ResultModel <EntrustModel_List>).data = resultmodel.data; return(t); } foreach (EntrustModel item in resultmodel.data.list) { (t as ResultModel <EntrustModel_List>).data.list.Add(item); } return(t); } if (selectindex == 3)//成交记录 { string result = ApiHelper.SendPostByHeader(InterfacePath.Default.chengjiaojilu, dic, header, "post"); ResultModel <RecordModel> resultmodel = JsonHelper.JsonToObj <ResultModel <RecordModel> >(result); if (resultmodel.code == 402) { ReloadLogin(); } if ((t as ResultModel <RecordModel>).data == null) { (t as ResultModel <RecordModel>).data = resultmodel.data; return(t); } foreach (RecordModel_List item in resultmodel.data.list) { (t as ResultModel <RecordModel>).data.list.Add(item); } return(t); } return(t); }