public string PRSMinuteRk(DateTime dateTime) { try { 数据库处理 sjkcl = new 数据库处理(adminCodes); return(sjkcl.分钟常规气压入库(dateTime.AddMinutes(-5), dateTime)); } catch { return(""); } }
/// <summary> /// 恢复前三天的数据 /// </summary> public void HFRk() { 数据库处理 sjkcl = new 数据库处理(adminCodes); DateTime sDateTime = DateTime.Now.Date.AddDays(-3), eDateTime = DateTime.Now.Date; ObservableCollection <资料种类> sjbg = sjkcl.获取数据库表信息(); foreach (资料种类 item in sjbg) { if (item.ID == 1) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟其他资料入库(dateTime.AddMinutes(-9), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 2) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟降水量入库(dateTime.AddMinutes(-9), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 3) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟常规气压入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他气压入库(dateTime.AddMinutes(-9), dateTime) + str; callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 4) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟常规湿度入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他湿度入库(dateTime.AddMinutes(-9), dateTime) + str; callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 5) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟常规温度入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他温度入库(dateTime.AddMinutes(-9), dateTime) + str; callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 6) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟其他风入库(dateTime.AddMinutes(-9), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 7) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时其他资料入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 8) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时降水量入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 9) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时气压入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 10) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时湿度入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 11) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时温度入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 12) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时风入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } } }
private void RadPathButton_Click(object sender, RoutedEventArgs e) { if (dataCom.SelectedItems.Count > 0 && sDatePic.SelectedValue.HasValue && eDatePic.SelectedValue.HasValue && sDatePic.SelectedValue <= eDatePic.SelectedValue) { System.Collections.IList lists = dataCom.SelectedItems; 数据库处理 sjkcl = new 数据库处理(); DateTime sDateTime = Convert.ToDateTime(sDatePic.SelectedValue), eDateTime = Convert.ToDateTime(eDatePic.SelectedValue); foreach (资料种类 item in lists) { if (item.ID == 1) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.分钟其他资料入库(dateTime.AddMinutes(-9), dateTime); dateTime = dateTime.AddMinutes(10); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 2) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.分钟降水量入库(dateTime.AddMinutes(-9), dateTime); dateTime = dateTime.AddMinutes(10); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 3) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.分钟常规气压入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他气压入库(dateTime.AddMinutes(-9), dateTime) + str; dateTime = dateTime.AddMinutes(10); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 4) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.分钟常规湿度入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他湿度入库(dateTime.AddMinutes(-9), dateTime) + str; dateTime = dateTime.AddMinutes(10); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 5) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.分钟常规温度入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他温度入库(dateTime.AddMinutes(-9), dateTime) + str; dateTime = dateTime.AddMinutes(10); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 6) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.分钟其他风入库(dateTime.AddMinutes(-9), dateTime); dateTime = dateTime.AddMinutes(10); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 7) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.小时其他资料入库(dateTime.AddHours(-4), dateTime); dateTime = dateTime.AddHours(5); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 8) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.小时降水量入库(dateTime.AddHours(-4), dateTime); dateTime = dateTime.AddHours(5); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 9) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.小时气压入库(dateTime.AddHours(-4), dateTime); dateTime = dateTime.AddHours(5); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 10) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.小时湿度入库(dateTime.AddHours(-4), dateTime); dateTime = dateTime.AddHours(5); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 11) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.小时温度入库(dateTime.AddHours(-4), dateTime); dateTime = dateTime.AddHours(5); callDuration.Text = str + callDuration.Text; } }); } else if (item.ID == 12) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); while (dateTime.CompareTo(eDateTime) <= 0) { string str = sjkcl.小时风入库(dateTime.AddHours(-4), dateTime); dateTime = dateTime.AddHours(5); callDuration.Text = str + callDuration.Text; } }); } } } else { RadWindow.Alert(new DialogParameters { Content = "参数输入错误,请重新输入选项" }); } }