/// <summary>更新配置信息--Python监测接口 /// </summary> /// <param name="setInfo"></param> /// <returns></returns> public bool Updata_APISets(MonitorSet setInfo) { if (setInfo == null) { return(false); } //GET请求并等待结果 string statusCode = ""; var result = zxcNetHelper.Get_ByHttpClient(_urlAPI_Set, setInfo.ToJson_Str(), out statusCode); if (statusCode.ToLower() != "ok") { return(false); } if (!setInfo.IsValid) { int ind = Quote_Datas._Datas._setsMoitor.FindIndex(e => e.IsValid == false && e.SpiderName == setInfo.SpiderName); Quote_Datas._Datas._setsMoitor.RemoveAt(ind); Quote_Datas._Datas._setsMoitor.SaveChanges(true); return(true); } List <MonitorSet> pSets = this.TransTo_MonitorSet(result); return(this.Updata_MonitorSets(pSets)); }
/// <summary>提取本地监测设置信息 /// </summary> /// <param name="spiderName"></param> /// <param name="isValid"></param> /// <param name="spiderTag"></param> /// <param name="timeSet"></param> /// <param name="mark"></param> /// <param name="autoCreate"></param> /// <returns></returns> public MonitorSet Get_MonitorSet(string spiderName, bool isValid, string mark = "", string spiderTag = "quote", string timeSet = "", bool autoCreate = true) { MonitorSet pSet = this.Get_MonitorSet(spiderName, spiderTag); //自动生成 if (pSet == null && autoCreate) { pSet = new MonitorSet { SpiderName = spiderName, SpiderTag = spiderTag, Mark = mark, TimeSet = timeSet != "" ? timeSet : "* 9.45-11.5;13-15.1 * * 1-6" } } ; pSet.IsValid = isValid; return(pSet); }
//积分添加 protected internal bool _Done_Quote_MonitorSet(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.ReadOnly) { //用户权限判断 Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot; if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot)) { return(false); } //提取行情API配置 string stockName = ((CmdInfos_QuoteQuantify)pRobotCmd.CmdInfos).StockName; if (string.IsNullOrEmpty(stockName)) { this.NotifyMsg("未指定标的名称,无法配置!", msg, "行情信息"); return(false); } //检查标的信息 bool isValid = stockName.Substring(0, 1) != "-"; stockName = stockName.Replace("+", "").Replace("-", ""); StockInfo pStockInfo = Quote_Manager._Manager.Stocks.Get_StockInfo(stockName); if (pStockInfo == null) { this.NotifyMsg(string.Format("标的({0})未识别!情检查确认。", stockName), msg, "行情信息"); return(false); } //更新API监测配置 if (Quote_Manager._Manager.QuoteMonitor._MonitorSets.Updata_APISets(pStockInfo.StockID_TagSina, isValid)) { MonitorSet pSet = Quote_Manager._Manager.QuoteMonitor._MonitorSets.Get_MonitorSet(pStockInfo.StockID_TagSina); string strMsg = string.Format("标的({0}) {1} 行情监测。", pStockInfo.StockName, pSet == null ? "已移除" : pSet.IsValid ? "已启动" : "已暂停"); zxcConsoleHelper.Debug(true, "行情信息:\n{0}", strMsg); this.NotifyMsg(strMsg, msg, "行情信息"); } return(true); }
/// <summary>将行情数据转换为Json /// </summary> /// <param name="strData"></param> /// <param name="barUnit">bar的时间单位</param> /// <returns></returns> protected internal List <MonitorSet> TransTo_MonitorSet(string strData) { JObject pRes = JObject.Parse(strData); JArray jsonDatas = (JArray)pRes["datas"]; if (jsonDatas == null) { return(null); } List <MonitorSet> pSets = new List <MonitorSet>(); foreach (var item in jsonDatas) { MonitorSet pSet = new MonitorSet(); if (pSet.FromJson(item)) { pSets.Add(pSet); } } return(pSets); }
/// <summary>提取本地监测设置信息 /// </summary> /// <param name="spiderName"></param> /// <param name="spiderTag"></param> /// <returns></returns> public MonitorSet Get_MonitorSet(string spiderName, string spiderTag = "quote") { MonitorSet pSet = Quote_Datas._Datas._setsMoitor.Find(e => e.SpiderName == spiderName && e.SpiderTag == spiderTag && e.IsValid == true && e.IsDel == false); return(pSet); }
/// <summary>更新配置信息--Python监测接口 /// </summary> /// <param name="spiderName"></param> /// <param name="isValid"></param> /// <param name="mark"></param> /// <param name="spiderTag"></param> /// <param name="timeSet"></param> /// <param name="autoCreate"></param> /// <returns></returns> public bool Updata_APISets(string spiderName, bool isValid, string mark = "", string spiderTag = "quote", string timeSet = "", bool autoCreate = true) { MonitorSet pSet = this.Get_MonitorSet(spiderName, isValid, mark, spiderTag, timeSet, autoCreate); return(this.Updata_APISets(pSet)); }