/// Execute main logic for DoRedirectSource action public override void Execute() { var errorMessage = (String)null; var linkToRedirect = (String)null; if (!this.context.Request.Contains("source")) { errorMessage = "Source name is required!"; } else { var sourceName = this.context.Request["source"]; if (!TRequest.IsDomainName(sourceName)) { errorMessage = "Incorrect source name!"; } else { var doSource = new DOSource(this.context.Connection); THashtable[] oSource = { new THashtable() }; if (!doSource.CheckSourceName(sourceName, oSource)) { errorMessage = "No such source name!"; } else { linkToRedirect = STR(oSource[0]["s_External"]); } } } this.ExecuteRedirect(linkToRedirect, errorMessage); }
/// <summary> /// Check source name from current query. /// </summary> /// <returns>True - source exists, False - error.</returns> public Boolean CheckSource() { var errMessage = ""; if (this.context.Request.Contains("source")) { var source = this.context.Request["source"]; if (BLANK(source)) { errMessage += "Empty source name!<br/>"; } else if (!TRequest.IsDomainName("source")) { errMessage += "Incorrect source name!<br/>"; } } if (errMessage.Length == 0) { return(true); } var prepare = new THashtable(); prepare["[#ErrMessage]"] = errMessage; this.Write("error", prepare); return(false); }
/// <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); }