public static string SearchDescriptions(string txt) { DataTable dt; if (string.IsNullOrWhiteSpace(txt)) { txt = "__NONE__"; // we don't allow blank searches for descriptions } dt = RQMT.RQMTBuilderDescriptionList_Get(0, txt, false); return(WTSPage.SerializeResult(dt)); }
public static string ExecuteComponentSearch(string compType, string txt) { DataTable dt = new DataTable(); bool returnAll = txt == "[ALL]"; if (txt != null && txt.Length > 2000) { txt = txt.Substring(0, 2000); } switch (compType) { case "rqmt": if (string.IsNullOrWhiteSpace(txt)) { txt = "[NONE]"; // we don't allow blank searches for rqmts } txt = txt.Trim(); txt = txt.Replace("\r", ""); txt = txt.Replace("\n", "[CR]"); // do another check for empty string if (string.IsNullOrWhiteSpace(txt)) { txt = "[NONE]"; } dt = RQMT.RQMTList_Get(0, txt, true); break; case "type": dt = RQMT.RQMTTypeList_Get(returnAll || string.IsNullOrWhiteSpace(txt) ? null : txt); // the type list is short so we default to showing all break; case "workarea": dt = MasterData.WorkAreaList_Get(); if (!string.IsNullOrWhiteSpace(txt)) { txt = txt.ToUpper(); foreach (DataRow row in dt.Rows) { if (row["WorkArea"].ToString().ToUpper().IndexOf(txt) == -1) { row.Delete(); } } } break; case "sys": dt = MasterData.SystemList_Get(); DataColumn col = dt.Columns["WTS_SystemID"]; col.ColumnName = "WTS_SYSTEMID"; if (!string.IsNullOrWhiteSpace(txt)) { txt = txt.ToUpper(); foreach (DataRow row in dt.Rows) { if (row["WTS_SYSTEM"].ToString().ToUpper().IndexOf(txt) == -1) { row.Delete(); } } } break; case "desc": if (string.IsNullOrWhiteSpace(txt)) { txt = "__NONE__"; // we don't allow blank searches for descriptions } dt = RQMT.RQMTBuilderDescriptionList_Get(0, txt, false); break; } // some of the source queries are returning invalid xml/json column names, so we fix the common errors foreach (DataColumn x in dt.Columns) { x.ColumnName = x.ColumnName.Replace(" ", "_").Replace("#", "NUM"); } dt.AcceptChanges(); string str = WTSPage.SerializeResult(dt); return(WTSPage.SerializeResult(dt)); }