public async Task <IActionResult> GetReport(QueryPara para) { _logger.LogInformation("参数:" + Newtonsoft.Json.JsonConvert.SerializeObject(para)); var storeoutList = new List <vw_storeout>(); if (!string.IsNullOrEmpty(para.StartDate)) { storeoutList = _context.vw_storeout.Where(f => f.OutTime > DateTime.Parse(para.StartDate) && f.OutTime < DateTime.Parse(para.EndDate) && f.OrgId == int.Parse(para.SelectedOrg)).ToList(); if (!string.IsNullOrEmpty(para.Operator)) { storeoutList = storeoutList.FindAll(f => f.Operator == int.Parse(para.Operator)); } } else { storeoutList = _context.vw_storeout.ToList(); } for (int i = 0; i < storeoutList.Count; i++) { storeoutList[i].Id = i + 1; } return(new OkObjectResult(storeoutList)); }
private FluentData.IDbCommand GetDbCommand(IDbContext dbContext, QueryPara queryPara, QueryItem queryItem) { FluentData.IDbCommand dbCommand = dbContext.Sql(queryItem.ExecSql, queryPara.Parameters.ToArray()); foreach (var param in queryPara.ParamSet) { dbCommand = dbCommand.Parameter(param.Key, param.Value); } return(dbCommand); }
public QueryResult <LearningType> QueryTypes(QueryPara query) { QueryResult <LearningType> result = new QueryResult <LearningType>(); result.Data = _learningType.GetListPaged(query.PageIndex, query.PageSize, query.Where, query.Order); result.Recount = _learningType.RecordCount(query.Where); result.PageSize = query.PageSize; result.PageIndex = query.PageIndex; return(result); }
/// <summary> /// 内容管理 /// </summary> /// <returns></returns> public IActionResult LearningInfoList() { QueryPara queryPara = new QueryPara(); var result = _learningService.QueryInfos(queryPara); List <LearningInfoModel> dlist = new List <LearningInfoModel>(); foreach (var item in result.Data) { dlist.Add(_learningService.ConverToInfoModel(item)); } return(View(dlist)); }
public string GenerateEntity() { QueryPara queryPara = new QueryPara { Sql = $"select * from 『{Table.Name}』 where 1=2" }; DataTable tbl = Table.Database.Query(queryPara); StringBuilder sb = new StringBuilder(); foreach (DataColumn column in tbl.Columns) { sb.AppendLine(); sb.AppendLine("public " + column.DataType.Name + " " + column.ColumnName + "{ get; set; }"); } return(sb.ToString()); }
/// <summary> /// 分类管理 /// </summary> /// <returns></returns> public IActionResult LearningTypeList() { QueryPara queryPara = new QueryPara(); var result = _learningService.LoadTypes(); List <LearningTypeModel> dlist = new List <LearningTypeModel>(); var treeData = _learningService.ConverTree(result.ToList()); foreach (var item in treeData) { dlist.Add(_learningService.ConverToTypeModel(item)); } return(View(dlist)); }
public int QueryPosition(QueryPara param) { CT2Packer packer = new CT2Packer(2); packer.BeginPack(); packer.AddField("user_token", Convert.ToSByte('S'), 512, 4); packer.AddField("account_code", Convert.ToSByte('S'), 32, 4); packer.AddField("combi_no", Convert.ToSByte('S'), 8, 4); packer.AddField("stock_code", Convert.ToSByte('S'), 16, 4); packer.AddStr(this.token); packer.AddStr(this.curraccno); packer.AddStr(this.currcombino); packer.AddStr(param.stock_code); packer.EndPack(); return(this.sendpacker(OptionFunctionCode.QueryPosition, packer, false)); }
public AOptionMakeMarket() { instanceid++; //行情引擎 MarketVendor mvendor = (MarketVendor)Config.GetInstance().GetParameter(Config.C_MARKETENGINE_OPTION); _optionengine = AMarket.GetInstance(mvendor); //委托引擎 EntrustVendor evendor = (EntrustVendor)Config.GetInstance().GetParameter(Config.C_ENTRUSTENGINE_OPTION); _entrustengine = AEntrust.GetInstance(evendor); _entrustengine.Logon(); //参数 c_min_entrust_volume = (int)Config.GetInstance().GetParameter(Config.C_PARA_MM_MIN_ENTRUST_VOLUME); _queryparam = new QueryPara(); _queryparam.fundcode = Config.GetInstance().GetParameter(Config.C_PARA_MM_FUNDCODE).ToString(); _queryparam.portfolio = Config.GetInstance().GetParameter(Config.C_PARA_MM_PORTFOLIO).ToString(); }
static void testHundsun3() { string user = "******"; string pwd = "Abc123456"; string acc = "1104"; string combi = "11040201"; string opcode = "90000229"; Option o = new Option(opcode, Exchange.SHE); EntrustHundsun eh = new EntrustHundsun(); eh.Logon(user, pwd); #region 查询持仓 QueryPara param = new QueryPara(); param.fundcode = acc; param.portfolio = combi; param.securitycode = opcode; eh.OptionPositionQuery(param, o.positionbook); eh.OptionEntrustQuery(param, o.entrustbook); #endregion }
static void testMM1() { string acc = "1104"; string combi = "11040201"; List <ASecurity> underlyinglist = new List <ASecurity>(); //underlyinglist.Add(new ETF("510050", Exchange.SHE)); underlyinglist.Add(new ETF("510180", Exchange.SHE)); underlyinglist.Add(new Stock("601318", Exchange.SHE)); //underlyinglist.Add(new Stock("600104", Exchange.SHE)); AMarket mkt = AMarket.GetInstance(MarketVendor.Exchange); List <Option> optionlist = mkt.GetOptionSet(underlyinglist); foreach (Option o in optionlist) { QueryPara param = new QueryPara(); param.fundcode = acc; param.portfolio = combi; param.securitycode = o.code; AEntrust et = AEntrust.GetInstance(EntrustVendor.Hundsun); et.OptionEntrustQuery(param, o.entrustbook); bool flg = o.makemarketstat.IsValid(); if (o.entrustbook != null && o.entrustbook.Count > 0) { foreach (EntrustBook eb in o.entrustbook) { eb.DebugPrint(); } } //Debug.Print(string.Format("spread, code={2},name={3},价差={0},{1}", o.makemarketstat.currminspreadpct.ToString("P2"), o.makemarketstat.message, o.code,o.name)); } }
protected virtual void sendorder(Option o, double askpx, double bidpx, QueryPara param) { if (askpx == bidpx) { MessageManager.GetInstance().Add(MessageType.Warning, string.Format("买价不能和卖价一样:{0},{1}", o.code, bidpx)); return; } //查询委托和持仓信息 _entrustengine.OptionEntrustQuery(param, o.entrustbook); _entrustengine.OptionPositionQuery(param, o.positionbook); //撤销现有委托 List <int> entrustnolist = new List <int>(); if (o.entrustbook.Count > 0) { entrustnolist.Clear(); foreach (EntrustBook eb in o.entrustbook) { entrustnolist.Add(eb.entrustno); } _entrustengine.OptionWithdraw(entrustnolist); } //查询持仓情况 int longposition = 0, shortposition = 0; if (o.positionbook.Count > 0) { foreach (PositionBook pb in o.positionbook) { if (pb.positiondirection == PostionDerection.LONG) { longposition = pb.volume; } else if (pb.positiondirection == PostionDerection.SHORT) { shortposition = pb.volume; } } } //委托参数 List <EntrustPara> paramlist = new List <EntrustPara>(); //卖出 EntrustPara paraAsk = new EntrustPara(); paraAsk.portfolio = param.portfolio; paraAsk.securitycode = param.securitycode; paraAsk.exchange = o.exchange; paraAsk.price = askpx; //Ask paraAsk.entrustdirection = TradeDirection.SELL; //卖出 paraAsk.volume = c_min_entrust_volume; if (longposition >= c_min_entrust_volume * 2) //开平 { paraAsk.futuredirection = FutureDirection.COVER; paraAsk.volume = c_min_entrust_volume * 2; } else if (longposition >= c_min_entrust_volume) { paraAsk.futuredirection = FutureDirection.COVER; } else { paraAsk.futuredirection = FutureDirection.OPEN; } //买入 EntrustPara paraBid = new EntrustPara(); paraBid.portfolio = param.portfolio; paraBid.securitycode = param.securitycode; paraBid.exchange = o.exchange; paraBid.price = bidpx; //Bid paraBid.entrustdirection = TradeDirection.BUY; //买入 paraBid.volume = c_min_entrust_volume; if (shortposition >= c_min_entrust_volume * 2) //开平 { paraBid.futuredirection = FutureDirection.COVER; paraBid.volume = c_min_entrust_volume * 2; } else if (shortposition >= c_min_entrust_volume) { paraBid.futuredirection = FutureDirection.COVER; } else { paraBid.futuredirection = FutureDirection.OPEN; } //篮子委托 paramlist.Add(paraAsk); paramlist.Add(paraBid); _entrustengine.OptionBasketEntrust(paramlist); }
static void Main(string[] args) { TimeDivider.Register("DbTimeDivider.Schema"); #region oracle var db = TimeDivider.GetService <OracleDB_Test>().Database; var tbl2 = TimeDivider.DbHosts[@"127.0.0.1"].Databases["user{0}"].Tables["ORACLE_SALE_BY_DAY_{0}"]; string ret = tbl2.ITableSchema.GenerateEntity(); //添加 var parameter = new QueryPara { Sql = @"『ORACLE_SALE_BY_DAY_{0}』", TargetTime1 = DateTime.Now, UseTransaction = true, }; OracleSaleByDay model3 = new OracleSaleByDay { PRODUCTID = Guid.NewGuid().ToString(), SYSNO = Guid.NewGuid().ToString(), BRANDID = Guid.NewGuid().ToString(), CATEGORYID = Guid.NewGuid().ToString(), SHOPID = Guid.NewGuid().ToString(), CREATEUSERID = Guid.NewGuid().ToString(), IMPORTGROUPID = Guid.NewGuid().ToString(), PRODUCTNAME = "abcd", CREATEDATE = DateTime.Now, STATISTICALDATE = DateTime.Now, UPDATEDATE = DateTime.Now, DATASOURCE = "aaa", OUTPRODUCTID = "ddd" + DateTime.Now.ToString() }; var rows = db.Insert <OracleSaleByDay>(parameter, model3); //执行查询 parameter = new QueryPara { Sql = @"select a.* from 『ORACLE_SALE_BY_DAY_{0}』 a", TargetTime1 = DateTime.Parse("2019-06-01"), TargetTime2 = DateTime.Parse("2020-05-01"), ParamSet = { { "SysNo", "99268d19-a950-4311-9aa5-017a4912d605" } }, Parameters = { "99268d19-a950-4311-9aa5-017a4912d605" } }; var tbl4 = db.Query(parameter); var list = db.Query <OracleSaleByDay>(parameter); #endregion #region sqlite db = TimeDivider.GetService <SqliteDB_Test>().Database; //添加 parameter = new QueryPara { Sql = @"『SaleByDay_{0}』", UseTransaction = true, }; SaleByDay model = new SaleByDay { ProductID = Guid.NewGuid().ToString(), SysNo = Guid.NewGuid().ToString(), BrandID = Guid.NewGuid().ToString(), CategoryID = Guid.NewGuid().ToString(), ShopID = Guid.NewGuid().ToString(), CreateUserID = Guid.NewGuid().ToString(), ImportGroupId = Guid.NewGuid().ToString(), ProductName = "abcd", CreateDate = DateTime.Now, StatisticalDate = DateTime.Now, UpdateDate = DateTime.Now, DataSource = "aaa", OutProductID = "ddd" + DateTime.Now.ToString() }; rows = db.Insert <SaleByDay>(parameter, model); //执行查询 parameter = new QueryPara { Sql = @"select a.* from 『SaleByDay_{0}』 a", TargetTime1 = DateTime.Parse("2019-06-01"), TargetTime2 = DateTime.Parse("2020-05-01"), ParamSet = { { "SysNo", "9A6F3506-33FF-4436-B845-02522BE98120" } }, Parameters = { "9A6F3506-33FF-4436-B845-02522BE98120" } }; tbl4 = db.Query(parameter); var list2 = db.Query <SaleByDay>(parameter); //删除 parameter = new QueryPara { Sql = @"delete from 『SaleByDay_{0}』 where SysNo = @0", TargetTime1 = DateTime.Parse("2019-06-01"), TargetTime2 = DateTime.Parse("2020-05-01"), Parameters = { "1be9fb12-f943-4c22-bea2-a3d51c711d02" }, UseTransaction = true }; rows = db.Execute(parameter); #endregion #region sql server db = TimeDivider.GetService <Lnsky_Test>().Database; //执行查询 parameter = new QueryPara { Sql = @"select a.* from 『Purify_ProductSaleByDay_{0}』 a left join 『SaleDetail_{0}』 b on a.SysNo = b.SysNo and b.SysNo = @0 where a.SysNo = @SysNo", TargetTime1 = DateTime.Parse("2019-06-01"), TargetTime2 = DateTime.Parse("2020-05-01"), ParamSet = { { "SysNo", "9A6F3506-33FF-4436-B845-02522BE98120" } }, Parameters = { "9A6F3506-33FF-4436-B845-02522BE98120" } }; tbl4 = db.Query(parameter); var list3 = db.Query <Purify_ProductSaleByDay>(parameter); //生成实体属性 //var tbl2 = TimeDivider.DbHosts[@".\sqlexpress"].Databases["Lnsky_Test_{0}"].Tables["Purify_ProductSaleByDay_{0}"]; //string ret = tbl2.ITableSchema.GenerateEntity(); //可执行添加、修改、删除 parameter = new QueryPara { Sql = @"insert into 『SaleDetail_{0}』(SysNo) values(@0)", TargetTime1 = DateTime.Parse("2019-06-01"), TargetTime2 = DateTime.Parse("2020-05-01"), Parameters = { "9A6F3506-33FF-4436-B845-02522BE98120" }, UseTransaction = true }; rows = db.Execute(parameter); //添加 parameter = new QueryPara { Sql = @"『Purify_ProductSaleByDay_{0}』", UseTransaction = true }; var model2 = new Purify_ProductSaleByDay { SysNo = Guid.NewGuid(), ProductName = "abcd", CreateDate = DateTime.Now, StatisticalDate = DateTime.Now, UpdateDate = DateTime.Now, DataSource = "aaa", OutProductID = "ddd" + DateTime.Now.ToString() }; rows = db.Insert <Purify_ProductSaleByDay>(parameter, model2, x => x.ProductID); //修改(注:主键是必须要排除的,有唯一索引时,不要多行更新成一样的值,会报错) parameter = new QueryPara { Sql = @"『Purify_ProductSaleByDay_{0}』", UseTransaction = true }; model2 = new Purify_ProductSaleByDay { SysNo = new Guid("9A6F3506-33FF-4436-B845-02522BE98120"), ProductName = "abcd", CreateDate = DateTime.Now, StatisticalDate = DateTime.Now, UpdateDate = DateTime.Now, DataSource = "aaa123", OutProductID = "ddd" + DateTime.Now.ToString() }; rows = db.Update <Purify_ProductSaleByDay>(parameter, model2, x => x.SysNo, i => i.SysNo); #endregion }