public static string SaveRQMTBase(int RQMTID, string txt) { var result = WTSPage.CreateDefaultResult(); var saveResult = RQMT.RQMT_Save(false, RQMTID, txt); result["success"] = saveResult["saved"].ToLower(); result["exists"] = saveResult["exists"].ToLower(); return(WTSPage.SerializeResult(result)); }
public static string CreateNewComponent(string compType, string txt) { var result = WTSPage.CreateDefaultResult(); try { if (compType == "rqmt") { txt = txt.Replace("|", "!"); txt = txt.Replace("\r", ""); txt = txt.Replace("\n", "|"); // we will be adding one rqmt for each | string[] txtarr = txt.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); txt = string.Join("|", txtarr); // rqmtsNeedingParents stores the indexes of the rqmts that had a > in front of them // after the saving is done, we make ajax calls to add the new rqmts to the sets displayed on the page, and will preserve parent-child relationships based on > characters string rqmtsNeedingParents = ""; for (int i = 0; i < txtarr.Length; i++) { if (i > 0) { rqmtsNeedingParents += ","; } rqmtsNeedingParents += txtarr[i].Trim().StartsWith(">") ? "1" : "0"; } var saveResult = RQMT.RQMT_Save(true, 0, txt); result["success"] = saveResult["saved"].ToLower(); result["rqmtid"] = saveResult["newID"]; result["rqmtids"] = saveResult["newIDs"]; result["exists"] = saveResult["exists"]; result["rqmtsneedingparents"] = rqmtsNeedingParents; } } catch (Exception e) { result["error"] = e.Message; } return(WTSPage.SerializeResult(result)); }