/// <summary> /// This sets up the Original Pretty URL, the current full URL and the app path /// </summary> private void SetupUrls() { //We want to use the PURL for this item. //NOTE: THIS NciUrl purl = this.PageInstruction.GetUrl(PageAssemblyInstructionUrls.PrettyUrl); if (purl == null || string.IsNullOrWhiteSpace(purl.ToString())) { throw new Exception("DynamicTrialListingPageDiseaseControl requires current PageAssemblyInstruction to provide its PrettyURL through GetURL. PrettyURL is null or empty."); } //It is expected that this is pure and only the pretty URL of this page. //This means that any elements on the same page as this app should NOT overwrite the //PrettyURL URL Filter. this.PrettyUrl = purl.ToString(); //Now, that we have the PrettyURL, let's figure out what the app paths are... NciUrl currURL = new NciUrl(); currURL.SetUrl(HttpContext.Current.Request.RawUrl); currURL.SetUrl(currURL.UriStem); //Make sure this URL starts with the pretty url if (currURL.UriStem.ToLower().IndexOf(this.PrettyUrl.ToLower()) != 0) { throw new Exception(String.Format("JSApplicationProxy: Cannot Determine App Path for Page, {0}, with PrettyURL {1}.", currURL.UriStem, PrettyUrl)); } this.CurrentUrl = currURL; }
protected void Page_Load(object sender, EventArgs e) { GetQueryParams(); //Set display props according to lang if (PageAssemblyContext.Current.PageAssemblyInstruction.Language == "es") { lblResultsFor.Text = "resultados de:"; } else { lblResultsFor.Text = "results found for:"; } SetupCommon(); SetupCanonicalUrl(this.DictionaryRouter.GetBaseURL()); LoadData(); //set up pager stuff string pageHtml = string.Empty; if (NumResults > 0 && PageAssemblyContext.Current.DisplayVersion != DisplayVersions.Print) { Dictionary <string, string> queryParams = GetPageQueryParams(); NciUrl pagerUrl = new NciUrl(); pagerUrl.SetUrl(PageAssemblyContext.Current.requestedUrl.ToString()); DrugPager objPager = new DrugPager(pagerUrl, queryParams, CurrentPageIndex, PageSize, 2, NumResults); pageHtml = objPager.RenderPager(); } litPager.Text = pageHtml; }
/// <summary> /// Gets the View URL for an ID /// </summary> /// <param name="id"></param> /// <returns></returns> public string GetDetailedViewUrl(string id) { NciUrl url = new NciUrl(); url.SetUrl(string.Format(this.BaseConfig.DetailedViewPagePrettyUrlFormatter, id)); return(url.ToString()); }
/// <summary> /// Method called to redirect old search URLs to the new search URL /// </summary> protected void RedirectToResultsList(string searchString, string contains, string first, string page) { NciUrl redirectURL = new NciUrl(); redirectURL.SetUrl(GetSearchUrl()); redirectURL.QueryParameters.Add("q", searchString); if (contains.Equals("true")) { redirectURL.QueryParameters.Add("contains", contains); } if (!string.IsNullOrEmpty(first)) { redirectURL.QueryParameters.Add("first", first); } if (!string.IsNullOrEmpty(page)) { redirectURL.QueryParameters.Add("page", page); } // Add redirect query parameter for analytics redirectURL.QueryParameters.Add("redirect", "true"); NCI.Web.CDE.Application.PermanentRedirector.DoPermanentRedirect(Response, redirectURL.ToString(), "Dictionary Friendly Name Redirect"); }
/// <summary> /// Parses the URL for all of the parameters for an intervention dynamic listing page /// </summary> protected override void ParseURL() { if (this.CurrAppPath == "/") { throw new HttpException(400, "Invalid Parameters"); } List <string> rawParams = new List <string>(); if (this.IsNoTrials) { NciUrl ParsedReqUrlParams = new NciUrl(true, true, true); //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL) ParsedReqUrlParams.SetUrl(this.Request.Url.Query); if (ParsedReqUrlParams.QueryParameters.Count == 0) { throw new HttpException(400, "Invalid Parameters"); } rawParams = GetRawParametersFromQueryString(ParsedReqUrlParams); SetDoNotIndex(); Response.StatusCode = 404; Response.TrySkipIisCustomErrors = true; } else { rawParams = this.CurrAppPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToList <string>(); } SetUpRawParametersForListingPage(rawParams); SetUpCanonicalUrl(); }
/// <summary> /// Gets an instance of a CTSSearchParams object based on params in URL. /// </summary> /// <param name="url">The URL to parse</param> /// <returns></returns> public CTSSearchParams Create(string url) { NciUrl reqUrl = new NciUrl(true, true, true); reqUrl.SetUrl(url); return(Create(reqUrl)); }
/// <summary> /// Gets the friendly name of the given CDRID, if it exists. /// Otherwise, returns the CDRID. /// </summary> public string GetSitemapUrl(string nciid) { NciUrl url = new NciUrl(); url.SetUrl(_rootUrl); url.AppendPathSegment(_config.DetailedViewPagePrettyUrl); url.QueryParameters.Add("id", nciid); return(_rootUrl + url.ToString()); }
/// <summary> /// Gets the URL for the given cdrID. /// Returns the URL with the friendly-name if found, otherwise with the CDRID. /// </summary> public string GetSitemapUrl(DictionaryInfo info, string cdrId) { NciUrl url = new NciUrl(); url.SetUrl(_rootUrl); url.AppendPathSegment(info.DefinitionUrl); url.AppendPathSegment(GetFriendlyName(info, cdrId)); return(_rootUrl + url.ToString()); }
/// <summary> /// Method called to redirect old view URLs to the new view URL /// </summary> protected void RedirectToDefinitionView(string id) { NciUrl redirectURL = new NciUrl(); string friendlyName = GetFriendlyName(id); if (!string.IsNullOrEmpty(friendlyName)) { redirectURL.SetUrl(GetDefinitionUrl() + friendlyName); } else { redirectURL.SetUrl(GetDefinitionUrl() + id); } // Add redirect query parameter for analytics redirectURL.QueryParameters.Add("redirect", "true"); NCI.Web.CDE.Application.PermanentRedirector.DoPermanentRedirect(Response, redirectURL.ToString(), "Dictionary Friendly Name Redirect"); }
public string GetCheckForUpdatesURL(string trialID, CTSSearchParams searchParams) { //Create a new url for the current details page. NciUrl url = new NciUrl(); url.SetUrl(_config.DetailedViewPagePrettyUrl); //Convert the current search parameters into a NciUrl NciUrl paramsUrl = CTSSearchParamFactory.ConvertParamsToUrl(searchParams); //Copy the params url.QueryParameters = paramsUrl.QueryParameters; url.QueryParameters.Add("id", trialID); return(url.ToString()); }
public string GetBackToResultsUrl() { //Create a new url for the current details page. NciUrl url = new NciUrl(); url.SetUrl(this.Config.ResultsPagePrettyUrl); //Convert the current search parameters into a NciUrl NciUrl paramsUrl = CTSSearchParamFactory.ConvertParamsToUrl(this.SearchParams); //Copy the params url.QueryParameters = paramsUrl.QueryParameters; url.QueryParameters.Add("pn", this.PageNum.ToString()); url.QueryParameters.Add("ni", this.ItemsPerPage.ToString()); return(url.ToString()); }
/// <summary> /// Initializes the CTSManager and Parses the Query Params /// </summary> protected override void Init() { base.Init(); ParsedReqUrlParams = new NciUrl(true, true, true); //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL) ParsedReqUrlParams.SetUrl(this.Request.Url.Query); ////////////////////////////// // Create an instance of a BasicCTSManager. ClinicalTrialsAPIClient apiClient = APIClientHelper.GetV1ClientInstance(); CTSManager = new BasicCTSManager(apiClient); ///////////////////////////// // Parse the Query to get the search params. try { // Get mapping file names from configuration TrialTermLookupConfig mappingConfig = new TrialTermLookupConfig(); mappingConfig.MappingFiles.AddRange(Config.MappingFiles.Select(fp => HttpContext.Current.Server.MapPath(fp))); CTSSearchParamFactory factory = new CTSSearchParamFactory(new TrialTermLookupService(mappingConfig, apiClient), new ZipCodeGeoLookup()); SearchParams = factory.Create(ParsedReqUrlParams); } catch (Exception ex) { log.Error("could not parse the CTS search parameters", ex); throw ex; } /////////////////////////// // Parse the page specific parameters if (IsInUrl(ParsedReqUrlParams, "pn")) { this._pageNum = ParsedReqUrlParams.CTSParamAsInt("pn", 1); } _itemsPerPage = Config.DefaultItemsPerPage; if (IsInUrl(ParsedReqUrlParams, "ni")) { this._itemsPerPage = ParsedReqUrlParams.CTSParamAsInt("ni", _itemsPerPage); } }
protected void Page_Load(object sender, EventArgs e) { GetQueryParams(); SetupCanonicalUrl(this.DictionaryRouter.GetBaseURL()); SetDoNotIndex(); SetupCommon(); this.dictionarySearchBlock.SearchBoxInputVal = HttpUtility.HtmlEncode(SearchStr); if (BContains == true) { this.dictionarySearchBlock.CheckRadioStarts = ""; this.dictionarySearchBlock.CheckRadioContains = "checked=\"checked\""; } //Set display props according to lang if (PageAssemblyContext.Current.PageAssemblyInstruction.Language == "es") { lblResultsFor.Text = "resultados de:"; } else { lblResultsFor.Text = "results found for:"; } LoadData(); //set up pager stuff string pageHtml = string.Empty; if (NumResults > 0 && PageAssemblyContext.Current.DisplayVersion != DisplayVersions.Print) { Dictionary<string, string> queryParams = GetPageQueryParams(); NciUrl pagerUrl = new NciUrl(); pagerUrl.SetUrl(PageAssemblyContext.Current.requestedUrl.ToString()); DrugPager objPager = new DrugPager(pagerUrl, queryParams, CurrentPageIndex, PageSize, 2, NumResults); pageHtml = objPager.RenderPager(); } litPager.Text = pageHtml; }
public string GetShowAllUrl() { //Create a new url for the current details page. NciUrl url = new NciUrl(); url.SetUrl(this.Config.DetailedViewPagePrettyUrl); //Convert the current search parameters into a NciUrl NciUrl paramsUrl = CTSSearchParamFactory.ConvertParamsToUrl(this.SearchParams); //Copy the params url.QueryParameters = paramsUrl.QueryParameters; url.QueryParameters.Add("id", TrialID); url.QueryParameters.Add("pn", this.PageNum.ToString()); url.QueryParameters.Add("ni", this.ItemsPerPage.ToString()); url.QueryParameters.Add("all", "1"); return(url.ToString()); }
protected sealed override void OnInit(EventArgs e) { base.OnInit(e); this.LoadConfig(); //This is referenced by the listing page templates. Those templates //should be updated to reference the Page Number directly. this.SearchParams = new VelocitySearchParams(this); //Set our default items per page based on the config _itemsPerPage = this.GetItemsPerPage(); //Using NciUrl for handling parameters instead of raw URL query //This is mainly for pagination ParsedReqUrlParams = new NciUrl(true, true, true); //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL) ParsedReqUrlParams.SetUrl(this.Request.Url.Query); _basicCTSManager = new BasicCTSManager(APIClientHelper.GetV1ClientInstance()); }
/// <summary> /// This method is called when no results are returned by the query. In this case the function checks that the current URL does not /// have the word notrials in it. If it is the case, the function will redirect the user to a page with the following URL: /// PRETTYURL/NOTRIALS?p1=a&p2=b /// </summary> protected override void OnEmptyResults() { if (this.IsNoTrials) { return; } NciUrl noTrialsUrl = new NciUrl(); noTrialsUrl.SetUrl(this.PrettyUrl + "/notrials"); //Parameters is always assumed to be greater than one string[] parameters = this.GetParametersForNoTrials(); for (int i = 0; i < parameters.Length; i++) { noTrialsUrl.QueryParameters.Add("p" + (i + 1), parameters[i]); } Response.Redirect(noTrialsUrl.ToString(), true); }
private void GeneratePrintCacheAndRedirect(HttpContext context, CTSPrintManager manager) { HttpRequest request = context.Request; HttpResponse response = context.Response; NciUrl parsedReqUrlParams = new NciUrl(true, true, true); //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL) parsedReqUrlParams.SetUrl(request.Url.Query); ClinicalTrialsAPIClient apiClient = APIClientHelper.GetV1ClientInstance(); CTSSearchParams searchParams = null; try { // Get mapping file names from configuration TrialTermLookupConfig mappingConfig = new TrialTermLookupConfig(); mappingConfig.MappingFiles.AddRange(_config.MappingFiles.Select(fp => HttpContext.Current.Server.MapPath(fp))); CTSSearchParamFactory factory = new CTSSearchParamFactory(new TrialTermLookupService(mappingConfig, apiClient), new ZipCodeGeoLookup()); searchParams = factory.Create(parsedReqUrlParams); } catch (Exception ex) { ErrorPageDisplayer.RaisePageByCode(this.GetType().ToString(), 400); //Anything here is just a bad request. } //Set our output to be JSON response.ContentType = "application/json"; response.ContentEncoding = Encoding.UTF8; //Try and get the request. Request req = null; try { req = GetRequestAndValidate(context); } catch (Exception) { ErrorPageDisplayer.RaisePageByCode(this.GetType().ToString(), 400); //Anything here is just a bad request. return; } // Store the cached print content Guid printCacheID = manager.StorePrintContent(req.TrialIDs, DateTime.Now, searchParams); //Add in debugging helper param to make debugging templates easier. //TODO: Refactor so get content and render is a single function. if (parsedReqUrlParams.QueryParameters.ContainsKey("debug") && parsedReqUrlParams.QueryParameters["debug"] == "true") { response.ContentType = "text/HTML"; response.ContentEncoding = Encoding.UTF8; // If there is no error, send the printID to the manager to retrieve the cached print content string printContent = manager.GetPrintContent(printCacheID); printContent = printContent.Replace("${generatePrintURL}", GetEmailUrl(printCacheID)); response.Write(printContent); response.End(); } else { // Format our return as JSON var resp = JsonConvert.SerializeObject(new { printID = printCacheID }); response.Write(resp); response.End(); } }
// Sets the URL Filter for the canonical URL private void SetupUrlFilter(string name, NciUrl url) { url.SetUrl(this.DictionaryRouter.GetDefinitionUrl() + GetFriendlyName(CdrID)); }
// Sets the URL Filter for the canonical URL private void SetupUrlFilter(string name, NciUrl url) { url.SetUrl(url.ToString()); }
private void FilterCurrentUrl(NciUrl url) { url.SetUrl("/cancertopics"); }