public static int CountHomePagePopup(SqlConnection conn, HomePagePopupQuery queryModel) { var flag = false; string sql = @"SELECT Count(0) FROM Configuration.dbo.HomePagePopupConfig WITH ( NOLOCK )"; if (!string.IsNullOrWhiteSpace(queryModel.DescriptionCriterion)) { sql += @" WHERE Description LIKE '%" + queryModel.DescriptionCriterion + @"%'"; flag = true; } if (queryModel.ChannelCriterion != 0) { sql += (flag ? " AND " : " WHERE ") + @"Channel=" + queryModel.ChannelCriterion; flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.TargetGroupsCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"N'" + queryModel.TargetGroupsCriterion + @"' IN ( SELECT * FROM Configuration.dbo.SplitString(TargetGroups, ',', 1))"; flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.StartVersionCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"StartVersion LIKE '%" + queryModel.StartVersionCriterion + @"%'"; flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.EndVersionCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"EndVersion LIKE '%" + queryModel.EndVersionCriterion + @"%'"; flag = true; } if (queryModel.VisibleCriterion != 0) { if (queryModel.VisibleCriterion == 1) { sql += (flag ? " AND " : " WHERE ") + @"StartDateTime<=GETDATE() AND EndDateTime>GETDATE() AND IsEnabled=1"; } else { sql += (flag ? " AND " : " WHERE ") + @"(IsEnabled=0 OR StartDateTime>GETDATE() OR EndDateTime<=GETDATE())"; } flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.CreatorCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"Creator LIKE '%" + queryModel.CreatorCriterion + @"%'"; } return((int)SqlHelper.ExecuteScalar(conn, CommandType.Text, sql)); }
public int CountHomePagePopup(HomePagePopupQuery model) { try { return(handler.CountHomePagePopup(model)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new DownloadAppException(1, "CountHomePagePopup", ex); Logger.Log(Level.Error, exception, "CountHomePagePopup"); throw ex; } }
public List <HomePagePopup> QueryHomePagePopup(HomePagePopupQuery model, int page) { try { return(handler.QueryHomePagePopup(model, page)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new DownloadAppException(1, "QueryHomePagePopup", ex); Logger.Log(Level.Error, exception, "QueryHomePagePopup"); throw ex; } }
public async Task <ViewResult> Index(HomePagePopupQuery popupQuery, int orderCriterion, int page = 1) { ViewBag.NewNoticeChannel = ViewBag.NoticeChannel = DownloadAppManager.QueryNoticeChannel() ?? new List <NoticeChannel>(); popupQuery.OrderCriterion = orderCriterion; if (!string.IsNullOrWhiteSpace(popupQuery.StartVersionCriterion)) { popupQuery.StartVersionCriterion = popupQuery.StartVersionCriterion.Trim(); } if (!string.IsNullOrWhiteSpace(popupQuery.EndVersionCriterion)) { popupQuery.EndVersionCriterion = popupQuery.EndVersionCriterion.Trim(); } var result = DownloadAppManager.QueryHomePagePopup(popupQuery, page); ViewBag.NumOfPopups = DownloadAppManager.CountHomePagePopup(popupQuery); ViewBag.Page = page; ViewBag.OrderCriterion = orderCriterion; ViewBag.AllTargetGroups = GetTargetGroupDic(); var scManager = new ShareConfigManager(); ViewBag.WxConfigs = JsonConvert.SerializeObject((await scManager.SelectWxConfigsAsync()).Select(_ => new { appId = _.appId, name = _.name })); return(View(result ?? new List <HomePagePopup>())); }
public static List <HomePagePopup> QueryHomePagePopup(SqlConnection conn, HomePagePopupQuery queryModel, int page) { var flag = false; string sql = @"SELECT * FROM Configuration.dbo.HomePagePopupConfig WITH ( NOLOCK )"; if (!string.IsNullOrWhiteSpace(queryModel.DescriptionCriterion)) { sql += @" WHERE Description LIKE N'%" + queryModel.DescriptionCriterion + @"%'"; flag = true; } if (queryModel.ChannelCriterion != 0) { sql += (flag ? " AND " : " WHERE ") + @"Channel=" + queryModel.ChannelCriterion; flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.TargetGroupsCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"N'" + queryModel.TargetGroupsCriterion + @"' IN ( SELECT * FROM Configuration.dbo.SplitString(TargetGroups, ',', 1))"; flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.StartVersionCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"StartVersion='" + queryModel.StartVersionCriterion + @"'"; flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.EndVersionCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"EndVersion='" + queryModel.EndVersionCriterion + @"'"; flag = true; } if (queryModel.VisibleCriterion != 0) { if (queryModel.VisibleCriterion == 1) { sql += (flag ? " AND " : " WHERE ") + @"StartDateTime<=GETDATE() AND EndDateTime>GETDATE() AND IsEnabled=1"; } else { sql += (flag ? " AND " : " WHERE ") + @"(IsEnabled=0 OR StartDateTime>GETDATE() OR EndDateTime<=GETDATE())"; } flag = true; } if (!string.IsNullOrWhiteSpace(queryModel.CreatorCriterion)) { sql += (flag ? " AND " : " WHERE ") + @"Creator LIKE N'%" + queryModel.CreatorCriterion + @"%'"; } switch (queryModel.OrderCriterion) { case 1: sql += @" ORDER BY PKID"; break; case 2: sql += @" ORDER BY Sort DESC"; break; case 3: sql += @" ORDER BY Sort"; break; case 4: sql += @" ORDER BY Period DESC"; break; case 5: sql += @" ORDER BY Period"; break; case 6: sql += @" ORDER BY CreateTime DESC"; break; case 7: sql += @" ORDER BY CreateTime"; break; default: sql += @" ORDER BY PKID DESC"; break; } sql += @" OFFSET " + (page - 1) * 50 + " ROWS FETCH NEXT 50 ROWS ONLY"; return(SqlHelper.ExecuteDataTable(conn, CommandType.Text, sql).ConvertTo <HomePagePopup>().ToList()); }
public int CountHomePagePopup(HomePagePopupQuery model) { return(DalHomePagePopup.CountHomePagePopup(conn, model)); }
public List <HomePagePopup> QueryHomePagePopup(HomePagePopupQuery model, int page) { return(DalHomePagePopup.QueryHomePagePopup(conn, model, page)); }