// GET: ShareConfig public async Task <ActionResult> Index(ShareConfigQuery query) { query.PageIndex = query.PageIndex == 0 ? 1 : query.PageIndex; var datas = ShareConfigManager.SelectShareConfig(query); ViewBag.query = query; return(View(datas ?? new List <ShareConfigSource>())); }
public List <ShareConfigSource> SelectShareConfig(ShareConfigQuery model) { try { return(handler.SelectShareConfig(model)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new DownloadAppException(1, "SelectShareConfig", ex); Logger.Log(Level.Error, exception, "SelectShareConfig"); throw ex; } }
public static List <ShareConfigSource> QueryShareConfigs(SqlConnection conn, ShareConfigQuery query) { string queryShareConfigSumText = @" SELECT Count(1) FROM Configuration..ShareConfigSource AS SCS WHERE(@Location IS NULL OR SCS.Location LIKE N'%' + @Location + '%') AND SCS.PKId = ISNULL(@PKId, SCS.PKId) AND(@Description IS NULL OR SCS.Description LIKE N'%' + @Description + '%') AND SCS.Status = ISNULL(@Status, SCS.Status) AND(@MinTime IS NULL OR SCS.CreateDateTime >= @MinTime) AND(@MaxTime IS NULL OR SCS.CreateDateTime <= @MaxTime) AND(@Creator IS NULL OR SCS.Creator LIKE N'%' + @Creator + '%') AND(@ShareType is NULL OR SCS.Location in(SELECT SCS.Location FROM Configuration..ShareConfigSource AS SCS left join Configuration..ShareSupervisionConfig AS SSC on SCS.Location=SSC.Location WHERE SSC.ShareType = @ShareType) )"; string queryShareConfigText = @"SELECT * FROM Configuration..ShareConfigSource AS SCS WHERE(@Location IS NULL OR SCS.Location LIKE N'%' + @Location + '%') AND SCS.PKId = ISNULL(@PKId, SCS.PKId) AND(@Description IS NULL OR SCS.Description LIKE N'%' + @Description + '%') AND SCS.Status = ISNULL(@Status, SCS.Status) AND(@MinTime IS NULL OR SCS.CreateDateTime >= @MinTime) AND(@MaxTime IS NULL OR SCS.CreateDateTime <= @MaxTime) AND(@Creator IS NULL OR SCS.Creator LIKE N'%' + @Creator + '%') AND(@ShareType is NULL OR SCS.Location in(SELECT SCS.Location FROM Configuration..ShareConfigSource AS SCS left join Configuration..ShareSupervisionConfig AS SSC on SCS.Location=SSC.Location WHERE SSC.ShareType = @ShareType) ) ORDER BY SCS.CreateDateTime DESC OFFSET @Page ROWS FETCH NEXT 50 ROWS ONLY"; var sqlParam = new[] { new SqlParameter("@PKId", query.IdCriterion), new SqlParameter("@Location", query.LocationCriterion), new SqlParameter("@Description", query.DescriptionCriterion), new SqlParameter("@Status", query.StatusCriterion), new SqlParameter("@MinTime", query.MinTimeCriterion), new SqlParameter("@MaxTime", query.MaxTimeCriterion), new SqlParameter("@Creator", query.CreatorCriterion), new SqlParameter("@ShareType", query.ShareTypeCriterion), new SqlParameter("@Page", (query.PageIndex - 1) * 50) }; query.TotalCount = (int)SqlHelper.ExecuteScalar(conn, CommandType.Text, queryShareConfigSumText, sqlParam); return(SqlHelper.ExecuteDataTable(conn, CommandType.Text, queryShareConfigText, sqlParam).ConvertTo <ShareConfigSource>().ToList()); }
public ActionResult TemplateEdit(int id = 0) { if (id == 0) { ViewBag.Title = "新增"; ShareConfigSource scs = new ShareConfigSource() { PKId = 0, Location = null, Description = null, Status = 1, }; return(View(scs)); } else if (id > 0) { ViewBag.Title = "修改"; ShareConfigQuery query = new ShareConfigQuery { IdCriterion = id, PageIndex = 1, }; var datas = ShareConfigManager.SelectShareConfig(query); ShareConfigSource scs = datas.FirstOrDefault() ?? new ShareConfigSource(); return(View(scs)); } else { ViewBag.Title = "复制"; ShareConfigQuery query = new ShareConfigQuery { IdCriterion = -id, PageIndex = 1, }; var datas = ShareConfigManager.SelectShareConfig(query); ShareConfigSource scs = datas.FirstOrDefault() ?? new ShareConfigSource(); scs.PKId = id; return(View(scs)); } }
public List <ShareConfigSource> SelectShareConfig(ShareConfigQuery query) { Func <SqlConnection, List <ShareConfigSource> > action = (connection) => DalShareConfig.QueryShareConfigs(connection, query); return(dbManager.Execute(action)); }