public static void StrategyThread(Object _obj) { Strategy stag = (Strategy)_obj; if (stag.printMsg != null) { stag.printMsg.Print("启动监控线程 成功!"); } Thread.Sleep(3000); for (; ;) { try { lock (stag) { stag.OnTimer(); } Thread.Sleep(2); } catch (JHTradeException ex) { JHLog.forTradeLog(ex.ToString()); if (stag.printMsg != null) { stag.printMsg.Print("监控线程执行异常!message:" + ex.Message); stag.printMsg.Print("重新启动监控线程 . . ."); } stag.thread = new Thread(new ParameterizedThreadStart(StrategyThread)); stag.thread.Start(stag); break; }catch (JHMarketException JM) { JHLog.forTradeLog(JM.ToString()); if (stag.printMsg != null) { stag.printMsg.Print("监控线程执行异常!message:" + JM.Message); stag.printMsg.Print("重新启动监控线程 . . ."); } stag.thread = new Thread(new ParameterizedThreadStart(StrategyThread)); stag.thread.Start(stag); break; } catch (Exception ex) { JHLog.forTradeLog(ex.ToString()); stag.PrintLine("异常停止!" + ex.Message); break; } } }
public IHttpActionResult Get() { var re = Request; var headers = re.Headers; string token = ""; if (headers.Contains("APIKey")) { token = headers.GetValues("APIKey").First(); } Validation validation = new Validation(); bool valid = validation.CheckApiKey(token); if (valid) // APIKey is valid { using (incposdbEntities entity = new incposdbEntities()) { var medalsList = (from MA in entity.medalAgent join M in entity.medals on MA.medalId equals M.medalId into JM join A in entity.agents on MA.agentId equals A.agentId into JA join U in entity.users on MA.createUserId equals U.userId into JU from JMM in JM.DefaultIfEmpty() from JAA in JA.DefaultIfEmpty() from JUU in JU.DefaultIfEmpty() select new MedalAgentModel() { id = MA.id, medalId = MA.medalId, agentId = MA.agentId, notes = MA.notes, isActive = MA.isActive, createDate = MA.createDate, updateDate = MA.updateDate, createUserId = MA.createUserId, updateUserId = MA.updateUserId, agentName = JAA.name, medalName = JMM.name, createUserName = JUU.username, } ).Select(c => new MedalAgentModel() { }) .ToList(); /* * * id * medalId * agentId * offerId * couponId * notes * isActive * createDate * updateDate * createUserId * updateUserId * */ // can delet or not if (medalsList == null) { return(NotFound()); } else { return(Ok(medalsList)); } } } //else return(NotFound()); }