public void getDataByCondition() { String builtinDatetimeDateResolution = DateTime.Now.ToString("yyyy-MM-dd"); builtinDatetimeDateResolution = "2017-01"; List <t_activity> activityList = new List <t_activity>(); //楼层 String basic_info_code = String.Empty; //楼层 String floor_code = String.Empty; ActivityDao activityDao = new ActivityDao(); activityList = activityDao.getDataByCondition(basic_info_code, floor_code, MSDateUtil.getBegin(builtinDatetimeDateResolution), MSDateUtil.getEnd(builtinDatetimeDateResolution)); //activityList = activityDao.getDataByCondition(basic_info_code, floor_code, MSDateUtil.getBegin(builtinDatetimeDateResolution), null); Debug.WriteLine("count = " + activityList.Count); }
public void tttt() { String s = "XXXX-03-03"; DateTime?dt = MSDateUtil.getBegin(s); if (dt.HasValue) { Debug.WriteLine(dt.ToString()); } else { Debug.WriteLine("null"); } DateTime?dt1 = MSDateUtil.getEnd(s); if (dt1.HasValue) { Debug.WriteLine(dt1.ToString()); } else { Debug.WriteLine("null"); } Debug.WriteLine(DateTime.Now.DayOfWeek); DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; DateTime dt11 = new DateTime(2016, 1, 1); //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay ,dfi.FirstDayOfWeek)); Debug.WriteLine("Week" + cal.GetWeekOfYear(dt11, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)); dt11 = cal.AddWeeks(dt11, 5); Debug.WriteLine("Week" + cal.GetWeekOfYear(dt11, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)); if (dt11.DayOfWeek == DayOfWeek.Sunday) { Debug.WriteLine("sunday"); Debug.WriteLine(dt11.ToString("yyyy/MM/dd")); Debug.WriteLine(dt11.AddDays(6).ToString("yyyy/MM/dd")); } else { Debug.WriteLine("other"); Debug.WriteLine(dt11.AddDays(8 - (int)dt11.DayOfWeek).AddDays(-7).ToString("yyyy/MM/dd")); Debug.WriteLine(dt11.AddDays(8 - (int)dt11.DayOfWeek).AddDays(-1).ToString("yyyy/MM/dd")); } //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Monday)); //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, dfi.FirstDayOfWeek)); //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday)); //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)); //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFullWeek, dfi.FirstDayOfWeek)); //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFullWeek, DayOfWeek.Sunday)); //Debug.WriteLine("Week" + cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday)); }
//根据基础信息、楼层,查询活动列表 public List <t_activity> GetActivityListByBasciInfoAndFloor(String basicInfoText, String floorText, String builtinDatetimeDateResolution) { List <t_activity> activityList = new List <t_activity>(); //楼层 String basic_info_code = String.Empty; //楼层 String floor_code = String.Empty; //判断基础信息是否为空 if (!String.IsNullOrWhiteSpace(basicInfoText)) { t_word bi_word = getWordBySynonym(basicInfoText); //判断基础信息是否可以查询到 if (null != bi_word) { basic_info_code = bi_word.code; } //基础信息查询不到就返回空列表 else { return(activityList); } } //判断楼层是否为空 if (!String.IsNullOrWhiteSpace(floorText)) { t_word f_word = getWordBySynonym(floorText); //判断楼层是否可以查询到 if (null != f_word) { floor_code = f_word.code; } //楼层查询不到就返回空列表 else { return(activityList); } } activityList = activityDao.getDataByCondition(basic_info_code, floor_code, MSDateUtil.getBegin(builtinDatetimeDateResolution), MSDateUtil.getEnd(builtinDatetimeDateResolution)); if (activityList.Count >= 5) { activityList = activityList.Take(5).ToList(); } return(activityList); }