private void ClearList() { NormalWaitAreaCountList.Clear(); NormalWaitAreaTimeList.Clear(); ExportWaitAreaCountList.Clear(); ExportWaitAreaTimeList.Clear(); }
private void ParseDataFromBase(List <FZDataInfo> currentDataList) { ClearList(); if (currentDataList == null || currentDataList.Count == 0) { LogHelper.logerror.Error("Cannot get data from sql server"); return; } try { foreach (var areaList in this._areaOfficeNameList) { #if Test var waitCountforOneArea = currentDataList.Where(x => x.HJBZ == "2" && areaList.Any(a => a == x.FZKS)) .Select(p => new { p.FZKS, p.expert_flag }) .ToList(); #else var waitCountforOneArea = currentDataList.Where(x => x.HJBZ == "0" && areaList.Any(a => a == x.FZKS)) .Select(p => new { p.FZKS, p.expert_flag }) .ToList(); #endif var queryMostCount = waitCountforOneArea .GroupBy(x => new { x.FZKS, x.expert_flag }) .Select(group => new { Key = group.Key, Count = group.Count() }); var ksinfo = queryMostCount.OrderByDescending(x => x.Count).FirstOrDefault(); MostWaitKSInfo = string.Format("提示: \r\n{0} {1} \r\n等待人数 : {2}", _ksNameList[ksinfo.Key.FZKS], ksinfo.Key.expert_flag == "0" ? "普通号" : "专家号", ksinfo.Count); //Update Wait count for normal NormalWaitAreaCountList.Add(waitCountforOneArea.Where(x => x.expert_flag == "0").Count()); //Update Wait count for export ExportWaitAreaCountList.Add(waitCountforOneArea.Where(x => x.expert_flag != "0").Count()); var templistforTime = (from p in currentDataList where p.FZSJ.HasValue && p.CALLTIME.HasValue && areaList.Any(a => a == p.FZKS) select new { p.CALLTIME, p.FZSJ, p.expert_flag }).ToList(); var timeInfoforNormal = templistforTime.Where(x => x.expert_flag == "0").Select(x => (x.CALLTIME - x.FZSJ).Value.TotalMinutes).ToList(); //Update wait avg time for normal if (timeInfoforNormal.Count > 0) { NormalWaitAreaTimeList.Add(Math.Round((double)timeInfoforNormal.Average(), 0)); } else { NormalWaitAreaTimeList.Add(0); } var timeInfoforExport = templistforTime.Where(x => x.expert_flag != "0").Select(x => (x.CALLTIME - x.FZSJ).Value.TotalMinutes).ToList(); //Update wait avg time for export if (timeInfoforExport.Count > 0) { ExportWaitAreaTimeList.Add(Math.Round((double)timeInfoforExport.Average(), 0)); } else { ExportWaitAreaTimeList.Add(0); } } NormalWaitAvgTime = (int)Math.Round(NormalWaitAreaTimeList.Average()); ExportWaitAvgTime = (int)Math.Round(ExportWaitAreaTimeList.Average()); WaitAvgTime = (NormalWaitAvgTime + ExportWaitAvgTime) / 2; LogHelper.loginfo.Info("Update data successfully!"); } catch (Exception ex) { LogHelper.logerror.Error(ex); } }