public ResultNoTime GetMessageDeleteId(string JSon) { try { string userID = string.Empty; string disID = string.Empty; string IDlist = string.Empty; JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" && JInfo["UnreadMessageID"].ToString() != "") { userID = JInfo["UserID"].ToString().Trim(); disID = JInfo["ResellerID"].ToString().Trim(); IDlist = JInfo["UnreadMessageID"].ToString().Trim(); } else { return(new ResultNoTime() { Result = "F", Description = "参数异常" }); } Hi.Model.SYS_Users user = new Hi.Model.SYS_Users(); if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(disID == "" ? "0" : disID))) { return new ResultNoTime() { Result = "F", Description = "用户异常" } } ; Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(disID)); if (dis == null || dis.dr == 1 || dis.IsEnabled == 0) { return new ResultNoTime() { Result = "F", Description = "经销商异常" } } ; string newlist = string.Empty; List <int> intList = new List <int>(); List <Hi.Model.BD_CompNews> list = new Hi.BLL.BD_CompNews().GetList("", "ID in (" + IDlist + ") and (dr=1 or IsEnabled=0)", ""); if (list != null && list.Count > 0) { newlist = string.Join(",", list.Select(p => p.ID)); } return(new ResultNoTime() { Result = "T", Description = "获取成功", DeleteMessageID = newlist }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetMessageDeleteId :" + JSon); return(new ResultNoTime() { Result = "F", Description = "参数异常" }); } }
public ResultNewsList CompNewsList(string JSon) { try { StringBuilder str = new StringBuilder(); #region JSon取值 string userID = string.Empty; string compID = string.Empty; string criticalOrderID = string.Empty; //当前列表最临界点产品ID:初始-1 string getType = string.Empty; //方向 string rows = string.Empty; string sortType = string.Empty; string sort = string.Empty; string orderType = string.Empty; string DisID = string.Empty; JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["CompanyID"].ToString() != "" && JInfo["Search"].ToString() != "" && JInfo["CriticalOrderID"].ToString() != "" && JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" && JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "" && JInfo["OrderType"].ToString() != "") { userID = JInfo["UserID"].ToString().Trim(); compID = JInfo["CompanyID"].ToString().Trim(); str.Append(" AND CompID='" + compID + "' AND IsEnabled=1 and dr=0"); criticalOrderID = JInfo["CriticalOrderID"].ToString(); getType = JInfo["GetType"].ToString(); rows = JInfo["Rows"].ToString(); sortType = JInfo["SortType"].ToString(); sort = JInfo["Sort"].ToString(); orderType = JInfo["OrderType"].ToString();//0:只按时间 1:置顶优先,再按时间排序 //DisID = JInfo["ResellerID"].ToString();//经销商登录时需要传入经销商ID用于对登录信息进行判断 } else { return(new ResultNewsList() { Result = "F", Description = "参数异常" }); } Hi.Model.SYS_Users user = new Hi.Model.SYS_Users(); //if (DisID == "") //{ // if (!new Common().IsLegitUser(int.Parse(userID), out user, int.Parse(compID))) // return new ResultNewsList() { Result = "F", Description = "登录信息异常" }; // Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Convert.ToInt32(compID)); // if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0) // return new ResultNewsList() { Result = "F", Description = "核心企业异常" }; //} //else //{ // if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(DisID))) // return new ResultNewsList() { Result = "F", Description = "登录信息异常" }; // //判断经销商信息是否异常 // Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(DisID)); // if (dis == null || dis.dr == 1 || dis.IsEnabled == 0 || dis.AuditState == 0) // return new ResultNewsList() { Result = "F", Description = "经销商信息异常" }; // //判断经销商对应的核心企业信息是否异常 // Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(dis.CompID); // if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0) // return new ResultNewsList() { Result = "F", Description = "核心企业异常" }; //} JsonData JMsg = JInfo["Search"]; if (JMsg.Count > 0) { string NewsID = JMsg["NewsID"].ToString().Trim(); string Title = JMsg["Title"].ToString().Trim(); string IsEnabled = JMsg["IsEnable"].ToString().Trim(); string IsTop = JMsg["IsTop"].ToString().Trim(); string NewsType = JMsg["NewsType"].ToString().Trim(); string ShowType = JMsg["ShowType"].ToString().Trim(); if (NewsID != "-1") { str.Append(" and ID ='" + NewsID + "' "); } if (Title != "-1") { str.Append(" and NewsTitle like '%" + Title + "%' "); } if (IsEnabled != "-1") { str.Append(" and IsEnable = '" + IsEnabled + "' "); } if (IsTop != "-1") { str.Append(" and IsTop = '" + IsTop + "' "); } if (NewsType != "-1") { str.Append(" and NewsType = '" + NewsType + "' "); } if (ShowType != "-1") { str.Append(ShowType == "3" ? " and ShowType = '1,2' " : " and ShowType = '" + ShowType + "' "); } } #endregion List <NewsInfo> NewsList = new List <NewsInfo>(); if (orderType == "1") { #region 取当前置顶的新闻公告 List <Hi.Model.BD_CompNews> newsList = new Hi.BLL.BD_CompNews().GetList("", " IsEnabled =1 and IsTop =1 and CompID='" + compID + "' and dr=0", "createDate desc"); if (newsList != null && newsList.Count != 0) { str.Append(" and ID not in (-1"); //通用列表中去除置顶公告 if (criticalOrderID.Trim() == "-1") { // List<NewsInfo> NewsList_select = newsList.Select(newsInfo => new NewsInfo() // { // NewsID = newsInfo.ID.ToString(), // Title = newsInfo.NewsTitle, // IsEnabled = newsInfo.IsEnabled.ToString(), // IsTop = newsInfo.IsTop.ToString(), // NewsType = newsInfo.NewsType.ToString(), // ShowType = // newsInfo.ShowType != "1" && newsInfo.ShowType != "2" && ClsSystem.gnvl(newsInfo.ShowType,"").Trim() != "" // ? "3" : newsInfo.ShowType, // CreateTime = newsInfo.CreateDate.ToString() // } // ).ToList(); foreach ( NewsInfo news in newsList.Select(newsInfo => new NewsInfo() { NewsID = newsInfo.ID.ToString(), Title = newsInfo.NewsTitle, IsEnabled = newsInfo.IsEnabled.ToString(), IsTop = newsInfo.IsTop.ToString(), NewsType = newsInfo.NewsType.ToString(), ShowType = newsInfo.ShowType != "1" && newsInfo.ShowType != "2" && ClsSystem.gnvl(newsInfo.ShowType, "").Trim() != "" ? "3" : newsInfo.ShowType, CreateTime = newsInfo.CreateDate.ToString() } )) //foreach (NewsInfo news in NewsList_select) { NewsList.Add(news); str.Append("," + news.NewsID); } } str.Append(")"); } #endregion int dtRow = Convert.ToInt32(rows) - NewsList.Count; if (dtRow > 1) { rows = dtRow.ToString(); } } #region 模拟分页 string tabName = " [dbo].[BD_CompNews]"; //表名 string strsql = string.Empty; //搜索sql sortType = "CreateDate"; sort = "0"; strsql = new Common().PageSqlString(criticalOrderID, "ID", tabName, sortType, sort, str.ToString(), getType, rows); if (strsql == "") { return new ResultNewsList() { Result = "F", Description = "基础数据异常" } } ; #endregion #region 赋值 DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql); if (ds.Tables.Count == 0) { if (NewsList.Count == 0) { return new ResultNewsList() { Result = "T", Description = "没有更多数据" } } ; else { return(new ResultNewsList() { Result = "T", Description = "", NewsList = NewsList }); } } DataTable dtList = ds.Tables[0]; if (dtList != null) { if (dtList.Rows.Count == 0) { if (NewsList.Count != 0) { return new ResultNewsList() { Result = "T", Description = "", NewsList = NewsList } } ; else { return(new ResultNewsList() { Result = "F", Description = "没有更多数据" }); } } foreach (DataRow newsInfo in dtList.Rows) { NewsInfo news = new NewsInfo(); news.NewsID = newsInfo["ID"].ToString(); news.Title = newsInfo["NewsTitle"].ToString(); news.IsOverdue = "0"; if (newsInfo["NewsType"].ToString() == "4") { if (newsInfo["PmID"] != null && Convert.ToInt32(newsInfo["PmID"]) != 0) { Hi.Model.BD_Promotion pro = new Hi.BLL.BD_Promotion().GetModel(Convert.ToInt32(newsInfo["PmID"].ToString())); if (pro.ProEndTime < DateTime.Now) { news.IsOverdue = "1"; } } } news.IsEnabled = newsInfo["IsEnabled"].ToString(); news.IsTop = newsInfo["IsTop"].ToString(); news.NewsType = newsInfo["NewsType"].ToString(); news.ShowType = newsInfo["ShowType"].ToString() != "1" && newsInfo["ShowType"].ToString() != "2" && newsInfo["ShowType"].ToString().Trim() != "" ? "3" : newsInfo["ShowType"].ToString(); news.CreateTime = newsInfo["CreateDate"].ToString(); NewsList.Add(news); } } #endregion return(new ResultNewsList() { Result = "T", Description = "获取成功", NewsList = NewsList }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "CompNewsList :" + JSon); return(new ResultNewsList() { Result = "F", Description = "异常" }); } }