public static ApplicationInfo.SendNewOrderResult SendNewOrder(string symbol, string side, long volume, string price, long publishVol, string condition, int ttf, string deposit, bool isAutoStopLoss)
 {
     ApplicationInfo.SendNewOrderResult sendNewOrderResult = new ApplicationInfo.SendNewOrderResult();
     sendNewOrderResult.IsAutoStopLoss = isAutoStopLoss;
     try
     {
         string message = SendNewOrderMessage.Pack(symbol, side, volume, price, ApplicationInfo.AccInfo.CurrentAccount, publishVol, condition, ttf.ToString(), ApplicationInfo.AccInfo.CurrInternetUser, deposit, ApplicationInfo.GetSession(), "", ApplicationInfo.IP, ApplicationInfo.GetTermicalId(), ApplicationInfo.AuthenKey);
         string data = ApplicationInfo.WebOrderService.SendNewOrder(message);
         using (DataSet dataSet = new DataSet())
         {
             MyDataHelper.StringToDataSet(data, dataSet);
             if (dataSet.Tables.Contains("Results") && dataSet.Tables["Results"].Rows.Count > 0)
             {
                 long.TryParse(dataSet.Tables["Results"].Rows[0]["code"].ToString(), out sendNewOrderResult.OrderNo);
                 sendNewOrderResult.ResultMessage = dataSet.Tables["Results"].Rows[0]["message"].ToString().Trim();
                 if (ApplicationInfo.SupportFreewill)
                 {
                     sendNewOrderResult.IsFwOfflineOrder = (sendNewOrderResult.ResultMessage == "ok_offline");
                 }
                 dataSet.Clear();
             }
         }
     }
     catch (Exception ex)
     {
         sendNewOrderResult.OrderNo = -1L;
         sendNewOrderResult.ResultMessage = ex.Message;
     }
     return sendNewOrderResult;
 }
示例#2
0
 private void bgwSendOrder_DoWork(object sender, DoWorkEventArgs e)
 {
     if (ApplicationInfo.IsEquityAccount)
     {
         try
         {
             this._verifyResultStr_Pin = string.Empty;
             this._verifyResult_Pin = false;
             string text = this.tbPin.Text.Trim();
             if (Settings.Default.MainBottomStyle == 5)
             {
                 text = this.tbMMPin.Text.Trim();
             }
             if (text == string.Empty)
             {
                 this._verifyResultStr_Pin = "Pincode is empty!!!";
                 return;
             }
             if (ApplicationInfo.UserPincodeWrongCount < ApplicationInfo.UserMaxRetryPincode)
             {
                 this.ShowSplash(true, "Check Pincode.", false);
                 this._verifyResult_Pin = ApplicationInfo.VerifyPincode(text, ref this._verifyResultStr_Pin);
                 this.ShowSplash(false, "", false);
             }
         }
         catch (Exception ex)
         {
             this.ShowSplash(false, "", false);
             this.ShowError("CheckPin", ex);
             this._verifyResultStr_Pin = ex.Message;
         }
         this._verifyResult = false;
         if (this._verifyResult_Pin)
         {
             if (this._commandType == "V")
             {
                 try
                 {
                     this.ShowSplash(true, "Verify New Order...", false);
                     string data = string.Empty;
                     if (ApplicationInfo.SupportFreewill)
                     {
                         data = ApplicationInfo.WebOrderService.VerifyOrderFw(this._OrdSymbol, this._OrdSide, this._OrdVolume, this._OrdPrice, this._OrdPubVol, this._OrdCondition);
                     }
                     else
                     {
                         data = ApplicationInfo.WebOrderService.VerifyOrder(this._OrdSymbol, this._OrdSide, this._OrdVolume, this._OrdPrice, ApplicationInfo.AccInfo.CurrentAccount, ApplicationInfo.IsRiskActive);
                     }
                     if (this._dsSendOrder == null)
                     {
                         this._dsSendOrder = new DataSet();
                     }
                     else
                     {
                         this._dsSendOrder.Clear();
                     }
                     MyDataHelper.StringToDataSet(data, this._dsSendOrder);
                     this._verifyResult = true;
                 }
                 catch (Exception ex)
                 {
                     this.ShowMessageInFormConfirm(ex.Message, frmOrderFormConfirm.OpenStyle.ShowBox);
                 }
                 this.ShowSplash(false, "", false);
             }
             else if (this._commandType == "S")
             {
                 try
                 {
                     this.ShowSplash(true, "Sending New Order...", false);
                     if (ApplicationInfo.SupportFreewill)
                     {
                         this.ShowMessageInFormConfirm("Please wait for confirmation.", frmOrderFormConfirm.OpenStyle.WaitingForm);
                     }
                     this._newOrderResult = ApplicationInfo.SendNewOrder(this._OrdSymbol, this._OrdSide, this._OrdVolume, this._OrdPrice, this._OrdPubVol, this._OrdCondition, this._OrdTtf, this._OrdIsDeposit, this._OrdAutoStopLoss);
                     this._verifyResult = true;
                 }
                 catch (Exception ex)
                 {
                     this.ShowMessageInFormConfirm("SendNewOrder:" + ex.Message, frmOrderFormConfirm.OpenStyle.ShowBox);
                 }
                 this.ShowSplash(false, "", false);
             }
         }
     }
     else if (this._commandType == "S")
     {
         try
         {
             this.ShowSplash(true, "Sending New Order...", false);
             string currentAccount = ApplicationInfo.AccInfo.CurrentAccount;
             string text2 = ApplicationInfo.WebServiceTFEX.SendTFEXNewOrder(this._OrdSymbol, this._OrdSide, this._OrdVolume, this._OrdPrice, currentAccount, this._OrdPubVol, this._OrdPosition, this._OrdTfexStopPrice, this._OrdTfexStopCond, this._OrdTfexStopSeries, this._OrdCondition, this._OrdValidityDate, ApplicationInfo.UserSessionID, "", "", ApplicationInfo.AuthenKey, ApplicationInfo.AccInfo.InternetUserTFEX, ApplicationInfo.IP, ApplicationInfo.KE_Session, ApplicationInfo.KE_LOCAL, "S", this._OrdPriceType);
             if (text2.Trim() == string.Empty)
             {
                 this.ShowMessageInFormConfirm("Request fail , return empty!!!", frmOrderFormConfirm.OpenStyle.ShowBox);
             }
             else if (text2.Trim().ToUpper() == "INVALID_SESSION_KEY")
             {
                 this.ShowMessageInFormConfirm("Invalid session key!!!", frmOrderFormConfirm.OpenStyle.ShowBox);
             }
             else
             {
                 if (this._dsSendOrderTfex == null)
                 {
                     this._dsSendOrderTfex = new DataSet();
                 }
                 else
                 {
                     this._dsSendOrderTfex.Clear();
                 }
                 MyDataHelper.StringToDataSet(text2, this._dsSendOrderTfex);
             }
         }
         catch (Exception ex)
         {
             this.ShowMessageInFormConfirm(ex.Message, frmOrderFormConfirm.OpenStyle.ShowBox);
         }
         this.ShowSplash(false, "", false);
     }
 }