protected void Btn_DataImport_Warn_Click(object sender, EventArgs e) { DateTime startTime = DateTime.Parse(DDL_Year_Warn.SelectedItem.Value + "-" + DDL_Month_Warn.SelectedItem.Value + "-01"); DateTime endTime = startTime.AddMonths(1); string[] categorys = { "暴雨", "暴雪", "大风", "大雾" }; EARLY_WARNING_COUNTRIES_BLL ebll = new EARLY_WARNING_COUNTRIES_BLL(); List <EARLY_WARNING_COUNTRIES> elist = ebll.GetList( a => a.COUNTRY == "青岛" && !a.WARNING_CONTENT.Contains("解除") && !a.WARNING_CONTENT.Contains("继续发布") && a.INSERTTIME >= startTime && a.INSERTTIME < endTime && categorys.Contains(a.WARNING_CATAGRAY)).OrderBy(a => a.INSERTTIME).ToList(); WarnCheck_BLL wbll = new WarnCheck_BLL(); wbll.Delete(a => a.ReleaseTime >= startTime && a.ReleaseTime < endTime); foreach (var warningCountries in elist) { DateTime da = DateTime.ParseExact(warningCountries.PUBLISHTIME, "yyyy年MM月dd日HH时mm分", CultureInfo.InvariantCulture); WarnCheck wc = new WarnCheck() { CheckID = Guid.NewGuid(), ReleaseTime = da, WarningCategory = warningCountries.WARNING_CATAGRAY, WarningLevel = warningCountries.WARNING_LEVEL.Substring(0, 2) }; wbll.Add(wc); } QueryWarnInfo(); Response.Write("<script language=javascript defer>alert('导入成功!');</script>"); }
public WarnCheck_ReachStation_ViewModel Caculate_Visibility(WarnCheck wc) { double minValue = 200; double maxValue = 500; if (wc.WarningLevel == "黄色") { minValue = 200; maxValue = 500; } else if (wc.WarningLevel == "橙色") { minValue = 50; maxValue = 200; } else if (wc.WarningLevel == "红色") { minValue = 0; maxValue = 50; } List <WarnCheck_Station> stations = new WarnCheck_Station_BLL().GetList().ToList(); DATAMINUTE_BLL dbll = new DATAMINUTE_BLL(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < stations.Count; i++) { if (i != stations.Count - 1) { sb.Append("'" + stations.ElementAt(i).StationName + "',"); } else { sb.Append("'" + stations.ElementAt(i).StationName + "'"); } } DateTime startTime = ((DateTime)wc.ReleaseTime).AddHours(-2); DateTime endTime = ((DateTime)wc.ReleaseTime).AddHours(12); string sql = "select staname as StationName,fdate as DateTime,visibility as Value from (SELECT * FROM DATAMINUTE a WHERE a.staname in (" + sb.ToString() + ") and a.fdate>= to_date('" + startTime.ToString("yyyy-MM-dd HH:mm") + "','yyyy-mm-dd hh24:mi') and a.fdate<= to_date('" + endTime.ToString("yyyy-MM-dd HH:mm") + "','yyyy-mm-dd hh24:mi') and visibility > " + minValue + " and visibility <= " + maxValue + " order by a.fdate) where rownum <= 1"; List <WarnCheck_ReachStation_ViewModel> list = db.Database.SqlQuery <WarnCheck_ReachStation_ViewModel>(sql) .ToList(); return(list.FirstOrDefault()); }