public static IEnumerable <CommentTousuType> GetTousuType(int level) { var dt = DALCommentReport.GetTousuType(level); if (dt == null || dt.Rows.Count <= 0) { return(new CommentTousuType[0]); } return(dt.Rows.Cast <DataRow>().Select(row => new CommentTousuType(row))); }
public static List <Tuple <int, string> > GetTousuType(List <int> ids) { var data = DALCommentReport.GetTousuInfo(ids); var tousuTypeItems = DALCommentReport.GetTousuType(); var result = new List <Tuple <int, string> >(); for (var i = 0; i < data.Count(); i++) { var complaint = data[i].Item2; string content = ""; if (!string.IsNullOrEmpty(complaint)) { var complaintItems = JsonConvert.DeserializeObject <List <TousuContent> >(complaint); foreach (var item in complaintItems) { var typeText = string.Empty; Tuple <int, string, string, string> tousuTypeItem = null; string key = item.key; int level = 0; bool flag = true; while (flag) { if (level == 0) { tousuTypeItem = tousuTypeItems.Where(fd => fd.Item2.Equals(key)).FirstOrDefault(); } else { tousuTypeItem = tousuTypeItems.Where(fd => fd.Item2.Equals(key) && fd.Item1.Equals(level - 1)).FirstOrDefault(); } if (tousuTypeItem != null) { typeText = tousuTypeItem.Item3 + "-" + typeText; key = tousuTypeItem.Item4; level = tousuTypeItem.Item1; } else { flag = false; } } if (!string.IsNullOrEmpty(typeText)) { typeText = typeText.TrimEnd('-'); content += typeText + "|"; } } } result.Add(Tuple.Create(data[i].Item1, content.TrimEnd('|'))); } return(result); }