private void DelData(HttpContext context, string btn) { if (btn != "btnDel") { context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}"); return; } BLL.System.sys_Attachment bll = new BLL.System.sys_Attachment(); Model.System.sys_LoginUser loginUserModel = BaseWeb.GetLoginInfo(); //string status = "0"; string operaAction = ""; string operaMemo = ""; try { UpLoad upFiles = new UpLoad(); DataTable dt = bll.GetList("Source=1 and UseId=0").Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { upFiles.fileDel(dt.Rows[i]["FilePath"].ToString()); } } bll.Delete("Source=1 and UseId=0"); //status = "1"; operaAction = Enums.ActionEnum.Delete.ToString(); operaMemo = "清理上传文件"; //写入操作日志 BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo); context.Response.Write("{\"status\":\"1\",\"msg\":\"清理成功!\"}"); return; } catch (Exception e) { context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}"); return; } }
private void GetList(HttpContext context, string btn) { if (btn != "show") { context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}"); return; } string fileName = RequestHelper.GetString("fileName"); string fileUse = RequestHelper.GetString("fileUse"); string operaName = RequestHelper.GetString("operaName"); string beginDate = RequestHelper.GetString("beginDate"); string endDate = RequestHelper.GetString("endDate"); StringBuilder strWhere = new StringBuilder(); strWhere.Append("Source=1 and "); List <SqlParameter> parameterList = new List <SqlParameter>(); SqlParameter tempParameter = new SqlParameter(); if (fileName != "") { strWhere.Append("FileName like '%' + @FileName + '%' and "); tempParameter = new SqlParameter("@FileName", SqlDbType.NVarChar); tempParameter.Value = fileName; parameterList.Add(tempParameter); } if (fileUse != "") { strWhere.Append("FilePath like '%' + @FilePath + '%' and "); tempParameter = new SqlParameter("@FilePath", SqlDbType.NVarChar); tempParameter.Value = fileUse; parameterList.Add(tempParameter); } if (operaName != "") { strWhere.Append("OperaName like '%' + @OperaName + '%' and "); tempParameter = new SqlParameter("@OperaName", SqlDbType.NVarChar); tempParameter.Value = operaName; parameterList.Add(tempParameter); } if (beginDate != "") { strWhere.Append("OperaTime >= @BeginOperTime and "); tempParameter = new SqlParameter("@BeginOperTime", SqlDbType.DateTime); tempParameter.Value = DateTime.Parse(beginDate); parameterList.Add(tempParameter); } if (endDate != "") { strWhere.Append("OperaTime <= @EndOperTime and "); tempParameter = new SqlParameter("@EndOperTime", SqlDbType.DateTime); tempParameter.Value = DateTime.Parse(endDate + " 23:59:59"); parameterList.Add(tempParameter); } BLL.System.sys_Attachment bll = new BLL.System.sys_Attachment(); try { DataTable dt = bll.GetList(Utils.DelLastChar(strWhere.ToString(), " and "), parameterList).Tables[0]; string rowsStr = Utils.ToJson(dt); StringBuilder jsonStr = new StringBuilder(); jsonStr.Append("{\"status\":\"1\",\"msg\":\"数据获取成功!\",\"info\":"); jsonStr.Append("{\"total\":" + dt.Rows.Count + ",\"rows\":"); jsonStr.Append(rowsStr); jsonStr.Append("}}"); context.Response.Write(jsonStr); } catch (Exception e) { context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}"); return; } }