/// Execute main logic for DoRedirectItem action public override void Execute() { var errorMessage = (String)null; var linkToRedirect = (String)null; if (!this.context.Request.Contains("id")) { errorMessage = "Item ID is required!"; } else { var id = this.context.Request["id"]; if (!TRequest.IsInteger(id) || INT(id) <= 0) { errorMessage = "Incorrect item ID!"; } else { var doItem = new DOItem(this.context.Connection); var dsItems = doItem.GetById(INT(id)); if (dsItems.GetSize() == 0) { errorMessage = "No item with such ID!"; } else { var oItem = dsItems.GetRow(0); linkToRedirect = STR(oItem["s_Link"]); } } } this.ExecuteRedirect(linkToRedirect, errorMessage); }
/// <summary> /// Check list from current query. /// </summary> /// <returns>True - checked OK, False - error.</returns> public Boolean CheckList() { if (this.context.Request.Contains("list")) { if (!TRequest.IsInteger(this.context.Request["list"])) { var prepare = new THashtable(); prepare["[#ErrMessage]"] = "Incorrect list number!"; this.Write("error", prepare); return(false); } } else { this.context.Request["list"] = "1"; } return(true); }
/// <summary> /// Fast check of input query parameters. /// </summary> /// <returns>Parsed parameters (or null in case of any error).</returns> public THashtable Check() { var prepare = new THashtable(); if (!this.context.Request.Contains("id")) { prepare["[#ErrMessage]"] = "Item ID is required!"; this.Write("error", prepare); return(null); } var id = this.context.Request["id"]; if (!TRequest.IsInteger(id)) { prepare["[#ErrMessage]"] = "Item ID must be positive integer!"; this.Write("error", prepare); return(null); } var pars = new THashtable(); pars["id"] = id; return(pars); }
/// <summary> /// Fast check of input query parameters. /// </summary> /// <returns>Parsed parameters (or null in case of any error).</returns> public THashtable Check() { var errorMessage = ""; var list = this.context.Request["list"]; if (!NUL(list)) { if (BLANK(list)) { errorMessage += "Empty list number!"; } else if (!TRequest.IsInteger(list)) { errorMessage += "Incorrect list number!"; } } var sourceName = this.context.Request["source"]; if (!NUL(sourceName)) { if (BLANK(sourceName)) { if (errorMessage.Length > 0) { errorMessage += "<br/>"; } errorMessage += "Empty source name!"; } else if (!TRequest.IsDomainName(sourceName)) { if (errorMessage.Length > 0) { errorMessage += "<br/>"; } errorMessage += "Incorrect source name!"; } } var filterName = this.context.Request["filter"]; if (!NUL(filterName)) { if (BLANK(filterName)) { if (errorMessage.Length > 0) { errorMessage += "<br/>"; } errorMessage += "Empty filter name!"; } else if (!TRequest.IsName(filterName)) { if (errorMessage.Length > 0) { errorMessage += "<br/>"; } errorMessage += "Incorrect filter name!"; } } if (errorMessage.Length > 0) { var prepare = new THashtable(); prepare["[#ErrMessage]"] = errorMessage; this.Write("error", prepare); return(null); } var pars = new THashtable(); if (!NUL(list)) { pars["list"] = list; } if (!NUL(sourceName)) { pars["source_name"] = sourceName; } if (!NUL(filterName)) { pars["filter_name"] = filterName; } return(pars); }