/// <summary> /// 根据用户ID获取用户的盈亏 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static double GetUserYingKui(string userid) { System.Data.Common.DbDataReader dbreader = null; double yingkui = 0; TradeClient tc = new TradeClient(); try { string data = string.Empty; Dictionary<string, ProPrice> prodic = tc.GetProPrice(); foreach (var item in prodic) { data += string.Format("{0},{1}|", item.Key, item.Value.realprice); } if (data.Length > 1) { data = data.Substring(0, data.Length - 1); } else { return 0; } //@data 参数格式[行情编码,价格|行情编码,价格|行情编码,价格|行情编码,价格|行情编码,价格] //存储过程proc_GetUserYingKui计算一个用户所有订单的盈亏之和 dbreader = DbHelper.RunProcedureGetDataReader("proc_GetUserYingKui", new System.Data.Common.DbParameter[] { DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type, "@userid", DbParameterType.String, userid, ParameterDirection.Input), DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type, "@data", DbParameterType.String, data, ParameterDirection.Input) }); if (dbreader.Read()) { yingkui = System.DBNull.Value != dbreader["yingkui"] ? Convert.ToDouble(dbreader["yingkui"]) : 0; } tc.Close(); } catch (Exception ex) { tc.Abort(); throw new Exception(ex.Message, ex); } finally { if (dbreader != null) { dbreader.Close(); dbreader.Dispose(); } } return yingkui; }
/// <summary> /// 获取商品时间和最新价格 /// </summary> /// <returns></returns> public static Dictionary<string, ProPrice> GetProPrice() { Dictionary<string, ProPrice> prodic = new Dictionary<string, ProPrice>(); TradeClient tc = new TradeClient(); try { prodic = tc.GetProPrice(); tc.Close(); } catch (Exception ex) { tc.Abort(); throw new Exception(ex.Message, ex); } return prodic; }