public string GetSectionHtml() { string[] headings = new string[cols.Length + 1]; headings[0] = ""; for (int i = 1; i < headings.Length; i++) { headings[i] = cols[i - 1].columnName; } StringBuilder sb = new StringBuilder(); AdminBase.SectionTitle(sb, tableName); AdminBase.SectionTableStart_N(sb, tableKey + "tbl", true, headings); lock (objToLockWhenReadingList) { for (int i = 0; i < myList.Count; i++) { T obj = myList[i]; string[] values = new string[cols.Length + 1]; values[0] = "<input type=\"checkbox\" class=\"listItemSelectionCheckbox_" + tableKey + "\" itemid=\"" + HttpUtility.JavaScriptStringEncode((string)GetItemId(obj)) + "\" />"; for (int j = 0; j < cols.Length; j++) { ItemTableColumnDefinition <T> cd = cols[j]; values[j + 1] = cd.valueFunc(myList[i]); } AdminBase.SectionTableEntry_N(sb, true, values); } } AdminBase.SectionTableEnd(sb); AdminBase.AddAndDeleteButtons(sb, tableKey, mode); return(sb.ToString()); }
public static void HandleRequest(string pageName, HttpProcessor p, Session s) { string pageKey = pageName.ToLower(); if (s.permission < 100) { pageKey = "login"; } Type type; if (!pageKeyToType.TryGetValue(pageKey, out type)) { p.writeFailure(); return; } ConstructorInfo ctor = type.GetConstructor(new Type[0]); object instance = ctor.Invoke(null); AdminBase page = (AdminBase)instance; string str = page.GetHtml(p, s, pageKey); if (str == null) { p.writeFailure("500 Internal Server Error"); return; } HttpCompressionBody response = new HttpCompressionBody(Encoding.UTF8.GetBytes(str), ".html"); p.writeSuccess(contentLength: response.body.Length, additionalHeaders: response.additionalHeaders); p.outputStream.Flush(); p.rawOutputStream.Write(response.body, 0, response.body.Length); }
public static void HandleRequest(string pageName, SimpleHttp.HttpProcessor p, Session s) { string pageKey = pageName.ToLower(); if (s.permission < 100) { pageKey = "login"; } Type type; if (!pageKeyToType.TryGetValue(pageKey, out type)) { p.writeFailure(); return; } ConstructorInfo ctor = type.GetConstructor(new Type[0]); object instance = ctor.Invoke(null); AdminBase page = (AdminBase)instance; string str = page.GetHtml(p, s, pageKey); if (str == null) { p.writeFailure("500 Internal Server Error"); return; } p.writeSuccess(); p.outputStream.Write(str); }
public static string HandleSaveList(HttpProcessor p, Session s) { string pageKey = p.GetPostParam("pagename").ToLower(); if (s.permission < 100) { return("0Insufficient Permission"); } Type type; if (!pageKeyToType.TryGetValue(pageKey, out type)) { return("0Invalid pagename"); } ConstructorInfo ctor = type.GetConstructor(new Type[0]); object instance = ctor.Invoke(null); AdminBase page = (AdminBase)instance; SortedList <string, SortedList <string, string> > items = new SortedList <string, SortedList <string, string> >(); string rawFullItemString = p.GetPostParam("items"); string[] itemStrings = rawFullItemString.Split('|'); foreach (string itemString in itemStrings) { SortedList <string, string> valuesList = new SortedList <string, string>(); string[] keyValuePairs = itemString.Split('*'); for (int i = 1; i < keyValuePairs.Length; i++) { string[] keyAndValue = keyValuePairs[i].Split(':'); valuesList.Add(keyAndValue[0], keyAndValue[1]); } items.Add(keyValuePairs[0], valuesList); } page.HandleSave(p, s, items); return("1"); }