public void wikiread(string id) { AWikiCell cell = OnLoadWikiCellWithContent(id); if (cell == null) { SendError("1"); return; } SendError(cell.ToArray()); }
public void wikimodify(string id, string content) { AWikiCell cell = OnLoadWikiCellWithoutContent(id); if (cell == null) { SendError("1"); return; } cell.content = content; var t = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); adb.UpdateOneData(TableName , ADBAccessor.filter_eq("i", cell.id) , ADBAccessor.updates_build( ADBAccessor.update("c", content) , ADBAccessor.update("lt", t) )); SendError(cell.ToArray()); }
AWikiCell OnLoadWikiCellWithoutContent(string id) { var i = typeParser.intParse(id); AWikiCell cell = OnGetWiki(id); if (cell == null) { var r = adb.FindOneData(TableName, ADBAccessor.filter_eq("i", i) , ADBAccessor.projections("i", "s", "t")); if (r == null) { SendError("1"); return(null); } cell = new AWikiCell(); cell.id = i; cell.time = r["t"].AsString; cell.subject = r["s"].AsString; dWikis.Add(cell.id, cell); } return(cell); }
public void wikilist(string page, string count) { var ipage = typeParser.intParse(page); var icount = typeParser.intParse(count); List <List <string> > lr = new List <List <string> >(); for (var i = (ipage + 1) * icount; i > ipage * icount; i--) { AWikiCell cell = null; if (dWikis.ContainsKey(i)) { cell = dWikis[i]; } else { var r = adb.FindOneData(TableName , ADBAccessor.filter_eq("i", i) , ADBAccessor.projections("i", "s", "t")); if (r == null) { continue; } cell = new AWikiCell(); cell.id = r["i"].AsInt32; cell.subject = r["s"].AsString; cell.time = r["t"].AsString; } var l = new List <string>(); l.Add("i"); l.Add(cell.id.ToString()); l.Add("s"); l.Add(cell.subject); l.Add("t"); l.Add(cell.time); lr.Add(l); } SendError("r", AWebServerUtils.ToJsonArray(lr.ToArray())); }
AWikiCell OnLoadWikiCellWithContent(string id) { var i = typeParser.intParse(id); AWikiCell cell = OnGetWiki(id); if (cell == null || string.IsNullOrEmpty(cell.content)) { var r = adb.FindOneData(TableName, ADBAccessor.filter_eq("i", i) , ADBAccessor.projections("s", "c", "t")); if (r == null) { SendError("1"); return(null); } if (cell == null) { cell = new AWikiCell(); } cell.id = i; cell.content = r["c"].AsString; cell.time = r["t"].AsString; cell.subject = r["s"].AsString; if (r.Contains("lt")) { cell.lastmodifytime = r["lt"].AsString; } if (dWikis.ContainsKey(cell.id)) { dWikis[cell.id] = cell; } else { dWikis.Add(cell.id, cell); } } return(cell); }