public MapperService() { var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <PoolDetail, LimitUp>() .ForMember(tag => tag.limit_timeline, sour => sour.MapFrom(p => JsonConvert.SerializeObject(p.limit_timeline))) .ForMember(tag => tag.surge_reason, sour => sour.MapFrom(p => JsonConvert.SerializeObject(p.surge_reason))) .ForMember(tag => tag.id, sour => sour.Ignore()); cfg.CreateMap <LimitUp, PoolDetail>() .ForMember(tag => tag.limit_timeline, sour => sour.MapFrom(p => JsonConvert.DeserializeObject <PoolDetail.LimitTimeline>(p.limit_timeline))) .ForMember(tag => tag.surge_reason, sour => sour.MapFrom(p => JsonConvert.DeserializeObject <PoolDetail.SurgeReason>(p.surge_reason))) .ForMember(tag => tag.id, sour => sour.Ignore()); cfg.CreateMap <PoolDetail, limitUpBroken>() .ForMember(tag => tag.limit_timeline, sour => sour.MapFrom(p => JsonConvert.SerializeObject(p.limit_timeline))) .ForMember(tag => tag.surge_reason, sour => sour.MapFrom(p => JsonConvert.SerializeObject(p.surge_reason))) .ForMember(tag => tag.id, sour => sour.Ignore()); cfg.CreateMap <limitUpBroken, PoolDetail>() .ForMember(tag => tag.limit_timeline, sour => sour.MapFrom(p => JsonConvert.DeserializeObject <PoolDetail.LimitTimeline>(p.limit_timeline))) .ForMember(tag => tag.surge_reason, sour => sour.MapFrom(p => JsonConvert.DeserializeObject <PoolDetail.SurgeReason>(p.surge_reason))) .ForMember(tag => tag.id, sour => sour.Ignore()); cfg.CreateMap <PoolDetail, APIPoolDetail>(). ForMember(tag => tag.thatDate, sour => sour.MapFrom(p => TimeHelper.ConvertToDateTime((long)p.last_limit_up).Date.ToString("yyyyMMdd") )).ForMember(tag => tag.strWeek, sour => sour.MapFrom(p => this.chineseStrWeek((long)p.last_limit_up) )); cfg.CreateMap <PoolDetail, APIPoolDetailWithoutST>(). ForMember(tag => tag.thatDate, sour => sour.MapFrom(p => p.last_limit_up )).ForMember(tag => tag.strWeek, sour => sour.MapFrom(p => this.chineseStrWeek((p.last_limit_up.ToString()) ))).ForMember(tag => tag.symbol, sour => sour.MapFrom(p => string.Empty )); //var tp = TimeHelper.ConvertToDateTime((long)item.last_limit_up).Date; //var dt = TimeHelper.ConvertToTimeStamp(tp); //item.last_limit_up = dt; //.ForMember(tag => tag.CHANNELNAME, sour => sour.MapFrom(p => p.details.dId)); }); configuration.AssertConfigurationIsValid(); _configuration = configuration; // var fooDto = mapper.Map<FooDto>(foo); }
public List <PoolDetail> GetAllTopPoolDetail(bool withoutST = false) { var list = new List <PoolDetail>(); try { var coloum = "last_limit_up,limit_up_days,stock_chi_name,symbol,stock_type"; string sql = $"select {coloum} from pool_detail where 1=1 "; var dynamicParams = new DynamicParameters(); if (withoutST) { sql += " and position('ST' in stock_chi_name)=0;"; // dynamicParams.Add("stock_type", 1); } var totayDBData = _dBService.FinanceDB.Query <LimitUp>(sql).ToList(); var resPoolDetail = new List <LimitUp>(); foreach (var item in totayDBData) { var tp = TimeHelper.ConvertToDateTime((long)item.last_limit_up).Date; var dt = TimeHelper.ConvertToTimeStamp(tp); item.last_limit_up = dt; } var a = totayDBData.GroupBy(p => p.last_limit_up); foreach (var item in a) { var max = item.ToList().OrderByDescending(p => p.limit_up_days).FirstOrDefault(); resPoolDetail.Add(max); } list = _mapperService.MapCheck <List <PoolDetail> >(resPoolDetail); } catch (Exception ex) { this.SetTaskLog("error_GetTodayPoolDetail", ex.Message + ex.StackTrace); } return(list); }
private string chineseStrWeek(long tT) { var k = TimeHelper.ConvertToDateTime(tT).Date.DayOfWeek.ToString(); var str = string.Empty; switch (k) { case "Monday": str = "周一"; break; case "Tuesday": str = "周二"; break; case "Wednesday": str = "周三"; break; case "Thursday": str = "周四"; break; case "Friday": str = "周五"; break; default: str = "未知"; break; } return(str); }
private int TOpenJwtToken(string token, string apiUri, out string strInfo) { int info = 0; strInfo = string.Empty; var k = new JwtSecurityToken(token); var end = k.Claims.Where(p => p.Type == "exp").FirstOrDefault().Value; var expired = TimeHelper.ConvertToDateTime(Convert.ToInt32(end)); if (DateTime.Now < expired) { info = 2;//正常 } else { var start = k.Claims.Where(p => p.Type == "nbf").FirstOrDefault().Value; var started = TimeHelper.ConvertToDateTime(Convert.ToInt32(start)); TimeSpan ts = expired.Subtract(started); int sec = (int)ts.TotalSeconds; if (DateTime.Now < expired.AddSeconds(sec * 2)) { if (apiUri == refreshtoken) { info = 2;//通过刷新API } else { info = 1;//需要刷新,但仍然正常返回 strInfo = k.Claims.Where(p => p.Type == "gk2823").FirstOrDefault().Value; } } else { info = 0;//超时 } } return(info); }