Пример #1
0
        private void insertSQL(bool isdelete, UseContract uc)
        {
            string[]           cmdTexts             = null;
            MySqlParameter[][] commandParameters    = null;
            MySqlParameter[]   delcommandParameters = new MySqlParameter[] {
                new MySqlParameter("@exchange_no", uc.FExchangeNo),
                new MySqlParameter("@code", uc.code)
            };

            Exchange ec = lstExchange.FirstOrDefault(p => p.FExchangeNo == uc.FExchangeNo);

            if (ec != null)
            {
                //将期货的交易所名字换成中文
                uc.FName = ec.FName;
            }
            MySqlParameter[] insertcommandParameters = new MySqlParameter[] {
                new MySqlParameter("@exchange_no", uc.FExchangeNo),
                new MySqlParameter("@exchange_name", uc.FName),
                new MySqlParameter("@commodity_no", uc.FCommodityNo),
                new MySqlParameter("@commodity_name", uc.CommodityFName),
                new MySqlParameter("@code", uc.code),
                new MySqlParameter("@contract_no", uc.FContractNo),
                new MySqlParameter("@contract_name", uc.ContractFName),
                new MySqlParameter("@futures_type", uc.FCommodityType),
                new MySqlParameter("@product_dot", uc.FProductDot),
                new MySqlParameter("@upper_tick", uc.FUpperTick),
                new MySqlParameter("@reg_date", DateTime.Now.ToString("yyyyMMdd")),
                new MySqlParameter("@expiry_date", uc.FTradeMonth),
                new MySqlParameter("@dot_num", uc.FDotNum),
                new MySqlParameter("@currency_no", uc.CommodityFCurrencyNo),
                new MySqlParameter("@currency_name", uc.CurrencyFName),
                new MySqlParameter("@lower_tick", uc.FLowerTick),
                new MySqlParameter("@exchange_no2", uc.FExchange2),
                new MySqlParameter("@deposit", uc.FFreezenMoney),
                new MySqlParameter("@deposit_percent", uc.FFreezenPercent),
                new MySqlParameter("@first_notice_day", uc.FTradeMonth),
                new MySqlParameter("@create_by", "batch_id"),
                new MySqlParameter("@create_date", DateTime.Now),
                new MySqlParameter("@update_by", "batch_id"),
                new MySqlParameter("@update_date", DateTime.Now),
                new MySqlParameter("@commodity_type", "00"),
                new MySqlParameter("@py_name", GetStringSpell.GetChineseSpell(uc.ContractFName))
            };
            if (isdelete)
            {
                //需要更新的时候
                cmdTexts = new string[]
                {
                    SQLText.deletefuturesSQL,
                    SQLText.insertfuturesSQL
                };
                commandParameters = new MySqlParameter[][] {
                    delcommandParameters,
                    insertcommandParameters
                };
            }
            else
            {
                cmdTexts = new string[]
                {
                    // deletefuturesSQL,
                    SQLText.insertfuturesSQL
                };
                commandParameters = new MySqlParameter[][] {
                    //delcommandParameters,
                    insertcommandParameters
                };
            }
            bool isInsert = MySqlHelper.ExecuteTransaction(MySqlHelper.ConnectionStringManager, CommandType.Text, cmdTexts, commandParameters);

            if (!isInsert)
            {
                PrintToTxt(uc.code + " 产品更新失败");
                marketErrorLoger.log(LogLevel.SYSTEMERROR, uc.code + " 产品更新失败");
            }
        }
Пример #2
0
        /// <summary>
        /// 执行行情接受线程
        /// </summary>
        public void ExecuteMarketThread()
        {
            string value = "";

            while (isSave)
            {
                try
                {
                    value = marketBlockingCollection.Take();
                    NetInfo ni = new NetInfo();
                    ni.MyReadString(value);

                    if (CommandCode.LOGIN.Equals(ni.code))
                    {
                        if (string.IsNullOrEmpty(ni.errorCode) || "00000".Equals(ni.errorCode))
                        {
                            PrintToTxt(user + " 登录成功!");
                        }
                        else
                        {
                            PrintToTxt(user + " 登录失败!");
                        }
                    }

                    if (CommandCode.LOGINHK.Equals(ni.code))
                    {
                        if (string.IsNullOrEmpty(ni.errorCode) || "00000".Equals(ni.errorCode))
                        {
                            PrintToTxt(user + " 登录成功!");
                        }
                        else
                        {
                            PrintToTxt(user + " 登录失败!");
                        }
                    }

                    if (CommandCode.GETTCONTRACT.Equals(ni.code))
                    {
                        //期货品种
                        List <UseContract> lstUc = CommonFunction.ObjectListFromString <UseContract>(UseContract.MyPropToString(), ni.infoT);
                        if (lstUc != null && lstUc.Count > 0)
                        {
                            InsertOrUpdateDaFutures(lstUc);
                            int received = CommonFunction.StringToInt(ni.systemCode);
                            if (received != 0)
                            {
                                RequestContract(received);
                            }
                        }
                        else
                        {
                            PrintToTxt("期货产品更新完成 " + ReloadData(ConfigurationManager.AppSettings["futures_reload_url"]));
                        }
                    }
                    if (CommandCode.CURRENCYLIST.Equals(ni.code))
                    {
                        //期货汇率
                        List <CurrencyInfo> lstUc = CommonFunction.ObjectListFromString <CurrencyInfo>(CurrencyInfo.MyPropToString(), ni.infoT);
                        foreach (CurrencyInfo ci in lstUc)
                        {
                            UpdateCurrency(ci);
                        }

                        PrintToTxt("汇率更新完成 " + ReloadData(ConfigurationManager.AppSettings["currency_reload_url"]));
                    }
                    if (CommandCode.GetContractStock.Equals(ni.code))
                    {
                        List <ContractStockHK> lstUc = CommonFunction.ObjectListFromString <ContractStockHK>(ContractStockHK.MyPropToString(), ni.infoT);
                        if (lstUc != null && lstUc.Count > 0)
                        {
                            foreach (ContractStockHK ci in lstUc)
                            {
                                InsertOrUpdateDaStock(ci);
                            }
                            int received = CommonFunction.StringToInt(ni.systemCode);
                            if (received != 0)
                            {
                                RequestContract(received);
                            }
                        }
                        else
                        {
                            PrintToTxt("证券产品更新完成 " + ReloadData(ConfigurationManager.AppSettings["stock_reload_url"]));
                        }
                    }
                    if (CommandCode.GetPlateList.Equals(ni.code) || CommandCode.GetPlateListStockHK.Equals(ni.code))
                    {
                        List <MyPlateCommodityInfo> list = CommonFunction.ObjectListFromString <MyPlateCommodityInfo>(PlateCommodityInfo.MyPropToString(), ni.infoT);
                        int i = 0;

                        foreach (MyPlateCommodityInfo ci in list)
                        {
                            ci.FSortId = i++.ToString();
                        }
                        InsertOrUpdatePlateView(list);
                        PrintToTxt("板块更新完成 " + ReloadData(ConfigurationManager.AppSettings["plate_reload_url"]));
                    }
                }
                catch (Exception ex)
                {
                    marketErrorLoger.log(LogLevel.SYSTEMERROR, ex.ToString());
                }
            }
        }