protected void Button2_Click(object sender, EventArgs e) { string output = ""; output += "BLL层整体简略测试结果:\n"; output += TestGroupQuery.generalTest(sampleCount); output += TestAccountAssist.generalTest(sampleCount); output += TestSearch.generalTest(sampleCount); output += TestFocusAndCreateTag.generalTest(sampleCount); output += TestNewsAssist.generalTest(sampleCount); output += TestManagerAssist.generalTest(sampleCount); TextArea1.Value = output; }
/// <summary> /// 查询导出 /// </summary> /// <param name="search"></param> /// <returns></returns> public HttpResponseMessage Get([FromUri] TestSearch search, bool isExport) { var dataList = dal.GetListByCondition(search); MemoryStream ms = new NPOIExcelExport().DataToExcel <TBLTEST>(dataList, search.ExportTitles.Split(',').ToList(), search.ExportColumns.Split(',').ToList(), search.ExportTimeZone); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StreamContent(ms); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = Guid.NewGuid() + ".xlsx" }; return(response); }
/// <summary> /// 添加 /// </summary> /// <param name="entity"></param> /// <returns></returns> public IHttpActionResult Put([FromBody] TBLTEST entity) { TestSearch search = new TestSearch(); search.UserCode = entity.USERCODE; if (dal.GetListByCondition(search).Count > 0) { return(Ok("用户名已经存在!")); } bool result = dal.AddLanguage(entity); if (result) { return(Ok("添加成功!")); } else { return(BadRequest("添加失败!")); } }
/// <summary> /// 分页查询 /// </summary> /// <param name="search">查询条件</param> /// <returns></returns> public PagedResult <TBLTEST> GetListByPage(TestSearch search) { string where = " WHERE 1=1"; if (!string.IsNullOrWhiteSpace(search.UserCode)) { where += " AND UserCode=:UserCode"; } //if (!string.IsNullOrWhiteSpace(search.Language)) //{ // where += " AND (LanguageA=:Language or LanguageB=:Language or LanguageC=:Language or LanguageD=:Language)"; //} var sql = @"BEGIN OPEN :rslt1 FOR SELECT COUNT(1) FROM tblTest" + where + ";" + "OPEN :rslt2 FOR SELECT * FROM tblTest" + where + ";" + " END;"; OracleDynamicParameters dynParams = new OracleDynamicParameters(); dynParams.Add(":rslt1", OracleDbType.RefCursor, ParameterDirection.Output); dynParams.Add(":rslt2", OracleDbType.RefCursor, ParameterDirection.Output); if (!string.IsNullOrWhiteSpace(search.UserCode)) { dynParams.Add(":UserCode", OracleDbType.Varchar2, ParameterDirection.Input, search.UserCode); } //if (!string.IsNullOrWhiteSpace(search.Language)) //{ // dynParams.Add(":Language", OracleDbType.Varchar2, ParameterDirection.Input, search.Language); //} using (IDbConnection dbConn = new OracleConnection(connectionString)) { var queryResult = dbConn.QueryMultiple(sql, param: dynParams); return(new PagedResult <TBLTEST> { Total = queryResult.Read <int>().Single(), Rows = queryResult.Read <TBLTEST>().Skip <TBLTEST>(search.Skip).Take <TBLTEST>(search.Count).ToList() }); } }
/// <summary> /// 导出 /// </summary> /// <param name="search"></param> /// <returns></returns> public List <TBLTEST> GetListByCondition(TestSearch search) { string where = " WHERE 1=1"; if (!string.IsNullOrWhiteSpace(search.UserCode)) { where += " AND UserCode=:UserCode"; } if (!string.IsNullOrWhiteSpace(search.Language)) { where += " AND (LanguageA=:Language or LanguageB=:Language or LanguageC=:Language or LanguageD=:Language)"; } var sql = @"BEGIN OPEN :rslt1 FOR SELECT * FROM tblTest" + where + ";" + " END;"; OracleDynamicParameters dynParams = new OracleDynamicParameters(); dynParams.Add(":rslt1", OracleDbType.RefCursor, ParameterDirection.Output); dynParams.Add(":UserCode", OracleDbType.Varchar2, ParameterDirection.Input, search.UserCode); dynParams.Add(":Language", OracleDbType.Varchar2, ParameterDirection.Input, search.Language); using (IDbConnection dbConn = new OracleConnection(connectionString)) { return(dbConn.Query <TBLTEST>(sql, param: dynParams).AsList()); } }
/// <summary> /// 分页查询 /// </summary> /// <param name="search"></param> /// <returns></returns> public PagedResult <TBLTEST> Get([FromUri] TestSearch search) { return(dal.GetListByPage(search)); }
protected void Button17_Click(object sender, EventArgs e) { TextArea1.Value = TestSearch.test(sampleCount); }