sys_upclear.aspx.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.Web;
  16. using System.Web.UI;
  17. using System.Web.UI.WebControls;
  18. using iNethinkCMS.Command;
  19. using iNethinkCMS.Web.UI;
  20. namespace iNethinkCMS.Web.admin.sys
  21. {
  22. public partial class sys_upclear : Admin_BasePage
  23. {
  24. iNethinkCMS.BLL.BLL_iNethinkCMS_Upload bll = new iNethinkCMS.BLL.BLL_iNethinkCMS_Upload();
  25. iNethinkCMS.Model.Model_iNethinkCMS_Upload model = new iNethinkCMS.Model.Model_iNethinkCMS_Upload();
  26. private string vNavInfo = "当前位置:";
  27. private string vAct = "";
  28. private int vPage = 1;
  29. private string vSQL = "";
  30. protected void Page_Load(object sender, EventArgs e)
  31. {
  32. CheckUserPower("e");
  33. vAct = Request.QueryString["Act"] != null ? Request.QueryString["Act"] : "";
  34. if (Request.QueryString["Page"] != null && Request.QueryString["Page"].Trim() != "")
  35. {
  36. if (!int.TryParse(Request.QueryString["Page"], out vPage))
  37. {
  38. vPage = 1;
  39. }
  40. }
  41. //vSQL = "UpType > 0 And Aid > 0";
  42. this.navButtonID.Visible = false;
  43. this.mainID.Visible = false;
  44. this.clearUpFileID.Visible = false;
  45. this.clearThumbFileID.Visible = false;
  46. switch (vAct)
  47. {
  48. case "clearupfile":
  49. this.navInfoID.InnerText = vNavInfo + "上传文件清理";
  50. this.clearUpFileID.Visible = true;
  51. break;
  52. case "clearupfile_do":
  53. //读取系统内所有无用的文件
  54. DataTable dt = bll.GetList("UpType = 0 And Aid = 0").Tables[0];
  55. try
  56. {
  57. for (int i = 0; i < dt.Rows.Count; i++)
  58. {
  59. string vDir = dt.Rows[i]["Dir"].ToString();
  60. vDir = Server.MapPath(vDir);
  61. if (System.IO.File.Exists(vDir))
  62. {
  63. System.IO.File.Delete(vDir);
  64. }
  65. //int vID = Convert.ToInt32(dt.Rows[i]["ID"]);
  66. //bll.Delete(vID);
  67. }
  68. iNethinkCMS.Helper.SQLHelper.ExecuteSql("Delete From [iNethinkCMS_Upload] Where [UpType] = 0 And [Aid] = 0");
  69. Response.Write(dt.Rows.Count.ToString());
  70. }
  71. catch (Exception ex){
  72. Response.Write(ex.Message);
  73. }
  74. Response.End();
  75. break;
  76. case "clearthumbfile":
  77. this.navInfoID.InnerText = vNavInfo + "清空缩略图";
  78. this.clearThumbFileID.Visible = true;
  79. break;
  80. case "clearthumbfile_do":
  81. int rInfo = 0;
  82. string vThumbPath = Server.MapPath(@"/upload/thumbnail");
  83. if (System.IO.Directory.Exists(vThumbPath))
  84. {
  85. rInfo = System.IO.Directory.GetFiles(vThumbPath).Length;
  86. System.IO.Directory.Delete(vThumbPath, true);
  87. }
  88. Response.Write(rInfo.ToString());
  89. Response.End();
  90. break;
  91. default:
  92. this.navInfoID.InnerText = vNavInfo + "上传文件管理";
  93. this.navButtonID.Visible = true;
  94. this.mainID.Visible = true;
  95. PageListInfo();
  96. break;
  97. }
  98. }
  99. protected string Fun_Switch_UpType(object byUpType)
  100. {
  101. string vBackInfo = "";
  102. switch (byUpType.ToString())
  103. {
  104. case "1":
  105. vBackInfo = "新闻信息相关";
  106. break;
  107. case "2":
  108. vBackInfo = "自定义标签相关";
  109. break;
  110. case "3":
  111. vBackInfo = "自定义页面相关";
  112. break;
  113. case "4":
  114. vBackInfo = "专题形象图";
  115. break;
  116. case "5":
  117. vBackInfo = "栏目形象图";
  118. break;
  119. case "6":
  120. vBackInfo = "友情链接LOGO";
  121. break;
  122. default:
  123. vBackInfo = "-";
  124. break;
  125. }
  126. return vBackInfo;
  127. }
  128. protected string Fun_Switch_FileValid(object byUpType)
  129. {
  130. return byUpType.ToString() == "0" ? "<font color=\"#ff0000\">无效</font>" : "有效";
  131. }
  132. protected void PageListInfo()
  133. {
  134. int vPageSize = int.Parse(siteConfig.PageListNum);
  135. int vRecordCount = bll.GetRecordCount(vSQL);
  136. Repeater.DataSource = bll.GetListByPage(vSQL, "ID Desc", (vPage - 1) * vPageSize, vPage * vPageSize);
  137. Repeater.DataBind();
  138. string pTemp = "";
  139. int vPageCount = 1;
  140. if (vRecordCount > 0)
  141. {
  142. vPageCount = (int)Math.Ceiling((double)vRecordCount / (double)vPageSize);
  143. pTemp = WebUI_PageList.GetPagingInfo_Manage(vPageCount, vRecordCount, vPage, vPageSize);
  144. }
  145. this.pagelist.InnerHtml = pTemp;
  146. this.iNoInfo.Visible = vRecordCount == 0 ? true : false;
  147. }
  148. }
  149. }