Code cleanup

main
Inga 🏳‍🌈 13 years ago
parent 4441dd4538
commit a78ecfc564
  1. 2
      Builder/IISMainHandler/build.txt
  2. 14
      IISMainHandler/handlers/request/maintenance/CleanCacheHandler.cs

@ -7,7 +7,7 @@ using FLocal.Core;
using FLocal.Common; using FLocal.Common;
namespace FLocal.IISHandler.handlers.request.maintenance { namespace FLocal.IISHandler.handlers.request.maintenance {
class CleanCacheHandler : AbstractNewMessageHandler { class CleanCacheHandler : AbstractPostHandler {
protected override string templateName { protected override string templateName {
get { get {
@ -19,17 +19,15 @@ namespace FLocal.IISHandler.handlers.request.maintenance {
if(context.account.user.name != Config.instance.AdminUserName) { if(context.account.user.name != Config.instance.AdminUserName) {
throw new FLocalException("access denied"); throw new FLocalException("access denied");
} }
string table = context.httprequest.Form["table"].Trim();
int start = int.Parse(context.httprequest.Form["start"]); int start = int.Parse(context.httprequest.Form["start"]);
int length = int.Parse(context.httprequest.Form["length"]); int length = int.Parse(context.httprequest.Form["length"]);
ISqlObjectTableSpec tableSpec = TableManager.TABLES[table]; ISqlObjectTableSpec tableSpec = TableManager.TABLES[context.httprequest.Form["table"].Trim()];
Action<int> refresher = (tableSpec is IComplexSqlObjectTableSpec)
? ((IComplexSqlObjectTableSpec)tableSpec).refreshSqlObjectAndRelated
: (Action<int>)tableSpec.refreshSqlObject;
foreach(int id in Enumerable.Range(start, length)) { foreach(int id in Enumerable.Range(start, length)) {
try { try {
if(tableSpec is IComplexSqlObjectTableSpec) { refresher(id);
((IComplexSqlObjectTableSpec)tableSpec).refreshSqlObjectAndRelated(id);
} else {
tableSpec.refreshSqlObject(id);
}
} catch(NotFoundInDBException) { } catch(NotFoundInDBException) {
} }
} }

Loading…
Cancel
Save