public void Calculate08() { File_Z_BLL zbll = new File_Z_BLL(); LiveData_BLL lbll = new LiveData_BLL(); DateTime lastDay = DateTime.Now.AddDays(-5); List <File_Z> zlist = zbll.GetList(a => a.Date >= lastDay).ToList(); DateTime newDay = (DateTime)zlist.Max(a => a.Date); List <File_Z> prelist = zlist.Where(a => a.Date != newDay).OrderBy(a => a.Date).ToList(); foreach (File_Z fileZ in prelist) { DateTime nextDay = ((DateTime)fileZ.Date).AddDays(1); File_Z nextFileZ = zlist.Where(a => a.Date == nextDay && a.CountryCode == fileZ.CountryCode).FirstOrDefault(); LiveData liveData = lbll.Get(a => a.FDate == fileZ.Date && a.CountryCode == fileZ.CountryCode && a.Category == "08时"); if (liveData != null) { if (liveData.Rain == null) { liveData.Rain = fileZ.Eight_Twenty + nextFileZ.Twenty_Eight; lbll.Update(liveData); } } else { liveData = new LiveData() { LDID = Guid.NewGuid(), Category = "08时", CountryCode = fileZ.CountryCode, CountryName = fileZ.CountryName, CreateTime = DateTime.Now, FDate = fileZ.Date, Rain = fileZ.Eight_Twenty + nextFileZ.Twenty_Eight }; lbll.Add(liveData); } Console.WriteLine("成功计算08时:" + fileZ.CountryName + fileZ.Date.ToString()); } }
public void Calculate20() { File_Z_BLL zbll = new File_Z_BLL(); LiveData_BLL lbll = new LiveData_BLL(); DateTime lastDay = DateTime.Now.AddDays(-5); List <File_Z> zlist = zbll.GetList(a => a.Date >= lastDay).OrderBy(a => a.Date).ToList(); foreach (File_Z fileZ in zlist) { LiveData liveData = lbll.Get(a => a.FDate == fileZ.Date && a.CountryCode == fileZ.CountryCode && a.Category == "20时"); if (liveData != null) { if (liveData.Rain == null) { liveData.Rain = fileZ.Twenty_Eight + fileZ.Eight_Twenty; lbll.Update(liveData); } } else { liveData = new LiveData() { LDID = Guid.NewGuid(), Category = "20时", CountryCode = fileZ.CountryCode, CountryName = fileZ.CountryName, CreateTime = DateTime.Now, FDate = fileZ.Date, Rain = fileZ.Twenty_Eight + fileZ.Eight_Twenty }; lbll.Add(liveData); } Console.WriteLine("成功计算20时:" + fileZ.CountryName + fileZ.Date.ToString()); } }