protected void Btn_LiveData_Query_Click(object sender, EventArgs e) { DateTime startTime = DateTime.Parse(DDL_LiveData_Query_Year.SelectedItem.Value + "-" + DDL_LiveData_Query_Month.SelectedItem.Value + "-01"); DateTime endTime = startTime.AddMonths(1); LiveData_BLL bll = new LiveData_BLL(); List <LiveData> list = bll.GetList(a => a.Category == DDL_LiveData_Query_Time.SelectedItem.Value && a.FDate >= startTime && a.FDate < endTime).OrderBy(a => a.FDate).ThenBy(a => a.CountryName).ToList(); GridView_LiveData.DataSource = list; GridView_LiveData.DataBind(); }
protected void Btn_DataCheck_Click(object sender, EventArgs e) { DateTime startTime = DateTime.Parse(DropDownList_Year.SelectedItem.Value + "-" + DropDownList_Month.SelectedItem.Value + "-01"); DateTime endTime = startTime.AddMonths(1); LiveData_BLL bll = new LiveData_BLL(); List <LiveData> list = bll.GetList( a => a.FDate >= startTime & a.FDate < endTime && a.Category == DropDownList_YBTime.SelectedItem.Value) .OrderBy(a => a.FDate).ThenBy(a => a.CountryCode) .ToList(); //GridView1.DataSource = list; //GridView1.DataBind(); TimeSpan timeSpan = endTime - startTime; List <LiveData_Check> ldcList = new List <LiveData_Check>(); List <string> citys = CityUtility.AllNameList(); for (int i = 0; i < timeSpan.Days; i++) { DateTime currentDate = startTime.AddDays(i); List <LiveData> daylist = list.Where(a => a.FDate == currentDate).ToList(); LiveData_Check ldc = new LiveData_Check(); ldc.Date = currentDate; StringBuilder dataMissStr = new StringBuilder(); foreach (string city in citys) { LiveData dayCity = daylist.Where(a => a.CountryName == city).FirstOrDefault(); if (dayCity != null) { if (dayCity.MaxTemp == null || dayCity.MinTemp == null || dayCity.Rain == null) { dataMissStr.Append("<li style='color:#ff6a00;'>" + city + " 缺少 "); string missElement = string.Empty; if (dayCity.MaxTemp == null) { missElement += "最高温度 "; } if (dayCity.MinTemp == null) { missElement += "最低温度 "; } if (dayCity.Rain == null) { missElement += "降水 "; } dataMissStr.Append(missElement); dataMissStr.Append("数据<br/></li>"); } } else { dataMissStr.Append("<li style='color:#ff0000;'>" + city + " 缺少 最高温度 最低温度 降水 数据<br/></li>"); } } ldc.DataMiss = dataMissStr.ToString(); if (!String.IsNullOrWhiteSpace(ldc.DataMiss)) { ldcList.Add(ldc); } } Repeater_DataCheck.DataSource = ldcList; Repeater_DataCheck.DataBind(); if (ldcList.Count() > 0) { Label_DataMiss.Text = startTime.ToString("yyyy年MM月") + DropDownList_YBTime.SelectedItem.Value + "实况数据有缺失,请及时补充!"; Panel_DataMiss.Visible = true; } else { Label_DataMiss.Text = startTime.ToString("yyyy年MM月") + DropDownList_YBTime.SelectedItem.Value + "实况数据齐全!"; Panel_DataMiss.Visible = false; } }