private void LoadData() { int totalRowsCount = 0; UserProfile user = UserProfile.GetInstance(); string employeeID = user.ID; StringBuilder sbWhere = new StringBuilder(); if (!user.Role.Any(item => item.RoleName.Contains("管理员"))) { sbWhere.AppendFormat(" employeeID = '{0}' AND type = 2 ", employeeID); } else { sbWhere.Append(" type = 2 "); } AspNetPager1.PageSize = 20; List <TaskTrend> lstTrend = new TaskTrendBLL().GetModelListPage(sbWhere.ToString(), AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalRowsCount); AspNetPager1.RecordCount = totalRowsCount; lblRecordCount.Text = totalRowsCount.ToString(); List <TaskTrendInterface> lstResult = new List <TaskTrendInterface>(); foreach (var item in lstTrend) { TaskTrendInterface taskTrendInterface = new TaskTrendInterface(); taskTrendInterface.ID = item.ID; taskTrendInterface.ProjectId = item.PROJECTID; taskTrendInterface.CreateDate = item.CREATEDATE ?? DateTime.Now; taskTrendInterface.FriendlyDate = DateTimeHelper.ChangeTime(item.CREATEDATE ?? DateTime.MinValue); if (item.DESCRIPTION.IndexOf("客户ID:") > -1) { string wangwangId = this.MidStrEx(item.DESCRIPTION, "客户ID:", "Store ID:").Trim(); if (!string.IsNullOrEmpty(item.DESCRIPTION)) { taskTrendInterface.TrendContent = item.DESCRIPTION.Replace(wangwangId, "<a href=\"http://www.taobao.com/webww/ww.php?ver=3&touid=" + wangwangId + "&siteid=cntaobao&status=2&charset=utf-8\" target=\"_blank\" class=\"awwm\">" + "<img border=\"0\" src = \"http://amos.alicdn.com/online.aw?v=2&uid=" + wangwangId + "&site=cntaobao&s=2&charset=utf-8\">" + wangwangId + "</a> ").Replace("客户ID:", string.Empty); } else { taskTrendInterface.TrendContent = string.Empty; } } else { taskTrendInterface.TrendContent = item.DESCRIPTION; } taskTrendInterface.ReadStatus = item.READSTATUS; lstResult.Add(taskTrendInterface); } gvTrend.DataSource = lstResult; gvTrend.DataBind(); }
private string GetTrends(HttpContext context) { StringBuilder sbJsonResult = new StringBuilder(); string employeeID = context.Request.Params["employeeID"]; List <TaskTrend> lstTrend = new TaskTrendBLL().GetTop10ModelList(" employeeID = '" + employeeID + "' AND type = 1"); List <TaskTrendInterface> lstResult = new List <TaskTrendInterface>(); foreach (var item in lstTrend) { TaskTrendInterface taskTrendInterface = new TaskTrendInterface(); taskTrendInterface.CreateDate = item.CREATEDATE ?? DateTime.Now; taskTrendInterface.FriendlyDate = DateTimeHelper.ChangeTime(item.CREATEDATE ?? DateTime.MinValue); taskTrendInterface.TrendContent = item.DESCRIPTION; lstResult.Add(taskTrendInterface); } sbJsonResult.Append(JsonConvert.SerializeObject(lstResult)); return(sbJsonResult.ToString()); }